1 | /* $Id: CbcFathom.hpp 1902 2013-04-10 16:58:16Z tkr $ */ |
---|
2 | // Copyright (C) 2004, International Business Machines |
---|
3 | // Corporation and others. All Rights Reserved. |
---|
4 | // This code is licensed under the terms of the Eclipse Public License (EPL). |
---|
5 | |
---|
6 | #ifndef CbcFathom_H |
---|
7 | #define CbcFathom_H |
---|
8 | #include "CbcConfig.h" |
---|
9 | |
---|
10 | /* |
---|
11 | This file contains two classes, CbcFathom and CbcOsiSolver. It's unclear why |
---|
12 | they're in the same file. CbcOsiSolver is a base class for CbcLinked. |
---|
13 | |
---|
14 | --lh, 071031 -- |
---|
15 | */ |
---|
16 | |
---|
17 | |
---|
18 | class CbcModel; |
---|
19 | |
---|
20 | //############################################################################# |
---|
21 | /** Fathom base class. |
---|
22 | |
---|
23 | The idea is that after some branching the problem will be effectively smaller than |
---|
24 | the original problem and maybe there will be a more specialized technique which can completely |
---|
25 | fathom this branch quickly. |
---|
26 | |
---|
27 | One method is to presolve the problem to give a much smaller new problem and then do branch |
---|
28 | and cut on that. Another might be dynamic programming. |
---|
29 | |
---|
30 | */ |
---|
31 | |
---|
32 | class CbcFathom { |
---|
33 | public: |
---|
34 | // Default Constructor |
---|
35 | CbcFathom (); |
---|
36 | |
---|
37 | // Constructor with model - assumed before cuts |
---|
38 | CbcFathom (CbcModel & model); |
---|
39 | |
---|
40 | virtual ~CbcFathom(); |
---|
41 | |
---|
42 | /// update model (This is needed if cliques update matrix etc) |
---|
43 | virtual void setModel(CbcModel * model); |
---|
44 | |
---|
45 | /// Clone |
---|
46 | virtual CbcFathom * clone() const = 0; |
---|
47 | |
---|
48 | /// Resets stuff if model changes |
---|
49 | virtual void resetModel(CbcModel * model) = 0; |
---|
50 | |
---|
51 | /** returns 0 if no fathoming attempted, 1 fully fathomed, |
---|
52 | 2 incomplete search, 3 incomplete search but treat as complete. |
---|
53 | If solution then newSolution will not be NULL and |
---|
54 | will be freed by CbcModel. It is expected that the solution is better |
---|
55 | than best so far but CbcModel will double check. |
---|
56 | |
---|
57 | If returns 3 then of course there is no guarantee of global optimum |
---|
58 | */ |
---|
59 | virtual int fathom(double *& newSolution) = 0; |
---|
60 | |
---|
61 | // Is this method possible |
---|
62 | inline bool possible() const { |
---|
63 | return possible_; |
---|
64 | } |
---|
65 | |
---|
66 | protected: |
---|
67 | |
---|
68 | /// Model |
---|
69 | CbcModel * model_; |
---|
70 | /// Possible - if this method of fathoming can be used |
---|
71 | bool possible_; |
---|
72 | private: |
---|
73 | |
---|
74 | /// Illegal Assignment operator |
---|
75 | CbcFathom & operator=(const CbcFathom& rhs); |
---|
76 | |
---|
77 | }; |
---|
78 | |
---|
79 | #include "OsiClpSolverInterface.hpp" |
---|
80 | |
---|
81 | //############################################################################# |
---|
82 | |
---|
83 | /** |
---|
84 | |
---|
85 | This is for codes where solver needs to know about CbcModel |
---|
86 | Seems to provide only one value-added feature, a CbcModel object. |
---|
87 | |
---|
88 | */ |
---|
89 | |
---|
90 | class CbcOsiSolver : public OsiClpSolverInterface { |
---|
91 | |
---|
92 | public: |
---|
93 | |
---|
94 | /**@name Constructors and destructors */ |
---|
95 | //@{ |
---|
96 | /// Default Constructor |
---|
97 | CbcOsiSolver (); |
---|
98 | |
---|
99 | /// Clone |
---|
100 | virtual OsiSolverInterface * clone(bool copyData = true) const; |
---|
101 | |
---|
102 | /// Copy constructor |
---|
103 | CbcOsiSolver (const CbcOsiSolver &); |
---|
104 | |
---|
105 | /// Assignment operator |
---|
106 | CbcOsiSolver & operator=(const CbcOsiSolver& rhs); |
---|
107 | |
---|
108 | /// Destructor |
---|
109 | virtual ~CbcOsiSolver (); |
---|
110 | |
---|
111 | //@} |
---|
112 | |
---|
113 | |
---|
114 | /**@name Sets and Gets */ |
---|
115 | //@{ |
---|
116 | /// Set Cbc Model |
---|
117 | inline void setCbcModel(CbcModel * model) { |
---|
118 | cbcModel_ = model; |
---|
119 | } |
---|
120 | /// Return Cbc Model |
---|
121 | inline CbcModel * cbcModel() const { |
---|
122 | return cbcModel_; |
---|
123 | } |
---|
124 | //@} |
---|
125 | |
---|
126 | //--------------------------------------------------------------------------- |
---|
127 | |
---|
128 | protected: |
---|
129 | |
---|
130 | |
---|
131 | /**@name Private member data */ |
---|
132 | //@{ |
---|
133 | /// Pointer back to CbcModel |
---|
134 | CbcModel * cbcModel_; |
---|
135 | //@} |
---|
136 | }; |
---|
137 | #endif |
---|