MCPcopy Create free account
hub / github.com/Gecode/gecode / setup

Method setup

test/ldsb.cpp:722–743  ·  view source on GitHub ↗

Setup problem constraints and symmetries

Source from the content-addressed store, hash-verified

720 static const int u = 3;
721 /// Setup problem constraints and symmetries
722 static void setup(Home home, IntVarArray& xs) {
723 Matrix<IntVarArray> m(xs, 3, 4);
724 // The values in the first column are distinct.
725 distinct(home, m.col(0));
726 // Each row sums to 3.
727 for (int i = 0 ; i < nrows ; ++i)
728 linear(home, m.row(i), IRT_EQ, 3);
729
730 Symmetries s;
731
732 IntArgs a = IntArgs::create(n, 0);
733 // Rows are interchangeable.
734 s << VariableSequenceSymmetry(xs, 3);
735 // Elements (i,1) and (i,2) in row i are interchangeable,
736 // separately for each row.
737 for (int i = 0 ; i < nrows ; i++) {
738 IntVarArgs symvars;
739 symvars << m(1,i) << m(2,i);
740 s << VariableSymmetry(symvars);
741 }
742 branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
743 }
744 /// Compute list of expected solutions
745 static std::vector<IntArgs> expectedSolutions(void) {
746 static std::vector<IntArgs> expected;

Callers

nothing calls this directly

Calls 10

distinctFunction · 0.85
mFunction · 0.85
INT_VAR_NONEFunction · 0.85
INT_VAL_MINFunction · 0.85
linearFunction · 0.50
VariableSequenceSymmetryFunction · 0.50
VariableSymmetryFunction · 0.50
branchFunction · 0.50
colMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected