I'm using the Python interface to Minizinc and read both model (.mzn) and data (.dzn) from external files. Is there a way to access problem data from Python?
As example I use cakes2-model from Minizinc manual, which has a decision variable b and a data field flour.
from minizinc import Instance, Model, Solver
solverToUse = "coinbc"
solver = Solver.lookup(solverToUse)
print(solver.name, ",", solver.version)
model = Model("cakes2.mzn")
model.add_file("cakes2.dzn")
instance = Instance(solver, model)
print(instance.method)
result=instance.solve()
b = result.solution.b
print(b)
This runs fine. But how can I access the data/parameter flour? Below is result when interactively asking for data in the same way as for decision variables:
C:\Users\MartinJo>python -i callingMinizinc2.py
COIN-BC , 2.10.5/1.17.5
Method.MAXIMIZE
3
>>> result.solution.b
3
>>> result.solution.flour
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Solution' object has no attribute 'flour'
>>>