Optimization

The linear optimization service, used to model and solve linear and mixed-integer linear
programs.

## Classes

| Name | Brief description |
|---|---|
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-constraint` | Object storing a linear constraint of the form `lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound` where `lowerBound` and `upperBound` are constants, `a(i)` are constant coefficients and `x(i)` are variables (unknowns). |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | The engine used to model and solve a linear program. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-service` | The linear optimization service, used to model and solve linear and mixed-integer linear programs. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-solution` | The solution of a linear program. |
| `https://developers.google.com/apps-script/reference/optimization/status` | Status of the solution. |
| `https://developers.google.com/apps-script/reference/optimization/variable-type` | Type of variables created by the engine. |

## `https://developers.google.com/apps-script/reference/optimization/linear-optimization-constraint`

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-constraint#setCoefficient(String,Number)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-constraint` | Sets the coefficient of a variable in the constraint. |

## `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine`

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#addConstraint(Number,Number)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-constraint` | Adds a new linear constraint in the model. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#addConstraints(Number,Number,String,Number)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Adds constraints in batch to the model. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#addVariable(String,Number,Number)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Adds a new continuous variable to the model. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#addVariable(String,Number,Number,VariableType)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Adds a new variable to the model. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#addVariable(String,Number,Number,VariableType,Number)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Adds a new variable to the model. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#addVariables(String,Number,Number,VariableType,Number)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Adds variables in batch to the model. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#setMaximization()` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Sets the optimization direction to maximizing the linear objective function. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#setMinimization()` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Sets the optimization direction to minimizing the linear objective function. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#setObjectiveCoefficient(String,Number)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Sets the coefficient of a variable in the linear objective function. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#solve()` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-solution` | Solves the current linear program with the default deadline of 30 seconds. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#solve(Number)` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-solution` | Solves the current linear program. |

## `https://developers.google.com/apps-script/reference/optimization/linear-optimization-service`

### Properties

| Property | Type | Description |
|---|---|---|
| `Status` | `https://developers.google.com/apps-script/reference/optimization/status` | Status of the solver. |
| `VariableType` | `https://developers.google.com/apps-script/reference/optimization/variable-type` | Type of variables created by the solver. |

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-service#createEngine()` | `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine` | Creates an engine to to solve linear programs (potentially mixed-integer programs). |

## `https://developers.google.com/apps-script/reference/optimization/linear-optimization-solution`

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-solution#getObjectiveValue()` | `Number` | Gets the value of the objective function in the current solution. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-solution#getStatus()` | `https://developers.google.com/apps-script/reference/optimization/status` | Gets the status of the solution. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-solution#getVariableValue(String)` | `Number` | Gets the value of a variable in the solution created by the last call to `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#solve()`. |
| `https://developers.google.com/apps-script/reference/optimization/linear-optimization-solution#isValid()` | `Boolean` | Determines whether the solution is either feasible or optimal. |

## `https://developers.google.com/apps-script/reference/optimization/status`

### Properties

| Property | Type | Description |
|---|---|---|
| `OPTIMAL` | `Enum` | Status when an optimal solution has been found. |
| `FEASIBLE` | `Enum` | Status when a feasible (not necessarily optimal) solution has been found. |
| `INFEASIBLE` | `Enum` | Status when the current model is unfeasible (has no solution). |
| `UNBOUNDED` | `Enum` | Status when the current model is unbound. |
| `ABNORMAL` | `Enum` | Status when it failed to find a solution for unexpected reasons. |
| `MODEL_INVALID` | `Enum` | Status when the model is invalid. |
| `NOT_SOLVED` | `Enum` | Status when `https://developers.google.com/apps-script/reference/optimization/linear-optimization-engine#solve()` has not been called yet. |

## `https://developers.google.com/apps-script/reference/optimization/variable-type`

### Properties

| Property | Type | Description |
|---|---|---|
| `INTEGER` | `Enum` | Type of variable that can only take integer values. |
| `CONTINUOUS` | `Enum` | Type of variable that can take any real value. |