BlisPseudo.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 #ifndef BlisPseudo_h_
25 #define BlisPseudo_h_
26 
27 #include "CoinError.hpp"
28 #include "AlpsKnowledge.h"
29 
30 //#############################################################################
31 
32 class BlisPseudocost : public AlpsKnowledge
33 {
34 private:
36  double weight_;
37 
39  double upCost_;
40 
42  int upCount_;
43 
45  double downCost_;
46 
48  int downCount_;
49 
54  double score_;
55 
56 public:
59  weight_(1.0),
60  upCost_(0.0),
61  upCount_(0),
62  downCost_(0.0),
63  downCount_(0),
64  score_(0.0)
65  {}
66 
68  BlisPseudocost(double uc,
69  int un,
70  double dc,
71  int dn,
72  double s)
73  :
74  weight_(1.0),
75  upCost_(uc),
76  upCount_(un),
77  downCost_(dc),
78  downCount_(dn),
79  score_(s)
80  {}
81 
84  weight_ = cost.weight_;
85  upCost_ = cost.upCost_;
86  upCount_ = cost.upCount_;
87  downCost_ = cost.downCost_;
88  downCount_ = cost.downCount_;
89  score_ = cost.score_;
90  }
91 
94  weight_ = cost.weight_;
95  upCost_ = cost.upCost_;
96  upCount_ = cost.upCount_;
97  downCost_ = cost.downCost_;
98  downCount_ = cost.downCount_;
99  score_ = cost.score_;
100  return *this;
101  }
102 
104  void setWeight(double w) {
105  if (w < 0.0 || w > 1.0) {
106  throw CoinError("weight is not in range [0,1]", "setWeight",
107  "BlisPseudo");
108  }
109  weight_= w;
110  }
111 
113  void update(const int dir,
114  const double parentObjValue,
115  const double objValue,
116  const double solValue);
117 
119  void update(const int dir,
120  const double objDiff,
121  const double solValue);
122 
124  void update(double upCost,
125  int upCount,
126  double downCost,
127  int downCount);
128 
130  int getUpCount() { return upCount_; }
131 
133  double getUpCost() { return upCost_; }
134 
136  int getDownCount() { return downCount_; }
137 
139  double getDownCost() { return downCost_; }
140 
142  double getScore() { return score_; }
143 
145  void setScore(double s) { score_ = s; }
146 
148  AlpsReturnStatus encodeTo(AlpsEncoded *encoded) const;
149 
152 
153  using AlpsKnowledge::encode ;
155  virtual AlpsEncoded* encode() const;
156 
158  virtual AlpsKnowledge* decode(AlpsEncoded&) const;
159 };
160 
161 #endif
BlisPseudocost()
Default constructor.
Definition: BlisPseudo.h:58
int getDownCount()
Get down branching count.
Definition: BlisPseudo.h:136
AlpsReturnStatus
Definition: Alps.h:118
void setWeight(double w)
Set weigth.
Definition: BlisPseudo.h:104
double getUpCost()
Get up branching cost.
Definition: BlisPseudo.h:133
BlisPseudocost(double uc, int un, double dc, int dn, double s)
Useful constructor.
Definition: BlisPseudo.h:68
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
double getDownCost()
Get down branching cost.
Definition: BlisPseudo.h:139
double upCost_
Average object change when branching up.
Definition: BlisPseudo.h:41
int getUpCount()
Get up branching count.
Definition: BlisPseudo.h:130
AlpsReturnStatus decodeFrom(AlpsEncoded &encoded)
Unpack pseudocost from the given encode object.
double score_
The estimated importance.
Definition: BlisPseudo.h:53
virtual AlpsKnowledge * decode(AlpsEncoded &) const
Decode a node from an encoded object.
AlpsReturnStatus encodeTo(AlpsEncoded *encoded) const
Pack pseudocost to the given object.
int downCount_
How many times being branched down.
Definition: BlisPseudo.h:44
double downCost_
Average object change when branching down.
Definition: BlisPseudo.h:47
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
int upCount_
How many times being branched up.
Definition: BlisPseudo.h:38
void update(const int dir, const double parentObjValue, const double objValue, const double solValue)
Update pseudocost.
Error Class thrown by an exception.
Definition: CoinError.hpp:42
double weight_
Use to calculate score.
Definition: BlisPseudo.h:35
BlisPseudocost & operator=(const BlisPseudocost &cost)
Overload operator =.
Definition: BlisPseudo.h:93
void setScore(double s)
Set importance.
Definition: BlisPseudo.h:145
virtual AlpsEncoded * encode() const
This method should encode the content of the object and return a pointer to the encoded form...
double getScore()
Get importance.
Definition: BlisPseudo.h:142
BlisPseudocost(const BlisPseudocost &cost)
Copy constructor.
Definition: BlisPseudo.h:83
virtual AlpsEncoded * encode() const
Encode this node for message passing.