'How to find the route order of my vehicle route problem

I am after building a linear optimization model to find the optimal route for a vehicle with a number of collection points on pyomo.

I have got solution for my code but I now want to show my route information.

In my code model.Z is my decision variable which shows that a node has been visited.

# Binary variable indicating whether node J has been traveled to from node I #
model.Z = Var(model.I, model.J, domain = Binary)  

I want to code something at the end of my code that gives me an output like below:

enter image description here

Or even something like this, which shows the values of the decision variables in order, and from this my route order can be seen.

enter image description here

How can I do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source