Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

lpsolution.inc
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <ogdf/lib/abacus/master.h>
33 #include <ogdf/lib/abacus/active.h>
34 #include <ogdf/lib/abacus/sub.h>
35 
36 namespace abacus {
37 
38 
39 template <class BaseType, class CoType>
41  Sub *sub,
42  bool primalVariables, Active<BaseType, CoType> *active )
43  :
44  master_(sub->master_),
45  nVarCon_(primalVariables ? sub->nVar() : sub->nCon()),
46  idSub_(sub->id_),
47  idLp_(sub->nIter_),
48  zVal_(master_, nVarCon_)
49 {
50  if(active == 0)
51  active_ = 0;
52  else
53  active_ = new Active<BaseType, CoType>(*active);
54 
55  double *p;
56  if(primalVariables==true)
57  p = sub->xVal_;
58  else
59  p = sub->yVal_;
60 
61  for(int i = 0; i < nVarCon_; i++)
62  zVal_[i] = p[i];
63 }
64 
65 
66 template <class BaseType, class CoType>
67 LpSolution<BaseType, CoType>::LpSolution(Master *master)
68  :
69  master_(master),
70  nVarCon_(0),
71  idSub_(0),
72  idLp_(0),
73  zVal_(master_, 0)
74 {
75  active_=0;
76 }
77 
78 
79 template <class BaseType, class CoType>
80 LpSolution<BaseType, CoType>::LpSolution(const LpSolution<BaseType, CoType> &rhs)
81  :
82  master_(rhs.master_),
83  nVarCon_(rhs.nVarCon_),
84  idSub_(rhs.idSub_),
85  idLp_(rhs.idLp_),
86  zVal_(rhs.zVal_)
87 {
88  if(rhs.active_)
89  active_=new Active<BaseType,CoType>(*rhs.active_);
90 }
91 
92 
93 template <class BaseType, class CoType>
94 LpSolution<BaseType, CoType>::~LpSolution()
95 {
96  delete active_;
97 }
98 
99 
100 template <class BaseType, class CoType>
101 std::ostream &operator<<(std::ostream &os, const LpSolution<BaseType, CoType> &rhs)
102 {
103  double machEps=rhs.master_->machineEps();
104  os << rhs.idSub_ << " ";
105  os << rhs.idLp_ << " ";
106  os << rhs.nVarCon_ << " ";
107  for(int i = 0; i < rhs.nVarCon_; i++)
108  if(fabs(rhs.zVal_[i]) < machEps)
109  os << "0.0 ";
110  else
111  os << rhs.zVal_[i] << " " ;
112  os << std::endl;
113  return os;
114 }
115 
116 
117 template <class BaseType, class CoType>
118 int LpSolution<BaseType, CoType>::nVarCon() const
119 {
120  return nVarCon_;
121 }
122 
123 
124 template <class BaseType, class CoType>
125 double* LpSolution<BaseType, CoType>::zVal()
126 {
127  return &(zVal_[0]);
128 }
129 
130 
131 template <class BaseType, class CoType>
132 Active<BaseType, CoType> * LpSolution<BaseType, CoType>::active()
133 {
134  return active_;
135 }
136 
137 
138 template <class BaseType, class CoType>
139 int LpSolution<BaseType, CoType>::idSub() const
140 {
141  return idSub_;
142 }
143 
144 
145 template <class BaseType, class CoType>
146 int LpSolution<BaseType, CoType>::idLp() const
147 {
148  return idLp_;
149 }
150 
151 }
abacus::LpSolution::LpSolution
LpSolution(Sub *sub, bool primalVariables, Active< BaseType, CoType > *active)
The constructor.
sub.h
lpsolution.h
lpsolution.
abacus
Definition: ILPClusterPlanarity.h:50
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:983
active.h
master.h
the master of the optimization.