00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "BonminConfig.h"
00012 #include "OsiClpSolverInterface.hpp"
00013
00014 #include "SepaSetup.hpp"
00015 #include "BonHeuristicInnerApproximation.hpp"
00016 #include "BonOuterDescription.hpp"
00017 namespace Bonmin
00018 {
00019 SepaSetup::SepaSetup(const CoinMessageHandler * handler):BonminSetup(handler)
00020 {}
00021
00022 SepaSetup::SepaSetup(const SepaSetup &other):BonminSetup(other)
00023 {}
00024
00025 SepaSetup::SepaSetup(const SepaSetup &other,
00026 OsiTMINLPInterface &nlp):
00027 BonminSetup(other, nlp)
00028 {
00029 }
00030
00031 SepaSetup::SepaSetup(const SepaSetup &other,
00032 OsiTMINLPInterface &nlp,
00033 const std::string &prefix):
00034 BonminSetup(other, nlp, prefix)
00035 {
00036 Algorithm algo = getAlgorithm();
00037 if (algo == B_OA)
00038 initializeSepa();
00039 }
00040
00041 void SepaSetup::registerAllOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions)
00042 {
00043 BonminSetup::registerAllOptions(roptions);
00044
00045 HeuristicInnerApproximation::registerOptions(roptions);
00046
00047 roptions->SetRegisteringCategory("Initial Approximations descriptions", RegisteredOptions::UndocumentedCategory);
00048 roptions->AddStringOption2("initial_outer_description",
00049 "Do we add all Outer Approximation constraints defining the initial Outer Approximation description of the MINLP. See the number_approximations_initial_outer option for fixing the number of approximation points",
00050 "yes",
00051 "no","Do not generate the description",
00052 "yes","Generate the description",
00053 "");
00054 roptions->AddUpperBoundedIntegerOption("number_approximations_initial_outer",
00055 "Number of Outer Approximation points needed for generating the initial Outer Approximation description, maximum value = 500, default value = 50",
00056 500,
00057 50,
00058 "");
00059 }
00060
00062 void
00063 SepaSetup::registerOptions()
00064 {
00065 registerAllOptions(roptions_);
00066 }
00067
00069 void
00070 SepaSetup::initialize(Ipopt::SmartPtr<TMINLP> tminlp, bool createContinuousSolver )
00071 {
00072 BonminSetup::initialize(tminlp, createContinuousSolver);
00073 if (getAlgorithm() == B_OA)
00074 initializeSepa();
00075 }
00076
00078 void
00079 SepaSetup::initialize(const OsiTMINLPInterface &nlpSi, bool createContinuousSolver )
00080 {
00081 BonminSetup::initialize(nlpSi, createContinuousSolver);
00082 if (getAlgorithm() == B_OA)
00083 initializeSepa();
00084 }
00085
00086 void SepaSetup::initializeSepa()
00087 {
00088
00089 int doOuter;
00090 int nbAp = 10;
00091 options()->GetEnumValue("initial_outer_description", doOuter, prefix_.c_str());
00092 options()->GetIntegerValue("number_approximations_initial_outer",
00093 nbAp, prefix_.c_str());
00094 if(doOuter)
00095 addOuterDescription(*nonlinearSolver(), *continuousSolver(), nonlinearSolver()->getColSolution(), nbAp, false);
00096 int doInner;
00097
00098 options()->GetEnumValue("heuristic_inner_approximation", doInner, prefix_.c_str());
00099 if(doInner){
00100 HeuristicInnerApproximation * inner = new HeuristicInnerApproximation(this);
00101 HeuristicMethod h;
00102 h.heuristic = inner;
00103 h.id = "InnerApproximation";
00104 heuristics_.push_back(h);
00105 }
00106
00107 }
00108
00109 }
00110