-
Notifications
You must be signed in to change notification settings - Fork 117
/
CbcBranchLink.hpp
154 lines (123 loc) · 4.07 KB
/
CbcBranchLink.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright (C) 2005, International Business Machines
// Corporation and others. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).
#ifndef CbcBranchLink_H
#define CbcBranchLink_H
#include "CbcBranchBase.hpp"
/** Define Special Linked Ordered Sets.
*/
class CbcLink : public CbcObject {
public:
// Default Constructor
CbcLink();
/** Useful constructor - A valid solution is if all variables are zero
apart from k*numberLink to (k+1)*numberLink-1 where k is 0 through
numberInSet-1. The length of weights array is numberInSet.
For this constructor the variables in matrix are the numberInSet*numberLink
starting at first. If weights null then 0,1,2..
*/
CbcLink(CbcModel *model, int numberMembers,
int numberLinks, int first,
const double *weights, int setNumber);
/** Useful constructor - A valid solution is if all variables are zero
apart from k*numberLink to (k+1)*numberLink-1 where k is 0 through
numberInSet-1. The length of weights array is numberInSet.
For this constructor the variables are given by list - grouped.
If weights null then 0,1,2..
*/
CbcLink(CbcModel *model, int numberMembers,
int numberLinks, int typeSOS, const int *which,
const double *weights, int setNumber);
// Copy constructor
CbcLink(const CbcLink &);
/// Clone
virtual CbcObject *clone() const;
// Assignment operator
CbcLink &operator=(const CbcLink &rhs);
// Destructor
~CbcLink();
/// Infeasibility - large is 0.5
virtual double infeasibility(int &preferredWay) const;
/// This looks at solution and sets bounds to contain solution
virtual void feasibleRegion();
/// Creates a branching object
virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
/// Number of members
inline int numberMembers() const
{
return numberMembers_;
}
/// Number of links for each member
inline int numberLinks() const
{
return numberLinks_;
}
/// Which variables
inline const int *which() const
{
return which_;
}
/** Array of weights */
inline const double *weights() const
{
return weights_;
}
private:
/// data
/// Weights
double *weights_;
/// Number of members
int numberMembers_;
/// Number of links
int numberLinks_;
/// Members
int *which_;
/// Type 1 or 2
int sosType_;
};
/** Branching object for Special ordered sets
Variable_ is the set id number (redundant, as the object also holds a
pointer to the set.
*/
class CbcLinkBranchingObject : public CbcBranchingObject {
public:
// Default Constructor
CbcLinkBranchingObject();
// Useful constructor
CbcLinkBranchingObject(CbcModel *model, const CbcLink *set,
int way,
double separator);
// Copy constructor
CbcLinkBranchingObject(const CbcLinkBranchingObject &);
// Assignment operator
CbcLinkBranchingObject &operator=(const CbcLinkBranchingObject &rhs);
/// Clone
virtual CbcBranchingObject *clone() const;
// Destructor
virtual ~CbcLinkBranchingObject();
/// Does next branch and updates state
virtual double branch();
/** \brief Print something about branch - only if log level high
*/
virtual void print();
/** Return the type (an integer identifier) of \c this */
virtual CbcBranchObjType type() const
{
return CbcBranchObjType(0);
} /*FIXME what type() should be returned here? */
/** Compare the \c this with \c brObj. \c this and \c brObj must be os the
same type and must have the same original object, but they may have
different feasible regions.
Return the appropriate CbcRangeCompare value (first argument being the
sub/superset if that's the case). In case of overlap (and if \c
replaceIfOverlap is true) replace the current branching object with one
whose feasible region is the overlap.
*/
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
private:
/// data
const CbcLink *set_;
/// separator
double separator_;
};
#endif