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 };
00046 typedef std::list<CuttingMethod> CuttingMethods;
00047 typedef std::list<CbcHeuristic * > HeuristicMethods;
00048
00050 enum NodeComparison {
00051 bestBound = 0 ,
00052 DFS ,
00053 BFS ,
00054 dynamic ,
00056 bestGuess
00057 };
00058
00060 enum TreeTraversal {
00061 HeapOnly=0 ,
00062 DiveFromBest ,
00063 ProbedDive ,
00064 DfsDiveFromBest ,
00065 DfsDiveDynamic
00066 };
00067
00068
00070 enum VarSelectStra_Enum {
00071 MOST_FRACTIONAL=0,
00072 STRONG_BRANCHING,
00073 RELIABILITY_BRANCHING,
00074 CURVATURE_ESTIMATOR,
00075 QP_STRONG_BRANCHING,
00076 LP_STRONG_BRANCHING,
00077 NLP_STRONG_BRANCHING,
00078 OSI_SIMPLE,
00079 OSI_STRONG,
00080 RANDOM
00081 };
00082
00084 enum IntParameter{
00085 BabLogLevel = 0 ,
00086 BabLogInterval,
00087 MaxFailures ,
00088 FailureBehavior ,
00089 MaxInfeasible ,
00091 NumberStrong ,
00092 MinReliability ,
00093 MaxNodes ,
00094 MaxSolutions ,
00095 MaxIterations ,
00096 SpecialOption ,
00097 DisableSos ,
00098 NumCutPasses,
00099 NumCutPassesAtRoot,
00100 NumberIntParam
00101 };
00102
00103
00105 enum DoubleParameter{
00106 CutoffDecr = 0 ,
00107 Cutoff ,
00108 AllowableGap ,
00109 AllowableFractionGap ,
00110 IntTol ,
00111 MaxTime ,
00112 NumberDoubleParam
00113 };
00114
00116 BabSetupBase();
00117
00119 BabSetupBase(Ipopt::SmartPtr<TMINLP> tminlp);
00121 BabSetupBase(Ipopt::SmartPtr<TNLPSolver> app);
00123 BabSetupBase(const OsiTMINLPInterface& nlp);
00124
00125
00127 BabSetupBase(const BabSetupBase & other);
00128
00130 virtual BabSetupBase * clone() const = 0;
00131
00133 virtual ~BabSetupBase();
00134
00138 void use(const OsiTMINLPInterface& nlp);
00140 void use(Ipopt::SmartPtr<TMINLP> tminlp );
00142 void use(Ipopt::SmartPtr<TMINLP2TNLP> prob);
00144 void setNonlinearSolver(OsiTMINLPInterface * s)
00145 {
00146 nonlinearSolver_ = s;
00147 }
00153 virtual void registerOptions();
00155 virtual void setBabDefaultOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions)
00156 {}
00158 static void registerAllOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
00159
00161 virtual void readOptionsFile()
00162 {
00163 if (readOptions_) return;
00164 readOptionsFile("bonmin.opt");
00165 }
00166
00168 void readOptionsFile(std::string fileName);
00169
00171 void readOptionsString(std::string opt_string);
00172
00174 void readOptionsStream(std::istream& is);
00175
00177 void mayPrintDoc();
00178
00179
00181 void setOptionsAndJournalist(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions,
00182 Ipopt::SmartPtr<Ipopt::OptionsList> options,
00183 Ipopt::SmartPtr<Ipopt::Journalist> journalist)
00184 {
00185 options_ = options;
00186 roptions_ = roptions;
00187 journalist_ = journalist;
00188 }
00189
00191 void initializeOptionsAndJournalist();
00197 OsiTMINLPInterface * nonlinearSolver()
00198 {
00199 return nonlinearSolver_;
00200 }
00202 OsiSolverInterface * continuousSolver()
00203 {
00204 return continuousSolver_;
00205 }
00207 CuttingMethods& cutGenerators()
00208 {
00209 return cutGenerators_;
00210 }
00212 HeuristicMethods& heuristics()
00213 {
00214 return heuristics_;
00215 }
00217 OsiChooseVariable * branchingMethod()
00218 {
00219 return branchingMethod_;
00220 }
00222 NodeComparison nodeComparisonMethod()
00223 {
00224 return nodeComparisonMethod_;
00225 }
00227 TreeTraversal treeTraversalMethod()
00228 {
00229 return treeTraversalMethod_;
00230 }
00232 int getIntParameter(const IntParameter &p)
00233 {
00234 return intParam_[p];
00235 }
00237 double getDoubleParameter(const DoubleParameter &p)
00238 {
00239 return doubleParam_[p];
00240 }
00244 void gatherParametersValues()
00245 {
00246 gatherParametersValues(options_);
00247 }
00249 void gatherParametersValues(Ipopt::SmartPtr<OptionsList> options);
00251 Ipopt::SmartPtr<Ipopt::Journalist> journalist()
00252 {
00253 return journalist_;
00254 }
00255
00257 Ipopt::SmartPtr<Ipopt::OptionsList> options()
00258 {
00259 return options_;
00260 }
00261
00263 Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions()
00264 {
00265 return roptions_;
00266 }
00267
00269 const vector<OsiObject *>& objects() const
00270 {
00271 return objects_;
00272 }
00273
00275 vector<OsiObject *>& objects()
00276 {
00277 return objects_;
00278 }
00279
00280 protected:
00282 void setPriorities();
00284 void addSos();
00285
00287 int intParam_[NumberIntParam];
00289 static int defaultIntParam_[NumberIntParam];
00291 double doubleParam_[NumberDoubleParam];
00293 static double defaultDoubleParam_[NumberDoubleParam];
00295 OsiTMINLPInterface * nonlinearSolver_;
00297 OsiSolverInterface * continuousSolver_;
00299 CuttingMethods cutGenerators_;
00301 HeuristicMethods heuristics_;
00303 OsiChooseVariable * branchingMethod_;
00305 NodeComparison nodeComparisonMethod_;
00307 TreeTraversal treeTraversalMethod_;
00309 vector<OsiObject *> objects_;
00310
00311
00313 Ipopt::SmartPtr<Ipopt::Journalist> journalist_;
00314
00316 Ipopt::SmartPtr<Ipopt::OptionsList> options_;
00317
00319 Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions_;
00320
00322 bool readOptions_;
00324 CoinMessageHandler * lpMessageHandler_;
00325 };
00326 }
00327 #endif
00328