00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef BabSetupBase_H
00011 #define BabSetupBase_H
00012
00013 #include <string>
00014 #include <list>
00015 #include "CglCutGenerator.hpp"
00016 #include "CbcHeuristic.hpp"
00017 #include "OsiChooseVariable.hpp"
00018 #include "BonOsiTMINLPInterface.hpp"
00019 namespace Bonmin
00020 {
00022 class BabSetupBase
00023 {
00024 public:
00026 struct CuttingMethod
00027 {
00028 int frequency;
00029 std::string id;
00030 CglCutGenerator * cgl;
00031 bool atSolution;
00032 bool normal;
00033 CuttingMethod():
00034 atSolution(false),
00035 normal(true)
00036 {}
00037
00038 CuttingMethod(const CuttingMethod & other):
00039 frequency(other.frequency),
00040 id(other.id),
00041 cgl(other.cgl),
00042 atSolution(other.atSolution),
00043 normal(other.normal)
00044 {}
00045 };
00047 struct HeuristicMethod
00048 {
00049 std::string id;
00050 CbcHeuristic* heuristic;
00051 HeuristicMethod()
00052 {}
00053
00054 HeuristicMethod(const HeuristicMethod & other):
00055 id(other.id),
00056 heuristic(other.heuristic)
00057 {}
00058 };
00059 typedef std::list<CuttingMethod> CuttingMethods;
00060 typedef std::list<HeuristicMethod > HeuristicMethods;
00061
00063 enum NodeComparison {
00064 bestBound = 0 ,
00065 DFS ,
00066 BFS ,
00067 dynamic ,
00069 bestGuess
00070 };
00071
00073 enum TreeTraversal {
00074 HeapOnly=0 ,
00075 DiveFromBest ,
00076 ProbedDive ,
00077 DfsDiveFromBest ,
00078 DfsDiveDynamic
00079 };
00080
00081
00083 enum VarSelectStra_Enum {
00084 MOST_FRACTIONAL=0,
00085 STRONG_BRANCHING,
00086 RELIABILITY_BRANCHING,
00087 CURVATURE_ESTIMATOR,
00088 QP_STRONG_BRANCHING,
00089 LP_STRONG_BRANCHING,
00090 NLP_STRONG_BRANCHING,
00091 OSI_SIMPLE,
00092 OSI_STRONG,
00093 RANDOM
00094 };
00095
00097 enum IntParameter{
00098 BabLogLevel = 0 ,
00099 BabLogInterval,
00100 MaxFailures ,
00101 FailureBehavior ,
00102 MaxInfeasible ,
00104 NumberStrong ,
00105 MinReliability ,
00106 MaxNodes ,
00107 MaxSolutions ,
00108 MaxIterations ,
00109 SpecialOption ,
00110 DisableSos ,
00111 NumCutPasses,
00112 NumCutPassesAtRoot,
00113 NumberIntParam
00114 };
00115
00116
00118 enum DoubleParameter{
00119 CutoffDecr = 0 ,
00120 Cutoff ,
00121 AllowableGap ,
00122 AllowableFractionGap ,
00123 IntTol ,
00124 MaxTime ,
00125 NumberDoubleParam
00126 };
00127
00129 BabSetupBase();
00130
00132 BabSetupBase(Ipopt::SmartPtr<TMINLP> tminlp);
00134 BabSetupBase(Ipopt::SmartPtr<TNLPSolver> app);
00136 BabSetupBase(const OsiTMINLPInterface& nlp);
00138 BabSetupBase(const BabSetupBase &setup,
00139 OsiTMINLPInterface &nlp);
00140
00142 BabSetupBase(const BabSetupBase & other);
00143
00145 virtual BabSetupBase * clone() const = 0;
00146
00148 virtual BabSetupBase *clone(OsiTMINLPInterface&nlp)const;
00150 virtual ~BabSetupBase();
00151
00155 void use(const OsiTMINLPInterface& nlp);
00157 void use(Ipopt::SmartPtr<TMINLP> tminlp );
00159 void use(Ipopt::SmartPtr<TMINLP2TNLP> prob);
00161 void setNonlinearSolver(OsiTMINLPInterface * s)
00162 {
00163 nonlinearSolver_ = s;
00164 }
00170 virtual void registerOptions();
00172 virtual void setBabDefaultOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions)
00173 {}
00175 static void registerAllOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
00176
00178 virtual void readOptionsFile()
00179 {
00180 if (readOptions_) return;
00181 readOptionsFile("bonmin.opt");
00182 }
00183
00185 void readOptionsFile(std::string fileName);
00186
00188 void readOptionsString(std::string opt_string);
00189
00191 void readOptionsStream(std::istream& is);
00192
00194 void mayPrintDoc();
00195
00196
00198 void setOptionsAndJournalist(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions,
00199 Ipopt::SmartPtr<Ipopt::OptionsList> options,
00200 Ipopt::SmartPtr<Ipopt::Journalist> journalist)
00201 {
00202 options_ = options;
00203 roptions_ = roptions;
00204 journalist_ = journalist;
00205 }
00206
00208 void initializeOptionsAndJournalist();
00214 OsiTMINLPInterface * nonlinearSolver()
00215 {
00216 return nonlinearSolver_;
00217 }
00219 OsiSolverInterface * continuousSolver()
00220 {
00221 return continuousSolver_;
00222 }
00224 CuttingMethods& cutGenerators()
00225 {
00226 return cutGenerators_;
00227 }
00229 HeuristicMethods& heuristics()
00230 {
00231 return heuristics_;
00232 }
00234 OsiChooseVariable * branchingMethod()
00235 {
00236 return branchingMethod_;
00237 }
00239 NodeComparison nodeComparisonMethod()
00240 {
00241 return nodeComparisonMethod_;
00242 }
00244 TreeTraversal treeTraversalMethod()
00245 {
00246 return treeTraversalMethod_;
00247 }
00249 int getIntParameter(const IntParameter &p) const
00250 {
00251 return intParam_[p];
00252 }
00254 double getDoubleParameter(const DoubleParameter &p) const
00255 {
00256 return doubleParam_[p];
00257 }
00259 void setIntParameter(const IntParameter &p, const int v)
00260 {
00261 intParam_[p] = v;
00262 }
00264 void setDoubleParameter(const DoubleParameter &p, const double v)
00265 {
00266 doubleParam_[p] = v;
00267 }
00271 void gatherParametersValues()
00272 {
00273 gatherParametersValues(options_);
00274 }
00276 void gatherParametersValues(Ipopt::SmartPtr<OptionsList> options);
00278 Ipopt::SmartPtr<Ipopt::Journalist> journalist()
00279 {
00280 return journalist_;
00281 }
00282
00284 Ipopt::SmartPtr<Ipopt::OptionsList> options()
00285 {
00286 return options_;
00287 }
00288
00290 Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions()
00291 {
00292 return roptions_;
00293 }
00294
00296 const vector<OsiObject *>& objects() const
00297 {
00298 return objects_;
00299 }
00300
00302 vector<OsiObject *>& objects()
00303 {
00304 return objects_;
00305 }
00306
00307 protected:
00309 void setPriorities();
00311 void addSos();
00312
00314 int intParam_[NumberIntParam];
00316 static int defaultIntParam_[NumberIntParam];
00318 double doubleParam_[NumberDoubleParam];
00320 static double defaultDoubleParam_[NumberDoubleParam];
00322 OsiTMINLPInterface * nonlinearSolver_;
00324 OsiSolverInterface * continuousSolver_;
00326 CuttingMethods cutGenerators_;
00328 HeuristicMethods heuristics_;
00330 OsiChooseVariable * branchingMethod_;
00332 NodeComparison nodeComparisonMethod_;
00334 TreeTraversal treeTraversalMethod_;
00336 vector<OsiObject *> objects_;
00337
00338
00340 Ipopt::SmartPtr<Ipopt::Journalist> journalist_;
00341
00343 Ipopt::SmartPtr<Ipopt::OptionsList> options_;
00344
00346 Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions_;
00347
00349 bool readOptions_;
00351 CoinMessageHandler * lpMessageHandler_;
00352 };
00353 }
00354 #endif
00355