class pymzn.MiniZincModel(mzn=None)

Mutable class representing a MiniZinc model.

It can use a mzn file as template, add variables and constraints, modify the solve and output statements. The output statement can also be replaced by a dzn representation of a list of output variables. The final model is a string combining the existing model (if provided) and the updates performed on the MiniZincModel instance.

Parameters:mzn (str) – The content or the path to the template mzn file.


array_variable(name, indexset, domain[, …]) Adds an array variable to the model.
comment(comment) Add a comment to the model.
compile([output_file]) Compiles the model and writes it to file.
constraint(constr) Adds a constraint to the current model.
constraints(constrs) Add a list of constraints.
maximize(expr) Shorthand for solve(‘maximize ‘ + expr)
minimize(expr) Shorthand for solve(‘minimize ‘ + expr)
output(output_stmt) Updates the output statement of the model.
parameter(*par[, assign]) Adds a parameter to the model.
parameters(pars[, assign]) Add a list of parameters.
satisfy() Shorthand for solve(‘satisfy’)
solve(solve_stmt) Updates the solve statement of the model.
variable(name, vartype[, value, output]) Adds a variable to the model.