# Class: CumulExpr

Cumulative expression.

Cumulative expression represents a resource usage over time. The resource could be a machine, a group of workers, a material, anything of a limited capacity. The resource usage is not known in advance as it depends on the variables of the problem. Cumulative expressions allow to model the resource usage and constrain it.

Basic cumulative expressions are:

: the resource is used over an interval of time. For example, pulse can be used to represent a task that requires certain number of workers during its execution. At the beginning of the interval the resource usage increases by a given amount and at the end of the interval the resource usage decreases by the same amount. Pulse can be created by function Model.pulse or IntervalVar.pulse .*Pulse*: given amount of resource is consumed or produced at a specified time (e.g. at a start of an interval variable). Steps can be used to represent an inventory of a material that is consumed or produced by some tasks (a*Step**reservoir*). Steps can be created by functions Model.stepAtStart, IntervalVar.stepAtStart, Model.stepAtEnd, IntervalVar.stepAtEnd. and Model.stepAt.

Cumulative expressions can be combined together using cumulPlus, cumulMinus, cumulNeg and cumulSum. The resulting cumulative expression represents a sum of the resource usage of the combined expressions.

Cumulative expressions can be constrained by cumulGe and cumulLe constraints to specify the minimum and maximum allowed resource usage.

See cumulLe and cumulGe for examples.

## Hierarchy

↳

`CumulExpr`

## Methods

### cumulGe

▸ **cumulGe**(`minCapacity`

): `void`

Constraints the cumulative function to be everywhere greater or equal to `minCapacity`

.

This function can be used to specify the minimum limit of resource usage at any time. For example to make sure that there is never less than zero material on stock.
See stepAtStart for an example with `cumulGe`

.

#### Parameters

Name | Type |
---|---|

`minCapacity` | `number` |

#### Returns

`void`

`See`

- Model.cumulGe for the equivalent function on Model.
- cumulLe for the opposite constraint.

### cumulLe

▸ **cumulLe**(`maxCapacity`

): `void`

Constraints the cumulative function to be everywhere less or equal to `maxCapacity`

.

This function can be used to specify the maximum limit of resource usage at any time. For example to limit number of workers working simultaneously, limit the maximum amount of material on stock etc.
See pulse for an example with `cumulLe`

.

#### Parameters

Name | Type |
---|---|

`maxCapacity` | `number` |

#### Returns

`void`

`See`

- Model.cumulLe for the equivalent function on Model.
- cumulGe for the opposite constraint.

### cumulMinus

▸ **cumulMinus**(`rhs`

): `CumulExpr`

Subtraction of two cumulative expressions.

#### Parameters

Name | Type |
---|---|

`rhs` | `CumulExpr` |

#### Returns

`Remarks`

This function is the same as Model.minus.

### cumulNeg

▸ **cumulNeg**(): `CumulExpr`

Negation of a cumulative expression.

#### Returns

`Remarks`

This function is the same as Model.neg.

### cumulPlus

▸ **cumulPlus**(`rhs`

): `CumulExpr`

Addition of two cumulative expressions.

#### Parameters

Name | Type |
---|---|

`rhs` | `CumulExpr` |

#### Returns

`Remarks`

This function is the same as Model.plus.

### getName

▸ **getName**(): `undefined`

| `string`

Returns the name assigned to the node.

#### Returns

`undefined`

| `string`

#### Inherited from

### setName

▸ **setName**(`name`

): `CumulExpr`

Assigns a name to the node.

#### Parameters

Name | Type | Description |
---|---|---|

`name` | `string` | Named to be assigned. |

#### Returns

The node itself so it can be used in chained expression.

`Remarks`

Assigning a name is optional. However is useful for debugging because variable names appear in the development traces. It is also useful for exporting the model to a file (see model2json).

`Example`

`let model = new CP.Model();`

let x = model.intervalVar({ length: 10 }).setName("x");

// The line above is equivalent to:

// let x = model.intervalVar({ length: 10, name:"x" });

let endOfX = model.endOf(x).setName("endOfX");

let result = await CP.solve(model);