SepaSetup.cpp
Go to the documentation of this file.
1 // (C) Copyright CNRS and others 2010
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, Université de la Méditérannée
7 // Hassan Hijazi, Orange Labs
8 //
9 // Date : 05/22/2010
10 
11 #include "BonminConfig.h"
12 #include "OsiClpSolverInterface.hpp"
13 
14 #include "SepaSetup.hpp"
15 #include "SepaTMINLP2OsiLP.hpp"
17 #include "BonOuterDescription.hpp"
18 
19 namespace Sepa
20 {
21  SepaSetup::SepaSetup(const CoinMessageHandler * handler):BonminSetup(handler)
22  {
23  }
24 
25  SepaSetup::SepaSetup(const SepaSetup &other):BonminSetup(other)
26  {}
27 
30  BonminSetup(other, nlp)
31  {
32  }
33 
36  const std::string &prefix):
37  BonminSetup(other, nlp, prefix)
38  {
40  if (algo == Bonmin::B_OA)
42  }
43 
45  {
47 
49 
50  roptions->SetRegisteringCategory("Initial Approximations descriptions", Bonmin::RegisteredOptions::UndocumentedCategory);
51  roptions->AddStringOption2("initial_outer_description",
52  "Do we add all Outer Approximation constraints defining the initial Outer Approximation "
53  "description of the MINLP. See the number_approximations_initial_outer option for fixing the "
54  "number of approximation points",
55  "yes", "no","Do not generate the description", "yes","Generate the description",
56  "");
57 
58  roptions->AddUpperBoundedIntegerOption("number_approximations_initial_outer",
59  "Number of Outer Approximation points needed for generating the initial Outer Approximation description, maximum value = 500, default value = 50",
60  500, 50, "");
61  }
62 
64  void
66  {
68  }
69 
71  void
72  SepaSetup::initialize(Ipopt::SmartPtr<Bonmin::TMINLP> tminlp, bool createContinuousSolver /*= false*/)
73  {
74 
75  int do_outer;
76  int n_approx;
77  options()->GetEnumValue("initial_outer_description", do_outer, prefix_.c_str());
78  options()->GetIntegerValue("number_approximations_initial_outer",
79  n_approx, prefix_.c_str());
80  SepaTMINLP2OsiLP* linearizer = new SepaTMINLP2OsiLP;
81  linearizer_ = linearizer;
82  if(do_outer)
83  linearizer->set_num_approx(n_approx);
84 
85  Bonmin::BonminSetup::initialize(tminlp, createContinuousSolver);
86 
87  if (getAlgorithm() == Bonmin::B_OA)
89  }
90 
92  void
93  SepaSetup::initialize(const Bonmin::OsiTMINLPInterface &nlpSi, bool createContinuousSolver /*= false*/)
94  {
95  int do_outer;
96  int n_approx;
97  options()->GetEnumValue("initial_outer_description", do_outer, prefix_.c_str());
98  options()->GetIntegerValue("number_approximations_initial_outer",
99  n_approx, prefix_.c_str());
100  SepaTMINLP2OsiLP* linearizer = new SepaTMINLP2OsiLP;
101  linearizer_ = linearizer;
102  if(do_outer)
103  linearizer->set_num_approx(n_approx);
104 
105  BonminSetup::initialize(nlpSi, createContinuousSolver);
106  if (getAlgorithm() == Bonmin::B_OA)
107  initializeSepa();
108  }
109 
111  {
112 
113 
114  int doOuter;
115  int nbAp = 10;
116  options()->GetEnumValue("initial_outer_description", doOuter, prefix_.c_str());
117  options()->GetIntegerValue("number_approximations_initial_outer",
118  nbAp, prefix_.c_str());
119 
120 #ifdef USE_OLD_FUNC
121  if(doOuter)
122  addOuterDescription(*nonlinearSolver(), *continuousSolver(), nonlinearSolver()->getColSolution(), nbAp, false);
123 #endif
124 
125  int doInner;
126 
127  options()->GetEnumValue("heuristic_inner_approximation", doInner, prefix_.c_str());
128  if(doInner){
130  HeuristicMethod h;
131  h.heuristic = inner;
132  h.id = "InnerApproximation";
133  heuristics_.push_back(h);
134  }
135 
136  }
137 
138 }/* end namespace Bonmin*/
139 
void initialize(Ipopt::SmartPtr< Bonmin::TMINLP > tminlp, bool createContinuousSolver=true)
Initialize, read options and create appropriate bonmin setup.
Definition: SepaSetup.cpp:72
void addOuterDescription(OsiTMINLPInterface &nlp, OsiSolverInterface &si, const double *x, int nbAp, bool getObj)
Adds an outer description of problem to linear formulation.
Type for heuristic method with its string identification.
SepaSetup(const CoinMessageHandler *handler=NULL)
Default constructor.
Definition: SepaSetup.cpp:21
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
HeuristicMethods heuristics_
Heuristic methods.
Algorithm
Type of algorithms which can be used.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options common to all local search based heuristics.
A transformer class to build outer approximations i.e.
algorithm setup.
Definition: SepaSetup.hpp:18
Bonmin::Algorithm getAlgorithm()
Get the algorithm used.
static void registerAllOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register all bonmin type executable options.
virtual void registerOptions()
Register all the options for this algorithm instance.
Definition: SepaSetup.cpp:65
Ipopt::SmartPtr< TMINLP2OsiLP > linearizer_
Method to linearize MINLPs.
std::string prefix_
Prefix to use when reading options.
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions_
Registered Options.
void initializeSepa()
Initialize a branch-and-cut with some OA.
Definition: SepaSetup.cpp:110
OsiTMINLPInterface * nonlinearSolver()
Pointer to the non-linear solver used.
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
OsiSolverInterface * continuousSolver()
Pointer to the continuous solver to use for relaxations.
static char prefix[100]
Definition: BM_lp.cpp:26
static void registerAllOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register all bonmin type executable options.
Definition: SepaSetup.cpp:44
void initialize(Ipopt::SmartPtr< TMINLP > tminlp, bool createContinuousSolver=true)
Initialize, read options and create appropriate bonmin setup.