Modelling

MiniZincModel([mzn]) Mutable class representing a MiniZinc model.
Statement(stmt) A statement of a MiniZincModel.
Constraint(constr[, comment]) A constraint statement.
Variable(name, vartype[, value, output]) A variable statement.
ArrayVariable(name, indexset, domain[, …]) An array variable statement.
OutputStatement(output) An output statement.
SolveStatement(solve) A solve statement.

PyMzn can also be used to dynamically change a model during runtime. For example, it can be useful to add constraints incrementally or change the solving statement dynamically. To dynamically modify a model, you can use the class MiniZincModel, providing a template model file as input which can then be modified by adding variables and constraints, and by modifying the solve or output statements. An instance of MiniZincModel can then be passed directly to the minizinc function to be solved.

model = pymzn.MiniZinModel('test.mzn')

for i in range(10):
    model.constraint('arr_1[i] <= arr_2[i]')
    pymzn.minizinc(model)