csnlp.wrappers.NlpScaling#
- class csnlp.wrappers.NlpScaling(nlp, scaler, warns=True)[source]#
Bases:
NonRetroactiveWrapper[SymType]Wraps an instance of
csnlp.Nlpto facilitate the scaling of its parameters and/or variables as well as the automatic scaling of expressions (e.g., objective and constraints).- Parameters:
- nlpNlp[T]
The NLP problem to be wrapped.
- scalerScaler
A class for scaling the NLP’s quantities. See
csnlp.core.scalingfor a collection of these.- warnsbool, optional
If
True, warns each time a variable or parameter is created which has not been registered to the scaler and thus cannot be scaled; otherwise, it will not raise warnings.
Methods
constraint(name, lhs, op, rhs[, soft, simplify])See
csnlp.Nlp.constraint.is_wrapped(wrapper_type)Gets whether the NLP instance is wrapped or not by the given wrapper type.
minimize(objective)See
csnlp.Nlp.minimize.parameter(name[, shape])See
csnlp.Nlp.parameter.scale(expr)Scales an expression with the MPC's scaled variables and parameters.
solve([pars, vals0])See
csnlp.Nlp.solve.solve_multi([pars, vals0, return_all_sols, ...])See
csnlp.MultistartNlp.solve_multi.unscale(expr)Unscales an expression with the MPC's unscaled variables and parameters.
variable(name[, shape, discrete, lb, ub])See
csnlp.Nlp.variable.Attributes
Gets the scaled parameters of the NLP scheme.
Gets the scaled variables of the NLP scheme.
Gets the unscaled parameters of the NLP scheme.
Gets the unscaled variables of the NLP scheme.
'Returns the original NLP of the wrapper.
- constraint(name, lhs, op, rhs, soft=False, simplify=True)[source]#
See
csnlp.Nlp.constraint.
- is_wrapped(wrapper_type)#
Gets whether the NLP instance is wrapped or not by the given wrapper type.
- Parameters:
- wrapper_typetype of Wrapper
Type of wrapper to check if the NLP is wrapped with.
- Returns:
- bool
Trueif wrapped by an instance ofwrapper_type;False, otherwise.
- Return type:
- minimize(objective)[source]#
See
csnlp.Nlp.minimize.- Return type:
- parameter(name, shape=(1, 1))[source]#
See
csnlp.Nlp.parameter.- Return type:
TypeVar(SymType,SX,MX)
- scale(expr)[source]#
Scales an expression with the MPC’s scaled variables and parameters.
- Parameters:
- exprcasadi.SX or MX
The expression to be scaled.
- Returns:
- casadi.SX or MX
The scaled expression.
- Return type:
TypeVar(SymType,SX,MX)
- solve(pars=None, vals0=None)[source]#
See
csnlp.Nlp.solve.
- solve_multi(pars=None, vals0=None, return_all_sols=False, return_stacked_sol=False)[source]#
See
csnlp.MultistartNlp.solve_multi.