Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
lpsolution.inc
Go to the documentation of this file.
1
29#pragma once
30
34#include <ogdf/lib/abacus/sub.h>
35
36namespace abacus {
37
38
39template <class BaseType, class CoType>
41 Sub *sub,
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
66template <class BaseType, class CoType>
67LpSolution<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
79template <class BaseType, class CoType>
80LpSolution<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
93template <class BaseType, class CoType>
94LpSolution<BaseType, CoType>::~LpSolution()
95{
96 delete active_;
97}
98
99
100template <class BaseType, class CoType>
101std::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
117template <class BaseType, class CoType>
118int LpSolution<BaseType, CoType>::nVarCon() const
119{
120 return nVarCon_;
121}
122
123
124template <class BaseType, class CoType>
125double* LpSolution<BaseType, CoType>::zVal()
126{
127 return &(zVal_[0]);
128}
129
130
131template <class BaseType, class CoType>
132Active<BaseType, CoType> * LpSolution<BaseType, CoType>::active()
133{
134 return active_;
135}
136
137
138template <class BaseType, class CoType>
139int LpSolution<BaseType, CoType>::idSub() const
140{
141 return idSub_;
142}
143
144
145template <class BaseType, class CoType>
146int LpSolution<BaseType, CoType>::idLp() const
147{
148 return idLp_;
149}
150
151}
LpSolution(Sub *sub, bool primalVariables, Active< BaseType, CoType > *active)
The constructor.
lpsolution.
the master of the optimization.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition Array.h:978