# Function1D

Function of one argument.

| JSON representation |
|---|
| ``` { // Union field `function` can be only one of the following: "constant": number, "pwl": { object (`https://developers.google.com/optimization/middlemileoptimization/reference/rest/v1/Function1D#PieceWiseAffineFunction`) } // End of list of possible types for union field `function`. } ``` |

| Fields ||
|---|---|
| Union field `function`. The unity of the argument of the function is supposed to be: - if a weight: kg - if a time: min - if a number of pallets: 1 `function` can be only one of the following: ||
| `constant` | `number` The function is a constant. |
| `pwl` | ``object (`https://developers.google.com/optimization/middlemileoptimization/reference/rest/v1/Function1D#PieceWiseAffineFunction`)`` The function is piecewise linear. |

## PieceWiseAffineFunction

Piecewise-linear function, limited to one argument. Design similar to <https://github.com/google/or-tools/blob/stable/ortools/util/piecewise_linear_function.h>

| JSON representation |
|---|
| ``` { "segments": [ { object (`https://developers.google.com/optimization/middlemileoptimization/reference/rest/v1/Function1D#PieceWiseAffineSegment`) } ] } ``` |

| Fields ||
|---|---|
| `segments[]` | ``object (`https://developers.google.com/optimization/middlemileoptimization/reference/rest/v1/Function1D#PieceWiseAffineSegment`)`` Linear segments of the function. |

## PieceWiseAffineSegment

One segment of a piecewise-linear function.

| JSON representation |
|---|
| ``` { "startX": number, "startY": number, "endX": number, "endY": number } ``` |

| Fields ||
|---|---|
| `startX` | `number` Beginning of the segment: x. |
| `startY` | `number` Beginning of the segment: y. |
| `endX` | `number` End of the segment: x. |
| `endY` | `number` End of the segment: y. |