1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker 35a3110598 Squashed 'software/chuffed/' content from commit 2ed0c015
git-subtree-dir: software/chuffed
git-subtree-split: 2ed0c01558d2a5c49c1ce57e048d32c17adf92d3
2021-06-18 09:36:35 +10:00

27 lines
706 B
C++

#include <chuffed/core/propagator.h>
void newBinGE(IntView<> x, IntView<> y, BoolView r);
void newBinNE(IntView<> x, IntView<> y, BoolView r);
// x lex< y
// b[i] = r[i] || b[i+1]
// b[i] -> x[i] <= y[i]
// r[i] -> x[i] < y[i]
void lex(vec<IntVar*>& x, vec<IntVar*>& y, bool strict) {
vec<BoolView> b, r;
b.push(bv_true);
for (int i = 1; i < x.size(); i++) b.push(newBoolVar());
b.push(bv_false);
for (int i = 0; i < x.size(); i++) r.push(newBoolVar());
for (int i = 0; i < x.size()-1+strict; i++) {
bool_rel(r[i], BRT_OR, b[i+1], b[i]);
newBinGE(IntView<>(y[i]), IntView<>(x[i],1,1), r[i]);
}
for (int i = 0; i < x.size(); i++) {
newBinGE(IntView<>(y[i]), IntView<>(x[i]), b[i]);
}
}