ExVrp.ClientGroup (ExVrp v0.4.2)

Copy Markdown View Source

Represents a group of clients with mutual constraints.

Client groups are used to express constraints like "visit at most one of these clients" (mutually exclusive) or other grouping requirements.

Groups are created empty and clients are added dynamically via Model.add_client/2 with the group: option.

Mutually Exclusive Groups

When required: false, the group is automatically marked as mutually exclusive, meaning at most one client from the group can be visited. This matches PyVRP's semantics.

Example

{model, group} = Model.add_client_group(model, required: false)
model = Model.add_client(model, x: 1, y: 1, group: group)
model = Model.add_client(model, x: 2, y: 2, group: group)

Summary

Functions

Adds a client index to the group.

Clears all clients from the group.

Creates a new client group.

Types

t()

@type t() :: %ExVrp.ClientGroup{
  clients: [non_neg_integer()],
  mutually_exclusive: boolean(),
  name: String.t(),
  required: boolean()
}

Functions

add_client(group, client_idx)

@spec add_client(t(), non_neg_integer()) :: t()

Adds a client index to the group.

This is called internally by Model.add_client/2 when a group is specified.

clear(group)

@spec clear(t()) :: t()

Clears all clients from the group.

Used when depots are added after clients, requiring re-indexing.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new client group.

Groups start empty - clients are added dynamically via Model.add_client/2.

Options

  • :required - Whether at least one client must be visited (default: true)
  • :mutually_exclusive - Whether only one client can be visited (default: not required)
  • :name - Group name for identification (default: "")

Examples

iex> ExVrp.ClientGroup.new(required: false)
%ExVrp.ClientGroup{clients: [], required: false, mutually_exclusive: true, name: ""}

iex> ExVrp.ClientGroup.new(required: true, name: "priority")
%ExVrp.ClientGroup{clients: [], required: true, mutually_exclusive: false, name: "priority"}