I need to use python-constraint
for solving a stowage problem. I have 2 different types of containers (standard S and refrigereted R) and two possible destinations. Containers must be stowed as shown in the next grid that
N N N N
N N N N
X E E X
X X X X
The containers info is a list of tuples where (idx, standard|energized, destination)
, as an example:
containers = [(1,S,1), (2,R,2), ...]
Where N is a normal location and E is an energized one, X is a not used position.
I've been trying to use python-constrain
the distribution of containers in ship. First my variables
problem = constraint.Problem()
problem.addVariables(range(1,len(containers)+1), containers)
And then I need to code my problem to assign cointainers into position in the ship but unsuccessful so far since I don't how to code the grid and assign them to each container. The n-queens is not working for this problem.
Any suggestions.
Edit: Using the n-rooks or n-queens as an example where the variables are the cells in the grid seems to work fine
problem.addVariables(rows, columns)
but then, adding the constraints (such as an unaccesible last row) I get:
for i, f in enumerate(rows):
if (0<=i<=n-1):
problem.adddConstraint(rows[i], cols)
So I don't seem to understand the syntax in the addConstraint function.