Class RegretKAlternatives
java.lang.Object
com.graphhopper.jsprit.core.algorithm.recreate.RegretKAlternatives
Holds k-best insertion alternatives for a job, sorted by insertion cost.
Used for regret-k insertion heuristics where k can be 2, 3, 4, or more.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a single insertion alternative with its route and cost. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(InsertionData insertionData, VehicleRoute route) Adds an alternative and maintains sorted order by cost.static RegretKAlternativesfromBestAndSecondBest(InsertionData best, InsertionData secondBest, VehicleRoute bestRoute, VehicleRoute secondBestRoute) Creates RegretKAlternatives from best and secondBest InsertionData for backward compatibility.get(int index) Returns the alternative at the given index (0-based).Returns all alternatives sorted by cost (ascending).getBest()Returns the best (lowest cost) alternative, or null if empty.Returns the second-best alternative for backward compatibility.getTopK(int k) Returns the top k alternatives (or all if fewer than k exist).booleanisEmpty()Returns true if there are no alternatives.intsize()Returns the number of alternatives.
-
Constructor Details
-
RegretKAlternatives
public RegretKAlternatives() -
RegretKAlternatives
-
-
Method Details
-
add
Adds an alternative and maintains sorted order by cost. -
getAlternatives
Returns all alternatives sorted by cost (ascending). -
getBest
Returns the best (lowest cost) alternative, or null if empty. -
getSecondBest
Returns the second-best alternative for backward compatibility. Returns null if fewer than 2 alternatives exist. -
get
Returns the alternative at the given index (0-based). Returns null if index is out of bounds. -
size
public int size()Returns the number of alternatives. -
isEmpty
public boolean isEmpty()Returns true if there are no alternatives. -
getTopK
Returns the top k alternatives (or all if fewer than k exist). -
fromBestAndSecondBest
public static RegretKAlternatives fromBestAndSecondBest(InsertionData best, InsertionData secondBest, VehicleRoute bestRoute, VehicleRoute secondBestRoute) Creates RegretKAlternatives from best and secondBest InsertionData for backward compatibility.
-