# scaling¶

Class attribute.

Optimizer.scaling

Query and set scaling of the optimization variables. The Optimizer.scaling() method is an indexed property, meaning getting and setting this property requires an index and calls this function. The power index (elements are seperated by comas) must contain atleast the following elements:

order index name valid options
1 variable type _x, _u and _z (and _p_est for MHE)
2 variable name Names defined in do_mpc.model.Model.

Further indices are possible (but not neccessary) when the referenced variable is a vector or matrix.

Example:

# Set with:
optimizer.scaling['_x', 'phi_1'] = 2
optimizer.scaling['_x', 'phi_2'] = 2

# Query with:
optimizer.scaling['_x', 'phi_1']


Scaling factors $$a$$ affect the MHE / MPC optimization problem. The optimization variables are scaled variables:

$\bar\phi = \frac{\phi}{a_{\phi}} \quad \forall \phi \in [x, u, z, p_{\text{est}}]$

Scaled variables are used to formulate the bounds $$\bar\phi_{lb} \leq \bar\phi_{ub}$$ and for the evaluation of the ODE. For the objective function and the nonlinear constraints the unscaled variables are used. The algebraic equations are also not scaled.

Note

Scaling the optimization problem is suggested when states and / or inputs take on values which differ by orders of magnitude.