13 #include "OsiAuxInfo.hpp"
18 static const char *
txt_id =
"check integer sol.";
26 b.
options()->GetEnumValue(
"feas_check_cut_types", ival, b.
prefix());
28 b.
options()->GetEnumValue(
"feas_check_discard_policy", ival, b.
prefix());
30 b.
options()->GetIntegerValue(
"generate_benders_after_so_many_oa", ival, b.
prefix());
39 BabInfo * babInfo,
double &cutoff,
const CglTreeInfo &
info)
const
44 OsiSolverInterface *
lp = lpManip.
si();
45 OsiBranchingInformation branch_info(lp,
false);
47 double milpBound = -COIN_DBL_MAX;
49 double * nlpSol = NULL;
50 int numberCutsBefore = cs.sizeRowCuts();
52 while (isInteger && feasible ) {
58 double * colsol =
const_cast<double *
>(lp->getColSolution());
59 branch_info.solution_ = colsol;
71 lp->setDblParam(OsiDualObjectiveLimit, cutoff);
88 int numberCuts = cs.sizeRowCuts() - numberCutsBefore;
94 double objvalue = lp->getObjValue();
96 feasible = (lp->isProvenOptimal() &&
97 !lp->isDualObjectiveLimitReached() && (objvalue<cutoff)) ;
109 branch_info.solution_ = lp->getColSolution();
119 printf(
"Obj value after cuts %g, %d rows\n",lp->getObjValue(),
123 int num_cuts_now = cs.sizeRowCuts();
125 for(
int i = numberCutsBefore ; i < num_cuts_now ; i++){
126 cs.rowCut(i).setEffectiveness(99.9e99);
131 debug_.printEndOfProcedureDebugMessage(cs,
true, cutoff, milpBound, isInteger, feasible, std::cout);
132 std::cout<<
"milpBound found: "<<milpBound<<std::endl;
143 roptions->AddStringOption2(
"feas_check_cut_types",
"Choose the type of cuts generated when an integer feasible solution is found",
145 "outer-approx",
"Generate a set of Outer Approximations cuts.",
146 "Benders",
"Generate a single Benders cut.",
147 "If it seems too much memory is used should try Benders to use less");
148 roptions->setOptionExtraInfo(
"feas_check_cut_types", 19);
151 roptions->AddStringOption3(
"feas_check_discard_policy",
"How cuts from feasibility checker are discarded",
153 "detect-cycles",
"Detect if a cycle occurs and only in this case force not to discard.",
154 "keep-all",
"Force cuts from feasibility checker not to be discarded (memory hungry but sometimes better).",
155 "treated-as-normal",
"Cuts from memory checker can be discarded as any other cuts (code may cycle then)",
156 "Normally to avoid cycle cuts from feasibility checker should not be discarded in the node where they are generated. "
157 "However Cbc sometimes does it if no care is taken which can lead to an infinite loop in Bonmin (usually on simple problems). "
158 "To avoid this one can instruct Cbc to never discard a cut but if we do that for all cuts it can lead to memory problems. "
159 "The default policy here is to detect cycles and only then impose to Cbc to keep the cut. "
160 "The two other alternative are to instruct Cbc to keep all cuts or to just ignore the problem and hope for the best");
161 roptions->setOptionExtraInfo(
"feas_check_discard_policy", 19);
163 roptions->AddLowerBoundedIntegerOption(
"generate_benders_after_so_many_oa",
"Specify that after so many oa cuts have been generated Benders cuts should be generated instead.",
165 "It seems that sometimes generating too many oa cuts slows down the optimization compared to Benders due to the size of the LP. "
166 "With this option we specify that after so many OA cuts have been generated we should switch to Benders cuts.");
167 roptions->setOptionExtraInfo(
"generate_benders_after_so_many_oa", 19);
Small class to manipulatee various things in an OsiSolverInterface and restore them.
void getOuterApproximation(OsiCuts &cs, int getObj, const double *x2, bool global)
Get the outer approximation constraints at the current optimal point.
OsiCuts savedCuts_
Saved cuts: in some cases when using OA to check feasible solution algorithm may loop because Cbc rem...
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.
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.
CutsTypes
See documentation for feas_check_cut_types option.
CutsPolicies pol_
Policy for keeping cuts.
double cbcIntegerTolerance_
integer tolerance (has to be the same as Cbc's)
OaFeasibilityChecker(BabSetupBase &b)
New usefull constructor.
virtual double getObjValue() const
Get objective function value (can't use default)
OsiObject ** objects_
Some objects the feasiblitiy of which to verify.
int nObjects_
Number of objects.*/.
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
A class to have all elements necessary to setup a branch-and-bound.
void installCuts(OsiSolverInterface &si, const OsiCuts &cs, int numberCuts)
Install cuts in solver.
unsigned int maximum_oa_cuts_
maximum number of OA cuts.
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.
~OaFeasibilityChecker()
Destructor.
void getBendersCut(OsiCuts &cs, bool global)
Get a benders cut from solution.
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.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register OA options.
double cbcCutoffIncrement_
cutoff min increase (has to be intialized trhough Cbc)
CutsTypes type_
Type of cuts.
void fixIntegers(OsiSolverInterface &si, const OsiBranchingInformation &info, double integer_tolerance, OsiObject **objects, int nObjects)
Fix integer variables in si to their values in colsol.
OsiSolverInterface * si()
Get pointer to solver interface.
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
static const char * txt_id
Base class for OA algorithms.
unsigned int cut_count_
Count the total number of cuts generated.
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.
CutsPolicies
See documentation for feas_check_discard_policy option.
Bonmin class for passing info between components of branch-and-cuts.
bool post_nlp_solve(BabInfo *babInfo, double cutoff) const
Solve the nlp and do output.
bool isInteger(CouNumber x)
is this number integer?