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