Commit 95654561 authored by Chuanren Wu's avatar Chuanren Wu

change a sort depends

parent 119ed67a
......@@ -59,7 +59,9 @@ struct LengthHelper
ConstraintExt *c;
bool isPlus;
double operator()()
{ return isPlus ? c->totalLengthPlus : c->totalLengthMinus; }
// { return isPlus ? c->totalLengthPlus : c->totalLengthMinus; }
{ return isPlus ? c->totalLengthPlus - c->knownLengthPlus
: c->totalLengthMinus - c->knownLengthMinus; }
};
static void insertNewValues(
......@@ -208,6 +210,14 @@ static bool isValid(const std::vector<ConstraintExt> &vc)
return true;
}
void sortLengthVector(std::vector<LengthHelper> &lh)
{
std::sort(
lh.begin(), lh.end(),
[](LengthHelper &a, LengthHelper &b) { return a() < b(); }
);
}
static std::vector<int> eliminate(
std::vector<LengthHelper> lh,
const std::vector<double> &vl,
......@@ -231,11 +241,13 @@ static std::vector<int> eliminate(
return std::vector<int>();
}
lh.pop_back();
// here to sort ?
sortLengthVector(lh);
}
return std::all_of(res.cbegin(), res.cend(),
std::bind2nd(std::greater_equal<int>(), 1)) ? res : std::vector<int>();
}
}
std::vector<int> discretizeImpl(
const std::vector<double> &vl,
......@@ -258,10 +270,6 @@ std::vector<int> discretizeImpl(
lh.push_back(LengthHelper{&c, true});
lh.push_back(LengthHelper{&c, false});
}
std::sort(
lh.begin(), lh.end(),
[](LengthHelper &a, LengthHelper &b) { return a() < b(); }
);
sortLengthVector(lh);
return eliminate(lh, vl, ve);
}
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