Bonmin 1.8.9
Loading...
Searching...
No Matches
BonOaDecBase.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#ifndef BonOaDecBase_HPP
10#define BonOaDecBase_HPP
11#include "BonSubMipSolver.hpp"
12#include "CglCutGenerator.hpp"
13#include "BonBabSetupBase.hpp"
14#include "BonOAMessages.hpp"
15#include "CbcModel.hpp"
16
17#include "CbcStrategy.hpp"
18
19#include "CoinTime.hpp"
20#include "OsiAuxInfo.hpp"
22#include <iostream>
23#include "BonBabInfos.hpp"
24namespace Bonmin
25{
28 {
29 public:
30
31
35 {
36 public:
38 solverManip(OsiSolverInterface *si , bool saveNumRows=true,
39 bool saveBasis=true, bool saveBounds=false,
40 bool saveCutoff = false, bool resolve=true);
41
47 void restore();
48
51 {
52 return si_;
53 }
54
56 void setObjects(OsiObject ** objects, int nObjects)
57 {
58 objects_ = objects;
59 nObjects_ = nObjects;
60 }
61
62 private:
66 int initialNumberRows_;
67
69 double * colLower_;
70
72 double * colUpper_;
73
75 CoinWarmStart * warm_;
76
78 double cutoff_;
79
81 bool deleteSolver_;
82
84 OsiObject * * objects_;
86 int nObjects_;
90 int numcols_;
92 int numrows_;
94 const double * siColLower_;
96 const double * siColUpper_;
97
98 void getCached();
100 };
101
103 OaDecompositionBase(BabSetupBase &b, bool leaveSiUnchanged,
104 bool reassignLpsolver);
105
108
109
112
114 virtual void generateCuts(const OsiSolverInterface &si, OsiCuts & cs,
115 const CglTreeInfo info = CglTreeInfo());
116
119 {
120 nlp_ = nlp;
121 }
122
125 {
126 lp_ = si;
127 }
128
130 {
131 return reassignLpsolver_;
132 }
134 void setObjects(OsiObject ** objects, int nObjects)
135 {
136 objects_ = objects;
137 nObjects_ = nObjects;
138 }
140 inline void setLeaveSiUnchanged(bool yesno)
141 {
142 leaveSiUnchanged_ = yesno;
143 }
144
147 {
157 double gap_tol_;
168
169
172
174 Parameters(const Parameters & other);
175
178 {
179 if (strategy_) delete strategy_;
180 }
181
183 void setStrategy(const CbcStrategy & strategy)
184 {
185 if (strategy_) delete strategy_;
186 strategy_ = strategy.clone();
187 }
188
189 const CbcStrategy * strategy() const
190 {
191 return strategy_;
192 }
193
194private:
196 CbcStrategy * strategy_;
197
198 };
199
201 {
202 return parameters_;
203 }
204
205 const Parameters& parameter()const
206 {
207 return parameters_;
208 }
209
210 void setLogLevel(int level)
211 {
212 handler_->setLogLevel(level);
213 }
214
217 }
219 protected:
220 void setupMipSolver(BabSetupBase &b, const std::string &prefix);
222
226 bool post_nlp_solve(BabInfo * babInfo, double cutoff) const;
230 virtual double performOa(OsiCuts &cs, solverManip &lpManip,
231 BabInfo * babInfo, double &, const CglTreeInfo & info) const = 0;
233 virtual bool doLocalSearch(BabInfo * babInfo) const = 0;
234
236
242 mutable int nSolve_;
250 mutable int nLocalSearch_;
262 mutable int numSols_;
263
266
275#ifdef OA_DEBUG
276 class OaDebug
277 {
278 public:
279 bool checkInteger(const OsiSolverInterface&nlp, std::ostream & os) const;
280
281 void printEndOfProcedureDebugMessage(const OsiCuts &cs,
282 bool foundSolution,
283 double solValue,
284 double milpBound,
285 bool isInteger,
286 bool feasible,
287 std::ostream & os) const;
288 };
289
291 OaDebug debug_;
292
293#endif
294 };
295}
296#endif
297
Bonmin class for passing info between components of branch-and-cuts.
A class to have all elements necessary to setup a branch-and-bound.
Small class to manipulatee various things in an OsiSolverInterface and restore them.
void setObjects(OsiObject **objects, int nObjects)
Set objects.
OsiSolverInterface * si()
Get pointer to solver interface.
solverManip(OsiSolverInterface *si, bool saveNumRows=true, bool saveBasis=true, bool saveBounds=false, bool saveCutoff=false, bool resolve=true)
Constructor.
solverManip(const OsiSolverInterface &si)
Constructor which clone an other interface.
Base class for OA algorithms.
int currentNodeNumber_
Store the current node number.
CoinMessages messages_
Messages for OA.
int nSolve_
Number of nlp solved done.
OsiTMINLPInterface * nlp_
Pointer to nlp interface.
void assignNlpInterface(OsiTMINLPInterface *nlp)
Assign an OsiTMINLPInterface.
OaDecompositionBase(const OaDecompositionBase &copy)
Copy constructor.
int nObjects_
Number of objects.*‍/.
virtual bool doLocalSearch(BabInfo *babInfo) const =0
virutal method to decide if local search is performed
void setupMipSolver(BabSetupBase &b, const std::string &prefix)
double timeBegin_
time of construction
CoinMessageHandler * handler_
messages handler.
Parameters parameters_
Parameters.
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Standard cut generation methods.
void setLeaveSiUnchanged(bool yesno)
Set whether to leave the solverinterface unchanged.
virtual double performOa(OsiCuts &cs, solverManip &lpManip, BabInfo *babInfo, double &, const CglTreeInfo &info) const =0
virtual method which performs the OA algorithm by modifying lp and nlp.
void setObjects(OsiObject **objects, int nObjects)
Set objects.
void assignLpInterface(OsiSolverInterface *si)
Assign an OsiTMINLPInterface.
BabSetupBase * s_
Pointer to setup.
void passInMessageHandler(CoinMessageHandler *handler)
virtual ~OaDecompositionBase()
Destructor.
OsiCuts savedCuts_
Saved cuts: in some cases when using OA to check feasible solution algorithm may loop because Cbc rem...
bool leaveSiUnchanged_
Wether or not we should remove cuts at the end of the procedure.
OsiObject ** objects_
Some objects the feasiblitiy of which to verify.
bool post_nlp_solve(BabInfo *babInfo, double cutoff) const
Solve the nlp and do output.
int numSols_
number of solutions found by OA_decomposition.
int nLocalSearch_
number of local searches performed
OsiSolverInterface * lp_
A linear solver.
OaDecompositionBase(BabSetupBase &b, bool leaveSiUnchanged, bool reassignLpsolver)
New usefull constructor.
bool reassignLpsolver_
Do we need to reassign the lp solver with Cbc.
const Parameters & parameter() const
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
void setLogLevel(int value)
(C) Copyright International Business Machines Corporation 2007
double gap_tol_
setting for gap tolerance.
void setStrategy(const CbcStrategy &strategy)
Strategy to apply when using Cbc as MILP sub-solver.
const CbcStrategy * strategy() const
Parameters(const Parameters &other)
Copy constructor.
bool addOnlyViolated_
Add only violated OA inequalities.
Parameters()
Constructor with default values.
double cbcCutoffIncrement_
cutoff min increase (has to be intialized trhough Cbc)
double maxLocalSearchTime_
maximum time for local searches
int maxLocalSearch_
Total max number of local searches.
double cbcIntegerTolerance_
integer tolerance (has to be the same as Cbc's)
int maxSols_
maximum number of solutions