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