:orphan:
.. _examples:
Examples
========
This section provides several examples of how to use **csnlp**. It ranges from the
basic, e.g., how to build an NLP with :class:`csnlp.Nlp`, to more advanced examples that
showcase, e.g., how to use the :mod:`csnlp.multistart` submodule.
.. _introductory_examples:
Introductory examples
---------------------
General-purpose and introductory examples for :mod:`csnlp`.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /auto_examples/images/thumb/sphx_glr_chain_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_chain.py`
.. raw:: html
A simple optimization problem: hanging chain
.. raw:: html
.. only:: html
.. image:: /auto_examples/images/thumb/sphx_glr_rosenbrock_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_rosenbrock.py`
.. raw:: html
A simple optimization problem: Rosenbrock function
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/auto_examples/chain
/auto_examples/rosenbrock
Integer Programming examples
--------------------------------
Here we show how to specify discrete and binary domains for variables.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /auto_examples/integer-programming/images/thumb/sphx_glr_milp_and_miqp_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_integer-programming_milp_and_miqp.py`
.. raw:: html
A mixed integer linear programming example
.. thumbnail-parent-div-close
.. raw:: html
Multistart Optimization examples
--------------------------------
The following examples demonstrate the use of :mod:`csnlp.multistart` to combat local
convergence.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /auto_examples/multistart/images/thumb/sphx_glr_nlp_with_multistart_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_multistart_nlp_with_multistart.py`
.. raw:: html
A simple problem with multiple minima
.. thumbnail-parent-div-close
.. raw:: html
Optimal control examples
------------------------
These examples detail how to use :mod:`csnlp` to create and solve optimal control
problems with :class:`csnlp.wrappers.Mpc`, :class:`csnlp.wrappers.ScenarioBasedMpc`, and
other similar wrapper classes.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /auto_examples/optimal_control/images/thumb/sphx_glr_open_loop_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_optimal_control_open_loop.py`
.. raw:: html
Simple open-loop MPC controller
.. raw:: html
.. only:: html
.. image:: /auto_examples/optimal_control/images/thumb/sphx_glr_linear_mpc_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_optimal_control_linear_mpc.py`
.. raw:: html
Linear MPC control
.. raw:: html
.. only:: html
.. image:: /auto_examples/optimal_control/images/thumb/sphx_glr_mpc_multiple_scenarios_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_optimal_control_mpc_multiple_scenarios.py`
.. raw:: html
Multiple Scenario MPC
.. raw:: html
.. only:: html
.. image:: /auto_examples/optimal_control/images/thumb/sphx_glr_scenario_approach_for_mpc_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_optimal_control_scenario_approach_for_mpc.py`
.. raw:: html
Scenario-based MPC
.. raw:: html
.. only:: html
.. image:: /auto_examples/optimal_control/images/thumb/sphx_glr_mpc_for_pwa_system_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_optimal_control_mpc_for_pwa_system.py`
.. raw:: html
MPC controller for PWA systems
.. thumbnail-parent-div-close
.. raw:: html
Scaling examples
----------------
Examples demonstrating the scaling capabilities of :class:`csnlp.wrappers.NlpScaling`.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /auto_examples/scaling/images/thumb/sphx_glr_nlp_scaling_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_scaling_nlp_scaling.py`
.. raw:: html
How scaling can help convergence
.. thumbnail-parent-div-close
.. raw:: html
Sensitivity examples
--------------------
Examples on sensitivity computations via :class:`csnlp.wrappers.NlpSensitivity`.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /auto_examples/sensitivity/images/thumb/sphx_glr_simple_sensitivity_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_sensitivity_simple_sensitivity.py`
.. raw:: html
A simple example of sensitivity analysis
.. raw:: html
.. only:: html
.. image:: /auto_examples/sensitivity/images/thumb/sphx_glr_simple_sensitivity_3d_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_sensitivity_simple_sensitivity_3d.py`
.. raw:: html
A simple example of sensitivity analysis (3d version)
.. raw:: html
.. only:: html
.. image:: /auto_examples/sensitivity/images/thumb/sphx_glr_comparison_sensitivities_thumb.png
:alt:
:ref:`sphx_glr_auto_examples_sensitivity_comparison_sensitivities.py`
.. raw:: html
Comparison of CasADi's and csnlp's sensitivity computations
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
:includehidden:
/auto_examples/integer-programming/index.rst
/auto_examples/multistart/index.rst
/auto_examples/optimal_control/index.rst
/auto_examples/scaling/index.rst
/auto_examples/sensitivity/index.rst
.. only:: html
.. container:: sphx-glr-footer sphx-glr-footer-gallery
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download all examples in Python source code: auto_examples_python.zip `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_