Debian Codegraph @

Bonmin/src/CbcBonmin/BonCbc.hpp

raw
1 // (C) Copyright International Business Machines Corporation 2007
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, International Business Machines Corporation
7 //
8 // Date : 04/19/2007
9
10 #ifndef BonCbc_H
11 #define BonCbc_H
12
13 //#include "BonBabSetupBase.hpp"
14 #include "CbcModel.hpp"
15
16 namespace Bonmin
17 {
18 class BabSetupBase;
19 class Bab
20 {
21 public:
22 /** Integer optimization return codes.*/
23 enum MipStatuses {FeasibleOptimal /** Optimum solution has been found and its optimality proved.*/,
24 ProvenInfeasible /** Problem has been proven to be infeasible.*/,
25 Feasible /** An integer solution to the problem has been found.*/,
26 UnboundedOrInfeasible /*Coninuous relaxation is unbounded.*/,
27 NoSolutionKnown/** No feasible solution to the problem is known*/,
28 NumMipStats};
29
30
31 /** Constructor.*/
32 Bab();
33 /** destructor.*/
34 virtual ~Bab();
35 /** Perform a branch-and-bound using given setup.*/
36 virtual void branchAndBound(BabSetupBase & s);
37
38 /**operator() performs the branchAndBound*/
39 virtual void operator()(BabSetupBase & s);
40
41 /**operator() performs the branchAndBound*/
42 virtual void operator()(BabSetupBase * s){
43 operator()(*s);}
44
45 /** get the best solution known to the problem (is optimal if MipStatus is FeasibleOptimal).
46 if no solution is known returns NULL.*/
47 const double * bestSolution() const
48 {
49 return bestSolution_;
50 }
51 /** return objective value of the bestSolution */
52 double bestObj() const
53 {
54 return bestObj_;
55 }
56
57 /** return Mip Status */
58 MipStatuses mipStatus() const
59 {
60 return mipStatus_;
61 }
62
63 /** return the best known lower bound on the objective value*/
64 double bestBound();
65
66 /** return the total number of nodes explored.*/
67 int numNodes() const
68 {
69 return numNodes_;
70 }
71 /** return the total number of iterations in the last mip solved.*/
72 int iterationCount()
73 {
74 return mipIterationCount_;
75 }
76 /** returns the value of the continuous relaxation. */
77 double continuousRelaxation()
78 {
79 return continuousRelaxation_;
80 }
81
82 /** virtual callback function to eventually modify objects for integer variable
83 (replace with user set). This is called after CbcModel::findIntegers */
84 virtual void replaceIntegers(OsiObject ** objects, int numberObjects)
85 {}
86 /** Get cbc model used to solve. */
87 const CbcModel& model() const
88 {
89 return model_;
90 }
91
92 /** Get cbc model used to solve as non-const, in case we want to
93 change options before things happen */
94 CbcModel& model()
95 {
96 return model_;
97 }
98
99 protected:
100 /** Stores the solution of MIP. */
101 double * bestSolution_;
102
103 /** Status of the mip solved*/
104 MipStatuses mipStatus_;
105 /** objValue of MIP */
106 double bestObj_;
107 /** best known (lower) bound.*/
108 double bestBound_;
109 /** Continuous relaxation of the problem */
110 double continuousRelaxation_;
111 /** Number of nodes enumerated.*/
112 int numNodes_;
113 /** get total number of iterations in last mip solved.*/
114 int mipIterationCount_;
115 /** CbcModel used to solve problem.*/
116 CbcModel model_;
117 /** Message handler for CbcModel. */
118 CoinMessageHandler * modelHandler_;
119 /** \brief OsiObjects of the model.
120 * this is not null if and only if there are some non-simple-integer branching objects such as SOS constraints.
121 * It is up to Bab to pass them over to appropriate components of the algorithm. */
122 OsiObject** objects_;
123 /** number of objects.*/
124 int nObjects_;
125 };
126 }
127 #endif