Minotaur 0.4.1
Docs for developers
CbcEngine.h
Go to the documentation of this file.
1//
2// Minotaur -- It's only 1/2 bull
3//
4// (C)opyright 2008 - 2025 The Minotaur Team.
5//
6
13#ifndef MINOTAURCBCENGINE_H
14#define MINOTAURCBCENGINE_H
15
16#include "MILPEngine.h"
17
18class OsiSolverInterface;
19
20namespace Minotaur {
21
22 class Timer;
23 class Environment;
24 class Problem;
25 class Solution;
26 class WarmStart;
27 typedef Environment* EnvPtr;
28 typedef Problem* ProblemPtr;
29 typedef Solution* SolutionPtr;
30 typedef WarmStart* WarmStartPtr;
31
33 struct CbcStats {
34 UInt calls;
35 double time;
36 };
37
39 class CbcEngine : public MILPEngine {
40 public:
42 CbcEngine(EnvPtr env);
43
45 ~CbcEngine();
46
47 // Implement Engine::addConstraint().
49
50 // Change bounds on a constraint.
51 void changeBound(ConstraintPtr cons, BoundType lu, double new_val);
52
53 // Implement Engine::changeBound(VariablePtr, BoundType, double).
54 void changeBound(VariablePtr var, BoundType lu, double new_val);
55
56 // Implement Engine::changeBound(VariablePtr, double, double).
57 void changeBound(VariablePtr var, double new_lb, double new_ub);
58
59 // Implement Engine::changeConstraint().
61 double lb, double ub);
62
63 // Implement Engine::changeConstraint().
65
66 // change the objective function.
67 void changeObj(FunctionPtr f, double cb);
68
70 void clear();
71
73
76
78
81
83 double getSolutionValue();
84
85 // Implement Engine::getSolution().
87
88 // Get a particular solution from solution pool.
90
91 // Implement Engine::getStatus().
93
94 // get name.
95 std::string getName() const;
96
98
100
106 void load(ProblemPtr problem);
107
109
110 // Convert 'min f' to 'min -f'.
111 void negateObj();
112
113 // base class method.
114 void removeCons(std::vector<ConstraintPtr> &delcons);
115
116 // Implement Engine::resetIterationLimit().
117 void resetIterationLimit();
118
119 // Implement Engine::setIterationLimit().
120 void setIterationLimit(int limit);
121
122 // Implement Engine::setDualObjLimit().
123 int setDualObjLimit(double) {return 1;};
124
125 // base class method
126 void setTimeLimit(double);
127
128 // base class method
129 void setUpperCutoff(double);
130
137
139 void writeLP(const char *filename) const;
140
142 void writeStats(std::ostream &out) const;
143
144 private:
147 bool bndChanged_;
148
150 bool consChanged_;
151
153 EnvPtr env_;
154
156 int maxIterLimit_;
157
159 static const std::string me_;
160
162 bool objChanged_;
163
167 OsiSolverInterface *osilp_;
168
170 ProblemPtr problem_;
171
173 SolutionPtr sol_;
174
176 CbcStats *stats_;
177
179 Timer *timer_;
180
182 void load_();
183 };
184
185 typedef CbcEngine* CbcEnginePtr;
186}
187
188#endif
Declare the class MILPEngine for solving MILPs and getting solution.
The CbcEngine class can be called to solve MILP problems.
Definition: CbcEngine.h:39
ConstSolutionPtr getSolution()
Get the solution obtained after solving the problem.
Definition: CbcEngine.cpp:142
EngineStatus getStatus()
Get the status of the last solve command.
Definition: CbcEngine.cpp:148
EngineStatus solve()
Definition: CbcEngine.cpp:319
void loadFromWarmStart(const WarmStartPtr)
Definition: CbcEngine.h:108
UInt getNumSols()
Get the number of solutions in the solution pool of Cbc.
Definition: CbcEngine.h:80
void resetIterationLimit()
Reset the iteration limit to maximum possible.
Definition: CbcEngine.cpp:299
void changeBound(ConstraintPtr cons, BoundType lu, double new_val)
Change a bound of a constraint.
Definition: CbcEngine.cpp:83
void setIterationLimit(int limit)
Definition: CbcEngine.cpp:304
EnginePtr emptyCopy()
Return an empty CbcEngine pointer.
Definition: CbcEngine.cpp:124
ConstSolutionPtr getSolutionFromPool(int)
Get a particular solution from solution pool.
Definition: CbcEngine.h:89
void enableStrBrSetup()
Make settings for strong branching.
Definition: CbcEngine.h:77
void removeCons(std::vector< ConstraintPtr > &delcons)
Delete constraints from the engine.
Definition: CbcEngine.cpp:293
~CbcEngine()
Destroy.
Definition: CbcEngine.cpp:57
CbcEngine(EnvPtr env)
Constructor with an environment.
Definition: CbcEngine.cpp:44
double getSolutionValue()
Return the solution value of the objective after solving the LP.
Definition: CbcEngine.cpp:136
void writeLP(const char *filename) const
Writes an LP file of the loaded LP.
Definition: CbcEngine.cpp:383
void setTimeLimit(double)
Set time limit for an iteration.
Definition: CbcEngine.cpp:309
void changeConstraint(ConstraintPtr con, LinearFunctionPtr lf, double lb, double ub)
Change the linear function, and the bounds of a constraint.
Definition: CbcEngine.cpp:98
WarmStartPtr getWarmStartCopy()
Definition: CbcEngine.h:99
void negateObj()
Negate the objective function. Min f is changed to Min -f.
Definition: CbcEngine.cpp:288
void clear()
Clear the problem.
Definition: CbcEngine.cpp:115
void load(ProblemPtr problem)
Definition: CbcEngine.cpp:154
void changeObj(FunctionPtr f, double cb)
Change objective function.
Definition: CbcEngine.cpp:110
int setDualObjLimit(double)
Set the dual objective limit.
Definition: CbcEngine.h:123
void disableStrBrSetup()
Restore settings after strong branching.
Definition: CbcEngine.h:72
void writeStats(std::ostream &out) const
Write statistics.
Definition: CbcEngine.cpp:388
void setUpperCutoff(double)
Set upper cutoff for an iteration.
Definition: CbcEngine.cpp:314
void addConstraint(ConstraintPtr)
Add a new constraint to the engine.
Definition: CbcEngine.cpp:78
ConstWarmStartPtr getWarmStart()
Definition: CbcEngine.h:97
std::string getName() const
Get the name.
Definition: CbcEngine.cpp:130
The Constraint class is used to manage a constraint.
Definition: Constraint.h:61
Definition: Engine.h:34
Definition: Environment.h:28
Definition: Function.h:37
The base class linear function is of the form c'x.
Definition: LinearFunction.h:31
Definition: MILPEngine.h:28
Base class for nonlinear functions.
Definition: NonlinearFunction.h:31
Definition: Problem.h:74
Definition: Solution.h:30
Definition: Timer.h:40
Definition: Variable.h:31
Definition: WarmStart.h:45
Definition: ActiveNodeStore.h:20
BoundType
Different types of variable-bounds.
Definition: Types.h:131
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
EngineStatus
Different status that an external engine may report.
Definition: Types.h:176
Statistics.
Definition: CbcEngine.h:33
double time
Total number of calls to solve.
Definition: CbcEngine.h:35

Minotaur source code documented by Doxygen 1.9.4 on Fri Apr 25 2025