Obtain optimal assignment
Closed this issue · 2 comments
Hi Gabriel
Thanks for a great project!
I am struggling to find a way to obtain the variables' assignments once I have solved the example knapsack problem and obtained an optimal solution. Somehow I cannot access the decision variables' values leading to the obtained optimal objective value.
I am assuming there must be a way to obtain the values of each integer variables in the results object, but I cannot figure out how. I have gone through the documentation, but can't seem to find anything. Any help? :)
Hi @alexberndt. The knapsack selections are available in the state
attribute of results.best_node
. The BinaryKnapsack
class stores the list of choices at each node in the last entry of the state
tuple.
Sorry this isn't documented very well. I'll add some additional comments to that example before closing this ticket.