Class InsertionCostBreakdown
java.lang.Object
com.graphhopper.jsprit.core.algorithm.recreate.InsertionCostBreakdown
Captures a breakdown of insertion costs by component.
This allows full transparency into why an insertion costs what it costs, showing contributions from each soft constraint and the base activity insertion cost.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a cost component.doubleGet the cost for a specific component.Get all cost components.doublegetTotal()Get the total cost (sum of all components).booleanisEmpty()Check if this breakdown has any components.voidmerge(InsertionCostBreakdown other) Merge another breakdown into this one.voidprint()Print the breakdown to stdout.toString()
-
Constructor Details
-
InsertionCostBreakdown
public InsertionCostBreakdown()
-
-
Method Details
-
add
Add a cost component.- Parameters:
name- The component name (e.g., "Route:SpatialCompactness", "ActivityInsertion")cost- The cost value (positive = penalty, negative = bonus)
-
merge
Merge another breakdown into this one. Costs for components with the same name are summed.- Parameters:
other- The breakdown to merge
-
getComponents
Get all cost components.- Returns:
- Unmodifiable map of component name to cost
-
get
Get the cost for a specific component.- Parameters:
name- The component name- Returns:
- The cost, or 0 if not present
-
getTotal
public double getTotal()Get the total cost (sum of all components).- Returns:
- Total cost
-
isEmpty
public boolean isEmpty()Check if this breakdown has any components.- Returns:
- true if at least one component was added
-
print
public void print()Print the breakdown to stdout. -
toString
-