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

- File List
- File Members

AbcNodeDesc.h
Go to the documentation of this file.
1 /*===========================================================================*
2 * This file is part of the Abstract Library for Parallel Search (ALPS). *
3 * *
4 * ALPS 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 *===========================================================================*/
22
23 //#############################################################################
24 // This file is modified from SbbNode.hpp
25 //#############################################################################
26
27 #ifndef AbcNodeDesc_h_
28 #define AbcNodeDesc_h_
29
30 #include "CoinHelperFunctions.hpp"
31 #include "CoinWarmStartBasis.hpp"
32
33 #include "AlpsNodeDesc.h"
34 #include "AbcModel.h"
35
36 class OsiSolverInterface;
37
38 class OsiCuts;
39 class OsiRowCut;
40 class OsiRowCutDebugger;
41
42 class AbcModel;
43 class AbcNode;
44
45 //#############################################################################
46
47
48 class AbcNodeDesc : public AlpsNodeDesc {
49
50 private:
51
52 /* Here, we need to fill in what the node description will look
53 like. For now, we will not use differencing -- just explicitly
54 represent it. Probably this means that we will just store the
55 original problem data and a list of the variables that have been
56 fixed. */
57
59 double* lowerBounds_;
61 double* upperBounds_;
62
65 int numberRows_;
67 int numberCols_;
68
70 int branchedOn_;
71
73 double branchedOnVal_;
74
76 int branchedDir_;
77 public:
78 AbcNodeDesc()
79 :
80 AlpsNodeDesc(0),
81 lowerBounds_(0),
82 upperBounds_(0),
83 numberRows_(0),
84 numberCols_(0),
85 branchedOn_(-8),
86 branchedOnVal_(0),
87 branchedDir_(1)
88 {
89 }
90
91 AbcNodeDesc(AbcModel* m)
92 :
93 AlpsNodeDesc(m),
94 lowerBounds_(0),
95 upperBounds_(0),
96 numberRows_(0),
97 numberCols_(0),
98 branchedOn_(-9),
99 branchedOnVal_(0),
100 branchedDir_(1)
101 {
102 }
103
104 AbcNodeDesc(AbcModel* m, const double* lb, const double* ub)
105 :
106 AlpsNodeDesc(m),
107 branchedOn_(-10),
108 branchedOnVal_(0),
109 branchedDir_(1)
110 {
111 numberRows_ = m->solver()->getNumRows();
112 numberCols_ = m->solver()->getNumCols();
113 assert(numberRows_ && numberCols_);
114 lowerBounds_ = new double [numberCols_];
115 upperBounds_ = new double [numberCols_];
116 memcpy(lowerBounds_, lb, sizeof(double)*numberCols_);
117 memcpy(upperBounds_, ub, sizeof(double)*numberCols_);
118 }
119
120 virtual ~AbcNodeDesc() {
121 if (lowerBounds_ != 0) {
122 delete [] lowerBounds_;
123 lowerBounds_ = 0;
124 }
125 if (upperBounds_ != 0) {
126 delete [] upperBounds_;
127 upperBounds_ = 0;
128 }
129 }
130
131 double* lowerBounds()
132 {
133 if(lowerBounds_ == 0) {
134 assert(model_);
135 AbcModel* m = dynamic_cast<AbcModel*>(model_);
136 const int num = m->getNumCols();
137 const double* lb = m->getColLower();
138 lowerBounds_ = new double [num];
139 memcpy(lowerBounds_, lb, sizeof(double)*num);
140 // std::cout << "AbcNodeDesc::lowerBounds--num=" << num
141 // <<std::endl;
142 }
143 return lowerBounds_;
144 }
145
146 void setLowerBounds(const double* lb, const int size)
147 {
148 if(!lowerBounds_) {
149 lowerBounds_ = new double [size];
150 }
151 CoinCopyN(lb, size, lowerBounds_);
152 }
153
154 void setLowerBound(const int index, const double lb)
155 {
156 if(!lowerBounds_) {
157 AbcModel * model = dynamic_cast<AbcModel*>(model_);
158 const int numCols = model->getNumCols();
159 assert(numCols > index);
160 lowerBounds_ = new double [numCols];
161 }
162
163 lowerBounds_[index] = lb;
164 }
165
166 double* upperBounds()
167 {
168 if(upperBounds_ == 0) {
169 assert(model_);
170 AbcModel* m = dynamic_cast<AbcModel*>(model_);
171 const int num = m->getNumCols();
172 const double* ub = m->getColUpper();
173 upperBounds_ = new double [num];
174 memcpy(upperBounds_, ub, sizeof(double)*num);
175 }
176 return upperBounds_;
177 }
178
179 void setUpperBounds(const double* ub, const int size)
180 {
181 if(!upperBounds_) {
182 upperBounds_ = new double [size];
183 }
184 CoinCopyN(ub, size, upperBounds_);
185 }
186
187 void setUpperBound(const int index, const double ub)
188 {
189 if (!upperBounds_) {
190 AbcModel * model = dynamic_cast<AbcModel*>(model_);
191 const int numCols = model->getNumCols();
192 assert(numCols > index);
193 upperBounds_ = new double [numCols];
194 }
195
196 upperBounds_[index] = ub;
197 }
199 void setBranchedOn(int b) { branchedOn_ = b; }
201 void setBranchedDir(int d) { branchedDir_ = d; }
203 void setBranchedOnValue(double b) { branchedOnVal_ = b; }
205 int getBranchedOn() const { return branchedOn_; }
207 int getBranchedDir() const { return branchedDir_; }
209 double getBranchedOnValue() const { return branchedOnVal_; }
210 };
211
212 #endif
AbcNodeDesc::upperBounds
double * upperBounds()
Definition: AbcNodeDesc.h:166
AbcNodeDesc::setBranchedDir
void setBranchedDir(int d)
Definition: AbcNodeDesc.h:201
AlpsNodeDesc.h
AbcNodeDesc::setLowerBounds
void setLowerBounds(const double *lb, const int size)
Definition: AbcNodeDesc.h:146
AbcModel::getNumCols
int getNumCols() const
Get number of columns.
Definition: AbcModel.h:501
AbcNodeDesc::setUpperBounds
void setUpperBounds(const double *ub, const int size)
Definition: AbcNodeDesc.h:179
AbcNodeDesc::setBranchedOnValue
void setBranchedOnValue(double b)
Definition: AbcNodeDesc.h:203
OsiRowCut
Row Cut Class.
Definition: OsiRowCut.hpp:29
AbcNodeDesc::branchedOnVal_
double branchedOnVal_
The solution value (non-integral) of the branching variable.
Definition: AbcNodeDesc.h:73
AbcNodeDesc::AbcNodeDesc
AbcNodeDesc(AbcModel *m, const double *lb, const double *ub)
Definition: AbcNodeDesc.h:104
OsiSolverInterface::getNumCols
virtual int getNumCols() const =0
Get the number of columns.
AbcModel::getColLower
const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
Definition: AbcModel.h:513
CoinHelperFunctions.hpp
OsiCuts
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
AbcNodeDesc::numberRows_
int numberRows_
Number of rows in problem (before these cuts).
Definition: AbcNodeDesc.h:65
AbcModel.h
CoinCopyN
void CoinCopyN(register const T *from, const int size, register T *to)
This helper function copies an array to another location using Duff&#39;s device (for a speedup of ~2)...
Definition: CoinHelperFunctions.hpp:44
AbcNodeDesc::AbcNodeDesc
AbcNodeDesc(AbcModel *m)
Definition: AbcNodeDesc.h:91
AbcNodeDesc::~AbcNodeDesc
virtual ~AbcNodeDesc()
Definition: AbcNodeDesc.h:120
AbcNodeDesc::setBranchedOn
void setBranchedOn(int b)
Definition: AbcNodeDesc.h:199
OsiSolverInterface::getNumRows
virtual int getNumRows() const =0
Get the number of rows.
AbcNodeDesc
Definition: AbcNodeDesc.h:48
AbcNodeDesc::getBranchedOn
int getBranchedOn() const
Definition: AbcNodeDesc.h:205
AbcNodeDesc::upperBounds_
double * upperBounds_
Definition: AbcNodeDesc.h:61
AbcNodeDesc::lowerBounds
double * lowerBounds()
Definition: AbcNodeDesc.h:131
AbcNodeDesc::branchedOn_
int branchedOn_
The index of the branching variable.
Definition: AbcNodeDesc.h:70
AbcNodeDesc::branchedDir_
int branchedDir_
Branching direction.
Definition: AbcNodeDesc.h:76
OsiSolverInterface
Abstract Base Class for describing an interface to a solver.
Definition: OsiSolverInterface.hpp:62
CoinWarmStartBasis.hpp
AbcModel::solver
OsiSolverInterface * solver() const
Returns solver - has current state.
Definition: AbcModel.h:398
AbcNodeDesc::AbcNodeDesc
AbcNodeDesc()
Definition: AbcNodeDesc.h:78
AbcModel::getColUpper
const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
Definition: AbcModel.h:517
AbcNodeDesc::setUpperBound
void setUpperBound(const int index, const double ub)
Definition: AbcNodeDesc.h:187
AlpsNodeDesc::model_
AlpsModel * model_
A pointer to model.
Definition: AlpsNodeDesc.h:41
OsiRowCutDebugger
Validate cuts against a known solution.
Definition: OsiRowCutDebugger.hpp:42
AbcNodeDesc::numberCols_
int numberCols_
Definition: AbcNodeDesc.h:67
AbcNodeDesc::lowerBounds_
double * lowerBounds_
Definition: AbcNodeDesc.h:59
AbcNodeDesc::getBranchedDir
int getBranchedDir() const
Definition: AbcNodeDesc.h:207
AbcNodeDesc::setLowerBound
void setLowerBound(const int index, const double lb)
Definition: AbcNodeDesc.h:154
AlpsNodeDesc
A class to refer to the description of a search tree node.
Definition: AlpsNodeDesc.h:35
AbcModel
Model class for ALPS Branch and Cut.
Definition: AbcModel.h:55
AbcNodeDesc::getBranchedOnValue
double getBranchedOnValue() const
Definition: AbcNodeDesc.h:209