Commit 69cca773 authored by Chuanren Wu's avatar Chuanren Wu

fix bug

parent 11d37559
......@@ -66,13 +66,21 @@ struct LengthHelper
ConstraintExt *c;
bool isPlus;
double operator()()
// { return isPlus ? c->totalLengthPlus : c->totalLengthMinus; }
// { return isPlus ? c->totalLengthPlus - c->knownLengthPlus : c->totalLengthMinus - c->knownLengthMinus; }
// { return isPlus ? c->plus.size() : c->minus.size(); }
#if 0
{ return isPlus ? c->totalLengthPlus : c->totalLengthMinus; }
#endif
#if 0
{ return isPlus ? c->totalLengthPlus - c->knownLengthPlus : c->totalLengthMinus - c->knownLengthMinus; }
#endif
#if 1
{ return isPlus ? c->plus.size() : c->minus.size(); }
#endif
#if 0
{ return isPlus
? std::accumulate(c->plus.cbegin(), c->plus.cend(), 0, [this](int s, int i) { return s+(*c->freedom)[i]; })
: std::accumulate(c->minus.cbegin(), c->minus.cend(), 0, [this](int s, int i) { return s+(*c->freedom)[i]; });
}
#endif
};
static ELIMINATION_ERROR insertNewValues(
......@@ -261,7 +269,8 @@ void sortLengthVector(std::vector<LengthHelper> &lh)
{
std::sort(
lh.begin(), lh.end(),
[](LengthHelper &a, LengthHelper &b) { return a() > b(); }
// note: not >, since we use rbegin() and pop_back()
[](LengthHelper &a, LengthHelper &b) { return a() < b(); }
);
}
......@@ -274,7 +283,9 @@ static std::vector<int> eliminate(
assert(lh.size()/2 == vc.size());
std::vector<int> res(vl.size());
std::fill(res.begin(), res.end(), -1989);
for (std::size_t i = 0; i < res.size(); ++i) {
res[i] = atLeast1(vl[i]);
}
while (!lh.empty()) {
int nTotal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment