12 #include "CbcModel.hpp"
13 #include "OsiBranchingObject.hpp"
60 Ipopt::TNLP::IndexStyleEnum index_style;
61 minlp->
get_nlp_info(numberColumns, numberRows, nnz_jac_g,
62 nnz_h_lag, index_style);
64 const double* x_l = minlp->
x_l();
65 const double* x_u = minlp->
x_u();
67 for(
int i=0; i<numberColumns; i++) {
69 (x_l[i] != 0.0 || x_u[i] != 1.0)) {
87 const double * bestSolution = model_->bestSolution();
95 int numberIntegers = model_->numberIntegers();
96 const int * integerVariable = model_->integerVariable();
98 double* vals =
new double[numberIntegers];
99 int* inds =
new int[numberIntegers];
101 for (
int i=0; i<numberIntegers; i++) {
102 int iColumn = integerVariable[i];
103 vals[i] = bestSolution[iColumn];
107 double rhs_local_branching_constraint = numberIntegers / 2;
108 nlp->switchToFeasibilityProblem(numberIntegers, vals, inds, rhs_local_branching_constraint);
111 r_val =
doLocalSearch(nlp, newSolution, objectiveValue, model_->getCutoff());
124 roptions->AddStringOption2(
125 "heuristic_local_branching",
126 "if yes runs the LocalBranching heuristic",
131 roptions->setOptionExtraInfo(
"heuristic_local_branching", 63);
int howOften_
How often to do (code can change)
For undocumented options.
virtual void validate()
Validate model i.e. sets when_ to 0 if necessary.
const TMINLP2TNLP * problem() const
get pointer to the TMINLP2TNLP adapter
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
OsiSolverInterface * clone(bool copyData=true) const
Virtual copy constructor.
void Initialize(Ipopt::SmartPtr< Ipopt::OptionsList > options)
Initiaize using passed options.
virtual void setModel(CbcModel *model)
Update model.
int solution(double &objectiveValue, double *newSolution)
Runs heuristic.
const Ipopt::Number * x_l()
Get the current values for the lower bounds.
virtual ~HeuristicLocalBranching()
Destructor.
const Ipopt::Number * x_u()
Get the current values for the upper bounds.
int doLocalSearch(OsiTMINLPInterface *solver, double *solution, double &solValue, double cutoff, std::string prefix="local_solver.") const
Do a local search based on setup and passed solver.
int numberSolutions_
Number of solutions so we can do something at solution.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options common to all local search based heuristics.
OsiTMINLPInterface * nonlinearSolver()
Pointer to the non-linear solver used.
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
virtual bool get_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, TNLP::IndexStyleEnum &index_style)
This call is just passed onto the TMINLP object.
HeuristicLocalBranching()
Default constructor.
VariableType
Type of the variables.
BonminSetup * setup_
Setup to use for local searches (will make copies).
const TMINLP::VariableType * var_types()
Get the variable types.