23 #include "absl/container/flat_hash_map.h"
24 #include "absl/container/flat_hash_set.h"
35 const std::function<int64_t(
Variable*)>& evaluator) {
41 return evaluator(arg.
Var());
44 LOG(FATAL) <<
"Cannot evaluate " << arg.
DebugString();
54 int64_t EvalAt(
const Argument& arg,
int pos,
55 const std::function<int64_t(
Variable*)>& evaluator) {
61 return evaluator(arg.
VarAt(pos));
64 LOG(FATAL) <<
"Cannot evaluate " << arg.
DebugString();
73 const std::function<int64_t(
Variable*)>& evaluator) {
74 absl::flat_hash_set<int64_t> visited;
77 if (visited.contains(
value)) {
80 visited.insert(
value);
86 bool CheckAlldifferentExcept0(
88 absl::flat_hash_set<int64_t> visited;
94 visited.insert(
value);
101 const std::function<int64_t(
Variable*)>& evaluator) {
102 const int64_t expected = Eval(
ct.
arguments[0], evaluator);
109 return count == expected;
113 const std::function<int64_t(
Variable*)>& evaluator) {
125 const std::function<int64_t(
Variable*)>& evaluator) {
137 const std::function<int64_t(
Variable*)>& evaluator) {
144 return result % 2 == 1;
148 const std::function<int64_t(
Variable*)>& evaluator) {
154 const int64_t shifted_index = Eval(
ct.
arguments[0], evaluator) - 1;
155 const int64_t element = EvalAt(
ct.
arguments[1], shifted_index, evaluator);
156 const int64_t target = Eval(
ct.
arguments[2], evaluator);
157 return element == target;
160 bool CheckArrayIntElementNonShifted(
165 const int64_t target = Eval(
ct.
arguments[2], evaluator);
166 return element == target;
169 bool CheckArrayVarIntElement(
176 const int64_t shifted_index = Eval(
ct.
arguments[0], evaluator) - 1;
177 const int64_t element = EvalAt(
ct.
arguments[1], shifted_index, evaluator);
178 const int64_t target = Eval(
ct.
arguments[2], evaluator);
179 return element == target;
183 const std::function<int64_t(
Variable*)>& evaluator) {
184 const int64_t expected = Eval(
ct.
arguments[0], evaluator);
191 return count <= expected;
195 const std::function<int64_t(
Variable*)>& evaluator) {
196 const int64_t left = Eval(
ct.
arguments[0], evaluator);
197 const int64_t right = Eval(
ct.
arguments[1], evaluator);
203 const std::function<int64_t(
Variable*)>& evaluator) {
221 const std::function<int64_t(
Variable*)>& evaluator) {
222 const int64_t left = Eval(
ct.
arguments[0], evaluator);
223 const int64_t right = Eval(
ct.
arguments[1], evaluator);
224 return left == 1 - right;
228 const std::function<int64_t(
Variable*)>& evaluator) {
229 const int64_t left = Eval(
ct.
arguments[0], evaluator);
230 const int64_t right = Eval(
ct.
arguments[1], evaluator);
236 const std::function<int64_t(
Variable*)>& evaluator) {
237 const int64_t left = Eval(
ct.
arguments[0], evaluator);
238 const int64_t right = Eval(
ct.
arguments[1], evaluator);
239 const int64_t target = Eval(
ct.
arguments[2], evaluator);
240 return target == (left + right == 1);
244 const std::function<int64_t(
Variable*)>& evaluator) {
248 absl::flat_hash_set<int64_t> visited;
250 for (
int i = 0; i < size; ++i) {
251 const int64_t
next = EvalAt(
ct.
arguments[0], current, evaluator) - base;
252 visited.insert(
next);
255 return visited.size() == size;
259 const std::function<int64_t(
Variable*)>& evaluator) {
269 const std::function<int64_t(
Variable*)>& evaluator) {
270 const int64_t count = ComputeCount(
ct, evaluator);
271 const int64_t expected = Eval(
ct.
arguments[2], evaluator);
272 return count == expected;
276 const std::function<int64_t(
Variable*)>& evaluator) {
277 const int64_t count = ComputeCount(
ct, evaluator);
278 const int64_t expected = Eval(
ct.
arguments[2], evaluator);
279 return count >= expected;
283 const std::function<int64_t(
Variable*)>& evaluator) {
284 const int64_t count = ComputeCount(
ct, evaluator);
285 const int64_t expected = Eval(
ct.
arguments[2], evaluator);
286 return count > expected;
290 const std::function<int64_t(
Variable*)>& evaluator) {
291 const int64_t count = ComputeCount(
ct, evaluator);
292 const int64_t expected = Eval(
ct.
arguments[2], evaluator);
293 return count <= expected;
297 const std::function<int64_t(
Variable*)>& evaluator) {
298 const int64_t count = ComputeCount(
ct, evaluator);
299 const int64_t expected = Eval(
ct.
arguments[2], evaluator);
300 return count < expected;
304 const std::function<int64_t(
Variable*)>& evaluator) {
305 const int64_t count = ComputeCount(
ct, evaluator);
306 const int64_t expected = Eval(
ct.
arguments[2], evaluator);
307 return count != expected;
311 const std::function<int64_t(
Variable*)>& evaluator) {
312 const int64_t count = ComputeCount(
ct, evaluator);
313 const int64_t expected = Eval(
ct.
arguments[2], evaluator);
315 return status == (expected == count);
319 const std::function<int64_t(
Variable*)>& evaluator) {
325 absl::flat_hash_map<int64_t, int64_t> usage;
326 for (
int i = 0; i < size; ++i) {
328 const int64_t duration = EvalAt(
ct.
arguments[1], i, evaluator);
329 const int64_t requirement = EvalAt(
ct.
arguments[2], i, evaluator);
330 for (int64_t t =
start; t <
start + duration; ++t) {
331 usage[t] += requirement;
341 const std::function<int64_t(
Variable*)>& evaluator) {
346 const std::function<int64_t(
Variable*)>& evaluator) {
351 const std::function<int64_t(
Variable*)>& evaluator) {
356 const std::function<int64_t(
Variable*)>& evaluator) {
361 const std::function<int64_t(
Variable*)>& evaluator) {
365 bool CheckDisjunctiveStrict(
371 const std::function<int64_t(
Variable*)>& evaluator) {
375 std::vector<int64_t> ComputeGlobalCardinalityCards(
377 std::vector<int64_t> cards(Size(
ct.
arguments[1]), 0);
378 absl::flat_hash_map<int64_t, int> positions;
379 for (
int i = 0; i <
ct.
arguments[1].values.size(); ++i) {
381 CHECK(!positions.contains(
value));
382 positions[
value] = i;
386 if (positions.contains(
value)) {
387 cards[positions[
value]]++;
393 bool CheckGlobalCardinality(
395 const std::vector<int64_t> cards =
396 ComputeGlobalCardinalityCards(
ct, evaluator);
399 const int64_t card = EvalAt(
ct.
arguments[2], i, evaluator);
400 if (card != cards[i]) {
407 bool CheckGlobalCardinalityClosed(
409 const std::vector<int64_t> cards =
410 ComputeGlobalCardinalityCards(
ct, evaluator);
413 const int64_t card = EvalAt(
ct.
arguments[2], i, evaluator);
414 if (card != cards[i]) {
418 int64_t sum_of_cards = 0;
419 for (int64_t card : cards) {
420 sum_of_cards += card;
425 bool CheckGlobalCardinalityLowUp(
427 const std::vector<int64_t> cards =
428 ComputeGlobalCardinalityCards(
ct, evaluator);
429 CHECK_EQ(cards.size(),
ct.
arguments[2].values.size());
430 CHECK_EQ(cards.size(),
ct.
arguments[3].values.size());
431 for (
int i = 0; i < cards.size(); ++i) {
432 const int64_t card = cards[i];
440 bool CheckGlobalCardinalityLowUpClosed(
442 const std::vector<int64_t> cards =
443 ComputeGlobalCardinalityCards(
ct, evaluator);
444 CHECK_EQ(cards.size(),
ct.
arguments[2].values.size());
445 CHECK_EQ(cards.size(),
ct.
arguments[3].values.size());
446 for (
int i = 0; i < cards.size(); ++i) {
447 const int64_t card = cards[i];
452 int64_t sum_of_cards = 0;
453 for (int64_t card : cards) {
454 sum_of_cards += card;
459 bool CheckGlobalCardinalityOld(
462 std::vector<int64_t> cards(size, 0);
469 for (
int i = 0; i < size; ++i) {
470 const int64_t card = EvalAt(
ct.
arguments[1], i, evaluator);
471 if (card != cards[i]) {
479 const std::function<int64_t(
Variable*)>& evaluator) {
480 const int64_t left = Eval(
ct.
arguments[0], evaluator);
481 const int64_t right = Eval(
ct.
arguments[1], evaluator);
482 return std::abs(left) == right;
486 const std::function<int64_t(
Variable*)>& evaluator) {
487 const int64_t left = Eval(
ct.
arguments[0], evaluator);
488 const int64_t right = Eval(
ct.
arguments[1], evaluator);
489 const int64_t target = Eval(
ct.
arguments[2], evaluator);
490 return target == left / right;
494 const std::function<int64_t(
Variable*)>& evaluator) {
495 const int64_t left = Eval(
ct.
arguments[0], evaluator);
496 const int64_t right = Eval(
ct.
arguments[1], evaluator);
497 return left == right;
501 const std::function<int64_t(
Variable*)>& evaluator) {
502 const int64_t left = Eval(
ct.
arguments[0], evaluator);
503 const int64_t right = Eval(
ct.
arguments[1], evaluator);
509 const std::function<int64_t(
Variable*)>& evaluator) {
510 const int64_t left = Eval(
ct.
arguments[0], evaluator);
511 const int64_t right = Eval(
ct.
arguments[1], evaluator);
513 return status == (left == right);
517 const std::function<int64_t(
Variable*)>& evaluator) {
518 const int64_t left = Eval(
ct.
arguments[0], evaluator);
519 const int64_t right = Eval(
ct.
arguments[1], evaluator);
520 return left >= right;
524 const std::function<int64_t(
Variable*)>& evaluator) {
525 const int64_t left = Eval(
ct.
arguments[0], evaluator);
526 const int64_t right = Eval(
ct.
arguments[1], evaluator);
532 const std::function<int64_t(
Variable*)>& evaluator) {
533 const int64_t left = Eval(
ct.
arguments[0], evaluator);
534 const int64_t right = Eval(
ct.
arguments[1], evaluator);
536 return status == (left >= right);
540 const std::function<int64_t(
Variable*)>& evaluator) {
541 const int64_t left = Eval(
ct.
arguments[0], evaluator);
542 const int64_t right = Eval(
ct.
arguments[1], evaluator);
547 const std::function<int64_t(
Variable*)>& evaluator) {
548 const int64_t left = Eval(
ct.
arguments[0], evaluator);
549 const int64_t right = Eval(
ct.
arguments[1], evaluator);
555 const std::function<int64_t(
Variable*)>& evaluator) {
556 const int64_t left = Eval(
ct.
arguments[0], evaluator);
557 const int64_t right = Eval(
ct.
arguments[1], evaluator);
559 return status == (left > right);
563 const std::function<int64_t(
Variable*)>& evaluator) {
564 const int64_t left = Eval(
ct.
arguments[0], evaluator);
565 const int64_t right = Eval(
ct.
arguments[1], evaluator);
566 return left <= right;
570 const std::function<int64_t(
Variable*)>& evaluator) {
571 const int64_t left = Eval(
ct.
arguments[0], evaluator);
572 const int64_t right = Eval(
ct.
arguments[1], evaluator);
578 const std::function<int64_t(
Variable*)>& evaluator) {
579 const int64_t left = Eval(
ct.
arguments[0], evaluator);
580 const int64_t right = Eval(
ct.
arguments[1], evaluator);
582 return status == (left <= right);
586 const std::function<int64_t(
Variable*)>& evaluator) {
587 const int64_t left = Eval(
ct.
arguments[0], evaluator);
588 const int64_t right = Eval(
ct.
arguments[1], evaluator);
593 const std::function<int64_t(
Variable*)>& evaluator) {
594 const int64_t left = Eval(
ct.
arguments[0], evaluator);
595 const int64_t right = Eval(
ct.
arguments[1], evaluator);
601 const std::function<int64_t(
Variable*)>& evaluator) {
602 const int64_t left = Eval(
ct.
arguments[0], evaluator);
603 const int64_t right = Eval(
ct.
arguments[1], evaluator);
605 return status == (left < right);
609 const std::function<int64_t(
Variable*)>& evaluator) {
619 const std::function<int64_t(
Variable*)>& evaluator) {
620 const int64_t left = ComputeIntLin(
ct, evaluator);
621 const int64_t right = Eval(
ct.
arguments[2], evaluator);
622 return left == right;
626 const std::function<int64_t(
Variable*)>& evaluator) {
627 const int64_t left = ComputeIntLin(
ct, evaluator);
628 const int64_t right = Eval(
ct.
arguments[2], evaluator);
634 const std::function<int64_t(
Variable*)>& evaluator) {
635 const int64_t left = ComputeIntLin(
ct, evaluator);
636 const int64_t right = Eval(
ct.
arguments[2], evaluator);
638 return status == (left == right);
642 const std::function<int64_t(
Variable*)>& evaluator) {
643 const int64_t left = ComputeIntLin(
ct, evaluator);
644 const int64_t right = Eval(
ct.
arguments[2], evaluator);
645 return left >= right;
649 const std::function<int64_t(
Variable*)>& evaluator) {
650 const int64_t left = ComputeIntLin(
ct, evaluator);
651 const int64_t right = Eval(
ct.
arguments[2], evaluator);
657 const std::function<int64_t(
Variable*)>& evaluator) {
658 const int64_t left = ComputeIntLin(
ct, evaluator);
659 const int64_t right = Eval(
ct.
arguments[2], evaluator);
661 return status == (left >= right);
665 const std::function<int64_t(
Variable*)>& evaluator) {
666 const int64_t left = ComputeIntLin(
ct, evaluator);
667 const int64_t right = Eval(
ct.
arguments[2], evaluator);
668 return left <= right;
672 const std::function<int64_t(
Variable*)>& evaluator) {
673 const int64_t left = ComputeIntLin(
ct, evaluator);
674 const int64_t right = Eval(
ct.
arguments[2], evaluator);
680 const std::function<int64_t(
Variable*)>& evaluator) {
681 const int64_t left = ComputeIntLin(
ct, evaluator);
682 const int64_t right = Eval(
ct.
arguments[2], evaluator);
684 return status == (left <= right);
688 const std::function<int64_t(
Variable*)>& evaluator) {
689 const int64_t left = ComputeIntLin(
ct, evaluator);
690 const int64_t right = Eval(
ct.
arguments[2], evaluator);
691 return left != right;
695 const std::function<int64_t(
Variable*)>& evaluator) {
696 const int64_t left = ComputeIntLin(
ct, evaluator);
697 const int64_t right = Eval(
ct.
arguments[2], evaluator);
703 const std::function<int64_t(
Variable*)>& evaluator) {
704 const int64_t left = ComputeIntLin(
ct, evaluator);
705 const int64_t right = Eval(
ct.
arguments[2], evaluator);
707 return status == (left != right);
711 const std::function<int64_t(
Variable*)>& evaluator) {
712 const int64_t left = Eval(
ct.
arguments[0], evaluator);
713 const int64_t right = Eval(
ct.
arguments[1], evaluator);
719 const std::function<int64_t(
Variable*)>& evaluator) {
720 const int64_t left = Eval(
ct.
arguments[0], evaluator);
721 const int64_t right = Eval(
ct.
arguments[1], evaluator);
727 const std::function<int64_t(
Variable*)>& evaluator) {
728 const int64_t left = Eval(
ct.
arguments[0], evaluator);
729 const int64_t right = Eval(
ct.
arguments[1], evaluator);
730 const int64_t target = Eval(
ct.
arguments[2], evaluator);
731 return target == left - right;
735 const std::function<int64_t(
Variable*)>& evaluator) {
736 const int64_t left = Eval(
ct.
arguments[0], evaluator);
737 const int64_t right = Eval(
ct.
arguments[1], evaluator);
738 const int64_t target = Eval(
ct.
arguments[2], evaluator);
739 return target == left % right;
743 const std::function<int64_t(
Variable*)>& evaluator) {
744 const int64_t left = Eval(
ct.
arguments[0], evaluator);
745 const int64_t right = Eval(
ct.
arguments[1], evaluator);
746 return left != right;
750 const std::function<int64_t(
Variable*)>& evaluator) {
751 const int64_t left = Eval(
ct.
arguments[0], evaluator);
752 const int64_t right = Eval(
ct.
arguments[1], evaluator);
758 const std::function<int64_t(
Variable*)>& evaluator) {
759 const int64_t left = Eval(
ct.
arguments[0], evaluator);
760 const int64_t right = Eval(
ct.
arguments[1], evaluator);
762 return status == (left != right);
766 const std::function<int64_t(
Variable*)>& evaluator) {
767 const int64_t left = Eval(
ct.
arguments[0], evaluator);
768 const int64_t right = Eval(
ct.
arguments[1], evaluator);
769 return left == -right;
773 const std::function<int64_t(
Variable*)>& evaluator) {
774 const int64_t left = Eval(
ct.
arguments[0], evaluator);
775 const int64_t right = Eval(
ct.
arguments[1], evaluator);
776 const int64_t target = Eval(
ct.
arguments[2], evaluator);
777 return target == left + right;
781 const std::function<int64_t(
Variable*)>& evaluator) {
782 const int64_t left = Eval(
ct.
arguments[0], evaluator);
783 const int64_t right = Eval(
ct.
arguments[1], evaluator);
784 const int64_t target = Eval(
ct.
arguments[2], evaluator);
785 return target == left * right;
789 const std::function<int64_t(
Variable*)>& evaluator) {
795 for (
int i = 0; i < size; ++i) {
796 const int64_t x = EvalAt(
ct.
arguments[0], i, evaluator) - invf_base;
797 const int64_t y = EvalAt(
ct.
arguments[1], i, evaluator) - f_base;
798 if (x < 0 || x >= size || y < 0 || y >= size) {
804 for (
int i = 0; i < size; ++i) {
805 const int64_t fi = EvalAt(
ct.
arguments[0], i, evaluator) - invf_base;
806 const int64_t invf_fi = EvalAt(
ct.
arguments[1], fi, evaluator) - f_base;
816 const std::function<int64_t(
Variable*)>& evaluator) {
819 const int64_t x = EvalAt(
ct.
arguments[0], i, evaluator);
820 const int64_t y = EvalAt(
ct.
arguments[1], i, evaluator);
833 const std::function<int64_t(
Variable*)>& evaluator) {
836 const int64_t x = EvalAt(
ct.
arguments[0], i, evaluator);
837 const int64_t y = EvalAt(
ct.
arguments[1], i, evaluator);
850 const std::function<int64_t(
Variable*)>& evaluator) {
851 const int64_t max_index = Eval(
ct.
arguments[1], evaluator) - 1;
852 const int64_t max_value = EvalAt(
ct.
arguments[0], max_index, evaluator);
854 for (
int i = 0; i < max_index; ++i) {
855 if (EvalAt(
ct.
arguments[0], i, evaluator) >= max_value) {
860 for (
int i = max_index + 1; i < Size(
ct.
arguments[0]); i++) {
861 if (EvalAt(
ct.
arguments[0], i, evaluator) > max_value) {
870 const std::function<int64_t(
Variable*)>& evaluator) {
875 return max_value == Eval(
ct.
arguments[0], evaluator);
879 const std::function<int64_t(
Variable*)>& evaluator) {
880 const int64_t min_index = Eval(
ct.
arguments[1], evaluator) - 1;
881 const int64_t min_value = EvalAt(
ct.
arguments[0], min_index, evaluator);
883 for (
int i = 0; i < min_index; ++i) {
884 if (EvalAt(
ct.
arguments[0], i, evaluator) <= min_value) {
889 for (
int i = min_index + 1; i < Size(
ct.
arguments[0]); i++) {
890 if (EvalAt(
ct.
arguments[0], i, evaluator) < min_value) {
899 const std::function<int64_t(
Variable*)>& evaluator) {
904 return min_value == Eval(
ct.
arguments[0], evaluator);
907 bool CheckNetworkFlowConservation(
910 const std::function<int64_t(
Variable*)>& evaluator) {
911 std::vector<int64_t> balance(balance_input.
values);
913 const int num_arcs = Size(arcs) / 2;
914 for (
int arc = 0;
arc < num_arcs;
arc++) {
917 const int64_t flow = EvalAt(flow_vars,
arc, evaluator);
918 balance[
tail] -= flow;
919 balance[
head] += flow;
922 for (
const int64_t
value : balance) {
923 if (
value != 0)
return false;
930 const std::function<int64_t(
Variable*)>& evaluator) {
936 const std::function<int64_t(
Variable*)>& evaluator) {
942 int64_t total_cost = 0;
944 for (
int arc = 0;
arc < num_arcs;
arc++) {
947 total_cost += flow *
cost;
950 return total_cost == Eval(
ct.
arguments[4], evaluator);
954 const std::function<int64_t(
Variable*)>& evaluator) {
955 const int64_t count = Eval(
ct.
arguments[0], evaluator);
956 absl::flat_hash_set<int64_t> all_values;
958 all_values.insert(EvalAt(
ct.
arguments[1], i, evaluator));
961 return count == all_values.size();
965 const std::function<int64_t(
Variable*)>& evaluator) {
970 const std::function<int64_t(
Variable*)>& evaluator) {
975 const std::function<int64_t(
Variable*)>& evaluator) {
981 const std::function<int64_t(
Variable*)>& evaluator) {
987 const std::function<int64_t(
Variable*)>& evaluator) {
994 const std::function<int64_t(
Variable*)>& evaluator) {
995 const int64_t low = Eval(
ct.
arguments[0], evaluator);
996 const int64_t up = Eval(
ct.
arguments[1], evaluator);
997 const int64_t length = Eval(
ct.
arguments[2], evaluator);
999 int64_t sliding_sum = 0;
1000 for (
int i = 0; i < std::min<int64_t>(length, Size(
ct.
arguments[3])); ++i) {
1001 sliding_sum += EvalAt(
ct.
arguments[3], i, evaluator);
1003 if (sliding_sum < low || sliding_sum > up) {
1006 for (
int i = length; i < Size(
ct.
arguments[3]); ++i) {
1007 sliding_sum += EvalAt(
ct.
arguments[3], i, evaluator) -
1009 if (sliding_sum < low || sliding_sum > up) {
1017 const std::function<int64_t(
Variable*)>& evaluator) {
1019 absl::flat_hash_map<int64_t, int> init_count;
1020 absl::flat_hash_map<int64_t, int> sorted_count;
1022 init_count[EvalAt(
ct.
arguments[0], i, evaluator)]++;
1023 sorted_count[EvalAt(
ct.
arguments[1], i, evaluator)]++;
1025 if (init_count != sorted_count) {
1028 for (
int i = 0; i < Size(
ct.
arguments[1]) - 1; ++i) {
1038 const std::function<int64_t(
Variable*)>& evaluator) {
1039 absl::flat_hash_set<int64_t> visited;
1042 int64_t current = -1;
1045 if (
next != i && current == -1) {
1047 }
else if (
next == i) {
1048 visited.insert(
next);
1053 const int residual_size = Size(
ct.
arguments[0]) - visited.size();
1054 for (
int i = 0; i < residual_size; ++i) {
1055 const int64_t
next = EvalAt(
ct.
arguments[0], current, evaluator) - base;
1056 visited.insert(
next);
1057 if (
next == current) {
1068 const std::function<int64_t(
Variable*)>& evaluator) {
1072 bool CheckSymmetricAllDifferent(
1075 for (
int i = 0; i < size; ++i) {
1077 if (value < 0 || value >= size) {
1080 const int64_t reverse_value = EvalAt(
ct.
arguments[0],
value, evaluator) - 1;
1081 if (reverse_value != i) {
1089 absl::flat_hash_map<std::string,
1091 std::function<int64_t(
Variable*)>)>>;
1100 CallMap CreateCallMap() {
1102 m[
"fzn_all_different_int"] = CheckAllDifferentInt;
1103 m[
"alldifferent_except_0"] = CheckAlldifferentExcept0;
1104 m[
"among"] = CheckAmong;
1105 m[
"array_bool_and"] = CheckArrayBoolAnd;
1106 m[
"array_bool_element"] = CheckArrayIntElement;
1107 m[
"array_bool_or"] = CheckArrayBoolOr;
1108 m[
"array_bool_xor"] = CheckArrayBoolXor;
1109 m[
"array_int_element"] = CheckArrayIntElement;
1110 m[
"array_int_element_nonshifted"] = CheckArrayIntElementNonShifted;
1111 m[
"array_var_bool_element"] = CheckArrayVarIntElement;
1112 m[
"array_var_int_element"] = CheckArrayVarIntElement;
1113 m[
"at_most_int"] = CheckAtMostInt;
1114 m[
"bool_and"] = CheckBoolAnd;
1115 m[
"bool_clause"] = CheckBoolClause;
1116 m[
"bool_eq"] = CheckIntEq;
1117 m[
"bool2int"] = CheckIntEq;
1118 m[
"bool_eq_imp"] = CheckIntEqImp;
1119 m[
"bool_eq_reif"] = CheckIntEqReif;
1120 m[
"bool_ge"] = CheckIntGe;
1121 m[
"bool_ge_imp"] = CheckIntGeImp;
1122 m[
"bool_ge_reif"] = CheckIntGeReif;
1123 m[
"bool_gt"] = CheckIntGt;
1124 m[
"bool_gt_imp"] = CheckIntGtImp;
1125 m[
"bool_gt_reif"] = CheckIntGtReif;
1126 m[
"bool_le"] = CheckIntLe;
1127 m[
"bool_le_imp"] = CheckIntLeImp;
1128 m[
"bool_le_reif"] = CheckIntLeReif;
1129 m[
"bool_left_imp"] = CheckIntLe;
1130 m[
"bool_lin_eq"] = CheckIntLinEq;
1131 m[
"bool_lin_le"] = CheckIntLinLe;
1132 m[
"bool_lt"] = CheckIntLt;
1133 m[
"bool_lt_imp"] = CheckIntLtImp;
1134 m[
"bool_lt_reif"] = CheckIntLtReif;
1135 m[
"bool_ne"] = CheckIntNe;
1136 m[
"bool_ne_imp"] = CheckIntNeImp;
1137 m[
"bool_ne_reif"] = CheckIntNeReif;
1138 m[
"bool_not"] = CheckBoolNot;
1139 m[
"bool_or"] = CheckBoolOr;
1140 m[
"bool_right_imp"] = CheckIntGe;
1141 m[
"bool_xor"] = CheckBoolXor;
1142 m[
"ortools_circuit"] = CheckCircuit;
1143 m[
"count_eq"] = CheckCountEq;
1144 m[
"count"] = CheckCountEq;
1145 m[
"count_geq"] = CheckCountGeq;
1146 m[
"count_gt"] = CheckCountGt;
1147 m[
"count_leq"] = CheckCountLeq;
1148 m[
"count_lt"] = CheckCountLt;
1149 m[
"count_neq"] = CheckCountNeq;
1150 m[
"count_reif"] = CheckCountReif;
1151 m[
"fzn_cumulative"] = CheckCumulative;
1152 m[
"var_cumulative"] = CheckCumulative;
1153 m[
"variable_cumulative"] = CheckCumulative;
1154 m[
"fixed_cumulative"] = CheckCumulative;
1155 m[
"fzn_diffn"] = CheckDiffn;
1156 m[
"diffn_k_with_sizes"] = CheckDiffnK;
1157 m[
"fzn_diffn_nonstrict"] = CheckDiffnNonStrict;
1158 m[
"diffn_nonstrict_k_with_sizes"] = CheckDiffnNonStrictK;
1159 m[
"disjunctive"] = CheckDisjunctive;
1160 m[
"disjunctive_strict"] = CheckDisjunctiveStrict;
1161 m[
"false_constraint"] = CheckFalseConstraint;
1162 m[
"global_cardinality"] = CheckGlobalCardinality;
1163 m[
"global_cardinality_closed"] = CheckGlobalCardinalityClosed;
1164 m[
"global_cardinality_low_up"] = CheckGlobalCardinalityLowUp;
1165 m[
"global_cardinality_low_up_closed"] = CheckGlobalCardinalityLowUpClosed;
1166 m[
"global_cardinality_old"] = CheckGlobalCardinalityOld;
1167 m[
"int_abs"] = CheckIntAbs;
1168 m[
"int_div"] = CheckIntDiv;
1169 m[
"int_eq"] = CheckIntEq;
1170 m[
"int_eq_imp"] = CheckIntEqImp;
1171 m[
"int_eq_reif"] = CheckIntEqReif;
1172 m[
"int_ge"] = CheckIntGe;
1173 m[
"int_ge_imp"] = CheckIntGeImp;
1174 m[
"int_ge_reif"] = CheckIntGeReif;
1175 m[
"int_gt"] = CheckIntGt;
1176 m[
"int_gt_imp"] = CheckIntGtImp;
1177 m[
"int_gt_reif"] = CheckIntGtReif;
1178 m[
"int_le"] = CheckIntLe;
1179 m[
"int_le_imp"] = CheckIntLeImp;
1180 m[
"int_le_reif"] = CheckIntLeReif;
1181 m[
"int_lin_eq"] = CheckIntLinEq;
1182 m[
"int_lin_eq_imp"] = CheckIntLinEqImp;
1183 m[
"int_lin_eq_reif"] = CheckIntLinEqReif;
1184 m[
"int_lin_ge"] = CheckIntLinGe;
1185 m[
"int_lin_ge_imp"] = CheckIntLinGeImp;
1186 m[
"int_lin_ge_reif"] = CheckIntLinGeReif;
1187 m[
"int_lin_le"] = CheckIntLinLe;
1188 m[
"int_lin_le_imp"] = CheckIntLinLeImp;
1189 m[
"int_lin_le_reif"] = CheckIntLinLeReif;
1190 m[
"int_lin_ne"] = CheckIntLinNe;
1191 m[
"int_lin_ne_imp"] = CheckIntLinNeImp;
1192 m[
"int_lin_ne_reif"] = CheckIntLinNeReif;
1193 m[
"int_lt"] = CheckIntLt;
1194 m[
"int_lt_imp"] = CheckIntLtImp;
1195 m[
"int_lt_reif"] = CheckIntLtReif;
1196 m[
"int_max"] = CheckIntMax;
1197 m[
"int_min"] = CheckIntMin;
1198 m[
"int_minus"] = CheckIntMinus;
1199 m[
"int_mod"] = CheckIntMod;
1200 m[
"int_ne"] = CheckIntNe;
1201 m[
"int_ne_imp"] = CheckIntNeImp;
1202 m[
"int_ne_reif"] = CheckIntNeReif;
1203 m[
"int_negate"] = CheckIntNegate;
1204 m[
"int_plus"] = CheckIntPlus;
1205 m[
"int_times"] = CheckIntTimes;
1206 m[
"ortools_inverse"] = CheckInverse;
1207 m[
"lex_less_bool"] = CheckLexLessInt;
1208 m[
"lex_less_int"] = CheckLexLessInt;
1209 m[
"lex_lesseq_bool"] = CheckLexLesseqInt;
1210 m[
"lex_lesseq_int"] = CheckLexLesseqInt;
1211 m[
"maximum_arg_int"] = CheckMaximumArgInt;
1212 m[
"maximum_int"] = CheckMaximumInt;
1213 m[
"array_int_maximum"] = CheckMaximumInt;
1214 m[
"minimum_arg_int"] = CheckMinimumArgInt;
1215 m[
"minimum_int"] = CheckMinimumInt;
1216 m[
"array_int_minimum"] = CheckMinimumInt;
1217 m[
"ortools_network_flow"] = CheckNetworkFlow;
1218 m[
"ortools_network_flow_cost"] = CheckNetworkFlowCost;
1219 m[
"nvalue"] = CheckNvalue;
1220 m[
"ortools_regular"] = CheckRegular;
1221 m[
"regular_nfa"] = CheckRegularNfa;
1222 m[
"set_in"] = CheckSetIn;
1223 m[
"int_in"] = CheckSetIn;
1224 m[
"set_not_in"] = CheckSetNotIn;
1225 m[
"int_not_in"] = CheckSetNotIn;
1226 m[
"set_in_reif"] = CheckSetInReif;
1227 m[
"sliding_sum"] = CheckSlidingSum;
1228 m[
"sort"] = CheckSort;
1229 m[
"ortools_subcircuit"] = CheckSubCircuit;
1230 m[
"symmetric_all_different"] = CheckSymmetricAllDifferent;
1231 m[
"ortools_table_bool"] = CheckTableInt;
1232 m[
"ortools_table_int"] = CheckTableInt;
1239 const std::function<int64_t(
Variable*)>& evaluator,
1242 const CallMap call_map = CreateCallMap();
1245 const auto& checker = call_map.at(
ct->
type);
1246 if (!checker(*
ct, evaluator)) {
bool CheckSolution(const Model &model, const std::function< int64_t(Variable *)> &evaluator, SolverLogger *logger)
Collection of objects used to extend the Constraint Solver library.
Variable * VarAt(int pos) const
std::string DebugString() const
std::vector< Variable * > variables
std::vector< int64_t > values
int64_t ValueAt(int pos) const
std::string DebugString() const
std::vector< Argument > arguments
#define SOLVER_LOG(logger,...)