choco

Modeling tennis matchups with Choco (CSP)

£可爱£侵袭症+ 提交于 2019-12-13 07:15:09
问题 I am trying to model a problem with Choco to get the combinations of possible matchups in a tennis event (or any sport). The way I am trying to do it I have the following: // Set of timeslots when the event is held (i.e. 10am-10pm) int nTimeslots = 12; // Courts available: court #1, #2 and #3 int nCourts = 3; String[] players = { "Novak", "Andy", "Roger", "Stan", "Rafel", "Kei", "Tomas", "David" }; int nPlayers = players.length; // Timeslots when each player cannot play for whatever reason

Choco solver old class

瘦欲@ 提交于 2019-12-11 15:07:05
问题 I found this code for solving the magic square program with the choco solver: public static void main(String[] args) { int n = 4; System.out.println("Magic Square Problem with n = " + n); Problem myPb = new Problem(); IntVar[] vars = new IntVar[n * n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { vars[i * n + j] = myPb.makeEnumIntVar("C" + i + "_" + j, 1, n * n); } IntVar sum = myPb.makeEnumIntVar("S", 1, n * n * (n * n + 1) / 2); myPb.post(myPb.eq(sum, n * (n*n + 1) / 2)); for