1 | #ifndef BonminBB_hpp |
---|
2 | #define BonminBB_hpp |
---|
3 | |
---|
4 | #include "BonminCbcParam.hpp" |
---|
5 | |
---|
6 | class IpoptInterface; |
---|
7 | class CbcObject; |
---|
8 | /** Class which performs optimization of an MINLP stored in an IpoptInterface. */ |
---|
9 | class BonminBB |
---|
10 | { |
---|
11 | public: |
---|
12 | /** Integer optimization return codes.*/ |
---|
13 | enum MipStatuses {FeasibleOptimal /** Optimum solution has been found and its optimality proved.*/, |
---|
14 | ProvenInfeasible /** Problem has been proven to be infeasible.*/, |
---|
15 | Feasible /** An integer solution to the problem has been found.*/, |
---|
16 | NoSolutionKnown/** No feasible solution to the problem is known*/}; |
---|
17 | /** Constructor.*/ |
---|
18 | BonminBB(); |
---|
19 | /** destructor.*/ |
---|
20 | virtual ~BonminBB(); |
---|
21 | /** Perform a branch-and-bound on given IpoptInterface using passed parameters.*/ |
---|
22 | void branchAndBound(IpoptInterface &ip, |
---|
23 | const BonminCbcParam&par); |
---|
24 | |
---|
25 | /**operator() performs the branchAndBound*/ |
---|
26 | void operator()(IpoptInterface &ip, const BonminCbcParam& par) |
---|
27 | { |
---|
28 | branchAndBound(ip,par); |
---|
29 | } |
---|
30 | |
---|
31 | /** get the best solution known to the problem (is optimal if MipStatus is FeasibleOptimal). |
---|
32 | if no solution is known returns NULL.*/ |
---|
33 | const double * bestSolution() const |
---|
34 | { |
---|
35 | return bestSolution_; |
---|
36 | } |
---|
37 | /** return objective value of the bestSolution */ |
---|
38 | double bestObj() const |
---|
39 | { |
---|
40 | return bestObj_; |
---|
41 | } |
---|
42 | /** return Mip Status */ |
---|
43 | MipStatuses mipStatus() const |
---|
44 | { |
---|
45 | return mipStatus_; |
---|
46 | } |
---|
47 | /** return the best known lower bound on the objective value*/ |
---|
48 | double bestBound(); |
---|
49 | /** return the total number of nodes explored.*/ |
---|
50 | int numNodes() const |
---|
51 | { |
---|
52 | return numNodes_; |
---|
53 | } |
---|
54 | /** return the total number of iterations in the last mip solved.*/ |
---|
55 | int iterationCount() |
---|
56 | { |
---|
57 | return mipIterationCount_; |
---|
58 | } |
---|
59 | /** returns the value of the continuous relaxation. */ |
---|
60 | double continuousRelaxation() |
---|
61 | { |
---|
62 | return continuousRelaxation_; |
---|
63 | } |
---|
64 | |
---|
65 | /** virtual callback function to eventually modify objects for integer variable |
---|
66 | (replace with user set). This is called after CbcModel::findIntegers */ |
---|
67 | virtual void replaceIntegers(CbcObject ** objects, int numberObjects) |
---|
68 | {}; |
---|
69 | private: |
---|
70 | /** Stores the solution of MIP. */ |
---|
71 | double * bestSolution_; |
---|
72 | /** Status of the mixed integer program. */ |
---|
73 | MipStatuses mipStatus_; |
---|
74 | /** objValue of MIP */ |
---|
75 | double bestObj_; |
---|
76 | /** best known (lower) bound.*/ |
---|
77 | double bestBound_; |
---|
78 | /** Continuous relaxation of the problem */ |
---|
79 | double continuousRelaxation_; |
---|
80 | /** Number of nodes enumerated.*/ |
---|
81 | int numNodes_; |
---|
82 | /** get total number of iterations in last mip solved.*/ |
---|
83 | int mipIterationCount_; |
---|
84 | }; |
---|
85 | #endif |
---|