Solution¶
Reference
Find the reference for the solution
module here.
ModelSolution
allows access to the solution of a gurobipy.Model
. It is a
simple convenience function that will collect the decision variables and their
values.
Consider the same script shown in the model section, which solves a
simple knapsack problem. You may use the ModelSolution
to obtain the solution
of the model. This convenience functionality is provided out of the box, but we
recommend that you customize how the model is interpreted to parse the solution.
import json
import nextmv_gurobipy as ngp
# Model code here.
solution = ngp.ModelSolution(model)
print(json.dumps(solution, indent=2))
Run the script: