Bonmin  1.8.8
BonSubMipSolver.hpp
Go to the documentation of this file.
1 // (C) Copyright International Business Machines (IBM) 2006
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // P. Bonami, International Business Machines
7 //
8 // Date : 12/07/2006
9 
10 
11 // Code separated from BonOaDecBase to try to clarify OAs
12 #ifndef BonSubMipSolver_HPP
13 #define BonSubMipSolver_HPP
14 #include "IpSmartPtr.hpp"
15 #include <string>
16 /* forward declarations.*/
17 class OsiSolverInterface;
18 class OsiClpSolverInterface;
19 class OsiCpxSolverInterface;
20 class CbcStrategy;
21 class CbcStrategyDefault;
22 
23 #include "OsiCuts.hpp"
24 
25 namespace Bonmin {
26  class RegisteredOptions;
27  class BabSetupBase;
30  {
31  public:
36  SubMipSolver(BabSetupBase &b, const std::string &prefix);
37 
39  SubMipSolver(const SubMipSolver &copy);
40 
41  ~SubMipSolver();
42 
44  void setLpSolver(OsiSolverInterface * lp);
45 
47  void setStrategy(CbcStrategyDefault * strategy);
48 
50  const double * getLastSolution()
51  {
52  return integerSolution_;
53  }
54 
55  double getLowerBound()
56  {
57  return lowBound_;
58  }
59 
60  void solve(double cutoff,
61  int loglevel,
62  double maxTime){
64  find_good_sol(cutoff, loglevel, maxTime);
65  }
66  else
67  optimize(cutoff, loglevel, maxTime);
68  }
69 
70 
72  void find_good_sol(double cutoff,
73  int loglevel,
74  double maxTime);
75 
77  void optimize(double cutoff,
78  int loglevel,
79  double maxTime);
80 
82  void optimize_with_lazy_constraints(double cutoff,
83  int loglevel,
84  double maxTime, const OsiCuts & cs);
85 
87  inline double lowBound()
88  {
89  return lowBound_;
90  }
91 
93  inline bool optimal()
94  {
95  return optimal_;
96  }
97 
99  inline int nodeCount()
100  {
101  return nodeCount_;
102  }
103 
105  inline int iterationCount()
106  {
107  return iterationCount_;
108  }
109 
110 
111  OsiSolverInterface * solver();
112 
114  static void registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
115  private:
117  OsiClpSolverInterface *clp_;
119  OsiCpxSolverInterface * cpx_;
121  double lowBound_;
123  bool optimal_;
127  CbcStrategyDefault * strategy_;
135  double gap_tol_;
137  bool ownClp_;
138  };
139 
140 }
141 
142 #endif
143 
bool ownClp_
say if owns copy of clp_.
void setStrategy(CbcStrategyDefault *strategy)
Assign a strategy.
int nodeCount_
number of nodes in last mip solved.
double * integerSolution_
Has an integer solution? then it is here.
double gap_tol_
setting for gap tolerance.
bool optimal_
Is optimality proven?
OsiSolverInterface * solver()
const double * getLastSolution()
get the solution found in last local search (return NULL if no solution).
A very simple class to provide a common interface for solving MIPs with Cplex and Cbc...
A class to have all elements necessary to setup a branch-and-bound.
MILP_solve_strategy milp_strat_
MILP search strategy.
OsiClpSolverInterface * clp_
If lp solver is clp (then have to use Cbc) (not owned).
void solve(double cutoff, int loglevel, double maxTime)
double lowBound_
lower bound obtained
bool optimal()
returns optimality status.
int iterationCount_
number of simplex iteration in last mip solved.
double lowBound()
Returns lower bound.
SubMipSolver(BabSetupBase &b, const std::string &prefix)
Constructor.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register options for that Oa based cut generation method.
void find_good_sol(double cutoff, int loglevel, double maxTime)
update cutoff and perform a local search to a good solution.
int iterationCount()
Returns number of simplex iterations in last solve.
void optimize(double cutoff, int loglevel, double maxTime)
update cutoff and optimize MIP.
void setLpSolver(OsiSolverInterface *lp)
Assign lp solver.
CbcStrategyDefault * strategy_
Strategy for solving sub mips with cbc.
void optimize_with_lazy_constraints(double cutoff, int loglevel, double maxTime, const OsiCuts &cs)
update cutoff, put OA constraints in cs as lazy constraints and optimize MIP.
int nodeCount()
Returns number of nodes in last solve.
OsiCpxSolverInterface * cpx_
If mip solver is cpx this is it (owned).