| 82 | } |
| 83 | |
| 84 | void CostFunctionManager::computeCostFunction( const Map<unsigned, double> &heuristicCost ) |
| 85 | { |
| 86 | /* |
| 87 | A heuristic-based cost function is computed by computing the core |
| 88 | cost function and adding to it the provided heuristic cost. |
| 89 | |
| 90 | The heuristic cost may include variables that are basic and variables |
| 91 | that are non-basic. The basic variables are added to the vector of basic |
| 92 | costs, which is normally used in computing the core cost fuction. |
| 93 | Afterwards, once the modified core cost function has been computed, |
| 94 | the remaining, non-basic variables are added. |
| 95 | */ |
| 96 | |
| 97 | // Reset cost function |
| 98 | std::fill( _costFunction, _costFunction + _n - _m, 0.0 ); |
| 99 | |
| 100 | // Compute the core basic costs |
| 101 | computeBasicOOBCosts(); |
| 102 | |
| 103 | // Iterate over the heuristic costs. Add any basic variables to the basic |
| 104 | // cost vector, and the rest directly to the cost function. |
| 105 | for ( const auto &variableCost : heuristicCost ) |
| 106 | { |
| 107 | unsigned variable = variableCost.first; |
| 108 | double cost = variableCost.second; |
| 109 | unsigned variableIndex = _tableau->variableToIndex( variable ); |
| 110 | if ( _tableau->isBasic( variable ) ) |
| 111 | _basicCosts[variableIndex] += cost; |
| 112 | else |
| 113 | _costFunction[variableIndex] += cost; |
| 114 | } |
| 115 | |
| 116 | // Complete the calculation of the modified core cost function |
| 117 | computeMultipliers(); |
| 118 | computeReducedCosts(); |
| 119 | } |
| 120 | |
| 121 | void CostFunctionManager::computeGivenCostFunction( const Map<unsigned, double> &heuristicCost ) |
| 122 | { |
nothing calls this directly
no test coverage detected