The Model

The Model

The model is where Numberjack problems are specified, it contains knowledge of the variables and constraints. Models are solver independent and can be solved by multiple solvers. Models can be constructed in two ways, constraints can be specified upon construction, constraints can be added as needed or you can do both.

model = Model() # To create an empty model

model = Model([
    constraint1,
    constraint2,
    .
    .
    .
    constraintN
]) # To create a model with some constraints already added.

Once you have a model created you can add constraints, lists of constraints of n-dimensional matrices of constraints to the model

model.add(constraints)
# or
model += constraints

You can also print your model since the __str__() function has been overridden. The model as a string outlines all the variables and constraints on those variables in the problem.