1 | // $Id$ |
---|
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 | // Edwin 11/13/2009-- carved out of CbcBranchCut |
---|
7 | |
---|
8 | #ifndef CbcBranchToFixLots_H |
---|
9 | #define CbcBranchToFixLots_H |
---|
10 | |
---|
11 | #include "CbcBranchCut.hpp" |
---|
12 | #include "CbcBranchBase.hpp" |
---|
13 | #include "OsiRowCut.hpp" |
---|
14 | #include "CoinPackedMatrix.hpp" |
---|
15 | |
---|
16 | /** Define a branch class that branches so that one way variables are fixed |
---|
17 | while the other way cuts off that solution. |
---|
18 | a) On reduced cost |
---|
19 | b) When enough ==1 or <=1 rows have been satisfied (not fixed - satisfied) |
---|
20 | */ |
---|
21 | |
---|
22 | |
---|
23 | class CbcBranchToFixLots : public CbcBranchCut { |
---|
24 | |
---|
25 | public: |
---|
26 | |
---|
27 | // Default Constructor |
---|
28 | CbcBranchToFixLots (); |
---|
29 | |
---|
30 | /** Useful constructor - passed reduced cost tolerance and fraction we would like fixed. |
---|
31 | Also depth level to do at. |
---|
32 | Also passed number of 1 rows which when clean triggers fix |
---|
33 | Always does if all 1 rows cleaned up and number>0 or if fraction columns reached |
---|
34 | Also whether to create branch if can't reach fraction. |
---|
35 | */ |
---|
36 | CbcBranchToFixLots (CbcModel * model, double djTolerance, |
---|
37 | double fractionFixed, int depth, |
---|
38 | int numberClean = 0, |
---|
39 | const char * mark = NULL, |
---|
40 | bool alwaysCreate = false); |
---|
41 | |
---|
42 | // Copy constructor |
---|
43 | CbcBranchToFixLots ( const CbcBranchToFixLots &); |
---|
44 | |
---|
45 | /// Clone |
---|
46 | virtual CbcObject * clone() const; |
---|
47 | |
---|
48 | // Assignment operator |
---|
49 | CbcBranchToFixLots & operator=( const CbcBranchToFixLots& rhs); |
---|
50 | |
---|
51 | // Destructor |
---|
52 | ~CbcBranchToFixLots (); |
---|
53 | |
---|
54 | /** Does a lot of the work, |
---|
55 | Returns 0 if no good, 1 if dj, 2 if clean, 3 if both |
---|
56 | FIXME: should use enum or equivalent to make these numbers clearer. |
---|
57 | */ |
---|
58 | int shallWe() const; |
---|
59 | |
---|
60 | /// Infeasibility for an integer variable - large is 0.5, but also can be infinity when known infeasible. |
---|
61 | virtual double infeasibility(const OsiBranchingInformation * info, |
---|
62 | int &preferredWay) const; |
---|
63 | /** \brief Return true if object can take part in normal heuristics |
---|
64 | */ |
---|
65 | virtual bool canDoHeuristics() const { |
---|
66 | return true; |
---|
67 | } |
---|
68 | |
---|
69 | /// Creates a branching object |
---|
70 | virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ; |
---|
71 | /// Redoes data when sequence numbers change |
---|
72 | virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns); |
---|
73 | |
---|
74 | |
---|
75 | protected: |
---|
76 | /// data |
---|
77 | |
---|
78 | /// Reduced cost tolerance i.e. dj has to be >= this before fixed |
---|
79 | double djTolerance_; |
---|
80 | /// We only need to make sure this fraction fixed |
---|
81 | double fractionFixed_; |
---|
82 | /// Never fix ones marked here |
---|
83 | char * mark_; |
---|
84 | /// Matrix by row |
---|
85 | CoinPackedMatrix matrixByRow_; |
---|
86 | /// Do if depth multiple of this |
---|
87 | int depth_; |
---|
88 | /// number of ==1 rows which need to be clean |
---|
89 | int numberClean_; |
---|
90 | /// If true then always create branch |
---|
91 | bool alwaysCreate_; |
---|
92 | }; |
---|
93 | #endif |
---|
94 | |
---|