MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit 2e6c74b2 authored by Olivier Cots's avatar Olivier Cots
Browse files

fix merge

parents 7df91bd4 cd4bef40
......@@ -11,6 +11,8 @@
*.so
*.so.dSYM
*.so.dSYM/*
.nfs*
*__pycache__*
# IPython
profile_default/
......@@ -23,5 +25,8 @@ ipython_config.py
# bocop files (build and exec)
build/
bocop
bocopApp
bocopwrapper.py
!bocop/
*.sol
libbocop.dylib
[compat]
julia = "1.6"
[deps]
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9"
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
# ct (control toolbox) gallery
Jupyter notebooks for use cases using solvers of `bocop` + `nutopy` packages and others.
Jupyter notebooks for use cases using solvers of `bocop` & `nutopy` packages and others.
[![Online examples](https://img.shields.io/badge/ct-gallery-blue.svg)](https://ct.gitlabpages.inria.fr/gallery)
[![Full directory](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.inria.fr%2Fct%2Fgallery.git/master?urlpath=lab/)
Special thanks: [A. Hurtig](http://www.alain.les-hurtig.org) for the logos ligatures!
Special thanks: [A. Hurtig](http://www.alain.les-hurtig.org) for the logos ligatures
## Procedure to get the examples and install the packages
In the following, `ROOT` is a variable standing for the root directory where the course repository will be stored. For example,
```bash
export ROOT=${HOME}
```
The examples are given in the form of python notebooks. To download all the examples, use the `git` command ([git](https://git-scm.com/downloads)). To clone the git repository and get the examples:
```bash
cd $ROOT
git clone https://gitlab.inria.fr/ct/gallery.git
```
The examples of our gallery uses python packages (see `pkg/env` directory). All theses packages may be installed in a conda environment for ease of use.
If you do not have the `conda` command, please install [miniconda](https://docs.conda.io/en/latest/miniconda.html) or [conda](https://docs.conda.io/en/latest/) (conda is longer to install than miniconda). Then, create the conda environment:
```bash
cd $ROOT/gallery
conda env create -f pkg/env/gallery-<YOUR_OS>.yaml
```
Where <YOUR_OS> must be replaced by ```linux```, ```mac``` or ```windows```, according to the platform used.
> If you only want to install the packages, that is you do not want to download all the examples, you can simply
> download the file `pkg/env/gallery-<YOUR_OS>.yaml` and then create the conda environment with:
> ```bash
> conda env create -f gallery-<YOUR_OS>.yaml
> ```
Activate the gallery conda environment to get access to all the packages:
```bash
conda activate gallery-dev
```
Run jupyterlab and access to the examples (in subdirectory `examples`):
```bash
jupyter-lab
```
## Revoming the environment
You can remove the gallery environment doing:
```bash
conda activate base
conda env remove --name gallery-dev
```
from subprocess import Popen
from os import chdir
def load_jupyter_server_extension(nbapp):
chdir("examples/bacteria")
Popen(["bokeh", "serve", "bacteria-panel.ipynb", "--allow-websocket-origin=*", "--port=5006"])
chdir("../..")
chdir("examples/swimmer")
Popen(["bokeh", "serve", "swimmer.ipynb", "--allow-websocket-origin=*", "--port=5007"])
chdir("../..")
name: ct-gallery
channels:
- control-toolbox
- conda-forge
- dtk-forge
- control-toolbox
dependencies:
- scipy
- matplotlib=3.1.*
- nutopy=0.3.*
- bocop>3.0.0
- cmake
- gfortran_linux-64
- cmake = 3.20.*
- gfortran_linux-64 = 7.5.*
- kernda
- plotly
- param = 1.10.*
- panel
- bokeh
- scipy = 1.4.*
- matplotlib = 3.1.*
- numba = 0.53.*
- numpy
- bocop = 3.1.*
- nutopy = 0.3.*
- nodejs
- ipywidgets
- jupyterlab = 3.0.*
- swig
- ffmpeg = 4.3.*
- pip
- pip:
- jupyter_contrib_nbextensions
- jupyter-server-proxy
This diff is collapsed.
This diff is collapsed.
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
if _swig_python_version_info < (2, 7, 0):
raise RuntimeError("Python 2.7 or later required")
# Import the low-level C/C++ module
if __package__ or "." in __name__:
from . import _bocopwrapper
else:
import _bocopwrapper
try:
import builtins as __builtin__
except ImportError:
import __builtin__
_swig_new_instance_method = _bocopwrapper.SWIG_PyInstanceMethod_New
_swig_new_static_method = _bocopwrapper.SWIG_PyStaticMethod_New
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
def _swig_setattr_nondynamic_instance_variable(set):
def set_instance_attr(self, name, value):
if name == "thisown":
self.this.own(value)
elif name == "this":
set(self, name, value)
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
set(self, name, value)
else:
raise AttributeError("You cannot add instance attributes to %s" % self)
return set_instance_attr
def _swig_setattr_nondynamic_class_variable(set):
def set_class_attr(cls, name, value):
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
set(cls, name, value)
else:
raise AttributeError("You cannot add class attributes to %s" % cls)
return set_class_attr
def _swig_add_metaclass(metaclass):
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
def wrapper(cls):
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
return wrapper
class _SwigNonDynamicMeta(type):
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
import weakref
class SwigPyIterator(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr
__swig_destroy__ = _bocopwrapper.delete_SwigPyIterator
value = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_value)
incr = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_incr)
decr = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_decr)
distance = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_distance)
equal = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_equal)
copy = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_copy)
next = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_next)
__next__ = _swig_new_instance_method(_bocopwrapper.SwigPyIterator___next__)
previous = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_previous)
advance = _swig_new_instance_method(_bocopwrapper.SwigPyIterator_advance)
__eq__ = _swig_new_instance_method(_bocopwrapper.SwigPyIterator___eq__)
__ne__ = _swig_new_instance_method(_bocopwrapper.SwigPyIterator___ne__)
__iadd__ = _swig_new_instance_method(_bocopwrapper.SwigPyIterator___iadd__)
__isub__ = _swig_new_instance_method(_bocopwrapper.SwigPyIterator___isub__)
__add__ = _swig_new_instance_method(_bocopwrapper.SwigPyIterator___add__)
__sub__ = _swig_new_instance_method(_bocopwrapper.SwigPyIterator___sub__)
def __iter__(self):
return self
# Register SwigPyIterator in _bocopwrapper:
_bocopwrapper.SwigPyIterator_swigregister(SwigPyIterator)
class VecDouble(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
iterator = _swig_new_instance_method(_bocopwrapper.VecDouble_iterator)
def __iter__(self):
return self.iterator()
__nonzero__ = _swig_new_instance_method(_bocopwrapper.VecDouble___nonzero__)
__bool__ = _swig_new_instance_method(_bocopwrapper.VecDouble___bool__)
__len__ = _swig_new_instance_method(_bocopwrapper.VecDouble___len__)
__getslice__ = _swig_new_instance_method(_bocopwrapper.VecDouble___getslice__)
__setslice__ = _swig_new_instance_method(_bocopwrapper.VecDouble___setslice__)
__delslice__ = _swig_new_instance_method(_bocopwrapper.VecDouble___delslice__)
__delitem__ = _swig_new_instance_method(_bocopwrapper.VecDouble___delitem__)
__getitem__ = _swig_new_instance_method(_bocopwrapper.VecDouble___getitem__)
__setitem__ = _swig_new_instance_method(_bocopwrapper.VecDouble___setitem__)
pop = _swig_new_instance_method(_bocopwrapper.VecDouble_pop)
append = _swig_new_instance_method(_bocopwrapper.VecDouble_append)
empty = _swig_new_instance_method(_bocopwrapper.VecDouble_empty)
size = _swig_new_instance_method(_bocopwrapper.VecDouble_size)
swap = _swig_new_instance_method(_bocopwrapper.VecDouble_swap)
begin = _swig_new_instance_method(_bocopwrapper.VecDouble_begin)
end = _swig_new_instance_method(_bocopwrapper.VecDouble_end)
rbegin = _swig_new_instance_method(_bocopwrapper.VecDouble_rbegin)
rend = _swig_new_instance_method(_bocopwrapper.VecDouble_rend)
clear = _swig_new_instance_method(_bocopwrapper.VecDouble_clear)
get_allocator = _swig_new_instance_method(_bocopwrapper.VecDouble_get_allocator)
pop_back = _swig_new_instance_method(_bocopwrapper.VecDouble_pop_back)
erase = _swig_new_instance_method(_bocopwrapper.VecDouble_erase)
def __init__(self, *args):
_bocopwrapper.VecDouble_swiginit(self, _bocopwrapper.new_VecDouble(*args))
push_back = _swig_new_instance_method(_bocopwrapper.VecDouble_push_back)
front = _swig_new_instance_method(_bocopwrapper.VecDouble_front)
back = _swig_new_instance_method(_bocopwrapper.VecDouble_back)
assign = _swig_new_instance_method(_bocopwrapper.VecDouble_assign)
resize = _swig_new_instance_method(_bocopwrapper.VecDouble_resize)
insert = _swig_new_instance_method(_bocopwrapper.VecDouble_insert)
reserve = _swig_new_instance_method(_bocopwrapper.VecDouble_reserve)
capacity = _swig_new_instance_method(_bocopwrapper.VecDouble_capacity)
__swig_destroy__ = _bocopwrapper.delete_VecDouble
# Register VecDouble in _bocopwrapper:
_bocopwrapper.VecDouble_swigregister(VecDouble)
class VecVecdouble(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
iterator = _swig_new_instance_method(_bocopwrapper.VecVecdouble_iterator)
def __iter__(self):
return self.iterator()
__nonzero__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___nonzero__)
__bool__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___bool__)
__len__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___len__)
__getslice__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___getslice__)
__setslice__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___setslice__)
__delslice__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___delslice__)
__delitem__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___delitem__)
__getitem__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___getitem__)
__setitem__ = _swig_new_instance_method(_bocopwrapper.VecVecdouble___setitem__)
pop = _swig_new_instance_method(_bocopwrapper.VecVecdouble_pop)
append = _swig_new_instance_method(_bocopwrapper.VecVecdouble_append)
empty = _swig_new_instance_method(_bocopwrapper.VecVecdouble_empty)
size = _swig_new_instance_method(_bocopwrapper.VecVecdouble_size)
swap = _swig_new_instance_method(_bocopwrapper.VecVecdouble_swap)
begin = _swig_new_instance_method(_bocopwrapper.VecVecdouble_begin)
end = _swig_new_instance_method(_bocopwrapper.VecVecdouble_end)
rbegin = _swig_new_instance_method(_bocopwrapper.VecVecdouble_rbegin)
rend = _swig_new_instance_method(_bocopwrapper.VecVecdouble_rend)
clear = _swig_new_instance_method(_bocopwrapper.VecVecdouble_clear)
get_allocator = _swig_new_instance_method(_bocopwrapper.VecVecdouble_get_allocator)
pop_back = _swig_new_instance_method(_bocopwrapper.VecVecdouble_pop_back)
erase = _swig_new_instance_method(_bocopwrapper.VecVecdouble_erase)
def __init__(self, *args):
_bocopwrapper.VecVecdouble_swiginit(self, _bocopwrapper.new_VecVecdouble(*args))
push_back = _swig_new_instance_method(_bocopwrapper.VecVecdouble_push_back)
front = _swig_new_instance_method(_bocopwrapper.VecVecdouble_front)
back = _swig_new_instance_method(_bocopwrapper.VecVecdouble_back)
assign = _swig_new_instance_method(_bocopwrapper.VecVecdouble_assign)
resize = _swig_new_instance_method(_bocopwrapper.VecVecdouble_resize)
insert = _swig_new_instance_method(_bocopwrapper.VecVecdouble_insert)
reserve = _swig_new_instance_method(_bocopwrapper.VecVecdouble_reserve)
capacity = _swig_new_instance_method(_bocopwrapper.VecVecdouble_capacity)
__swig_destroy__ = _bocopwrapper.delete_VecVecdouble
# Register VecVecdouble in _bocopwrapper:
_bocopwrapper.VecVecdouble_swigregister(VecVecdouble)
class CallbackF(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
handle = _swig_new_instance_method(_bocopwrapper.CallbackF_handle)
__swig_destroy__ = _bocopwrapper.delete_CallbackF
def __init__(self):
if self.__class__ == CallbackF:
_self = None
else:
_self = self
_bocopwrapper.CallbackF_swiginit(self, _bocopwrapper.new_CallbackF(_self, ))
def __disown__(self):
self.this.disown()
_bocopwrapper.disown_CallbackF(self)
return weakref.proxy(self)
# Register CallbackF in _bocopwrapper:
_bocopwrapper.CallbackF_swigregister(CallbackF)
solve = _bocopwrapper.solve
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display, clear_output
import ipywidgets as widgets
class PyCallback(CallbackF):
def __init__(self):
super().__init__()
self.initialized = False
self.g_state = [] #for each iter, 2 dims np array
self.g_control = []
self.out = widgets.Output()
self.outText = widgets.Output(layout={'border': '1px solid black'})
def update(self, iteration):
if self.initialized:
len_state = len(self.g_state[iteration])
clear_output(wait=True)
for i in range(len_state):
self.axs[i].clear()
self.axs[i].plot(self.x_state ,self.g_state[iteration][i])
self.axs[i].title.set_text(f"State {i}")
self.axs[i].relim()
self.axs[i].autoscale()
self.fig.canvas.blit(self.axs[i].bbox)
for i in range(len(self.g_control[iteration])):
self.axs[len_state + i].clear()
self.axs[len_state + i].plot(self.x_control ,self.g_control[iteration][i], color='r')
self.axs[len_state + i].relim()
self.axs[len_state + i].set_title(f"Control {i}")
self.axs[len_state + i].autoscale()
self.fig.canvas.blit(self.axs[len_state + i].bbox)
self.outText.clear_output()
with self.outText:
objective = self.g_state[iteration][-1][-1]
print(f"iteration {iteration} objective : {objective}")
display(self.fig)
display(self.outText)
def handle(self, state, control):
if not self.initialized:
self.initialized = True
plt.ioff()
nrows = len(state) + len(control)
with self.out:
self.fig, self.axs = plt.subplots(nrows=nrows, ncols=1)
self.fig.tight_layout()
self.fig.canvas.header_visible = False # Hide the Figure name at the top of the figure
# If true then scrolling while the mouse is over the canvas will not move the entire notebook
self.fig.canvas.capture_scroll = True
self.x_state = np.arange(len(state[0]))
self.x_control = np.arange(len(control[0]))
plt.ion()
self.g_state.append(np.asarray(state))
self.g_control.append(np.asarray(control))
self.update(len(self.g_state) -1)
# Definition file
# Dimensions
dim.state 4
dim.control 1
dim.boundaryconditions 4
dim.pathconstraints 0
dim.parameters 0
dim.constants 4
# Time interval
initial.time 0
final.time 20
# Constants
constant.0 0.6
constant.1 0.003
constant.2 0.5
constant.3 0.07
# Time discretisation
ode.discretization midpoint_implicit
time.steps 200
# Bounds for constraints (initial conditions for our case)
boundarycond.0.lowerbound 0.03
boundarycond.0.upperbound 0.03
boundarycond.1.lowerbound 0.1
boundarycond.1.upperbound 0.1
boundarycond.2.lowerbound 0.2
boundarycond.2.upperbound 0.2
boundarycond.3.lowerbound 0.003
boundarycond.3.upperbound 0.003
# Bounds for variables (dynamical bound for each variable and control)
state.0.lowerbound 0
state.1.lowerbound 0
state.2.lowerbound 0
state.3.lowerbound 0
#Optimal value calculated for our initial conditions
control.0.lowerbound 0.4679139313552532
control.0.upperbound 0.4679139313552532
# 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 0.1
state.1.init 0.1
state.2.init 0.1
state.3.init 0.1
control.0.init 0.4679139313552532
# Ipopt
ipoptIntOption.print_level 5
ipoptIntOption.max_iter 1000
ipoptStrOption.mu_strategy adaptive
ipoptNumOption.tol 1e-12
# Misc
ad.retape 0
# Definition file
# Dimensions
dim.state 4
dim.control 1
dim.boundaryconditions 4
dim.pathconstraints 0
dim.parameters 0
dim.constants 4
# Time interval
initial.time 0
final.time 20
# Constants
constant.0 0.6
constant.1 0.003
constant.2 0.5
constant.3 0.07
# Time discretisation
ode.discretization midpoint_implicit
time.steps 200
# Bounds for constraints (initial conditions for our case)
boundarycond.0.lowerbound 0.03
boundarycond.0.upperbound 0.03
boundarycond.1.lowerbound 0.1
boundarycond.1.upperbound 0.1
boundarycond.2.lowerbound 0.2
boundarycond.2.upperbound 0.2
boundarycond.3.lowerbound 0.003
boundarycond.3.upperbound 0.003
# Bounds for variables (dynamical bound for each variable and control)
state.0.lowerbound 0
state.1.lowerbound 0
state.2.lowerbound 0
state.3.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 0.1
state.1.init 0.1
state.2.init 0.1
state.3.init 0.1
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
# Definition file
# Dimensions
dim.state 4
dim.control 1
dim.boundaryconditions 4
dim.pathconstraints 0
dim.parameters 0
dim.constants 4
# Time interval
initial.time 0
final.time 20
# Constants
constant.0 0.7
constant.1 0.003
constant.2 0.5
constant.3 0.07
# Time discretisation
ode.discretization midpoint_implicit
time.steps 2000
# Bounds for constraints (initial conditions for our case)
boundarycond.0.lowerbound 0.03
boundarycond.0.upperbound 0.03
boundarycond.1.lowerbound 0.17433823529411765
boundarycond.1.upperbound 0.17433823529411765
boundarycond.2.upperbound 0.3256617647058824
boundarycond.2.upperbound 0.3256617647058824
boundarycond.3.lowerbound 0.003
boundarycond.3.upperbound 0.003
# Bounds for variables (dynamical bound for each variable and control)
state.0.lowerbound 0
state.1.lowerbound 0
state.2.lowerbound 0
state.3.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 0.1
state.1.init 0.1
state.2.init 0.1
state.3.init 0.1
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
# Definition file
# Dimensions
dim.state 4
dim.control 1
dim.boundaryconditions 4
dim.pathconstraints 0
dim.parameters 0
dim.constants 4
# Time interval
initial.time 0
final.time 20
# Constants
constant.0 0.7
constant.1 0.003
constant.2 0.3