- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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-2013, 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
38 class BlisBranchObjectInt : public BcpsBranchObject {
39
40 protected:
41
44 double down_[2];
45
48 double up_[2];
49
50 public:
51
53 BlisBranchObjectInt()
54 :
55 BcpsBranchObject()
56 {
57 type_ = BlisBranchingObjectTypeInt;
58 down_[0] = 0.0;
59 down_[1] = 0.0;
60 up_[0] = 0.0;
61 up_[1] = 0.0;
62 }
63
69 BlisBranchObjectInt(BlisModel * model,
70 int varInd,
71 int direction,
72 double value)
73 :
74 BcpsBranchObject(model, varInd, direction, value)
75 {
76 type_ = BlisBranchingObjectTypeInt;
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
91 BlisBranchObjectInt(BlisModel * model,
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 {
100 type_ = BlisBranchingObjectTypeInt;
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
113 BlisBranchObjectInt(BlisModel * model,
114 int varInd,
115 int direction,
116 double lowerValue,
117 double upperValue)
118 :
119 BcpsBranchObject(model, varInd, direction, lowerValue)
120 {
121 type_ = BlisBranchingObjectTypeInt;
122 numBranchesLeft_ = 1;
123 down_[0] = lowerValue;
124 down_[1] = upperValue;
125 up_[0] = lowerValue;
126 up_[1] = upperValue;
127 }
128
130 BlisBranchObjectInt(const BlisBranchObjectInt &);
131
133 BlisBranchObjectInt & operator = (const BlisBranchObjectInt& rhs);
134
136 virtual BcpsBranchObject * clone() const {
137 return (new BlisBranchObjectInt(*this));
138 }
139
141 virtual ~BlisBranchObjectInt() {}
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
160 AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const {
161 assert(encoded);
162 AlpsReturnStatus status = AlpsReturnStatusOk;
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
176 AlpsReturnStatus decodeBlis(AlpsEncoded &encoded) {
177 AlpsReturnStatus status = AlpsReturnStatusOk;
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 {
194 AlpsReturnStatus status = AlpsReturnStatusOk;
195
196 status = encodeBcps(encoded);
197 status = encodeBlis(encoded);
198
199 return status;
200 }
201
203 virtual AlpsReturnStatus decode(AlpsEncoded &encoded) {
204
205 AlpsReturnStatus status = AlpsReturnStatusOk;
206
207 status = decodeBcps(encoded);
208 status = decodeBlis(encoded);
209
210 return status;
211 }
212
213 };
214
BlisModel
Definition: BlisModel.h:60
AlpsEncoded::readRep
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:173
AlpsEncoded::writeRep
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:163
BlisBranchingObjectTypeInt
Definition: Blis.h:125
BlisBranchObjectInt::decodeBlis
AlpsReturnStatus decodeBlis(AlpsEncoded &encoded)
Unpack Blis portion from an encoded object.
Definition: BlisBranchObjectInt.h:176
BlisBranchObjectInt::BlisBranchObjectInt
BlisBranchObjectInt(BlisModel *model, int varInd, int direction, double lowerValue, double upperValue)
Create a degenerate branching object.
Definition: BlisBranchObjectInt.h:113
BlisBranchObjectInt::down_
double down_[2]
Down_[0]: the lower bound of down arm; Down_[1]: the upper bound of down arm;.
Definition: BlisBranchObjectInt.h:44
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:118
BlisModel::getColUpper
const double * getColUpper()
Get column upper bound.
Definition: BlisModel.h:338
BlisBranchObjectInt::up_
double up_[2]
Up_[0]: the lower bound of upper arm; Up_[1]: the upper bound of upper arm;.
Definition: BlisBranchObjectInt.h:48
BlisBranchObjectInt::encode
virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const
Pack to an encoded object.
Definition: BlisBranchObjectInt.h:193
BlisBranchObjectInt::decode
virtual AlpsReturnStatus decode(AlpsEncoded &encoded)
Unpack a branching object from an encoded object.
Definition: BlisBranchObjectInt.h:203
BlisModel::getIntColIndices
int * getIntColIndices() const
Get integers&#39; column indices.
Definition: BlisModel.h:648
BlisBranchObjectInt::~BlisBranchObjectInt
virtual ~BlisBranchObjectInt()
Destructor.
Definition: BlisBranchObjectInt.h:141
BlisBranchObjectInt::BlisBranchObjectInt
BlisBranchObjectInt(BlisModel *model, int varInd, int direction, double value)
Construct a branching object, which branching on variable varInd.
Definition: BlisBranchObjectInt.h:69
BlisBranchObjectInt::operator=
BlisBranchObjectInt & operator=(const BlisBranchObjectInt &rhs)
Assignment operator.
BcpsBranchObject::objectIndex_
int objectIndex_
Branch object index.
Definition: BcpsBranchObject.h:60
BcpsBranchObject::value_
double value_
Current branching value.
Definition: BcpsBranchObject.h:82
BcpsBranchObject
BcpsBranchObject contains the member data required when choosing branching entities and excuting actu...
Definition: BcpsBranchObject.h:47
BcpsBranchObject::model
BcpsModel * model() const
Return model.
Definition: BcpsBranchObject.h:213
BlisBranchObjectInt::getDown
const double * getDown() const
Get down arm bounds.
Definition: BlisBranchObjectInt.h:152
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
BlisBranchObjectInt::getUp
const double * getUp() const
Get upper arm bounds.
Definition: BlisBranchObjectInt.h:155
BlisBranchObjectInt::print
virtual void print(bool normalBranch)
Print something about branch - only if log level high.
AlpsReturnStatusOk
Definition: Alps.h:119
BlisBranchObjectInt::BlisBranchObjectInt
BlisBranchObjectInt()
Default constructor.
Definition: BlisBranchObjectInt.h:53
BcpsBranchObject::decodeBcps
AlpsReturnStatus decodeBcps(AlpsEncoded &encoded)
Unpack Bcps portion from an encoded object.
Definition: BcpsBranchObject.h:232
BlisModel::solver
virtual OsiSolverInterface * solver()
Get lp solver.
Definition: BlisModel.h:310
OsiSolverInterface::getColLower
virtual const double * getColLower() const =0
Get a pointer to an array[getNumCols()] of column lower bounds.
BlisModel.h
BlisBranchObjectInt
Definition: BlisBranchObjectInt.h:38
BcpsBranchObject::encodeBcps
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
Pack Bcps portion to an encoded object.
Definition: BcpsBranchObject.h:218
BlisBranchObjectInt::BlisBranchObjectInt
BlisBranchObjectInt(BlisModel *model, int varInd, int intScore, double dblScore, int direction, double value)
Construct a branching object, which branching on variable varInd.
Definition: BlisBranchObjectInt.h:91
BcpsBranchObject::numBranchesLeft_
int numBranchesLeft_
Number of arms remaining to be evaluated.
Definition: BcpsBranchObject.h:85
BlisBranchObjectInt::clone
virtual BcpsBranchObject * clone() const
Clone.
Definition: BlisBranchObjectInt.h:136
BlisBranchObjectInt::encodeBlis
AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const
Pack Blis portion to an encoded object.
Definition: BlisBranchObjectInt.h:160
BcpsBranchObject.h
BlisBranchObjectInt::branch
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...
BcpsBranchObject::type_
int type_
Type of branching.
Definition: BcpsBranchObject.h:52