csnlp.wrappers.Wrapper#

class csnlp.wrappers.Wrapper(nlp)[source]#

Bases: Generic[SymType]

Wraps an instance of csnlp.Nlp to allow a modular transformation of its methods. This class is the base class for all wrappers. The subclass can then override some methods to change the behavior of the original environment without touching the original code.

The base class is retroactive, in the sense that it can be applied to any NLP instance that already defines variables, parameters, and/or objective. Use NonRetroactiveWrapper for wrappers that need to wrap an NLP before it is defined.

Parameters:
nlpNlp or subclass

The NLP to wrap.

Methods

is_wrapped(wrapper_type)

Gets whether the NLP instance is wrapped or not by the given wrapper type.

Attributes

unwrapped

'Returns the original NLP of the wrapper.

is_wrapped(wrapper_type)[source]#

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

True if wrapped by an instance of wrapper_type; False, otherwise.

Return type:

bool

property unwrapped: Nlp[SymType]#

‘Returns the original NLP of the wrapper.

Examples using csnlp.wrappers.Wrapper#

Linear MPC control

Linear MPC control

MPC controller for PWA systems

MPC controller for PWA systems

Multiple Scenario MPC

Multiple Scenario MPC

Simple open-loop MPC controller

Simple open-loop MPC controller

Scenario-based MPC

Scenario-based MPC

How scaling can help convergence

How scaling can help convergence

Comparison of CasADi’s and csnlp’s sensitivity computations

Comparison of CasADi's and csnlp's sensitivity computations

A simple example of sensitivity analysis

A simple example of sensitivity analysis

A simple example of sensitivity analysis (3d version)

A simple example of sensitivity analysis (3d version)