# Compartment

> Modelling areas of a vehicle which have additional side constraints.

Page: https://docs.icepack.ai/ivr/compartment/

## Overview
Compartment modelling is typically used when large vehicles may have their carrying capacity broken up into areas, or compartments. We are interested in modelling the constraints that exist over collections of compartments. There may also be constraints between tasks as to which compartments they may be assigned to or the maximum holding capacity of a single compartment. Typical use cases for compartments include modelling upper and lower "decks" in a vehicle (where some products may not be placed on the upper deck), fuel compartments in a trailer where certain products may only be assigned to certain areas (such as petrol, diesel or paraffin). In addition, it would be typical in fuel modelling to include axel load constraints across compartments to ensure that the vehicle is stable across all transits on a particular route. This would form part of a [compartment set](/ivr/compartment-set/) constraint.


### Applicable models
* IVR8 `ivr8-yni1c9k2swof`

<hr>

## Compartment
A compartment is the most granular unit available for modelling a portion of a vehicle's carriage. A [task](/ivr/task/) is required to be assigned to a compartment if the dimensions of the task (i.e. the quantities specified in the attributes of a task) fall within the _remaining_ compartment dimensions at that point in a particular route. This means that two tasks may be assigned to the same compartment if the sum of their dimensional quantities is within the capacity limits specified by the compartment. 

As tasks cannot be "split", if no compartment exists which is larger than the largest dimensional quantity on a particular task, then the task is considered trivially infeasible.

### Schema definition 

```protobuf
message Compartment {
  required string id = 1;
  repeated Capacity capacities = 2;
}
```



### Fields

id
: The unique identifier for this compartment definition. If there are duplicate compartment definitions in the [model](/ivr/model/), the payload will be rejected.

capacities
: A list of [dimension](/ivr/dimension/) constraints which indicate the maximum cumulative [task](/ivr/task/) quantity that may be assigned to this compartment in the course of a route.


### Examples
This sample defines a compartment labelled `c1` which has a maximum capacity of 1 tonne (the weight dimension is measured in kilograms).
```protobuf
id: "c1"
capacities {
  dimensionId: "weight"
  capacity: 1000
}
```



<hr> 

## Compartment Capacity
A compartment capacity defines the dimensional constraint for a particular compartment. No collection of tasks may be assigned to the compartment where the cumulative sum of dimensional quantities at any point on a route exceeds the dimensional limit specified.

### Schema definition 

```protobuf
message Capacity {
  required string dimensionId = 1;
  required float capacity = 2;
}
```



### Fields

dimensionId
: The [dimension](/ivr/dimension/) to which this compartment capacity should be applied.

capacity
: The maximum capacity of the [dimension](/ivr/dimension/) specified.

### Examples
This example has two dimensions defined, a `weight` dimension, measured in kg's and a `height` dimension measured in centimeters.
```protobuf
capacities {
  dimensionId: "weight"
  capacity: 750
}
capacities {
  dimensionId: "height"
  capacity: 100
}
```


The restrictions on this compartment are that the tasks assigned to this compartment may not exceed 750kg or a stacking height of 100cm.

<hr>

