Skip to content

Commit

Permalink
feat: improve 'eval_robustness' utility (#313)
Browse files Browse the repository at this point in the history
This commit improves the 'eval_robustness' utility so that users no
longer need to modify their environments to use it with this utility.
The disturbers are now implemented as [gymnasium
wrappers](https://gymnasium.farama.org/api/wrappers/). Because of this,
they can be used with any [gymnasium
environment](https://gymnasium.farama.org/). If you want to add a new
disturber, you only have to ensure that it is a Python class that
inherits from the
[gym.Wrapper](https://github.com/Farama-Foundation/Gymnasium/blob/ba348890af369dad6e6093665fd4e54d8d4b4824/gymnasium/core.py#L246-L249)
class.
  • Loading branch information
rickstaa committed Aug 2, 2023
1 parent ae7d3bc commit 3985867
Show file tree
Hide file tree
Showing 43 changed files with 2,537 additions and 1,718 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: Docs
on:
on:
push:
tags:
- v*.*.*
paths:
- 'docs/**'
- "docs/**"
workflow_dispatch:
permissions:
contents: write
contents: write
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
with:
python-version: 3.8
cache: 'pip'
cache: "pip"
cache-dependency-path: pyproject.toml
- name: Install system dependencies
run: sudo apt-get update; sudo apt-get install libopenmpi-dev
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/stable_learning_control.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: 'pip'
cache: "pip"
cache-dependency-path: pyproject.toml
- name: Install the stable_learning_control package with its dependencies
run: |
Expand All @@ -56,7 +56,7 @@ jobs:
strategy:
fail-fast: false # Run all matrix jobs.
matrix:
python-version: [3.8, 3.9, '3.10'] # Supported python versions.
python-version: [3.8, 3.9, "3.10"] # Supported python versions.
steps:
- name: Checkout stable-learning-control repository
uses: actions/checkout@v3
Expand All @@ -66,7 +66,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache: "pip"
cache-dependency-path: pyproject.toml
- name: Install the stable_learning_control package with its dependencies
run: |
Expand All @@ -78,5 +78,5 @@ jobs:
set +o pipefail
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ We love your input! 🚀 We want to make contributing to this project as easy an

We use Github to host code, track issues and feature requests, and accept pull requests.

### We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
### We Use [Github Flow](https://docs.github.com/en), So All Code Changes Happen Through Pull Requests

Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://docs.github.com/en/get-started/quickstart/github-flow)). We actively welcome your pull requests:

Expand Down Expand Up @@ -96,4 +96,4 @@ See the [documentation guidelines](https://rickstaa.dev/stable-learning-control/

## Any contributions you make will be under the MIT Software License

In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](https://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Package Overview

The Stable Learning Control (SLC) framework is a collection of robust Reinforcement Learning control algorithms designed to ensure stability. These algorithms are built upon the Lyapunov actor-critic architecture introduced by [Han et al. 2020](http://arxiv.org/abs/2004.14288). They guarantee stability and robustness by leveraging [Lyapunov stability theory](https://en.wikipedia.org/wiki/Lyapunov_stability). These algorithms are specifically tailored for use with [gymnasium environments](https://gymnasium.farama.org/) that feature a positive definite cost function. Several ready-to-use compatible environments can be found in the [stable-gym](https://github.com/rickstaa/stable-gym) package.
The Stable Learning Control (SLC) framework is a collection of robust Reinforcement Learning control algorithms designed to ensure stability. These algorithms are built upon the Lyapunov actor-critic architecture introduced by [Han et al. 2020](https://arxiv.org/abs/2004.14288). They guarantee stability and robustness by leveraging [Lyapunov stability theory](https://en.wikipedia.org/wiki/Lyapunov_stability). These algorithms are specifically tailored for use with [gymnasium environments](https://gymnasium.farama.org/) that feature a positive definite cost function. Several ready-to-use compatible environments can be found in the [stable-gym](https://github.com/rickstaa/stable-gym) package.

## Installation and Usage

Expand All @@ -21,5 +21,5 @@ We use [husky](https://github.com/typicode/husky) pre-commit hooks and github ac

## References

* [Han et al. 2020](http://arxiv.org/abs/2004.14288) - Used as a basis for the Lyapunov actor-critic architecture.
* [Han et al. 2020](https://arxiv.org/abs/2004.14288) - Used as a basis for the Lyapunov actor-critic architecture.
* [Spinningup](https://spinningup.openai.com/en/latest/) - Used as a basis for the code structure.
53 changes: 7 additions & 46 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,20 @@
# Makefile for Stable Learning Control Sphinx documentation
# Makefile for Stable Learnig Control Sphinx documentation.

# You can set these variables from the command line
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = Stable Learning Control
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
GH_PAGES_SOURCES = docs stable_learning_control examples

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from https://sphinx-doc.org/)
endif
GH_PAGES_SOURCES = stable_learning_control

# Put it first so that "make" without argument is like "make help".
.PHONY: help Makefile
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# Create make clean command
.PHONY: clean
clean:
@rm -rf $(BUILDDIR)/*
@rm -rf $(SOURCEDIR)/dev/api/_autosummary
@echo "Build folder cleaned"

# Publish gh-pages command
.PHONY: gh-pages
gh-pages:
cd .. && \
git submodule update --recursive && \
git checkout gh-pages && \
git rm -rf . && git clean -fxd && \
git checkout main $(GH_PAGES_SOURCES) && \
git reset HEAD && \
cd docs && \
make clean && \
make html && \
cd .. && \
git add docs/build/html && \
git clean -ffxd && \
mv -fv docs/build/html/* ./ && \
mv -fv docs/build/html/.[!.]* ./ && \
rm -rf $(GH_PAGES_SOURCES) && \
git add -A && \
git commit -m "docs: Generated gh-pages for `git log main -1 --pretty=short --abbrev-commit`" && \
git push origin gh-pages && \
git checkout main && \
git submodule update --recursive && \
pnpm install && \
pnpm run prepare && \
git restore pnpm-lock.yaml
.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
git submodule update --init --recursive
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15 changes: 7 additions & 8 deletions docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
set SPHINXPROJ=SpinningUp

if "%1" == "" goto help
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
Expand All @@ -22,15 +19,17 @@ if errorlevel 9009 (
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://sphinx-doc.org/
echo.https://www.sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
7 changes: 6 additions & 1 deletion docs/source/dev/doc_dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ directory and run the ``make html`` command. This command will generate the html
the ``docs/build/html`` directory. If the documentation is successfully created, you can also use the
``make linkcheck`` command to check for broken links.

.. note::
.. attention::

Ensure you are in the Conda environment where you installed the :slc:`stable_learning_control <>`
package with its dependencies.

.. note::

Sometimes the ``make linkcheck`` command doesn't show the results on the stdout. You can also find the results
in the ``docs/build/linkcheck`` folder.

.. _HTML: https://www.w3schools.com/html/

Deploying
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ready-to-use compatible environments can be found in the :stable-gym:`stable-gy
utils/mpi
utils/run_utils
utils/plotter
utils/tester
utils/testers

.. toctree::
:maxdepth: 2
Expand Down

0 comments on commit 3985867

Please sign in to comment.