ExVrp.LoadSegment (ExVrp v0.4.2)

Copy Markdown View Source

Load segments for tracking capacity during optimization.

Load segments track delivery and pickup loads, and can be efficiently concatenated to track capacity violations resulting from visiting clients in the concatenated order.

This is a core data structure used by the local search operators to efficiently evaluate moves.

Example

ls1 = ExVrp.LoadSegment.new(10, 0, 10, 0)
ls2 = ExVrp.LoadSegment.new(0, 5, 5, 0)
merged = ExVrp.LoadSegment.merge(ls1, ls2)
ExVrp.LoadSegment.excess_load(merged, 12)

Summary

Functions

Returns the delivery amount, that is, the total amount of load delivered to clients on this segment.

Returns the load violation on this segment.

Finalises the load on this segment.

Returns the maximum load encountered on this segment.

Merges two load segments.

Creates a new load segment.

Returns the amount picked up from clients on this segment.

Types

t()

@type t() :: reference()

Functions

delivery(segment)

@spec delivery(t()) :: integer()

Returns the delivery amount, that is, the total amount of load delivered to clients on this segment.

excess_load(segment, capacity)

@spec excess_load(t(), integer()) :: integer()

Returns the load violation on this segment.

Parameters

  • segment - The load segment
  • capacity - Segment capacity

finalise(segment, capacity)

@spec finalise(t(), integer()) :: t()

Finalises the load on this segment.

Returns a new segment where any excess load has been moved to the cumulative excess load field. This is useful with reloading, because the finalised segment can be concatenated with load segments of subsequent trips.

Parameters

  • segment - The load segment to finalise
  • capacity - The capacity constraint

load(segment)

@spec load(t()) :: integer()

Returns the maximum load encountered on this segment.

merge(first, second)

@spec merge(t(), t()) :: t()

Merges two load segments.

Parameters

  • first - First load segment
  • second - Second load segment

Returns

A new merged load segment.

new(delivery, pickup, load, excess_load \\ 0)

@spec new(integer(), integer(), integer(), integer()) :: t()

Creates a new load segment.

Parameters

  • delivery - Total delivery amount on this segment
  • pickup - Total pickup amount on this segment
  • load - Maximum load on this segment
  • excess_load - Cumulative excess load on this segment (default 0)

pickup(segment)

@spec pickup(t()) :: integer()

Returns the amount picked up from clients on this segment.