Bonmin 1.8.9
Loading...
Searching...
No Matches
BonBabSetupBase.hpp
Go to the documentation of this file.
1// (C) Copyright International Business Machines Corporation 2007
2// All Rights Reserved.
3// This code is published under the Eclipse Public License.
4//
5// Authors :
6// Pierre Bonami, International Business Machines Corporation
7//
8// Date : 04/12/2007
9
10#ifndef BabSetupBase_H
11#define BabSetupBase_H
12
13#include <string>
14#include <list>
15#include "CglCutGenerator.hpp"
16#include "CbcHeuristic.hpp"
17#include "OsiChooseVariable.hpp"
19#include "IpSmartPtr.hpp"
20#include "BonTMINLP2OsiLP.hpp"
21
22namespace Bonmin
23{
26 {
27 public:
30 {
32 std::string id;
35 bool normal;
36 bool always;
38 atSolution(false),
39 normal(true),
40 always(false)
41 {}
42
44 frequency(other.frequency),
45 id(other.id),
46 cgl(other.cgl),
48 normal(other.normal),
49 always(other.always)
50 {}
51 };
52
54 {
55 std::string id;
56 CbcHeuristic* heuristic;
59
61 id(other.id),
62 heuristic(other.heuristic)
63 {}
64 };
65 typedef std::list<CuttingMethod> CuttingMethods;
66 typedef std::list<HeuristicMethod > HeuristicMethods;
67
77
86
87
103
124
125
136
138 BabSetupBase(const CoinMessageHandler * handler = NULL);
139
148 OsiTMINLPInterface &nlp);
149
153 const std::string &prefix);
154
157
159 virtual BabSetupBase * clone() const = 0;
160
164 virtual ~BabSetupBase();
165
169 void use(const OsiTMINLPInterface& nlp);
179
180
184 virtual void registerOptions();
188
190
192 virtual void readOptionsFile()
193 {
194 if (readOptions_) return;
195 readOptionsFile("bonmin.opt");
196 }
197
199 void readOptionsFile(std::string fileName);
200
202 void readOptionsString(std::string opt_string);
203
205 void readOptionsStream(std::istream& is);
206
209
210
212 const char * prefix() const {
213 return prefix_.c_str();
214 }
215
225
229
237
242
244 {
245 return cutGenerators_;
246 }
247
249 {
250 return heuristics_;
251 }
252
257
262
267
268 int getIntParameter(const IntParameter &p) const
269 {
270 return intParam_[p];
271 }
272
273 double getDoubleParameter(const DoubleParameter &p) const
274 {
275 return doubleParam_[p];
276 }
277
278 void setIntParameter(const IntParameter &p, const int v)
279 {
280 intParam_[p] = v;
281 }
282
283 void setDoubleParameter(const DoubleParameter &p, const double v)
284 {
285 doubleParam_[p] = v;
286 }
287
288
294
301
307
313
316 {
317 return objects_;
318 }
319
322 {
323 return objects_;
324 }
325
327 cutGenerators_.push_back(cg);
328 }
329
330 void set_linearizer(TMINLP2OsiLP * linearizer){
331 linearizer_ = linearizer;
332 }
333
334 protected:
338 void addSos();
339
366
367
370
373
376
382 std::string prefix_;
383 };
384}/* End namespace Bonmin. */
385#endif
386
void gatherParametersValues()
Get the values of base parameters from the options stored.
virtual void readOptionsFile()
Get the options from default text file (bonmin.opt) if don't already have them.
OsiChooseVariable * branchingMethod_
Branching method.
void mayPrintDoc()
May print documentation of options if options print_options_documentation is set to yes.
void setPriorities()
Set the priorities into OsiTMINLPInterface when needed.
CuttingMethods cutGenerators_
Cut generation methods.
static double defaultDoubleParam_[NumberDoubleParam]
default values for double parameters.
vector< OsiObject * > objects_
Extra object to add to Cbc (not OsiObjects).
OsiTMINLPInterface * nonlinearSolver()
Pointer to the non-linear solver used.
void initializeOptionsAndJournalist()
Initialize the options and the journalist.
void readOptionsStream(std::istream &is)
Get the options from stream.
BabSetupBase(const BabSetupBase &setup, OsiTMINLPInterface &nlp, const std::string &prefix)
Copy but uses an other nlp.
BabSetupBase(const OsiTMINLPInterface &nlp)
Construct from existing TMINLP interface.
Ipopt::SmartPtr< Ipopt::Journalist > journalist()
Acces storage of Journalist for output.
TreeTraversal treeTraversalMethod_
Tree traversal method.
double getDoubleParameter(const DoubleParameter &p) const
Return value of double parameter.
BabSetupBase(const CoinMessageHandler *handler=NULL)
Default constructor.
OsiTMINLPInterface * nonlinearSolver_
Storage of the non-linear solver used.
const vector< OsiObject * > & objects() const
Access to extra objects.
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
void readOptionsFile(std::string fileName)
Get the options from given fileName.
BabSetupBase(Ipopt::SmartPtr< TNLPSolver > app)
Construct from existing application.
std::string prefix_
Prefix to use when reading options.
int getIntParameter(const IntParameter &p) const
Return value of integer parameter.
BabSetupBase(Ipopt::SmartPtr< TMINLP > tminlp, const CoinMessageHandler *handler=NULL)
Construct from existing tminlp.
vector< OsiObject * > & objects()
Access to extra objects.
void use(Ipopt::SmartPtr< TMINLP > tminlp)
Read options (if not done before) and create interface using tminlp.
void setNonlinearSolver(OsiTMINLPInterface *s)
Set the non-linear solver used.
void set_linearizer(TMINLP2OsiLP *linearizer)
void gatherParametersValues(Ipopt::SmartPtr< Ipopt::OptionsList > options)
Get the values of the base parameters from the passed options.
bool readOptions_
flag to say if option file was read.
BabSetupBase(const BabSetupBase &setup, OsiTMINLPInterface &nlp)
Copy but uses an other nlp.
HeuristicMethods & heuristics()
list of Heuristic methods to use.
CuttingMethods & cutGenerators()
list of cutting planes methods to apply with their frequencies.
NodeComparison nodeComparisonMethod_
Node comparison method.
OsiSolverInterface * continuousSolver_
Storage of continuous solver.
HeuristicMethods heuristics_
Heuristic methods.
void addSos()
Add SOS constraints to OsiTMINLPInterface when needed.
Ipopt::SmartPtr< TMINLP2OsiLP > linearizer_
Method to linearize MINLPs.
NodeComparison
Strategies for comparing the nodes on the heap.
@ BFS
Best First Search.
@ dynamic
Dynamic strategy, see CbcBranchActual.hpp for explanations.
@ bestGuess
Best guessed integer solution is subtree below, based on pseudo costs.
@ DFS
Depth First Search.
virtual void setBabDefaultOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Setup the defaults options for this algorithm.
NodeComparison & nodeComparisonMethod()
Method used to compare nodes.
Ipopt::SmartPtr< Ipopt::OptionsList > options_
List of Options.
int intParam_[NumberIntParam]
storage of integer parameters.
virtual BabSetupBase * clone() const =0
virtual copy constructor.
Ipopt::SmartPtr< Ipopt::Journalist > journalist_
Storage of Journalist for output.
static void registerAllOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register all the options for this algorithm instance.
void addCutGenerator(CuttingMethod &cg)
OsiChooseVariable * branchingMethod()
branching method to use.
const char * prefix() const
Get prefix to use for options.
void use(Ipopt::SmartPtr< TMINLP2TNLP > prob)
use specific instanciation of a TMINLP2TNLP.
void setOptionsAndJournalist(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions, Ipopt::SmartPtr< Ipopt::OptionsList > options, Ipopt::SmartPtr< Ipopt::Journalist > journalist)
Set the value for options, output...
void use(const OsiTMINLPInterface &nlp)
use existing TMINLP interface (containing the options).
IntParameter
Parameters represented by an integer.
@ MinReliability
Minimum reliability before trust pseudo-costs.
@ RootLogLevel
Log level for root relaxation.
@ DisableSos
Consider or not SOS constraints.
@ MaxFailures
Max number of failures in a branch.
@ MaxInfeasible
Max number of consecutive infeasible problem in a branch before fathoming.
@ MaxIterations
Global iteration limit.
@ NumCutPassesAtRoot
Number of cut passes at nodes.
@ MaxSolutions
limit on number of integer feasible solution.
@ SpecialOption
Spetial option in particular for Cbc.
@ NumberIntParam
Dummy end to size table.
@ MaxNodes
Global node limit.
@ BabLogInterval
Display information every logIntervval nodes.
@ FailureBehavior
Behavior of the algorithm in the case of a failure.
@ NumberStrong
Number of candidates for strong branching.
@ NumCutPasses
Number of cut passes at nodes.
DoubleParameter
Parameters represented by a double.
@ NumberDoubleParam
Dummy end to size table.
@ IntTol
Integer tolerance.
@ MaxTime
Global time limit.
@ AllowableGap
Stop if absolute gap is less than this.
@ AllowableFractionGap
Stop if relative gap is less than this.
virtual BabSetupBase * clone(OsiTMINLPInterface &nlp) const
Make a copy with solver replace by one passed .
std::list< HeuristicMethod > HeuristicMethods
virtual void registerOptions()
Register all the options for this algorithm instance.
BabSetupBase(const BabSetupBase &other)
Copy constructor.
virtual ~BabSetupBase()
Virtual destructor.
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions()
Access registered Options.
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions_
Registered Options.
TreeTraversal treeTraversalMethod()
Method used to traverse tree.
OsiSolverInterface * continuousSolver()
Pointer to the continuous solver to use for relaxations.
double doubleParam_[NumberDoubleParam]
storage of double parameters.
std::list< CuttingMethod > CuttingMethods
CoinMessageHandler * messageHandler_
separate message handler.
void readOptionsString(std::string opt_string)
Get the options from long string containing all.
TreeTraversal
Strategies for traversing the tree.
@ DfsDiveFromBest
dive from top node of the heap with more elaborate strategy (see options doc).
@ DiveFromBest
dive from top node of the heap untill it gets to a leaf of the tree.
@ ProbedDive
Eplore two kids before following on dive.
@ DfsDiveDynamic
Same as DfsDiveFromBest, but after a prescribed number of integer solution are found switch to best-b...
static int defaultIntParam_[NumberIntParam]
default values for int parameters.
void setDoubleParameter(const DoubleParameter &p, const double v)
Return value of double parameter.
void setIntParameter(const IntParameter &p, const int v)
Return value of integer parameter.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
A transformer class to build outer approximations i.e.
A small wrap around std::vector to give easy access to array for interfacing with fortran code.
Definition BonTypes.hpp:9
(C) Copyright International Business Machines Corporation 2007
Type for cut generation method with its frequency and string identification.
CuttingMethod(const CuttingMethod &other)
HeuristicMethod(const HeuristicMethod &other)