Skip to content

Commit

Permalink
Fixed #39 caused when subproblem is terminated due to time or node li…
Browse files Browse the repository at this point in the history
…mit without a primal feasible solution
  • Loading branch information
kibaekkim committed Oct 29, 2018
1 parent dc66eef commit 1df9767
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Solver/DualDecomp/DdMW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ DSP_RTN_CODE DdMW::storeCouplingSolutions(Solutions& stored)
/** store solutions to distribute */
for (int s = 0; s < model_->getNumSubproblems(); ++s)
{
if (master_->subprimobj_[s] == COIN_DBL_MAX)
continue;

int nx = model_->getNumSubproblemCouplingCols(s);

DSPdebugMessage2("ubSolutions_ %lu\n", ubSolutions_.size());
Expand Down
5 changes: 5 additions & 0 deletions src/Solver/DualDecomp/DdSub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ DSP_RTN_CODE DdSub::solve()
DSPdebugMessage("primal objective %+e\n", primobj_);
dualinfeas = false;
break;
case DSP_STAT_LIM_INFEAS:
primobj_ = COIN_DBL_MAX;
dualobj_ = si_->getDualBound();
dualinfeas = false;
break;
case DSP_STAT_DUAL_INFEASIBLE:
message_->print(0, "Subproblem %d is dual infeasible. DSP will fix any unbounded column bounds to a large number.\n", sind_);
for (int j = 0; j < si_->getNumCols(); ++j) {
Expand Down
6 changes: 5 additions & 1 deletion src/Solver/DualDecomp/DdWorkerLB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ DSP_RTN_CODE DdWorkerLB::solve() {
switch (subprobs_[s]->si_->getStatus()) {
case DSP_STAT_STOPPED_TIME:
case DSP_STAT_LIM_ITERorTIME:
case DSP_STAT_LIM_INFEAS:
case DSP_STAT_STOPPED_GAP:
case DSP_STAT_STOPPED_NODE:
message_->print(3, "Warning: subproblem %d solution status is %d\n",
Expand Down Expand Up @@ -106,7 +107,10 @@ DSP_RTN_CODE DdWorkerLB::solve() {
if (status_ == DSP_STAT_MW_STOP)
break;

primobj += subprobs_[s]->si_->getPrimalBound();
if (subprobs_[s]->si_->getStatus() == DSP_STAT_LIM_INFEAS)
primobj = COIN_DBL_MAX;
else if (primobj < COIN_DBL_MAX)
primobj += subprobs_[s]->si_->getPrimalBound();
dualobj += subprobs_[s]->si_->getDualBound();
total_cputime += CoinCpuTime() - cputime;
total_walltime += CoinGetTimeOfDay() - walltime;
Expand Down
16 changes: 14 additions & 2 deletions src/SolverInterface/SolverInterfaceCpx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,20 @@ void SolverInterfaceCpx::setGapTol(double tol)

DSP_RTN_CODE SolverInterfaceCpx::getStatus() {
int cpxstat = CPXgetstat(cpx_->getEnvironmentPtr(), cpx_->getLpPtr(OsiCpxSolverInterface::KEEPCACHED_ALL));
if (cpxstat == CPXMIP_TIME_LIM_FEAS) {
if (cpxstat == CPXMIP_NODE_LIM_FEAS ||
cpxstat == CPXMIP_TIME_LIM_FEAS)
return DSP_STAT_LIM_ITERorTIME;
}
else if (cpxstat == CPXMIP_NODE_LIM_INFEAS ||
cpxstat == CPXMIP_TIME_LIM_INFEAS)
return DSP_STAT_LIM_INFEAS;
return SolverInterfaceOsi::getStatus();
}


/** get dual bound (lower bound in minimization) */
double SolverInterfaceCpx::getDualBound()
{
double objval;
CPXgetbestobjval(cpx_->getEnvironmentPtr(), cpx_->getLpPtr(OsiCpxSolverInterface::KEEPCACHED_ALL), &objval);
return objval;
}
3 changes: 3 additions & 0 deletions src/SolverInterface/SolverInterfaceCpx.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class SolverInterfaceCpx: public SolverInterfaceOsi {
/** solution status */
virtual DSP_RTN_CODE getStatus();

/** get dual bound (lower bound in minimization) */
virtual double getDualBound();

/** set node limit */
virtual void setNodeLimit(int limit);

Expand Down
1 change: 1 addition & 0 deletions src/Utility/DspRtnCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef int DSP_RTN_CODE;
#define DSP_STAT_LIM_PRIM_OBJ 3014
#define DSP_STAT_LIM_DUAL_OBJ 3015
#define DSP_STAT_FEASIBLE 3016
#define DSP_STAT_LIM_INFEAS 3018
#define DSP_STAT_MW_STOP 3100 /**< stop signal for master-worker framework */
#define DSP_STAT_MW_CONTINUE 3101 /**< continue signal for master-worker framework */
#define DSP_STAT_MW_EXACT 3102 /**< force to evaluate exactly */
Expand Down

0 comments on commit 1df9767

Please sign in to comment.