Skip to content

Commit

Permalink
Use type* for pointers instead of auto&, add const qualifier (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes authored Dec 21, 2023
1 parent e4f486d commit 326068f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/solver/utils/ortools_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static void extractSolutionValues(const std::vector<MPVariable*>& variables,
int nbVar = problemeSimplexe->NombreDeVariables;
for (int idxVar = 0; idxVar < nbVar; ++idxVar)
{
auto& var = variables[idxVar];
const MPVariable* var = variables[idxVar];
problemeSimplexe->X[idxVar] = var->solution_value();
}
}
Expand All @@ -167,7 +167,7 @@ static void extractReducedCosts(const std::vector<MPVariable*>& variables,
int nbVar = problemeSimplexe->NombreDeVariables;
for (int idxVar = 0; idxVar < nbVar; ++idxVar)
{
auto& var = variables[idxVar];
const MPVariable* var = variables[idxVar];
problemeSimplexe->CoutsReduits[idxVar] = var->reduced_cost();
}
}
Expand All @@ -178,12 +178,12 @@ static void extractDualValues(const std::vector<MPConstraint*>& constraints,
int nbRows = problemeSimplexe->NombreDeContraintes;
for (int idxRow = 0; idxRow < nbRows; ++idxRow)
{
auto& row = constraints[idxRow];
const MPConstraint* row = constraints[idxRow];
problemeSimplexe->CoutsMarginauxDesContraintes[idxRow] = row->dual_value();
}
}

static void extract_from_MPSolver(MPSolver* solver,
static void extract_from_MPSolver(const MPSolver* solver,
Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* problemeSimplexe)
{
assert(solver);
Expand All @@ -196,9 +196,9 @@ static void extract_from_MPSolver(MPSolver* solver,

if (isMIP)
{
// TODO extract dual values & marginal costs from LP with fixed integer variables
const int nbVar = problemeSimplexe->NombreDeVariables;
std::fill(problemeSimplexe->CoutsReduits, problemeSimplexe->CoutsReduits + nbVar, 0.);

const int nbRows = problemeSimplexe->NombreDeContraintes;
std::fill(problemeSimplexe->CoutsMarginauxDesContraintes,
problemeSimplexe->CoutsMarginauxDesContraintes + nbRows,
Expand All @@ -207,7 +207,6 @@ static void extract_from_MPSolver(MPSolver* solver,
else
{
extractReducedCosts(solver->variables(), problemeSimplexe);

extractDualValues(solver->constraints(), problemeSimplexe);
}
}
Expand Down

0 comments on commit 326068f

Please sign in to comment.