10 #include "CoinPragma.hpp"
12 #include "CbcModel.hpp"
59 const double* newSolution,
63 double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance);
65 const double* x_l = minlp->
x_l();
66 const double* x_u = minlp->
x_u();
69 double smallestFraction = COIN_DBL_MAX;
72 for(
int iIntCol=0; iIntCol<(
int)integerColumns.size(); iIntCol++) {
73 int iColumn = integerColumns[iIntCol];
74 double value=newSolution[iColumn];
75 if (fabs(floor(value+0.5)-value)>integerTolerance) {
76 double below = floor(value);
77 double downFraction = COIN_DBL_MAX;
78 if(below >= x_l[iColumn])
79 downFraction = value-below;
80 double above = ceil(value);
81 double upFraction = COIN_DBL_MAX;
82 if(above <= x_u[iColumn])
83 upFraction = ceil(value)-value;
86 if(downFraction < upFraction) {
87 fraction = downFraction;
89 }
else if(downFraction > upFraction) {
90 fraction = upFraction;
93 double randomNumber = CoinDrand48();
94 if(randomNumber<0.5) {
95 fraction = downFraction;
98 fraction = upFraction;
102 if(fraction<smallestFraction) {
103 smallestFraction = fraction;
104 bestColumn = iColumn;
115 roptions->AddStringOption2(
116 "heuristic_dive_MIP_fractional",
117 "if yes runs the Dive MIP Fractional heuristic",
122 roptions->setOptionExtraInfo(
"heuristic_dive_MIP_fractional", 63);
HeuristicDiveMIP & operator=(const HeuristicDiveMIP &rhs)
Assignment operator.
void Initialize(Ipopt::SmartPtr< Ipopt::OptionsList > options)
Initiaize using passed options.
virtual void setInternalVariables(TMINLP2TNLP *minlp)
sets internal variables
HeuristicDiveMIPFractional & operator=(const HeuristicDiveMIPFractional &rhs)
Assignment operator.
const Ipopt::Number * x_l()
Get the current values for the lower bounds.
const Ipopt::Number * x_u()
Get the current values for the upper bounds.
virtual CbcHeuristic * clone() const
Clone.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options common to all local search based heuristics.
HeuristicDiveMIPFractional()
Default Constructor.
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
virtual void selectVariableToBranch(TMINLP2TNLP *minlp, const vector< int > &integerColumns, const double *newSolution, int &bestColumn, int &bestRound)
Selects the next variable to branch on.