# `ExVrp.SameVehicleGroup`
[🔗](https://github.com/sephianl/ex_vrp/blob/v0.4.2/lib/ex_vrp/same_vehicle_group.ex#L1)

A group of clients that must be served by the same vehicle.

If multiple clients from the group are visited, they must all be on the
same route. It is allowed to visit only a subset of the group (or none
at all), but any visited clients must share a vehicle.

## PyVRP Parity

This module mirrors PyVRP's `SameVehicleGroup` class.

## Example

    model =
      ExVrp.Model.new()
      |> ExVrp.Model.add_depot(x: 0, y: 0)
      |> ExVrp.Model.add_client(x: 1, y: 1)
      |> ExVrp.Model.add_client(x: 2, y: 2)
      |> ExVrp.Model.add_client(x: 3, y: 3)
      |> ExVrp.Model.add_vehicle_type(num_available: 2)

    # Get client references
    [c1, c2, c3] = model.clients

    # Clients c1 and c2 must be on the same vehicle if visited
    model = ExVrp.Model.add_same_vehicle_group(model, [c1, c2], name: "group1")

# `t`

```elixir
@type t() :: %ExVrp.SameVehicleGroup{clients: [non_neg_integer()], name: String.t()}
```

# `add_client`

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

Adds a client to the group.

Raises `ArgumentError` if the client is already in the group.

# `clear`

```elixir
@spec clear(t()) :: t()
```

Clears all clients from the group.

# `empty?`

```elixir
@spec empty?(t()) :: boolean()
```

Returns true if the group has no clients.

# `new`

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

Creates a new same-vehicle group.

## Options

- `:clients` - List of client indices (default: `[]`)
- `:name` - Free-form name for the group (default: `""`)

# `size`

```elixir
@spec size(t()) :: non_neg_integer()
```

Returns the number of clients in the group.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
