BlisNodeDesc.h
Go to the documentation of this file.
1 /*===========================================================================*
2  * This file is part of the Bcps Linear 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 #ifndef BlisNodeDesc_h_
25 #define BlisNodeDesc_h_
26 
27 //#############################################################################
28 
29 #include "CoinWarmStartBasis.hpp"
30 
31 #include "AlpsNodeDesc.h"
32 #include "BcpsNodeDesc.h"
33 
34 #include "BlisHelp.h"
35 #include "BlisModel.h"
36 
37 //#############################################################################
38 
39 
40 class BlisNodeDesc : public BcpsNodeDesc {
41 
42  private:
43 
46 
49 
51  double branchedVal_;
52 
55 
56  public:
57 
60  BcpsNodeDesc(),
61  branchedDir_(0),
62  branchedInd_(-1),
63  branchedVal_(0.0),
64  basis_(NULL)
65  {}
66 
69  :
70  BcpsNodeDesc(m),
71  branchedDir_(0),
72  branchedInd_(-1),
73  branchedVal_(0.0),
74  basis_(NULL)
75  {}
76 
78  virtual ~BlisNodeDesc() { delete basis_; }
79 
82  if (basis_) { delete basis_; }
83  basis_= ws;
84  ws = NULL;
85  }
86 
88  CoinWarmStartBasis * getBasis() const { return basis_; }
89 
91  void setBranchedDir(int d) { branchedDir_ = d; }
92 
94  int getBranchedDir() const { return branchedDir_; }
95 
97  void setBranchedInd(int d) { branchedInd_ = d; }
98 
100  int getBranchedInd() const { return branchedInd_; }
101 
103  void setBranchedVal(double d) { branchedVal_ = d; }
104 
106  double getBranchedVal() const { return branchedVal_; }
107 
108  protected:
109 
113 
114  encoded->writeRep(branchedDir_);
115  encoded->writeRep(branchedInd_);
116  encoded->writeRep(branchedVal_);
117 
118  // Basis
119  int ava = 0;
120  if (basis_) {
121  ava = 1;
122  encoded->writeRep(ava);
123  BlisEncodeWarmStart(encoded, basis_);
124  }
125  else {
126  encoded->writeRep(ava);
127  }
128 
129  return status;
130  }
131 
135 
136  encoded.readRep(branchedDir_);
137  encoded.readRep(branchedInd_);
138  encoded.readRep(branchedVal_);
139 
140  // Basis
141  int ava;
142  encoded.readRep(ava);
143  if (ava == 1) {
144  basis_ = BlisDecodeWarmStart(encoded, &status);
145  }
146  else {
147  basis_ = NULL;
148  }
149 
150  return status;
151  }
152 
153  public:
154 
156  virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const {
158 
159  status = encodeBcps(encoded);
160  status = encodeBlis(encoded);
161 
162  return status;
163  }
164 
166  virtual AlpsReturnStatus decode(AlpsEncoded &encoded) {
167 
169 
170  status = decodeBcps(encoded);
171  status = decodeBlis(encoded);
172 
173  return status;
174  }
175 
176 };
177 #endif
For a given type, the objectVecStorage_ structure holds the description.
Definition: BcpsNodeDesc.h:128
int getBranchedInd() const
Get branching object index.
Definition: BlisNodeDesc.h:100
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:173
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:163
int branchedInd_
Branched object index to create it.
Definition: BlisNodeDesc.h:48
CoinWarmStartBasis * getBasis() const
Get warm start basis.
Definition: BlisNodeDesc.h:88
AlpsReturnStatus
Definition: Alps.h:118
int BlisEncodeWarmStart(AlpsEncoded *encoded, const CoinWarmStartBasis *ws)
Pack coin warm start into an encoded object.
double getBranchedVal() const
Get branching direction.
Definition: BlisNodeDesc.h:106
AlpsReturnStatus decodeBlis(AlpsEncoded &encoded)
Unpack blis portion of node description from an encoded.
Definition: BlisNodeDesc.h:133
double branchedVal_
Branched value to create it.
Definition: BlisNodeDesc.h:51
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
void setBranchedInd(int d)
Set branching object index.
Definition: BlisNodeDesc.h:97
virtual AlpsReturnStatus decode(AlpsEncoded &encoded)
Unpack a node description from an encoded.
Definition: BlisNodeDesc.h:166
virtual ~BlisNodeDesc()
Destructor.
Definition: BlisNodeDesc.h:78
void setBranchedDir(int d)
Set branching direction.
Definition: BlisNodeDesc.h:91
BlisNodeDesc()
Default constructor.
Definition: BlisNodeDesc.h:59
int getBranchedDir() const
Get branching direction.
Definition: BlisNodeDesc.h:94
AlpsReturnStatus decodeBcps(AlpsEncoded &encoded)
Unpack bcps node description into an encoded.
virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const
Pack node description into an encoded.
Definition: BlisNodeDesc.h:156
int branchedDir_
Branched direction to create it.
Definition: BlisNodeDesc.h:45
BlisNodeDesc(BlisModel *m)
Useful constructor.
Definition: BlisNodeDesc.h:68
void setBranchedVal(double d)
Set branching value.
Definition: BlisNodeDesc.h:103
void setBasis(CoinWarmStartBasis *&ws)
Set basis.
Definition: BlisNodeDesc.h:81
CoinWarmStartBasis * BlisDecodeWarmStart(AlpsEncoded &encoded, AlpsReturnStatus *rc)
Unpack coin warm start from an encoded object.
CoinWarmStartBasis * basis_
Warm start.
Definition: BlisNodeDesc.h:54
AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const
Pack blis portion of node description into an encoded.
Definition: BlisNodeDesc.h:111
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
Pack bcps node description into an encoded.
The default COIN simplex (basis-oriented) warm start class.