Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17477

Fixing an element with itertools.permutations()

$
0
0

I have a list of tuples of the form route_cost = [(route, vehicle, cost),...]. Consider that I have 2 routes and 3 vehicles, I want to find the cheapest allocation of 1 vehicle to route 1 and 1 vehicle to route 2. When a vehicle is used it can not be used again.

I considered using itertools.permutations(route_cost, 2) but this of course will consider permutations for every entry. Ideally, I could fix a route and a vehicle i for the route and sum over all other routes and vehicles not equal to the fixed route or i.


Viewing all articles
Browse latest Browse all 17477

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>