30#ifndef RECTANGLE_OVERLAP_LOGGING
31 #define RECTANGLE_OVERLAP_LOGGING 0
34void Block::addVariable(
Variable *v) {
54 wp += (v->desiredPosition - v->offset) * v->weight;
59 setUpConstraintHeap(
in,
true);
62 setUpConstraintHeap(
out,
false);
68 vector<Constraint*> *cs= use_in ? &v->in : &v->out;
71 if ((c->left->block !=
this && use_in) || (c->right->block !=
this && !use_in)) {
80 f<<
" merging on: "<<*c<<
",c->left->offset="<<c->
left->
offset<<
",c->right->offset="<<c->
right->
offset<<
"\n";
92 f<<
" merged block="<<(b->
deleted?*
this:*b)<<
"\n";
105 f<<
" merging: "<<*b<<
"dist="<<
dist<<
"\n";
122 f<<
" merging constraint heaps... \n";
127 in->merge(b->
in.get());
130 f<<
" merged heap: "<<*
in<<
"\n";
140 vector<Constraint*> outOfDate;
141 while (!
in->isEmpty()) {
148 f<<
" checking constraint ... "<<*v;
149 f<<
" timestamps: left="<<lb->
timeStamp<<
" right="<<rb->
timeStamp<<
" constraint="<<v->timeStamp<<
"\n";
155 f<<
" violated internal constraint found! "<<*v<<
"\n";
156 f<<
" lb="<<*lb<<
"\n";
157 f<<
" rb="<<*rb<<
"\n";
162 f<<
" ... skipping internal constraint\n";
167 outOfDate.push_back(v);
170 f<<
" reinserting out of date (reinsert later)\n";
188 if(
out->isEmpty())
return nullptr;
192 if(
out->isEmpty())
return nullptr;
201 f<<
"deleteMinInConstraint... \n";
202 f<<
" result: "<<*
in<<
"\n";
223 if(canFollowRight(c,u)) {
224 dfdv+=c->lm=compute_dfdv(c->right,v,min_lm);
225 if(min_lm==
nullptr||c->lm<min_lm->
lm) min_lm=c;
229 if(canFollowLeft(c,u)) {
230 dfdv-=c->
lm=-compute_dfdv(c->left,v,min_lm);
231 if(min_lm==
nullptr||c->lm<min_lm->
lm) min_lm=c;
251 Direction dir =
NONE,
bool changedDirection =
false) {
255 if(canFollowLeft(c,u)) {
257 changedDirection =
true;
262 Pair p=compute_dfdv_between(r,c->left,v,
263 LEFT,changedDirection);
264 dfdv -= c->lm = -p.first;
270 if(canFollowRight(c,u)) {
272 changedDirection =
true;
277 Pair p=compute_dfdv_between(r,c->right,v,
278 RIGHT,changedDirection);
279 dfdv += c->lm = p.first;
281 m = changedDirection && c->
lm < p.second->lm
294 if(canFollowRight(c,u)) {
296 reset_active_lm(c->right,v);
300 if(canFollowLeft(c,u)) {
302 reset_active_lm(c->left,v);
312 reset_active_lm(
vars.front(),
nullptr);
313 compute_dfdv(
vars.front(),
nullptr,min_lm);
318 reset_active_lm(
vars.front(),
nullptr);
319 min_lm=compute_dfdv_between(rv,lv,
nullptr).second;
328 if (canFollowLeft(c,u))
329 populateSplitBlock(b, c->left, v);
332 if (canFollowRight(c,u))
333 populateSplitBlock(b, c->right, v);
345 f<<
" need to split between: "<<*vl<<
" and "<<*vr<<
"\n";
350 f<<
" going to split on: "<<*c<<
"\n";
377 c += v->
weight * diff * diff;
static agxbuf last
last message
#define RECTANGLE_OVERLAP_LOGGING
ostream & operator<<(ostream &os, const Block &b)
#define LOGFILE
A block structure defined over the variables.
Constraint * findMinInConstraint()
std::vector< Variable * > vars
void split(Block *&l, Block *&r, Constraint *c)
Constraint * splitBetween(Variable *vl, Variable *vr, Block *&lb, Block *&rb)
void deleteMinOutConstraint()
Block(Variable *v=nullptr)
void setUpOutConstraints()
void setUpInConstraints()
std::unique_ptr< PairingHeap< Constraint * > > out
double desiredWeightedPosition()
Constraint * findMinOutConstraint()
void merge(Block *b, Constraint *c, double dist)
void deleteMinInConstraint()
Constraint * findMinLMBetween(Variable *lv, Variable *rv)
std::unique_ptr< PairingHeap< Constraint * > > in
Pairing heap datastructure implementation.
static bool compareConstraints(Constraint *const &l, Constraint *const &r)
static double dist(int dim, double *x, double *y)
A constraint determines a minimum or exact spacing required between two variables.