BonDummyPump.cpp
Go to the documentation of this file.
1 // (C) Copyright CNRS
2 // This code is published under the Eclipse Public License.
3 //
4 // Authors :
5 // Pierre Bonami, LIF Université de la Méditérannée-CNRS
6 //
7 // Date : 06/18/2008
8 
9 #include "BonDummyPump.hpp"
10 #include "CbcModel.hpp"
11 #include "OsiBranchingObject.hpp"
12 
13 namespace Bonmin {
14 
18  }
22  }
23 
26  (const DummyPump &other):
28  }
29 
31  }
32 
34  int
35  DummyPump::solution(double & objectiveValue,
36  double * newSolution){
37  if(model_->getNodeCount() || model_->getCurrentPassNumber() > 1) return 0;
38  //int numberObjects = model_->numberObjects();
39  //OsiObject ** objects = model_->objects();
40  OsiTMINLPInterface * nlp = dynamic_cast<OsiTMINLPInterface *>
42 
43  OsiBranchingInformation info = model_->usefulInformation();
44  info.solution_ = model_->getColSolution();
45  int numcols = model_->getNumCols();
46  vector<double> vals;
47  vector<int> inds;
48 
49  for(int i = 0 ;i < numcols ; i++){
50  if(nlp->isInteger(i)){
51  vals.push_back(info.solution_[i]);
52  inds.push_back(i);
53  }
54  }
55  nlp->switchToFeasibilityProblem(inds.size(), vals(), inds(), 1., 0., 1);
56 
57  double cutoff = info.cutoff_;
58  int r_val = doLocalSearch(nlp, newSolution, objectiveValue, cutoff);
59  delete nlp;
60  return r_val;
61  }
62 
63  void
65  roptions->SetRegisteringCategory("Primal Heuristics (undocumented)", RegisteredOptions::UndocumentedCategory);
66  roptions->AddStringOption2(
67  "dummy_pump_heuristic",
68  "if yes runs a heuristic which looks like a dummy FP",
69  "no",
70  "no", "don't run it",
71  "yes", "runs the heuristic",
72  "");
73  roptions->setOptionExtraInfo("dummy_pump_heuristic", 63);
74  }
75 
77  void
79  }
80 }/* ends bonmin namespace*/
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
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
virtual bool isInteger(int columnNumber) const
Return true if column is integer.
DummyPump()
Default constructor.
OsiSolverInterface * clone(bool copyData=true) const
Virtual copy constructor.
int solution(double &objectiveValue, double *newSolution)
Runs heuristic.
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.
virtual ~DummyPump()
Destructor.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options common to all local search based heuristics.
void Initialize(Ipopt::SmartPtr< Ipopt::OptionsList > options)
Initiaize using passed options.
OsiTMINLPInterface * nonlinearSolver()
Pointer to the non-linear solver used.
BonminSetup * setup_
Setup to use for local searches (will make copies).