12 #include "OsiSolverInterface.hpp"
31 knowInfeasible_(
false),
33 knowDualInfeasible_(
false)
44 OsiSolverInterface (src),
69 knowDualInfeasible_ =
false;
88 knowDualInfeasible_ =
true;
92 if (cutgen_ -> Problem () -> nUnusedOriginals () > 0) {
94 CoinCopyN (T::getColSolution (), T::getNumCols (), x);
95 cutgen_ -> Problem () -> restoreUnusedOriginals (x);
96 T::setColSolution (x);
103 return knowInfeasible_ || T::isProvenPrimalInfeasible();
108 return knowOptimal_ || T::isProvenOptimal();
113 return knowDualInfeasible_ || T::isProvenDualInfeasible();
124 static int count = -1;
128 if (cutgen_ && (cutgen_ -> check_lp ())) {
130 sprintf (filename,
"resolve_%d", count);
131 T::writeMps (filename);
136 knowDualInfeasible_ =
false;
138 const CoinWarmStart *
ws = NULL;
140 if (cutgen_ && (cutgen_ -> check_lp ()))
141 ws = T::getWarmStart ();
154 knowDualInfeasible_ =
true;
156 int objind = cutgen_ -> Problem () -> Obj (0) -> Body () -> Index ();
160 curCutoff = cutgen_ -> Problem () -> getCutOff (),
161 objvalGlob = objind >= 0 ? T::getColSolution () [objind] : cutgen_ -> Problem () -> Obj (0) -> Body () -> Value ();
164 bool isChecked =
false;
166 double curBestVal = 1.e50;
167 if(cutgen_->Problem()->getRecordBestSol()->getHasSol()) {
168 curBestVal = cutgen_->Problem()->getRecordBestSol()->getVal();
170 curBestVal = (curBestVal < curCutoff ? curBestVal : curCutoff);
171 if(isProvenOptimal()) {
172 isChecked = cutgen_->Problem()->checkNLP2(T::getColSolution(),
176 cutgen_->Problem()->getFeasTol());
178 objvalGlob = cutgen_->Problem()->getRecordBestSol()->getModSolVal();
186 bool ckIsChecked =
false;
187 double ckObj = objvalGlob;
188 if(isProvenOptimal () &&
190 ckIsChecked = cutgen_->Problem()->checkNLP(T::getColSolution (),
193 if(!isChecked && ckIsChecked) {
194 printf(
"CouenneSolverInterface::resolve(): ### ERROR: isChecked: false ckIsChecked: true\n");
198 printf(
"CouenneSolverInterface::resolve(): isChecked == ckIsChecked\n");
203 if(isProvenOptimal () &&
205 isChecked = cutgen_->Problem()->checkNLP(T::getColSolution (),
217 cutgen_ -> Problem () -> setCutOff (objvalGlob);
219 #ifdef FM_TRACE_OPTSOL
221 cutgen_->Problem()->getRecordBestSol()->update();
226 if (cutgen_ -> Problem () -> nUnusedOriginals () > 0) {
228 CoinCopyN (T::getColSolution (), T::getNumCols (), x);
229 cutgen_ -> Problem () -> restoreUnusedOriginals (x);
230 T::setColSolution (x);
234 cutgen_->Problem()->getRecordBestSol()->update(T::getColSolution(),
235 cutgen_->Problem()->nVars(),
237 cutgen_->Problem()->getFeasTol());
244 if (cutgen_ && (cutgen_ -> check_lp ())) {
250 sprintf (filename,
"resolve_%d.mps", count);
251 nsi -> readMps (filename);
253 nsi -> messageHandler () -> setLogLevel (0);
254 nsi -> setWarmStart (ws);
256 nsi -> initialSolve ();
258 if ((nsi -> isProvenOptimal () && isProvenOptimal ()) ||
259 (!(nsi -> isProvenOptimal ()) && !isProvenOptimal ())) {
261 if (nsi -> isProvenOptimal () &&
262 (fabs (nsi -> getObjValue () - T::getObjValue ()) /
263 (1. + fabs (nsi -> getObjValue ()) + fabs (T::getObjValue ())) > 1
e-2))
265 printf (
"Warning: discrepancy between saved %g and current %g [%g], file %s\n",
266 nsi -> getObjValue (), T::getObjValue (),
267 nsi -> getObjValue () - T::getObjValue (),
271 csi -> messageHandler () -> setLogLevel (0);
272 csi -> setWarmStart (ws);
274 csi -> initialSolve ();
276 if ((csi -> isProvenOptimal () && isProvenOptimal ()) ||
277 (!(csi -> isProvenOptimal ()) && !isProvenOptimal ())) {
279 if (csi -> isProvenOptimal () &&
280 (fabs (csi -> getObjValue () - getObjValue ()) /
281 (1. + fabs (csi -> getObjValue ()) + fabs (getObjValue ())) > 1
e-2))
283 printf (
"Warning: discrepancy between cloned %g and current %g [%g]\n",
284 csi -> getObjValue (), getObjValue (),
285 csi -> getObjValue () - getObjValue ());
302 {OsiSolverInterface::markHotStart ();}
308 {OsiSolverInterface::unmarkHotStart();}
317 knowDualInfeasible_ =
false;
322 knowDualInfeasible_ =
true;
326 if (cutgen_ -> Problem () -> nUnusedOriginals () > 0) {
328 CoinCopyN (T::getColSolution (), T::getNumCols (), x);
329 cutgen_ -> Problem () -> restoreUnusedOriginals (x);
330 T::setColSolution (x);
334 if (isProvenPrimalInfeasible ()) knowInfeasible_ =
true;
335 if (isProvenOptimal ()) knowOptimal_ =
true;
336 if (isProvenDualInfeasible ()) knowDualInfeasible_ =
true;
343 return cutgen_ -> Problem () -> constObjVal () + T::getObjValue();
Cut Generator for linear convexifications.
CouenneCutGenerator * cutgen_
The pointer to the Couenne cut generator.
virtual void unmarkHotStart()
Delete the hot start snapshot.
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
virtual void solveFromHotStart()
Optimize starting from the hot start snapshot.
const double Couenne_large_bound
used to declare LP unbounded
bool isProvenDualInfeasible() const
set doingResolve_
bool knowOptimal_
Flag indicating that optimality was detected during solveFromHotStart.
virtual double getObjValue() const
Get the objective function value.
virtual bool isProvenOptimal() const
we need to overwrite this since we might have internal knowledge
void sparse2dense(int ncols, t_chg_bounds *chg_bds, int *&changed, int &nchanged)
translate sparse to dense vector (should be replaced)
void fint fint fint real fint real real real real real real real real real * e
Solver interface class with a pointer to a Couenne cut generator.
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real * ws
virtual void initialSolve()
Solve initial LP relaxation.
double CouNumber
main number type in Couenne
bool knowDualInfeasible_
Flag indicating this problem's continuous relaxation is unbounded.
CouenneSolverInterface(CouenneCutGenerator *cg=NULL)
Constructor.
~CouenneSolverInterface()
Destructor.
virtual void resolve()
Resolve an LP relaxation after problem modification.
bool knowInfeasible_
Flag indicating that infeasibility was detected during solveFromHotStart.
virtual void markHotStart()
Create a hot start snapshot of the optimization process.
void fint fint fint real fint real * x
virtual bool isProvenPrimalInfeasible() const
we need to overwrite this since we might have internal knowledge