Commit 137aed1d authored by Olivier Cots's avatar Olivier Cots
Browse files

Merge branch 'develop' into 'master'

Develop

See merge request !242
parents 1fdb3fa1 54617718
Pipeline #300546 passed with stage
in 4 minutes and 44 seconds
......@@ -29,3 +29,4 @@ bocopApp
bocopwrapper.py
!bocop/
*.sol
libbocop.dylib
......@@ -2,9 +2,6 @@
import os
import sys
#import pkg_resources
#sys.path.insert(0, os.path.abspath('../../src'))
# Use sphinx-quickstart to create your own conf.py file!
# After that, you have to edit a few things. See below.
......@@ -13,39 +10,19 @@ import sys
# ----------------------------------------------------------------------------------------
# Select nbsphinx and, if needed, other Sphinx extensions:
extensions = [
# 'matplotlib.sphinxext.plot_directive',
'sphinx.ext.autodoc', # for generation of api documentation
'sphinx.ext.napoleon', # numpy docstrings
'sphinx.ext.intersphinx', # to reference others projects, as numpy.ndarray
# 'sphinx.ext.doctest', # for the presentation of result in api documentation examples
'recommonmark', # for the use of markdown files for the documentation
'nbsphinx',
'nbsphinx_link', # A sphinx extension for including notebook files from outside the sphinx source root.
'sphinx_copybutton', # for "copy to clipboard" buttons
'sphinx.ext.mathjax', # for math equations
'nbsphinx_link', # A sphinx extension for including notebook files from outside the sphinx source root.
'sphinx_copybutton', # for "copy to clipboard" buttons
'sphinx.ext.mathjax', # for math equations
'sphinx.ext.viewcode',
'sphinxcontrib.bibtex', # for bibliographic references
# 'sphinxcontrib.rsvgconverter', # for SVG->PDF conversion in LaTeX output
'sphinx_gallery.load_style', # load CSS for gallery (needs SG >= 0.6)
'sphinxcontrib.bibtex', # for bibliographic references
'sphinx_gallery.load_style', # load CSS for gallery (needs SG >= 0.6)
]
## Napoleon settings
napoleon_google_docstring = False
napoleon_numpy_docstring = True
#napoleon_include_init_with_doc = False
#napoleon_include_private_with_doc = False
#napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = True
napoleon_use_ivar = True
napoleon_use_param = False
napoleon_use_rtype = False
#napoleon_use_keyword = True
# images for the gallery
nbsphinx_thumbnails = {
'irrigation/irrigation': 'irrigation/image.jpg',
'irrigation_and_rainfall/irrigation_and_rainfall': 'irrigation_and_rainfall/image.jpg',
'solarsail/solarsail-simple-version': 'solarsail/solarsail.jpeg',
'substrate/depletion': 'substrate/depletion.png',
'bacteria/bacteria': 'bacteria/maintenance.png',
......@@ -64,15 +41,6 @@ nbsphinx_thumbnails = {
'geometry2D/ellipsoid/ellipsoid': 'geometry2D/ellipsoid/ellipsoid.png',
}
#intersphinx_mapping = {
# 'python': ('https://docs.python.org/', None),
# 'numpy': ('http://docs.scipy.org/doc/numpy/', None)
#}
intersphinx_mapping = {'python': ('http://docs.python.org/', None),
'numpy': ('http://docs.scipy.org/doc/numpy', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference', None),
'matplotlib': ('http://matplotlib.sourceforge.net', None)}
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
......@@ -81,15 +49,6 @@ pygments_style = 'sphinx'
# Exclude build directory and Jupyter backup files:
exclude_patterns = ['_build', '**.ipynb_checkpoints', 'Thumbs.db', '.DS_Store']
# Default language for syntax highlighting in reST and Markdown cells:
highlight_language = 'none'
# Don't add .txt suffix to source files:
#html_sourcelink_suffix = ''
# Work-around until https://github.com/sphinx-doc/sphinx/issues/4229 is solved:
#html_scaled_image_link = False
# List of arguments to be passed to the kernel that executes the notebooks:
# If you use Matplotlib for plots, this setting is recommended:
nbsphinx_execute_arguments = [
......@@ -100,43 +59,10 @@ nbsphinx_execute_arguments = [
nbsphinx_execute = 'never'
# To get a prompt similar to the Classic Notebook, use
nbsphinx_input_prompt = ' In [%s]:'
nbsphinx_output_prompt = ' Out [%s]:'
#nbsphinx_input_prompt = ' In [%s]:'
#nbsphinx_output_prompt = ' Out [%s]:'
#nbsphinx_prompt_width = '10'
# Use a different kernel than stored in the notebook metadata, e.g.:
# nbsphinx_kernel_name = 'python3'
# Environment variables to be passed to the kernel:
#os.environ['MY_DUMMY_VARIABLE'] = 'Hello from conf.py!'
#nbsphinx_thumbnails = {
# 'gallery/thumbnail-from-conf-py': 'gallery/a-local-file.png',
# 'gallery/*-rst': '_static/copy-button.svg',
#}
# --------------------------------------------
# --------------------------------------------
# Debut : Cette partie ne fonctionne pas
# --------------------------------------------
# --------------------------------------------
## This is processed by Jinja2 and inserted before each notebook
#nbsphinx_prolog = """
#{% set docname = env.doc2path(env.docname, base=None) %}
#
#.. only:: html
#
# Mettre ici un lien vers binder, etc. Pour l'instant, je ne sais pas comment faire.
# Il faut peut-être que le projet soit public.
# On peut comme ici mettre un texte automatique pour tous les notebooks. Voir https://github.com/spatialaudio/nbsphinx/tree/0.6.0.
# On peut aussi mettre le lien binder dans le notebook directement.
#
#.. only:: latex
#
# The following section was created from :file:`{{ docname }}`.
#"""
# This is processed by Jinja2 and inserted before each notebook
nbsphinx_prolog = r"""
{% set docname = 'examples/' + env.doc2path(env.docname, base=None) %}
......@@ -148,7 +74,7 @@ nbsphinx_prolog = r"""
<a class="reference external" href="https://gitlab.inria.fr/ct/gallery-env/-/blob/master/{{ docname|e }}">{{ docname|e }}</a>
<br>Run the notebook yourself on binder
<a href="https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.inria.fr%2Fct%2Fgallery-env.git/master?urlpath=lab/tree/{{
docname|e }}"><img alt="Binder badge" src="https://static.mybinder.org/badge_logo.svg" style="vertical-align:text-bottom"></a>
docname|e }}"><img alt="Binder badge" src="https://static.mybinder.org/badge_logo.svg" style="vertical-align:text-bottom"></a>
</p>
</div>
......@@ -159,90 +85,15 @@ nbsphinx_prolog = r"""
\sphinxcode{\sphinxupquote{\strut {{ docname | escape_latex }}}} \dotfill}}
"""
# <script>
# if (document.location.host) {
# var p = document.currentScript.previousSibling.previousSibling;
# var a = document.createElement('a');
# a.innerHTML = 'View in <em>nbviewer</em>';
# a.href = `https://nbviewer.jupyter.org/url${
# (window.location.protocol == 'https:' ? 's/' : '/') +
# window.location.host +
# window.location.pathname.slice(0, -4) }ipynb`;
# a.classList.add('reference');
# a.classList.add('external');
# p.appendChild(a);
# p.appendChild(document.createTextNode('.'));
# }
# </script>
#nbsphinx_prolog = """
#----
#
#Generated by nbsphinx_ from a Jupyter_ notebook.
#
#.. _nbsphinx: https://nbsphinx.readthedocs.io/
#.. _Jupyter: https://jupyter.org/
#"""
#
#nbsphinx_prolog = """
#Go there: https://example.org/notebooks/{{ env.doc2path(env.docname, base=None) }}
#
#----
#"""
#
## This is processed by Jinja2 and inserted after each notebook
#nbsphinx_epilog = r"""
#{% set docname = 'doc/' + env.doc2path(env.docname, base=None) %}
#.. raw:: latex
# \nbsphinxstopnotebook{\scriptsize\noindent\strut
# \textcolor{gray}{\dotfill\ \sphinxcode{\sphinxupquote{\strut
# {{ docname | escape_latex }}}} ends here.}}
#"""
# --------------------------------------------
# --------------------------------------------
# Fin : Cette partie ne fonctionne pas
# --------------------------------------------
# --------------------------------------------
mathjax_config = {
'TeX': {'equationNumbers': {'autoNumber': 'AMS', 'useLabelIds': True}},
}
# Additional files needed for generating LaTeX/PDF output:
#latex_additional_files = ['references.bib']
# Support for notebook formats other than .ipynb
#nbsphinx_custom_formats = {
# '.pct.py': ['jupytext.reads', {'fmt': 'py:percent'}],
#}
# ----------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------
# -- The settings below this line are not specific to nbsphinx ------------
#
# where we stop the documentation: when coming to fortran files
#autodoc_mock_imports = ['nutopy.mod_nlesolve',
# 'nutopy.mod_ivpsolve',
# 'nutopy.mod_pathsolve',
# ]
# Default processing flags for sphinx
autoclass_content = 'class'
autodoc_member_order = 'bysource'
autodoc_default_options = {
'members': True,
'undoc-members':True,
'show-inheritance':True
}
#autodoc_member_order = 'alphabetical' #'bysource'
add_module_names = False
add_function_parentheses = False
# The suffix(es) of source filenames.
source_suffix = {
'.rst': 'restructuredtext',
......@@ -250,40 +101,49 @@ source_suffix = {
}
#---sphinx-themes-----
html_theme = 'sphinx_rtd_theme'
html_theme = 'pydata_sphinx_theme'
# options for sphinx_rtd_theme: see https://sphinx-rtd-theme.readthedocs.io/en/stable/configuring.html#
html_theme_options = {
'canonical_url': '',
# 'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard
'logo_only': False,
'display_version': False,
'prev_next_buttons_location': 'bottom',
'style_external_links': False,
# 'style_nav_header_background': 'white',
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False
"collapse_navigation": True,
"navigation_depth": 2,
"show_toc_level": 2,
"use_edit_page_button": True,
"external_links": [
{"url": "https://ct.gitlabpages.inria.fr/bocop3/", "name": "Bocop Docs"},
{"url": "https://ct.gitlabpages.inria.fr/nutopy/", "name": "Nutopy Docs"}
],
"gitlab_url": "https://gitlab.inria.fr/ct/gallery",
"navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
"navbar_end": ["search-field", "navbar-icon-links"], # Just for testing
"search_bar_text": "Search...",
#"page_sidebar_items": ["page-toc", "edit-this-page"],
#"footer_items": ["copyright", "sphinx-version", ""]
}
html_sidebars = {
"**": ["sidebar-nav-bs", "sidebar-ethical-ads"],
}
html_context = {
"gitlab_url": "https://gitlab.inria.fr", # or your self-hosted GitLab
"gitlab_user": "ct",
"gitlab_repo": "gallery",
"gitlab_version": "master",
"doc_path": "examples",
}
html_logo = 'logo-ct.svg'
author = 'Olivier Cots'
project = u'control toolbox gallery'
import time
copyright = u'%s, ct gallery project.' % time.strftime('%Y') # a changer
copyright = u'%s, ct gallery project' % time.strftime('%Y') # a changer
#version = '0.2' # a voir comment gerer doc et version
#release = '0.2.1'
html_logo = 'logo-ct.svg'
master_doc = 'index'
# Grab the setup entry
#distribution = pkg_resources.require(project)[0]
#linkcheck_ignore = [r'http://localhost:\d+/']
# -- Get version information and date from Git ----------------------------
......@@ -299,50 +159,4 @@ except Exception:
# -- Options for HTML output ----------------------------------------------
html_title = project #+ ' version ' + release
# -- Options for LaTeX output ---------------------------------------------
# See https://www.sphinx-doc.org/en/master/latex.html
#latex_elements = {
# 'papersize': 'a4paper',
# 'printindex': '',
# 'sphinxsetup': r"""
# %verbatimwithframe=false,
# %verbatimwrapslines=false,
# %verbatimhintsturnover=false,
# VerbatimColor={HTML}{F5F5F5},
# VerbatimBorderColor={HTML}{E0E0E0},
# noteBorderColor={HTML}{E0E0E0},
# noteborder=1.5pt,
# warningBorderColor={HTML}{E0E0E0},
# warningborder=1.5pt,
# warningBgColor={HTML}{FBFBFB},
# """,
# 'preamble': r"""
#\usepackage[sc,osf]{mathpazo}
#\linespread{1.05} % see http://www.tug.dk/FontCatalogue/urwpalladio/
#\renewcommand{\sfdefault}{pplj} % Palatino instead of sans serif
#\IfFileExists{zlmtt.sty}{
# \usepackage[light,scaled=1.05]{zlmtt} % light typewriter font from lmodern
#}{
# \renewcommand{\ttdefault}{lmtt} % typewriter font from lmodern
#}
#\usepackage{booktabs} % for Pandas dataframes
#""",
#}
#
#latex_documents = [
# (master_doc, 'nbsphinx.tex', project, author, 'howto'),
#]
#
#latex_show_urls = 'footnote'
#latex_show_pagerefs = True
# -- Options for EPUB output ----------------------------------------------
# These are just defined to avoid Sphinx warnings related to EPUB:
version = release
#suppress_warnings = ['epub.unknown_project_files']
html_title = "ct gallery" #+ ' version ' + release
**********
Dashboards
**********
Bacteria
========
.. image:: bacteria/bacteria-panel.jpeg
:width: 600
:alt: Bacteria
:align: center
:target: https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.inria.fr%2Fct%2Fgallery-env.git/master?urlpath=%2Fproxy%2F5006%2Fbacteria-panel
Swimmer
=======
.. image:: swimmer/swimmer.jpeg
:width: 600
:alt: Swimmer
:align: center
:target: https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.inria.fr%2Fct%2Fgallery-env.git/master?urlpath=%2Fproxy%2F5007%2Fswimmer
*********************
Welcome to ct gallery
#####################
*********************
Examples from the ct (control toolbox) project
using `bocop <https://ct.gitlabpages.inria.fr/bocop3>`_, `nutopy <https://ct.gitlabpages.inria.fr/nutopy>`_ and other packages.
Dashboards
**********
.. toctree::
:maxdepth: 2
.. image:: bacteria/bacteria-panel.jpeg
:height: 100
:target: https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.inria.fr%2Fct%2Fgallery-env.git/master?urlpath=%2Fproxy%2F5006%2Fbacteria-panel
.. image:: swimmer/swimmer.jpeg
:height: 100
:target: https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.inria.fr%2Fct%2Fgallery-env.git/master?urlpath=%2Fproxy%2F5007%2Fswimmer
Notebooks
*********
.. nbgallery::
:caption: Notebooks
:name: ocp-gallery
:glob:
:reversed:
sir/SIR
nlp_indirect/nlp2
nlp_indirect/nlp1
ihm/ihm
geometry2D/ellipsoid/ellipsoid
substrate/depletion
bacteria/bacteria
bistable/bistable
clr/clr
nav/nav-julia-N3
nav/nav
solarsail/solarsail-simple-version
kepler-c/kepler-c
kepler-py/kepler-py
kepler/kepler
regulator/regulator
goddard/goddard
smooth_case/smooth_case
shooting_tutorials/simple_shooting_general
dashboards
notebooks
This diff is collapsed.
// +++DRAFT+++ This class implements the OCP functions
// It derives from the generic class bocop3OCPBase
// OCP functions are defined with templates since they will be called
// from both the NLP solver (double arguments) and AD tool (ad_double arguments)
//#pragma once
#include <OCP.h>
// ///////////////////////////////////////////////////////////////////
template <typename Variable>
inline void OCP::finalCost(double initial_time, double final_time, const Variable *initial_state, const Variable *final_state, const Variable *parameters, const double *constants, Variable &final_cost)
{
final_cost = -final_state[1];
}
template <typename Variable>
inline void OCP::dynamics(double time, const Variable *state, const Variable *control, const Variable *parameters, const double *constants, Variable *state_dynamics)
{
double S_w = constants[0];
double S_etoile = constants[1];
double S_h = constants[2];
double Fmax = constants[4];
double k1 = constants [5];
double k2 = constants [6];
double k3 = constants [7];
double alpha = constants [8];
double n = constants [9];
Variable S = state[0];
Variable B = state[1];
Variable V = state[2];
Variable u = control[0];
Variable KS;
Variable KR;
Variable phi;
KS=(S-S_w)/(S_etoile-S_w);
KS= (1/n)*log(1+exp(n*KS));
KS=(1/-n)*log(exp(-n)+exp(-n*KS));
//KS= S;
//KS=(S-S_w)/(S_etoile-S_w);
//KS=fmin(1.0,fmax(0.0,KS));
KR=(S-S_h)/(1.0-S_h);
phi=pow(time/final_time,alpha);
//phi= time;
// HERE : description of the function for the dynamics
// Please give a function or a value for the dynamics of each state variable
state_dynamics[0] = k1*(-KS*phi-KR*(1-phi)+k2*u);
state_dynamics[1] = k3*KS*phi;
state_dynamics[2] = Fmax*u;
}
template <typename Variable>
inline void OCP::boundaryConditions(double initial_time, double final_time, const Variable *initial_state, const Variable *final_state, const Variable *parameters, const double *constants, Variable *boundary_conditions)
{
double Q = constants[3];
boundary_conditions[0] = initial_state[0];
boundary_conditions[1] = initial_state[1];
boundary_conditions[2] = initial_state[2];
boundary_conditions[3] = Q-final_state[2];
}
template <typename Variable>
inline void OCP::pathConstraints(double time, const Variable *state, const Variable *control, const Variable *parameters, const double *constants, Variable *path_constraints)
{
}
void OCP::preProcessing()
{}
// ///////////////////////////////////////////////////////////////////
// explicit template instanciation for template functions, with double and double_ad
// +++ could be in an included separate file ?
// but needs to be done for aux functions too ? APPARENTLY NOT !
template void OCP::finalCost<double>(double initial_time, double final_time, const double *initial_state, const double *final_state, const double *parameters, const double *constants, double &final_cost);
template void OCP::dynamics<double>(double time, const double *state, const double *control, const double *parameters, const double *constants, double *state_dynamics);
template void OCP::boundaryConditions<double>(double initial_time, double final_time, const double *initial_state, const double *final_state, const double *parameters, const double *constants, double *boundary_conditions);
template void OCP::pathConstraints<double>(double time, const double *state, const double *control, const double *parameters, const double *constants, double *path_constraints);
template void OCP::finalCost<double_ad>(double initial_time, double final_time, const double_ad *initial_state, const double_ad *final_state, const double_ad *parameters, const double *constants, double_ad &final_cost);
template void OCP::dynamics<double_ad>(double time, const double_ad *state, const double_ad *control, const double_ad *parameters, const double *constants, double_ad *state_dynamics);
template void OCP::boundaryConditions<double_ad>(double initial_time, double final_time, const double_ad *initial_state, const double_ad *final_state, const double_ad *parameters, const double *constants, double_ad *boundary_conditions);
template void OCP::pathConstraints<double_ad>(double time, const double_ad *state, const double_ad *control, const double_ad *parameters, const double *constants, double_ad *path_constraints);
# Definition file
# Dimensions
dim.state 3
dim.control 1
dim.boundaryconditions 4
dim.pathconstraints 0
dim.parameters 0
dim.constants 10
# Time interval
initial.time 0
final.time 1
# Constants
constant.0 0.4
constant.1 0.7
constant.2 0.2
constant.3 0.05
constant.4 1.2
constant.5 3
constant.6 5
constant.7 1
constant.8 1
constant.9 350
# Time discretisation
ode.discretization midpoint_implicit
time.steps 500
# Bounds for constraints (initial conditions for our case)
boundarycond.0.lowerbound 1
boundarycond.0.upperbound 1
boundarycond.1.lowerbound 0.001
boundarycond.1.upperbound 0.001
boundarycond.2.lowerbound 0
boundarycond.2.upperbound 0
boundarycond.3.lowerbound 0
boundarycond.3.upperbound 0
# Bounds for variables (dynamical bound for each variable and control)
state.0.lowerbound 0
state.0.upperbound 1
state.1.lowerbound 0
control.0.lowerbound 0
control.0.upperbound 1
# Initialization for discretized problem (initial point for the optimization algorithm.. this we can touch only if the algorithm is not working, otherwise we can leave it like this)
state.0.init 1
state.1.init 0.001
state.2.init 0
state.3.init 0
control.0.init 0.5
# Ipopt
ipoptIntOption.print_level 5
ipoptIntOption.max_iter 1000
ipoptStrOption.mu_strategy adaptive
ipoptNumOption.tol 1e-12
# Misc
ad.retape 0
Stages M1 - Montpellier
Répertoire contenant les notebooks concernant les problèmes d'irrigation.
// +++DRAFT+++ This class implements the OCP functions
// It derives from the generic class bocop3OCPBase
// OCP functions are defined with templates since they will be called
// from both the NLP solver (double arguments) and AD tool (ad_double arguments)
//#pragma once
#include <OCP.h>
// ///////////////////////////////////////////////////////////////////
template <typename Variable>
inline void OCP::finalCost(double initial_time, double final_time, const Variable *initial_state, const Variable *final_state, const Variable *parameters, const double *constants, Variable &final_cost)