Examples#

This section provides several examples of how to use csnlp. It ranges from the basic, e.g., how to build an NLP with csnlp.Nlp, to more advanced examples that showcase, e.g., how to use the csnlp.multistart submodule.

Introductory examples#

General-purpose and introductory examples for csnlp.

A simple optimization problem: hanging chain

A simple optimization problem: hanging chain

A simple optimization problem: Rosenbrock function

A simple optimization problem: Rosenbrock function

Integer Programming examples#

Here we show how to specify discrete and binary domains for variables.

A mixed integer linear programming example

A mixed integer linear programming example

Multistart Optimization examples#

The following examples demonstrate the use of csnlp.multistart to combat local convergence.

A simple problem with multiple minima

A simple problem with multiple minima

Optimal control examples#

These examples detail how to use csnlp to create and solve optimal control problems with csnlp.wrappers.Mpc, csnlp.wrappers.ScenarioBasedMpc, and other similar wrapper classes.

Simple open-loop MPC controller

Simple open-loop MPC controller

Linear MPC control

Linear MPC control

Multiple Scenario MPC

Multiple Scenario MPC

Scenario-based MPC

Scenario-based MPC

MPC controller for PWA systems

MPC controller for PWA systems

Scaling examples#

Examples demonstrating the scaling capabilities of csnlp.wrappers.NlpScaling.

How scaling can help convergence

How scaling can help convergence

Sensitivity examples#

Examples on sensitivity computations via csnlp.wrappers.NlpSensitivity.

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)

Comparison of CasADi’s and csnlp’s sensitivity computations

Comparison of CasADi's and csnlp's sensitivity computations

Gallery generated by Sphinx-Gallery