Remove CoeffMap typedef in linear_solver

This commit is contained in:
Laurent Perron
2018-07-24 09:32:14 -07:00
parent be233ca283
commit a9dd4aec9a
10 changed files with 143 additions and 84 deletions

View File

@@ -357,7 +357,7 @@ void GLPKInterface::SetObjectiveOffset(double value) {
// Clear objective of all its terms (linear)
void GLPKInterface::ClearObjective() {
InvalidateSolutionSynchronization();
for (CoeffEntry entry : solver_->objective_->coefficients_) {
for (const auto& entry : solver_->objective_->coefficients_) {
const int mpsolver_var_index = entry.first->index();
// Variable may have not been extracted yet.
if (!variable_is_extracted(mpsolver_var_index)) {
@@ -432,7 +432,7 @@ void GLPKInterface::ExtractOneConstraint(MPConstraint* const constraint,
double* const coefs) {
// GLPK convention is to start indexing at 1.
int k = 1;
for (CoeffEntry entry : constraint->coefficients_) {
for (const auto& entry : constraint->coefficients_) {
DCHECK(variable_is_extracted(entry.first->index()));
indices[k] = MPSolverIndexToGlpkIndex(entry.first->index());
coefs[k] = entry.second;
@@ -477,7 +477,7 @@ void GLPKInterface::ExtractNewConstraints() {
int k = 1;
for (int i = 0; i < solver_->constraints_.size(); ++i) {
MPConstraint* ct = solver_->constraints_[i];
for (CoeffEntry entry : ct->coefficients_) {
for (const auto& entry : ct->coefficients_) {
DCHECK(variable_is_extracted(entry.first->index()));
constraint_indices[k] = MPSolverIndexToGlpkIndex(ct->index());
variable_indices[k] = MPSolverIndexToGlpkIndex(entry.first->index());
@@ -507,7 +507,7 @@ void GLPKInterface::ExtractNewConstraints() {
void GLPKInterface::ExtractObjective() {
// Linear objective: set objective coefficients for all variables
// (some might have been modified).
for (CoeffEntry entry : solver_->objective_->coefficients_) {
for (const auto& entry : solver_->objective_->coefficients_) {
glp_set_obj_coef(lp_, MPSolverIndexToGlpkIndex(entry.first->index()),
entry.second);
}