Docsity

MiniZinc to Constraint Programming: A Step-by-Step Guide, Study notes of Computer Numerical Control

Partial preview of the text

Download MiniZinc to Constraint Programming: A Step-by-Step Guide and more Study notes Computer Numerical Control in PDF only on Docsity!

Alan M. Frisch Artificial Intelligence Group Department of Computer Science University of York

Translating a MiniZinc

Specification to a CSP Instance

Constraint Programming Last updated: 6 December 2010

Generality

  • We consider MiniZinc, but the process is similar for other languages.

Eliminate Conditionals

  • If then else endif
  • Evaluate and replace the conditional with either or

Eliminate Comprehensions

  • [ exp1 | exp2]
  • {exp1 | exp2}
  • Often called unrolling

Test All Assertions

  • Constraint assert (boolean, string)
  • Evaluate boolean. If true then output the string and halt else just remove the assertion.

You Now Have a CSP Instance

  • BUT……… it probably contains constraints that are not supported by your solver. - Compound constraints: - (B1 /! B2) -> (B3 / B4) - But many solvers support linear constraints E.g., 2X + 3Y –Z <= 17 - Global constraints - Alldifferent(X1,X2,X3,X4) - Not all solvers support set variables

Decompose Unsupported

Constraints

  • Replace Alldifferent(X1,X2,X3,X4) with
    1. X1 != X
    2. X1 != X
    3. X1 != X
    4. X2 != X
    5. X2 != X
    6. X3 != X

Remove Set Variables if Unsupported

  • Occurrence representation is usually/ always used.