13 #include "OsiClpSolverInterface.hpp"
15 #include "CbcModel.hpp"
18 #include "OsiCpxSolverInterface.hpp"
20 #include "OsiAuxInfo.hpp"
27 static const char *
txt_id =
"OA decomposition";
34 std::string bonmin=
"bonmin.";
36 prefix +=
"oa_decomposition.";
39 b.
options()->GetNumericValue(
"time_limit",oaTime,prefix);
65 double & cutoff,
const CglTreeInfo &
info)
const
68 double lastPeriodicLog = CoinCpuTime();
80 nlp_->linearizer()->get_refined_oa(cs);
85 OsiBranchingInformation branch_info(lp,
false);
89 double milpBound = -COIN_DBL_MAX;
99 feasible = milpBound < cutoff;
113 int numberPasses = 0;
116 bool foundSolution = 0;
118 double * nlpSol = NULL;
121 while (isInteger && feasible) {
124 double time = CoinCpuTime();
130 lastPeriodicLog = CoinCpuTime();
135 int numberCutsBefore = cs.sizeRowCuts();
138 const double * colsol =
140 branch_info.solution_ = colsol;
152 lp->setDblParam(OsiDualObjectiveLimit, cutoff);
168 int numberCuts = cs.sizeRowCuts() - numberCutsBefore;
174 double objvalue = lp->getObjValue();
176 feasible = (lp->isProvenOptimal() &&
177 !lp->isDualObjectiveLimitReached() && (objvalue<cutoff)) ;
179 bool changed = !feasible;
180 branch_info.solution_ = lp->getColSolution();
196 printf(
"Obj value after cuts %g %d rows\n",lp->getObjValue(),
204 gap = (ub - milpBound)/fabs(ub);
206 gap = -milpBound/(1
e-10);
217 gap = (ub - milpBound)/fabs(ub);
219 gap = -milpBound/(1
e-10);
239 isInteger = (colsol != 0);
241 feasible = (milpBound < cutoff);
243 if (feasible && isInteger) {
244 bool changed =
false;
260 if (milpBound < cutoff)
270 if(milpBound >= cutoff){
272 <<ub<<milpBound<<CoinMessageEol;
276 <<ub<<milpBound<<CoinMessageEol;
281 debug_.printEndOfProcedureDebugMessage(cs, foundSolution, cutoff, milpBound, isInteger, feasible, std::cout);
291 roptions->AddStringOption2(
"oa_decomposition",
"If yes do initial OA decomposition",
296 roptions->setOptionExtraInfo(
"oa_decomposition",19);
299 roptions->AddBoundedIntegerOption(
"oa_log_level",
300 "specify OA iterations log level.",
302 "Set the level of output of OA decomposition solver : "
303 "0 - none, 1 - normal, 2 - verbose"
305 roptions->setOptionExtraInfo(
"oa_log_level", 25);
307 roptions->AddLowerBoundedNumberOption(
"oa_log_frequency",
308 "display an update on lower and upper bounds in OA every n seconds",
311 roptions->setOptionExtraInfo(
"oa_log_frequency", 25);
int getIntParameter(const IntParameter &p) const
Return value of integer parameter.
int maxSols_
maximum number of solutions
Small class to manipulatee various things in an OsiSolverInterface and restore them.
int nLocalSearch_
number of local searches performed
void getOuterApproximation(OsiCuts &cs, int getObj, const double *x2, bool global)
Get the outer approximation constraints at the current optimal point.
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real fint fint fint fint * info
bool addOnlyViolated_
Add only violated OA inequalities.
double maxLocalSearchTime_
maximum time for local searches
bool IsValid(const OSSmartPtr< U > &smart_ptr)
double cbcIntegerTolerance_
integer tolerance (has to be the same as Cbc's)
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register OA options.
virtual double performOa(OsiCuts &cs, solverManip &lpManip, BabInfo *babInfo, double &cutoff, const CglTreeInfo &info) const
virtual method which performs the OA algorithm by modifying lp and nlp.
virtual bool doLocalSearch(BabInfo *babInfo) const
virutal method to decide if local search is performed
virtual double getObjValue() const
Get objective function value (can't use default)
OsiObject ** objects_
Some objects the feasiblitiy of which to verify.
const double * getLastSolution()
get the solution found in last local search (return NULL if no solution).
CoinMessageHandler * handler_
messages handler.
double gap_tol_
setting for gap tolerance.
int nObjects_
Number of objects.*/.
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
void fint fint fint real fint real real real real real real real real real * e
A very simple class to provide a common interface for solving MIPs with Cplex and Cbc...
A class to have all elements necessary to setup a branch-and-bound.
limit on number of integer feasible solution.
OACutGenerator2(BabSetupBase &b)
Constructor with basic setup.
void installCuts(OsiSolverInterface &si, const OsiCuts &cs, int numberCuts)
Install cuts in solver.
bool isDifferentOnIntegers(OsiSolverInterface &si, OsiObject **objects, int nObjects, double integer_tolerance, const double *colsol, const double *otherSol)
Check if two solutions are the same on integer variables.
double timeBegin_
time of construction
void fint fint fint real fint real real real real real real real real real fint real fint * lp
virtual void resolve()
Resolve the continuous relaxation after problem modification.
Parameters parameters_
Parameters.
int numSols_
number of solutions found by OA_decomposition.
void solve(double cutoff, int loglevel, double maxTime)
double cbcCutoffIncrement_
cutoff min increase (has to be intialized trhough Cbc)
OsiSolverInterface * solver()
int subMilpLogLevel_
sub milp log level.
bool optimal()
returns optimality status.
void fixIntegers(OsiSolverInterface &si, const OsiBranchingInformation &info, double integer_tolerance, OsiObject **objects, int nObjects)
Fix integer variables in si to their values in colsol.
double lowBound()
Returns lower bound.
~OACutGenerator2()
Destructor.
double logFrequency_
Frequency of log.
CoinMessages messages_
Messages for OA.
int maxLocalSearch_
Total max number of local searches.
int iterationCount()
Returns number of simplex iterations in last solve.
OsiSolverInterface * si()
Get pointer to solver interface.
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
double getDoubleParameter(const DoubleParameter &p) const
Return value of double parameter.
static const char * txt_id
Base class for OA algorithms.
bool integerFeasible(OsiSolverInterface &si, const OsiBranchingInformation &info, double integer_tolerance, OsiObject **objects, int nObjects)
Check for integer feasibility of a solution return 1 if it is.
OsiTMINLPInterface * nlp_
Pointer to nlp interface.
const char * prefix() const
Get prefix to use for options.
void setLpSolver(OsiSolverInterface *lp)
Assign lp solver.
Bonmin class for passing info between components of branch-and-cuts.
int nodeCount()
Returns number of nodes in last solve.
bool post_nlp_solve(BabInfo *babInfo, double cutoff) const
Solve the nlp and do output.
bool isInteger(CouNumber x)
is this number integer?