Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use type* for pointers instead of auto&, add const qualifier #1838

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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