13 #include "OsiClpSolverInterface.hpp"
15 #include "CbcModel.hpp"
18 #include "OsiCpxSolverInterface.hpp"
20 #include "OsiAuxInfo.hpp"
27 static const char *
txt_id =
"FP for MINLP";
33 std::string bonmin=
"bonmin.";
35 prefix +=
"pump_for_minlp.";
38 b.
options()->GetNumericValue(
"time_limit",oaTime,prefix);
66 double & cutoff,
const CglTreeInfo &
info)
const
84 for(
int i = 0; i < numcols ; i++) {
86 if(!lp->isInteger(i)) {
88 else { indices.push_back(i);}
92 const double * colsol = NULL;
94 OsiBranchingInformation branch_info(lp,
false);
95 branch_info.lower_ = savedColLower();
96 branch_info.upper_ = savedColUpper();
99 lp->setObjCoeff(numcols,0);
101 bool milpOptimal =
false;
105 lp->setColUpper(numcols, cutoff);
110 milpOptimal =
subMip_ -> optimal();
119 int numberPasses = 0;
122 bool foundSolution = 0;
124 double * nlpSol = NULL;
125 int major_iteration = 0;
131 int numberCutsBefore = cs.sizeRowCuts();
134 branch_info.solution_ = colsol;
137 for(
unsigned int i = 0 ; i < indices.size() ; i++){
138 assert(fabs(colsol[indices[i]] - floor(colsol[indices[i]] + 0.5)) < 1
e-5);
139 x_bar[i] = colsol[indices[i]];
145 <<dist<<CoinMessageEol;
155 bool restart =
false;
179 <<major_iteration<<cutoff<<CoinMessageEol;
197 int numberCuts = cs.sizeRowCuts() - numberCutsBefore;
200 numberCutsBefore = cs.sizeRowCuts();
214 lp->setColUpper(numcols, cutoff);
219 milpOptimal =
subMip_ -> optimal();
239 <<ub<<CoinMessageEol;
250 roptions->AddStringOption2(
"fp_pass_infeasible",
"Say whether feasibility pump should claim to converge or not",
252 "no",
"When master MILP is infeasible just bail out (don't stop all algorithm). This is the option for using in B-Hyb.",
253 "yes",
"Claim convergence, numerically dangerous.",
"");
256 roptions->AddBoundedIntegerOption(
"fp_log_level",
257 "specify FP iterations log level.",
259 "Set the level of output of OA decomposition solver : "
260 "0 - none, 1 - normal, 2 - verbose"
262 roptions->setOptionExtraInfo(
"fp_log_level",3);
264 roptions->AddLowerBoundedNumberOption(
"fp_log_frequency",
265 "display an update on lower and upper bounds in FP every n seconds",
268 roptions->setOptionExtraInfo(
"fp_log_frequency",3);
277 int colnum = obj->columnNumber();
279 double round = floor(colsol[colnum] + 0.5);
280 double coeff = (colsol[colnum] - round ) < 0;
281 si.setObjCoeff(colnum, 1 - 2 * coeff);
284 throw CoinError(
"OaDecompositionBase::solverManip",
286 "Can not use FP on problem with SOS constraints");
292 for (
int i = 0; i < numcols ; i++) {
294 double round = floor(colsol[i] + 0.5);
295 double coeff = (colsol[i] - round ) < 0;
296 si.setObjCoeff(i, 1 - 2*coeff);
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.
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
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
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register OA options.
virtual bool isInteger(int columnNumber) const
Return true if column is integer.
int passBound_
Wether or not to pass bound to master algorithm.
double maxLocalSearchTime_
maximum time for local searches
double cbcIntegerTolerance_
integer tolerance (has to be the same as Cbc's)
virtual int getNumCols() const
Get number of columns.
virtual bool isProvenOptimal() const
Is optimality proven?
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 solveFeasibilityProblem(size_t n, const double *x_bar, const int *ind, double a, double s, int L)
Given a point x_bar this solves the problem of finding the point which minimize a convex combination ...
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...
~MinlpFeasPump()
Destructor.
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound.
A class to have all elements necessary to setup a branch-and-bound.
limit on number of integer feasible solution.
void installCuts(OsiSolverInterface &si, const OsiCuts &cs, int numberCuts)
Install cuts in solver.
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.
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.
void fixIntegers(OsiSolverInterface &si, const OsiBranchingInformation &info, double integer_tolerance, OsiObject **objects, int nObjects)
Fix integer variables in si to their values in colsol.
CoinMessages messages_
Messages for OA.
int maxLocalSearch_
Total max number of local searches.
MinlpFeasPump(BabSetupBase &b)
Constructor with basic setup.
void relaxIntegers(OsiSolverInterface &si, const OsiBranchingInformation &info, double integer_tolerance, OsiObject **objects, int nObjects)
Slightly relax integer variables in si.
virtual const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
virtual void addObjectiveFunction(OsiSolverInterface &si, const double *x)
Add constraint corresponding to objective function.
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.
void set_fp_objective(OsiSolverInterface &si, const double *colsol) const
Put objective of MIP according to FP scheme.
static const char * txt_id
Base class for OA algorithms.
virtual void setColLower(int elementIndex, double elementValue)
Set a single column lower bound.
OsiTMINLPInterface * nlp_
Pointer to nlp interface.
virtual bool doLocalSearch(BabInfo *babInfo) const
virutal method to decide if local search is performed
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.