Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lecoutre committed Sep 22, 2024
1 parent cfedda6 commit 2ffc5fb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
11 changes: 7 additions & 4 deletions academic/FoxGeeseCorn/FoxGeeseCorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@

from pycsp3 import *

# data from Minizinc challenge 2019
mzn19 = [(6, 7, 8, 4, 15, 8, 12, 9), (50, 50, 50, 7, 35, 9, 10, 8), (6, 7, 8, 1, 31, 0, 6, 3), (118, 213, 124, 178, 3, 7, 5, 3), (10, 10, 12, 5, 19, 1, 1, 1)]
# data from Minizinc challenge 2019 (indexes from 0 to 4) and 2024 (indexes from 5 to 0)
mzn = (
[(6, 7, 8, 4, 15, 8, 12, 9), (50, 50, 50, 7, 35, 9, 10, 8), (6, 7, 8, 1, 31, 0, 6, 3), (118, 213, 124, 178, 3, 7, 5, 3), (10, 10, 12, 5, 19, 1, 1, 1)]
+ [(6, 26, 8, 2, 25, 4, 4, 3), (20, 20, 22, 6, 15, 6, 5, 4), (36, 37, 40, 3, 35, 9, 9, 9), (36, 37, 40, 6, 35, 9, 10, 8), (35, 27, 52, 6, 22, 1, 0, 0)]
)

nFoxes, nGeese, nCorns, boatCapacity, horizon, pf, pg, pc = mzn19[data] if isinstance(data, int) else data
nFoxes, nGeese, nCorns, boatCapacity, horizon, pf, pg, pc = mzn[data] if isinstance(data, int) else data

EAST = [i for i in range(1, horizon + 1) if i % 2 == 1]
WEST = [i for i in range(1, horizon + 1) if i % 2 != 1]
Expand Down Expand Up @@ -155,7 +158,7 @@ def alone(i):
ef[z] * pf + eg[z] * pg + ec[z] * pc
)

"""
""" Comments
1) It is possible to avoid declaring the array aux, and declare a variable when calling 'alone(i)' as follows:
tmp = Var(dom=range(4), id="tmp" + str(i))
"""
4 changes: 3 additions & 1 deletion academic/PeacableQueens/PeacableQueens.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def automaton():
""" Comments
1) Note that (q2, [0,2], q2) is a shortcut for {(q2, 0, q2), (q2, 2, q2)}
It is also possible to save the automatas in this compact form with the option -keepSmartTransitions
2) Data used in 2021 are: 8, 11, 25, 40, 50
2) Data used
in 2021 are: 8, 11, 25, 40, 50
in 2024 are: 7, 9, 12, 19, 35
3) Note that
x[symmetry])
is equivalent o:
Expand Down
11 changes: 9 additions & 2 deletions academic/Triangular/Triangular.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

n = data

# x[i,j] is 1 iff the jth node in the ith row is selected
# x[i][j] is 1 iff the jth node in the ith row is selected
x = VarArray(size=[n, n], dom=lambda i, j: {0, 1} if i >= j else None)

satisfy(
Expand All @@ -45,8 +45,15 @@
)

""" Comments
1) Data used in challenges are:
1) Data used in Minizinc challenges are:
10, 16, 22, 28, 37 in 2015
10, 17, 23, 29, 37 in 2019
10, 18, 24, 30, 39 in 2022
09, 11, 14, 20, 31 in 2024
2)
AtLeastOne(
within=[x[i + m][j], x[i + k][j + m], x[i + k - m][j + k - m]],
value=0
) for i in range(n) for j in range(i + 1) for k in range(1, n - i) for m in range(k)
seems to be less efficient
"""

0 comments on commit 2ffc5fb

Please sign in to comment.