Alps 1.5.12
Loading...
Searching...
No Matches
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-2019, 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
36class OsiSolverInterface;
37
38class OsiCuts;
39class OsiRowCut;
40class OsiRowCutDebugger;
41
42class AbcModel;
43class AbcNode;
44
45//#############################################################################
46
47
48class 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
68
71
74
77 public:
79 :
80 AlpsNodeDesc(0),
81 lowerBounds_(0),
82 upperBounds_(0),
83 numberRows_(0),
84 numberCols_(0),
85 branchedOn_(-8),
88 {
89 }
90
92 :
93 AlpsNodeDesc(m),
94 lowerBounds_(0),
95 upperBounds_(0),
96 numberRows_(0),
97 numberCols_(0),
98 branchedOn_(-9),
100 branchedDir_(1)
101 {
102 }
103
104 AbcNodeDesc(AbcModel* m, const double* lb, const double* ub)
105 :
106 AlpsNodeDesc(m),
107 branchedOn_(-10),
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
Model class for ALPS Branch and Cut.
Definition AbcModel.h:55
OsiSolverInterface * solver() const
Returns solver - has current state.
Definition AbcModel.h:398
int getNumCols() const
Get number of columns.
Definition AbcModel.h:501
const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
Definition AbcModel.h:517
const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
Definition AbcModel.h:513
int getBranchedOn() const
double getBranchedOnValue() const
int getBranchedDir() const
void setLowerBounds(const double *lb, const int size)
int branchedOn_
The index of the branching variable.
Definition AbcNodeDesc.h:70
virtual ~AbcNodeDesc()
AbcNodeDesc(AbcModel *m, const double *lb, const double *ub)
AbcNodeDesc(AbcModel *m)
Definition AbcNodeDesc.h:91
double * upperBounds_
Definition AbcNodeDesc.h:61
double * upperBounds()
int branchedDir_
Branching direction.
Definition AbcNodeDesc.h:76
void setUpperBounds(const double *ub, const int size)
double * lowerBounds_
Definition AbcNodeDesc.h:59
void setBranchedDir(int d)
void setBranchedOnValue(double b)
int numberRows_
Number of rows in problem (before these cuts).
Definition AbcNodeDesc.h:65
void setUpperBound(const int index, const double ub)
double * lowerBounds()
void setLowerBound(const int index, const double lb)
void setBranchedOn(int b)
double branchedOnVal_
The solution value (non-integral) of the branching variable.
Definition AbcNodeDesc.h:73
A class to refer to the description of a search tree node.
AlpsModel * model_
A pointer to model.