Blis 0.95.0
Loading...
Searching...
No Matches
BlisNodeDesc.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-2023, 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 "BlisConfig.h"
35#include "BlisHelp.h"
36#include "BlisModel.h"
37
38//#############################################################################
39
40
41class BLISLIB_EXPORT BlisNodeDesc : public BcpsNodeDesc {
42
43 private:
44
46 int branchedDir_;
47
49 int branchedInd_;
50
52 double branchedVal_;
53
55 CoinWarmStartBasis *basis_;
56
57 public:
58
61 BcpsNodeDesc(),
62 branchedDir_(0),
63 branchedInd_(-1),
64 branchedVal_(0.0),
65 basis_(NULL)
66 {}
67
70 :
71 BcpsNodeDesc(m),
72 branchedDir_(0),
73 branchedInd_(-1),
74 branchedVal_(0.0),
75 basis_(NULL)
76 {}
77
79 virtual ~BlisNodeDesc() { delete basis_; basis_ = NULL; }
80
82 void setBasis(CoinWarmStartBasis *&ws) {
83 if (basis_) { delete basis_; }
84 basis_= ws;
85 ws = NULL;
86 }
87
89 CoinWarmStartBasis * getBasis() const { return basis_; }
90
92 void setBranchedDir(int d) { branchedDir_ = d; }
93
95 int getBranchedDir() const { return branchedDir_; }
96
98 void setBranchedInd(int d) { branchedInd_ = d; }
99
101 int getBranchedInd() const { return branchedInd_; }
102
104 void setBranchedVal(double d) { branchedVal_ = d; }
105
107 double getBranchedVal() const { return branchedVal_; }
108
109 protected:
110
112 AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const {
113 AlpsReturnStatus status = AlpsReturnStatusOk;
114
115 encoded->writeRep(branchedDir_);
116 encoded->writeRep(branchedInd_);
117 encoded->writeRep(branchedVal_);
118
119 // Basis
120 int ava = 0;
121 if (basis_) {
122 ava = 1;
123 encoded->writeRep(ava);
124 BlisEncodeWarmStart(encoded, basis_);
125 }
126 else {
127 encoded->writeRep(ava);
128 }
129
130 return status;
131 }
132
134 AlpsReturnStatus decodeBlis(AlpsEncoded &encoded) {
135 AlpsReturnStatus status = AlpsReturnStatusOk;
136
137 encoded.readRep(branchedDir_);
138 encoded.readRep(branchedInd_);
139 encoded.readRep(branchedVal_);
140
141 // Basis
142 int ava;
143 encoded.readRep(ava);
144 if (ava == 1) {
145 if (basis_) delete basis_;
146 basis_ = BlisDecodeWarmStart(encoded, &status);
147 }
148 else {
149 basis_ = NULL;
150 }
151
152 return status;
153 }
154
155 public:
156
158 virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const {
159 AlpsReturnStatus status = AlpsReturnStatusOk;
160
161 status = encodeBcps(encoded);
162 status = encodeBlis(encoded);
163
164 return status;
165 }
166
168 virtual AlpsReturnStatus decode(AlpsEncoded &encoded) {
169
170 AlpsReturnStatus status = AlpsReturnStatusOk;
171
172 status = decodeBcps(encoded);
173 status = decodeBlis(encoded);
174
175 return status;
176 }
177
178};
179#endif
BLISLIB_EXPORT int BlisEncodeWarmStart(AlpsEncoded *encoded, const CoinWarmStartBasis *ws)
Pack coin warm start into an encoded object.
BLISLIB_EXPORT CoinWarmStartBasis * BlisDecodeWarmStart(AlpsEncoded &encoded, AlpsReturnStatus *rc)
Unpack coin warm start from an encoded object.
virtual ~BlisNodeDesc()
Destructor.
AlpsReturnStatus decodeBlis(AlpsEncoded &encoded)
Unpack blis portion of node description from an encoded.
BlisNodeDesc()
Default constructor.
void setBranchedInd(int d)
Set branching object index.
virtual AlpsReturnStatus decode(AlpsEncoded &encoded)
Unpack a node description from an encoded.
void setBranchedDir(int d)
Set branching direction.
int getBranchedInd() const
Get branching object index.
double getBranchedVal() const
Get branching direction.
AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const
Pack blis portion of node description into an encoded.
int getBranchedDir() const
Get branching direction.
virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const
Pack node description into an encoded.
BlisNodeDesc(BlisModel *m)
Useful constructor.
CoinWarmStartBasis * getBasis() const
Get warm start basis.
void setBasis(CoinWarmStartBasis *&ws)
Set basis.
void setBranchedVal(double d)
Set branching value.
#define BLISLIB_EXPORT
Definition config.h:5