Blis 0.94
Loading...
Searching...
No Matches
BlisBranchObjectInt.h
Go to the documentation of this file.
1/*===========================================================================*
2 * This file is part of the BiCePS Linear Integer Solver (BLIS). *
3 * *
4 * BLIS is distributed under the Eclipse Public License as part of the *
5 * COIN-OR repository (http://www.coin-or.org). *
6 * *
7 * Authors: *
8 * *
9 * Yan Xu, Lehigh University *
10 * Ted Ralphs, Lehigh University *
11 * *
12 * Conceptual Design: *
13 * *
14 * Yan Xu, Lehigh University *
15 * Ted Ralphs, Lehigh University *
16 * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17 * Matthew Saltzman, Clemson University *
18 * *
19 * *
20 * Copyright (C) 2001-2019, Lehigh University, Yan Xu, and Ted Ralphs. *
21 * All Rights Reserved. *
22 *===========================================================================*/
23
24
25//#############################################################################
26// Borrow ideas from COIN/Cbc
27//#############################################################################
28
29
30#include "BcpsBranchObject.h"
31
32#include "BlisModel.h"
33
34
35//#############################################################################
36
37
39
40 protected:
41
44 double down_[2];
45
48 double up_[2];
49
50 public:
51
54 :
56 {
58 down_[0] = 0.0;
59 down_[1] = 0.0;
60 up_[0] = 0.0;
61 up_[1] = 0.0;
62 }
63
70 int varInd,
71 int direction,
72 double value)
73 :
74 BcpsBranchObject(model, varInd, direction, value)
75 {
77 int iColumn = model->getIntColIndices()[objectIndex_];
78 down_[0] = model->solver()->getColLower()[iColumn];
79 down_[1] = floor(value_);
80 up_[0] = ceil(value_);
81 up_[1] = model->getColUpper()[iColumn];
82 }
83
92 int varInd,
93 int intScore,
94 double dblScore,
95 int direction,
96 double value)
97 :
98 BcpsBranchObject(model, varInd, intScore, dblScore, direction, value)
99 {
101 int iColumn = model->getIntColIndices()[objectIndex_];
102 down_[0] = model->solver()->getColLower()[iColumn];
103 down_[1] = floor(value_);
104 up_[0] = ceil(value_);
105 up_[1] = model->getColUpper()[iColumn];
106 }
107
114 int varInd,
115 int direction,
116 double lowerValue,
117 double upperValue)
118 :
119 BcpsBranchObject(model, varInd, direction, lowerValue)
120 {
123 down_[0] = lowerValue;
124 down_[1] = upperValue;
125 up_[0] = lowerValue;
126 up_[1] = upperValue;
127 }
128
131
134
136 virtual BcpsBranchObject * clone() const {
137 return (new BlisBranchObjectInt(*this));
138 }
139
142
146 virtual double branch(bool normalBranch = false);
147
149 virtual void print(bool normalBranch);
150
152 const double *getDown() const { return down_; }
153
155 const double *getUp() const { return up_; }
156
157 protected:
158
161 assert(encoded);
163 int j;
164 // TODO: N-way.
165 for (j = 0; j < 2; ++j) {
166 encoded->writeRep(down_[j]);
167 }
168 for (j = 0; j < 2; ++j) {
169 encoded->writeRep(up_[j]);
170 }
171
172 return status;
173 }
174
178 int j;
179 // TODO: N-way.
180 for (j = 0; j < 2; ++j) {
181 encoded.readRep(down_[j]);
182 }
183 for (j = 0; j < 2; ++j) {
184 encoded.readRep(up_[j]);
185 }
186
187 return status;
188 }
189
190 public:
191
193 virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const {
195
196 status = encodeBcps(encoded);
197 status = encodeBlis(encoded);
198
199 return status;
200 }
201
204
206
207 status = decodeBcps(encoded);
208 status = decodeBlis(encoded);
209
210 return status;
211 }
212
213};
214
AlpsReturnStatus
AlpsReturnStatusOk
@ BlisBranchingObjectTypeInt
Definition: Blis.h:125
AlpsEncoded & readRep(T &value)
AlpsEncoded & writeRep(const T &value)
AlpsReturnStatus decodeBcps(AlpsEncoded &encoded)
BcpsModel * model() const
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
virtual void print(bool normalBranch)
Print something about branch - only if log level high.
virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const
Pack to an encoded object.
BlisBranchObjectInt(BlisModel *model, int varInd, int direction, double lowerValue, double upperValue)
Create a degenerate branching object.
AlpsReturnStatus decodeBlis(AlpsEncoded &encoded)
Unpack Blis portion from an encoded object.
const double * getDown() const
Get down arm bounds.
BlisBranchObjectInt(BlisModel *model, int varInd, int direction, double value)
Construct a branching object, which branching on variable varInd.
BlisBranchObjectInt(BlisModel *model, int varInd, int intScore, double dblScore, int direction, double value)
Construct a branching object, which branching on variable varInd.
AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const
Pack Blis portion to an encoded object.
BlisBranchObjectInt()
Default constructor.
double up_[2]
Up_[0]: the lower bound of upper arm; Up_[1]: the upper bound of upper arm;.
BlisBranchObjectInt & operator=(const BlisBranchObjectInt &rhs)
Assignment operator.
virtual double branch(bool normalBranch=false)
Set the bounds for the variable according to the current arm of the branch and advances the object st...
virtual ~BlisBranchObjectInt()
Destructor.
double down_[2]
Down_[0]: the lower bound of down arm; Down_[1]: the upper bound of down arm;.
const double * getUp() const
Get upper arm bounds.
virtual AlpsReturnStatus decode(AlpsEncoded &encoded)
Unpack a branching object from an encoded object.
BlisBranchObjectInt(const BlisBranchObjectInt &)
Copy constructor.
virtual BcpsBranchObject * clone() const
Clone.