Skip to content

Commit

Permalink
Fix for #134: unbounded objective variable and Cbc
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaslundell committed Feb 23, 2022
1 parent 33b62ac commit 7f2b2af
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/MIPSolver/MIPSolverCbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ E_ProblemSolutionStatus MIPSolverCbc::solveProblem()
// To find a feasible point for an unbounded dual problem and not when solving the minimax-problem
if(MIPSolutionStatus == E_ProblemSolutionStatus::Unbounded && env->results->getNumberOfIterations() > 0)
{
std::vector<PairIndexValue> originalObjectiveCoefficients;
VectorInteger variablesWithChangedBounds;
bool problemUpdated = false;

if((env->reformulatedProblem->objectiveFunction->properties.classification
Expand All @@ -771,9 +771,9 @@ E_ProblemSolutionStatus MIPSolverCbc::solveProblem()
{
if(V->isDualUnbounded())
{
// Temporarily remove unbounded terms from objective
originalObjectiveCoefficients.emplace_back(V->index, osiInterface->getObjCoefficients()[V->index]);
osiInterface->setObjCoeff(V->index, 0.0);
// Temporarily introduce bounds [-1e20,1e20] for unbounded variables in objective
updateVariableBound(V->index, -1e20, 1e20);
variablesWithChangedBounds.push_back(V->index);
problemUpdated = true;
}
}
Expand Down Expand Up @@ -831,10 +831,10 @@ E_ProblemSolutionStatus MIPSolverCbc::solveProblem()
if(MIPSolutionStatus == E_ProblemSolutionStatus::Optimal)
MIPSolutionStatus = E_ProblemSolutionStatus::Feasible;

for(auto& P : originalObjectiveCoefficients)
for(auto& I : variablesWithChangedBounds)
{
osiInterface->setObjCoeff(P.index, P.value);
assert(osiInterface->getObjCoefficients()[P.index] == P.value);
updateVariableBound(I, env->reformulatedProblem->getVariableLowerBound(I),
env->reformulatedProblem->getVariableUpperBound(I));
}

env->results->getCurrentIteration()->hasInfeasibilityRepairBeenPerformed = true;
Expand Down

0 comments on commit 7f2b2af

Please sign in to comment.