QDpy
Loading...
Searching...
No Matches
qdpy.algorithms.traveling_thief.TravelingThiefProblem Class Reference

Score a route and packing and solve exact packing for a fixed tour. More...

Public Member Functions

 evaluate (self, tour, packing)
 Measure the true travel cost and reward for a feasible route and packing.
 solve_packing (self, tour)
 Maximize net fitness for a fixed tour using sparse weight states.

Detailed Description

Score a route and packing and solve exact packing for a fixed tour.

Travel speed decreases linearly with the current carried weight.

Pick up items before leaving their cities and include the final
edge back to the depot. The objective maximizes packed profit
minus the rental cost of travel time. Both tour directions retain
their own load order.

:param distances: Square finite nonnegative distance matrix.
:param items: Sequence of TravelingThiefItem objects.
:param capacity: Positive integer weight capacity.
:param min_speed: Speed at capacity.
:param max_speed: Speed when empty.
:param rent: Nonnegative cost per travel-time unit.

Definition at line 67 of file traveling_thief.py.

Member Function Documentation

◆ evaluate()

qdpy.algorithms.traveling_thief.TravelingThiefProblem.evaluate ( self,
tour,
packing )

Measure the true travel cost and reward for a feasible route and packing.

Parameters
tourPermutation of all cities. The final leg returns to the depot.
packingDistinct zero-based item IDs from the input sequence.
Return the score and archive descriptors for the supplied item IDs.

Definition at line 121 of file traveling_thief.py.

◆ solve_packing()

qdpy.algorithms.traveling_thief.TravelingThiefProblem.solve_packing ( self,
tour )

Maximize net fitness for a fixed tour using sparse weight states.

Parameters
tourPermutation of all cities.
Returns
The best route-packing pair and number of feasible item additions considered.
Return (solution, item_transitions) for one exact packing solve.

Keep the best partial net profit for each reachable weight.
Apply the next travel cost once all items at the current city
have been considered. Count each candidate item addition that
stays within capacity, including candidates discarded by the DP.

Definition at line 147 of file traveling_thief.py.


The documentation for this class was generated from the following file: