sources/JobAssignment.cpp
/**
 * Assigns a job to the worker with the lowest cost, until there are no more jobs left to assign, 
 *      but only if the worker is free. It also calculates the total cost using the 2D 
 *      assignations vector.
 * 
 * @param[in] &costs the address in memory of the 2D vector that represents the costs of each job per 
 *      worker
 * @param[in] &assignations the address in memory of the 2D vector that represents the job assignations
 * @param[in] jobs the number of jobs
 * @param[in] max the maximum cost that a job can have
 * 
 * @returns the total cost of a solution 
*/
Assigns a job to the worker with the lowest cost, until there are no more jobs left to assign,
but only if the worker is free. It also calculates the total cost using the 2D
assignations vector.

@param[in] &costs the address in memory of the 2D vector that represents the costs of each job per
worker
@param[in] &assignations the address in memory of the 2D vector that represents the job assignations
@param[in] jobs the number of jobs
@param[in] max the maximum cost that a job can have

@returns the total cost of a solution
Assigns a job to the worker with the lowest cost until there are no more jobs left to assign but only if the worker is free . It also calculates the total cost using the 2D assignations vector . @param [ in ] &costs the address in memory of the 2D vector that represents the costs of each job per worker @param [ in ] &assignations the address in memory of the 2D vector that represents the job assignations @param [ in ] jobs the number of jobs @param [ in ] max the maximum cost that a job can have @returns the total cost of a solution
int assignJobs(vector<vector<int>> &costs, vector<vector<int>> &assignations, int jobs, int max){
    int row;
    int col;
    int min = max;
    int spotX;
    int spotY;
    int totalCost = 0;
    bool isItFree;
    for (col = 0; col < jobs; col++){
        for (row = 0; row < jobs; row++){
            isItFree = checkIfFree(assignations, jobs, row);
            if ((costs[row][col] < min) && (isItFree == true)){
                min = costs[row][col];
                spotX = row;
                spotY = col;
            }
        }
        assignations[spotX][spotY] = 1;
        min = max;
    }
    for (col = 0; col < jobs; col++){
        for (row = 0; row < jobs; row++){
            if (assignations[row][col] == 1){
                totalCost += costs[row][col];
            }
        }
    }
    return totalCost;
}
int assignJobs ( vector < vector < int > > & costs , vector < vector < int > > & assignations , int jobs , int max ) { int row ; int col ; int min = max ; int spotX ; int spotY ; int totalCost = 0 ; bool isItFree ; for ( col = 0 ; col < jobs ; col ++ ) { for ( row = 0 ; row < jobs ; row ++ ) { isItFree = checkIfFree ( assignations , jobs , row ) ; if ( ( costs [ row ] [ col ] < min ) && ( isItFree == true ) ) { min = costs [ row ] [ col ] ; spotX = row ; spotY = col ; } } assignations [ spotX ] [ spotY ] = 1 ; min = max ; } for ( col = 0 ; col < jobs ; col ++ ) { for ( row = 0 ; row < jobs ; row ++ ) { if ( assignations [ row ] [ col ] == 1 ) { totalCost += costs [ row ] [ col ] ; } } } return totalCost ; }
Assigns a job to the worker with the lowest cost, until there are no more jobs left to assign,
      but only if the worker is free.
Assigns a job to the worker with the lowest cost until there are no more jobs left to assign but only if the worker is free .
// Used to represent a row // Used to represent a column // Represents the minimum cost, but starts as the value of the maximum // Saves the row of a promising worker for the solution // Saves the column of a promising worker for the solution  // The total cost of a solution, it first starts as 0 // Tells if a worker is free to be assigned to a job // Iterate over the columns of the 2D vector // Iterate over the rows of the 2D vector /**
             * Calls the method that checks if a worker is free to be assigned to a job and saves
             * the "true" or "false" value in the variable.
            */ // If the current worker has the lowest cost and is free for the job // Saves the new minimum cost  // The row and column of the worker is saved  //Close if  //Close for  // Assigns the job to the worker that is currently saved // Resets the minimum cost  //Close for // Iterate over the columns of the 2D vector // Iterate over the rows of the 2D vector // If a worker assigned to a job was found // Add up the total cost //Close if //Close for //Close for 