1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
// (C) Copyright Carnegie Mellon University 2005, 2006
// All Rights Reserved.
// This code is published under the Eclipse Public License.
//
// Authors :
// P. Bonami, Carnegie Mellon University
//
// Date : 05/26/2005
#ifndef BonOaNlpOptim_HPP
#define BonOaNlpOptim_HPP
#include "CglCutGenerator.hpp"
#include "BonOsiTMINLPInterface.hpp"
#include "BonOAMessages.hpp"
#include "BonBabSetupBase.hpp"
namespace Bonmin
{
/** Generate cuts for the nlp corresponding to continuous relaxation at a node.*/
class OaNlpOptim : public CglCutGenerator
{
public:
/// Default constructor
OaNlpOptim(OsiTMINLPInterface * si = NULL,
int maxDepth = 10, bool addOnlyViolated = false,
bool globalCuts = true);
/// Constructor with basic setup
OaNlpOptim(BabSetupBase &b);
/// Copy constructor
OaNlpOptim(const OaNlpOptim ©)
:
CglCutGenerator(copy),
nlp_(copy.nlp_),
maxDepth_(copy.maxDepth_),
nSolve_(0),
addOnlyViolated_(copy.addOnlyViolated_),
global_(copy.global_),
solves_per_level_(copy.solves_per_level_)
{
handler_ = new CoinMessageHandler();
handler_ -> setLogLevel(copy.handler_->logLevel());
messages_ = OaMessages();
}
void passInMessageHandler(const CoinMessageHandler * handler)
{
delete handler_;
handler_ = handler->clone();
}
///Abstract constructor
virtual CglCutGenerator * clone() const
{
return new OaNlpOptim(*this);
}
/** Desctructor */
virtual ~OaNlpOptim()
{
if (handler_)
delete handler_;
}
/// Assign an OsiTMINLPInterface
void assignInterface(OsiTMINLPInterface * si);
/// cut generation method
virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
const CglTreeInfo info);
inline void setMaxDepth(int value)
{
maxDepth_ = value;
}
inline void setAddOnlyViolated(bool yesno)
{
addOnlyViolated_ = yesno;
}
inline void setGlobalCuts(bool yesno)
{
global_ = yesno;
}
inline int getNSolve()
{
return nSolve_;
}
/**set log level */
void setLogLevel(int value)
{
handler_->setLogLevel(value);
}
/** Register OaNlpOptim options.*/
static void registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
private:
/// Pointer to the Ipopt interface
OsiTMINLPInterface * nlp_;
/** maximum depth at which generate cuts*/
int maxDepth_;
///Number of NLP resolution done
mutable int nSolve_;
/** messages handler. */
CoinMessageHandler * handler_;
/** handler */
CoinMessages messages_;
/** Add only violated cuts?*/
bool addOnlyViolated_;
/** Add cuts as global?*/
bool global_;
/** Average number of nodes per level in tree */
double solves_per_level_;
};
}
#endif
|