model/LoadBalancing.cpp
int lba::utilizationbased(std::vector<ServiceNode> nodeList, Job job) {
  // NOTE: this should still work for both sqms and mqms
  int least_utilized{0};

  // find the index with the least utilization
  for (size_t ii = 0; ii < nodeList.size(); ii++) {
    // process queue
    nodeList[ii].processQueue(job.getArrival());

    // check if this is less utilized
    // NOTE: using calc util seems to make things better i.e. more balanced
    if (nodeList[least_utilized].calcUtil(job) > nodeList[ii].calcUtil(job)) {
      least_utilized = ii;
    }
  }
  return least_utilized;
}
/**
 * These two algorithms have an issue
 * These algorithms assume that reading the queue length or
 * Utilization retrieves the Nodes "current" status
 * but since it is possible for jobs to have not entered these
 * nodes for a long time, (maybe they are already full) they
 * don'd update their utilization or queue length so they might
 * never be picked again
 */
These two algorithms have an issue
These algorithms assume that reading the queue length or
Utilization retrieves the Nodes "current" status
but since it is possible for jobs to have not entered these
nodes for a long time, (maybe they are already full) they
don'd update their utilization or queue length so they might
never be picked again
These two algorithms have an issue These algorithms assume that reading the queue length or Utilization retrieves the Nodes " current " status but since it is possible for jobs to have not entered these nodes for a long time ( maybe they are already full ) they don ' d update their utilization or queue length so they might never be picked again
int lba::utilizationbased(std::vector<ServiceNode> nodeList, Job job) {
  int least_utilized{0};
  for (size_t ii = 0; ii < nodeList.size(); ii++) {
    nodeList[ii].processQueue(job.getArrival());
    if (nodeList[least_utilized].calcUtil(job) > nodeList[ii].calcUtil(job)) {
      least_utilized = ii;
    }
  }
  return least_utilized;
}
int lba :: utilizationbased ( std :: vector < ServiceNode > nodeList , Job job ) { int least_utilized { 0 } ; for ( size_t ii = 0 ; ii < nodeList . size ( ) ; ii ++ ) { nodeList [ ii ] . processQueue ( job . getArrival ( ) ) ; if ( nodeList [ least_utilized ] . calcUtil ( job ) > nodeList [ ii ] . calcUtil ( job ) ) { least_utilized = ii ; } } return least_utilized ; }
These two algorithms have an issue
 These algorithms assume that reading the queue length or
 Utilization retrieves the Nodes "current" status
 but since it is possible for jobs to have not entered these
 nodes for a long time, (maybe they are already full) they
 don'd update their utilization or queue length so they might
 never be picked again
These two algorithms have an issue These algorithms assume that reading the queue length or Utilization retrieves the Nodes " current " status but since it is possible for jobs to have not entered these nodes for a long time ( maybe they are already full ) they don ' d update their utilization or queue length so they might never be picked again
// NOTE: this should still work for both sqms and mqms // find the index with the least utilization // process queue // check if this is less utilized // NOTE: using calc util seems to make things better i.e. more balanced