1 | // Copyright (C) 2005, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef CbcBranchLink_H |
---|
4 | #define CbcBranchLink_H |
---|
5 | |
---|
6 | #include "CbcBranchBase.hpp" |
---|
7 | |
---|
8 | /** Define Special Linked Ordered Sets. |
---|
9 | |
---|
10 | */ |
---|
11 | |
---|
12 | |
---|
13 | class CbcLink : public CbcObject { |
---|
14 | |
---|
15 | public: |
---|
16 | |
---|
17 | // Default Constructor |
---|
18 | CbcLink (); |
---|
19 | |
---|
20 | /** Useful constructor - A valid solution is if all variables are zero |
---|
21 | apart from k*numberLink to (k+1)*numberLink-1 where k is 0 through |
---|
22 | numberInSet-1. The length of weights array is numberInSet. |
---|
23 | For this simple version the variables in matrix are the numberInSet*numberLink |
---|
24 | starting at first. If weights null then 0,1,2.. |
---|
25 | */ |
---|
26 | CbcLink (CbcModel * model, int numberMembers, |
---|
27 | int numberLinks, int first, |
---|
28 | const double * weights, int setNumber); |
---|
29 | |
---|
30 | // Copy constructor |
---|
31 | CbcLink ( const CbcLink &); |
---|
32 | |
---|
33 | /// Clone |
---|
34 | virtual CbcObject * clone() const; |
---|
35 | |
---|
36 | // Assignment operator |
---|
37 | CbcLink & operator=( const CbcLink& rhs); |
---|
38 | |
---|
39 | // Destructor |
---|
40 | ~CbcLink (); |
---|
41 | |
---|
42 | /// Infeasibility - large is 0.5 |
---|
43 | virtual double infeasibility(int & preferredWay) const; |
---|
44 | |
---|
45 | /// This looks at solution and sets bounds to contain solution |
---|
46 | virtual void feasibleRegion(); |
---|
47 | /// Creates a branching object |
---|
48 | virtual CbcBranchingObject * createBranch(int way) ; |
---|
49 | |
---|
50 | /// Number of members |
---|
51 | inline int numberMembers() const |
---|
52 | {return numberMembers_;}; |
---|
53 | |
---|
54 | /// Number of links for each member |
---|
55 | inline int numberLinks() const |
---|
56 | {return numberLinks_;}; |
---|
57 | |
---|
58 | /// First variable in matrix |
---|
59 | inline int first() const |
---|
60 | {return first_;}; |
---|
61 | |
---|
62 | /** Array of weights */ |
---|
63 | inline const double * weights() const |
---|
64 | { return weights_;}; |
---|
65 | |
---|
66 | private: |
---|
67 | /// data |
---|
68 | |
---|
69 | /// Weights |
---|
70 | double * weights_; |
---|
71 | |
---|
72 | /// Number of members |
---|
73 | int numberMembers_; |
---|
74 | /// Number of links |
---|
75 | int numberLinks_; |
---|
76 | /// First member |
---|
77 | int first_; |
---|
78 | }; |
---|
79 | /** Branching object for Special ordered sets |
---|
80 | |
---|
81 | Variable_ is the set id number (redundant, as the object also holds a |
---|
82 | pointer to the set. |
---|
83 | */ |
---|
84 | class CbcLinkBranchingObject : public CbcBranchingObject { |
---|
85 | |
---|
86 | public: |
---|
87 | |
---|
88 | // Default Constructor |
---|
89 | CbcLinkBranchingObject (); |
---|
90 | |
---|
91 | // Useful constructor |
---|
92 | CbcLinkBranchingObject (CbcModel * model, const CbcLink * set, |
---|
93 | int way, |
---|
94 | double separator); |
---|
95 | |
---|
96 | // Copy constructor |
---|
97 | CbcLinkBranchingObject ( const CbcLinkBranchingObject &); |
---|
98 | |
---|
99 | // Assignment operator |
---|
100 | CbcLinkBranchingObject & operator=( const CbcLinkBranchingObject& rhs); |
---|
101 | |
---|
102 | /// Clone |
---|
103 | virtual CbcBranchingObject * clone() const; |
---|
104 | |
---|
105 | // Destructor |
---|
106 | virtual ~CbcLinkBranchingObject (); |
---|
107 | |
---|
108 | /// Does next branch and updates state |
---|
109 | virtual double branch(bool normalBranch=false); |
---|
110 | |
---|
111 | /** \brief Print something about branch - only if log level high |
---|
112 | */ |
---|
113 | virtual void print(bool normalBranch); |
---|
114 | private: |
---|
115 | /// data |
---|
116 | const CbcLink * set_; |
---|
117 | /// separator |
---|
118 | double separator_; |
---|
119 | }; |
---|
120 | #endif |
---|