Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

active.inc
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <ogdf/lib/abacus/active.h>
32 #include <ogdf/lib/abacus/master.h>
35 #include <ogdf/lib/abacus/convar.h>
37 
38 namespace abacus {
39 
40 template <class BaseType, class CoType>
42  Master *master,
43  Active<BaseType, CoType> *a,
44  int max)
45  :
46 master_(master),
47  n_(0),
48  active_(max),
49  redundantAge_(0,max-1, 0)
50 {
51  n_ = (max < a->number()) ? max : a->number();
52 
53  for (int i = 0; i < n_; i++)
54  active_[i] = new PoolSlotRef<BaseType, CoType>(*(a->active_[i]));
55 }
56 
57 
58 template <class BaseType, class CoType>
59 Active<BaseType, CoType>::Active(const Active<BaseType, CoType> &rhs)
60  :
61  master_(rhs.master_),
62  n_(rhs.n_),
63  active_(/*rhs.master_,*/ rhs.max()),
64  redundantAge_(/*master_*/0, rhs.max()-1, 0)
65 {
66  for (int i = 0; i < n_; i++) {
67  active_[i] = new PoolSlotRef<BaseType, CoType>(*(rhs.active_[i]));
68  redundantAge_[i] = rhs.redundantAge_[i];
69  }
70 }
71 
72 
73 template <class BaseType, class CoType>
74 Active<BaseType, CoType>::~Active()
75 {
76  for (int i = 0; i < n_; i++)
77  delete active_[i];
78 }
79 
80 
81 template <class BaseType, class CoType>
82 std::ostream &operator<<(std::ostream &out, const Active<BaseType, CoType> &rhs)
83 {
84  for (int i = 0; i < rhs.n_; i++) {
85  out << i << ": ";
86  BaseType *cv = rhs.active_[i]->conVar();
87  if (cv != 0)
88  cv->print(out);
89  else
90  out << "void" << std::endl;
91  }
92  return out;
93 }
94 
95 
96 template <class BaseType, class CoType>
97 void Active<BaseType, CoType>::insert(PoolSlot<BaseType, CoType> *ps)
98 {
99  OGDF_ASSERT(n_ != max()); // buffer is full
100 
101  active_[n_] = new PoolSlotRef<BaseType, CoType>(ps);
102  redundantAge_[n_] = 0;
103  n_++;
104 }
105 
106 
107 template <class BaseType, class CoType>
108 void Active<BaseType, CoType>::insert(
109  ArrayBuffer<PoolSlot<BaseType, CoType> *> &ps)
110 {
111  const int nPs = ps.size();
112 
113  for(int i = 0; i < nPs; i++)
114  insert(ps[i]);
115 }
116 
117 
118 template <class BaseType, class CoType>
119 void Active<BaseType, CoType>::remove(ArrayBuffer<int> &del)
120 {
121  const int nDel = del.size();
122 
123  for(int i = 0; i < nDel; i++)
124  delete active_[del[i]];
125  active_.leftShift(del);
126  redundantAge_.leftShift(del);
127  n_ -= nDel;
128 }
129 
130 
131 template <class BaseType, class CoType>
132 void Active<BaseType, CoType>::realloc(int newSize)
133 {
134  active_.resize(newSize);
135  redundantAge_.resize(newSize);
136 }
137 
138 }
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
convar.h
constraints and variables.
abacus
Definition: ILPClusterPlanarity.h:50
poolslotref.h
poolslotref
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
sparvec.h
sparse vector.
abacus::Active::Active
Active(Master *master, int max)
Creates an empty set of active items.
Definition: active.h:70
master.h
the master of the optimization.
poolslot.h
poolslot.
Minisat::Internal::remove
static void remove(V &ts, const T &t)
Definition: Alg.h:36