diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5ee0dacd00629b7897db60ba96e1e8a9221c5a58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ + +# Created by https://www.gitignore.io/api/jupyternotebooks +# Edit at https://www.gitignore.io/?templates=jupyternotebooks + +### JupyterNotebooks ### +# gitignore template for Jupyter Notebooks +# website: http://jupyter.org/ + +.ipynb_checkpoints +*/.ipynb_checkpoints/* +*.so +*.so.dSYM +*.so.dSYM/* +.nfs* +*__pycache__* + +# IPython +profile_default/ +ipython_config.py + +# Remove previous ipynb_checkpoints +# git rm -r .ipynb_checkpoints/ + +# End of https://www.gitignore.io/api/jupyternotebooks + +# bocop files (build and exec) +build/ +bocopApp +bocopwrapper.py +!bocop/ +*.sol + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..7ae21240e522a6c468e76c80f7a879d4474322f5 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,18 @@ +image: intelpython/intelpython3_full:latest + +pages: + stage: deploy + before_script: + - conda install -c conda-forge pandoc + script: + - python --version + - python -m pip install -r requirements.txt + - pip list + - conda list + - python -m sphinx -b html examples/ public + artifacts: + paths: + - public + only: + - master + diff --git a/README.md b/README.md index 534f83d3d24bb6d24ebce3ef1f261e2d35617f20..cd7d75124e7c201a22db9add99f780a728d1926e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ * [Introduction to the multiple shooting method](doc/exercices/bsb_turnpike_regularized.ipynb) -[FAQ](https://optimalcontrol.zulip.beta.cimpa-lms.info/#narrow/stream/284-geometric_methods1) +[FAQ](https://optimalcontrol.zulip.beta.cimpa-lms.info/#narrow/stream/285-geometric_methods2) # References diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 index 0000000000000000000000000000000000000000..15af6c188e0f14c597ddb23d4cb858119eda6874 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,332 @@ +#!/usr/bin/env python3 + +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. + +# ---------------------------------------------------------------------------------------- +# ---------------------------------------------------------------------------------------- +# 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 + '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) +] + +## 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 = { +# 'bacteria/bacteria': 'bacteria/maintenance.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' + +# ---------------------------------------------------------------------------------------- +# ---------------------------------------------------------------------------------------- +# 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 = [ + "--InlineBackend.figure_formats={'svg', 'pdf'}", + "--InlineBackend.rc={'figure.dpi': 96}", +] + +nbsphinx_execute = 'never' + +# To get a prompt similar to the Classic Notebook, use +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) %} + +.. raw:: html + + <div class="admonition note"> + <p>Notebook source code: + <a class="reference external" href="https://gitlab.irit.fr/toc/cimpa/gnmoc/-/blob/master/{{ docname|e }}">{{ docname|e }}</a> + <br>Run it yourself on binder + <a href="https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.irit.fr%2Ftoc%2F%2Fcimpa%2Fgnmoc.git/master?urlpath=lab/tree/{{ docname|e }}"><img alt="Binder badge" src="https://mybinder.org/badge_logo.svg" style="vertical-align:text-bottom"></a> + </p> + </div> + +.. raw:: latex + + \nbsphinxstartnotebook{\scriptsize\noindent\strut + \textcolor{gray}{The following section was generated from + \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', + '.md': 'markdown' +} + +#---sphinx-themes----- +html_theme = 'sphinx_rtd_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 +} + +author = 'Olivier Cots' +project = u'Cimpa course' +import time +copyright = u'%s, cimpa course 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 ---------------------------- + +try: + from subprocess import check_output + release = check_output(['git', 'describe', '--tags', '--always']) + release = release.decode().strip() + today = check_output(['git', 'show', '-s', '--format=%ad', '--date=short']) + today = today.decode().strip() +except Exception: + release = '<unknown>' + today = '<unknown date>' + +# -- 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'] + + diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..72a33558153fb57def85612b021ec596ef2a51b9 --- /dev/null +++ b/doc/index.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/doc/logo-ct.svg b/doc/logo-ct.svg new file mode 100644 index 0000000000000000000000000000000000000000..68fdf499328aa77317686c59d057198e67803f45 --- /dev/null +++ b/doc/logo-ct.svg @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + inkscape:version="1.0 (4035a4f, 2020-05-01)" + sodipodi:docname="ct.svg" + xml:space="preserve" + enable-background="new 0 0 134 140" + viewBox="0 0 134 140" + height="140px" + width="134px" + y="0px" + x="0px" + id="Calque_1" + version="1.1"><metadata + id="metadata19"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs17" /><sodipodi:namedview + inkscape:current-layer="Calque_1" + inkscape:window-maximized="0" + inkscape:window-y="23" + inkscape:window-x="0" + inkscape:cy="70" + inkscape:cx="67" + inkscape:zoom="6.3642857" + showgrid="false" + id="namedview15" + inkscape:window-height="973" + inkscape:window-width="1007" + inkscape:pageshadow="2" + inkscape:pageopacity="0" + guidetolerance="10" + gridtolerance="10" + objecttolerance="10" + borderopacity="1" + bordercolor="#666666" + pagecolor="#ffffff" /> +<g + id="g12"> + <path + id="path10" + d="m 99.274,69.221 c -0.345,7.912 -0.517,16.167 -0.517,24.08 V 110.5 c 0,12.9 5.849,15.137 8.944,15.137 3.956,0 8.944,-0.688 11.352,-2.236 0.86,-0.516 1.548,-0.344 2.064,0.344 l 0.86,1.548 c 0.516,0.688 0.172,1.376 -0.345,1.892 -1.72,1.721 -8.771,6.881 -19.092,6.881 -8.428,0 -16.684,-8.084 -16.684,-14.62 0,-7.052 0.517,-22.188 0.517,-24.596 v -3.784 c 0,-3.096 0.172,-14.619 0.344,-21.843 h -10.49 c -1.548,0 -2.58,-0.688 -2.58,-2.064 0,-1.376 1.032,-1.892 3.268,-2.752 4.301,-1.892 9.633,-5.16 12.041,-10.492 C 91.019,49.271 91.88,40.671 89.987,34.479 87.407,26.223 81.903,17.452 65.736,17.452 50.771,17.45 38.56,27.77 38.56,39.81 c 0,6.708 1.376,12.384 8.943,18.576 13.588,1.72 18.06,10.492 18.06,13.76 -0.172,3.957 -2.752,6.02 -6.364,6.02 -3.956,0 -6.88,-2.236 -9.46,-6.88 -3.784,-7.052 -7.396,-7.568 -11.524,-7.568 -9.804,0 -20.295,8.944 -20.295,26.66 0,9.287 4.128,19.779 8.771,26.144 5.676,7.396 12.9,8.771 18.748,8.771 8.6,0 13.071,-1.892 18.919,-7.396 0.344,-0.344 0.86,-0.516 1.376,0 l 1.72,1.72 c 0.688,0.688 0.859,1.204 0,2.235 -4.988,5.677 -15.996,12.213 -27.692,12.213 -9.116,0 -18.748,-2.064 -26.66,-12.04 -6.364,-8.429 -7.74,-15.651 -7.74,-23.392 0,-19.779 13.588,-39.731 35.432,-40.419 V 57.87 C 35.462,54.43 30.13,47.034 30.13,39.982 c 0,-14.964 11.868,-28.035 35.259,-28.035 19.436,0 35.604,11.008 35.604,29.583 0,6.192 -1.031,14.104 -1.204,18.748 h 23.735 c 1.032,0 1.549,0.86 1.205,1.548 l -1.721,6.02 c -0.172,0.86 -0.516,1.376 -1.548,1.376 H 99.274 Z" /> +</g> +</svg> diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000000000000000000000000000000000000..28acf4f37431b2414247d2fa947a6c8b8d76ace3 --- /dev/null +++ b/environment.yml @@ -0,0 +1,22 @@ +name: ct-gallery +channels: + - control-toolbox + - conda-forge + - dtk-forge +dependencies: + - cmake + - gfortran_linux-64 + - kernda + - scipy + - matplotlib + - numba + - numpy + - bocop + - nutopy + - nodejs + - ipywidgets + - jupyterlab + - swig + - pip + - pip: + - jupyter_contrib_nbextensions diff --git a/mykernel.sh b/mykernel.sh new file mode 100755 index 0000000000000000000000000000000000000000..3c37ec32b7c1cbe9f12254d20cd9441ec9041333 --- /dev/null +++ b/mykernel.sh @@ -0,0 +1,26 @@ +#! /bin/bash + +CONDA_HOME=`which conda` +CONDA_HOME=`dirname ${CONDA_HOME}` +CONDA_HOME=`dirname ${CONDA_HOME}` +<<<<<<< HEAD +CONDA_HOME2=${HOME}/.conda +JUPYTER_DIR=`jupyter --data-dir` + +if [ -d ${CONDA_HOME2}/envs/$1 ] +then + source ${CONDA_HOME}/bin/activate ${CONDA_HOME2}/envs/$1 +======= +CONDA_ENVS=${HOME}/.conda/envs +JUPYTER_DIR=`jupyter --data-dir` + +if [ -d ${CONDA_ENVS}/$1 ] +then + source ${CONDA_HOME}/bin/activate ${CONDA_ENVS}/$1 +>>>>>>> develop + python -m ipykernel install --user --name $1 + conda deactivate + kernda ${JUPYTER_DIR}/kernels/$1/kernel.json -o > /dev/null +else + echo "Unknown conda environment" +fi diff --git a/pkg/env/cimpa-linux.yaml b/pkg/env/cimpa-linux.yaml new file mode 100644 index 0000000000000000000000000000000000000000..94f99a498c969dd6c768719d8146a51305681c0a --- /dev/null +++ b/pkg/env/cimpa-linux.yaml @@ -0,0 +1,17 @@ +name: cimpa + +channels: + - control-toolbox + - conda-forge + - dtk-forge + +dependencies: + - scipy + - matplotlib + - nutopy + - bocop + - cmake + - gfortran_linux-64 + - jupyterlab + - numba + - ipympl diff --git a/pkg/env/cimpa-mac.yaml b/pkg/env/cimpa-mac.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8144f8b834f48d19f8166f4c41650a77c8cd24b6 --- /dev/null +++ b/pkg/env/cimpa-mac.yaml @@ -0,0 +1,17 @@ +name: cimpa + +channels: + - control-toolbox + - conda-forge + - dtk-forge + +dependencies: + - scipy + - matplotlib + - nutopy + - bocop + - cmake + - gfortran_osx-64 + - jupyterlab + - numba + - ipympl diff --git a/pkg/env/cimpa-windows.yaml b/pkg/env/cimpa-windows.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0415790bd9f09eb480b85b9bce852578744f4d80 --- /dev/null +++ b/pkg/env/cimpa-windows.yaml @@ -0,0 +1,15 @@ +name: cimpa + +channels: + - control-toolbox + - conda-forge + - dtk-forge + +dependencies: + - bocop>3.0.0 + - jupyterlab + - m2w64-gcc-fortran + - matplotlib=3.1.* + - numba + - nutopy=0.3.* + - scipy diff --git a/postBuild b/postBuild new file mode 100755 index 0000000000000000000000000000000000000000..6e810ae9a6146ca68981a2c5d6d398788cbe5049 --- /dev/null +++ b/postBuild @@ -0,0 +1,3 @@ +jupyter contrib nbextension install --user +jupyter nbextension enable --py widgetsnbextension +jupyter labextension install @jupyter-widgets/jupyterlab-manager --minimize=False diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..759377208936bb7b2895b57e5a5f7b60c9249fda --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +pandas +ipywidgets +sphinx +sphinx_rtd_theme +recommonmark +nbsphinx +sphinxcontrib-bibtex<2.0.0 +sphinx_copybutton +sphinx-gallery +nbsphinx_link +ipython