Skip to content

Commit

Permalink
Multiprocessing and derecations removed.
Browse files Browse the repository at this point in the history
Multiprocessing is now a thing! Performances improved by at least 30%
The function, methods marked as deprecated are now removed.
PyGAD is no longer compatible, tqdm is requiered.
  • Loading branch information
HugoFara committed Jul 21, 2021
1 parent 6f099b3 commit 51cf249
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 218 deletions.
115 changes: 76 additions & 39 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,93 @@
# Changelog
All notable changes to this project will be documented in this file.
All notable changes to the LeggedSnake will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Multiprocessing is here! The genetic optimization can now be run in parallel!
Performances are easily improved by 30 % using 4 processes.

### Changed
- The sidebar in the documentation a bit more useful.
- Not having tqdm will cause an exception.

### Removed
- native support for PyGAD is no longer present.
- ``evolutionnary_optimization`` (replaced by ``evolutionary_optimization``)

## [0.2.0-alpha] - 2021-07-14
### Added
- Dependency to [tqdm](https://tqdm.github.io/) and matplotlib.
- The ``evolutionary_optimization`` replaces ``evolutionnary_optimization``.
- The ``ite`` parameter renamed ``iters`` for consistency with pylinkage.
- The new parameter ``verbose`` let you display a nice progress bar, more information on optimization state, or nothing.
- The new parameter ``verbose`` let you display a nice progress bar, more
information on optimization state, or nothing.
- The best solution can be displayed with PyGAD as well.

### Changed
- Typos and cleans-up in ``docs/examples/strider.py``.
- ``evolutionnary_optimization_legacy`` renamed to ``evolutionary_optimization_builtin``.
- ``evolutionnary_optimization_legacy`` renamed to
``evolutionary_optimization_builtin``.

### Deprecated
- ``evolutionnary_optimization`` is now deprecated. Please use ``evolutionary_optimization``.
- ``evolutionnary_optimization`` is now deprecated. Please use
``evolutionary_optimization``.

### Removed
- Explicit dependency to PyGAD. There is no longer an annoying message when PyGAD is not installed.
- Explicit dependency to PyGAD. There is no longer an annoying message when
PyGAD is not installed.

## [0.1.4-alpha] - 2021-07-12
### Added
- It is now possible and advised to import class and functions using quick paths, for instance ``from leggedsnake import Walker`` instead of ``from leggedsnake.walker import Walker``.
- You do no longer have to manually import [pylinkage](https://hugofara.github.io/pylinkage/), we silently import the useful stuff for you.
- We now use [bump2version](https://pypi.org/project/bump2version/) for version maintenance.
- This is fixed by the ``road_y`` parameter in ``World`` let you define a custom height for the base ground.
- It is now possible and advised to import class and functions using quick
paths, for instance ``from leggedsnake import Walker`` instead of
``from leggedsnake.walker import Walker``.
- You do no longer have to manually import
[pylinkage](https://hugofara.github.io/pylinkage/), we silently import the
useful stuff for you.
- We now use [bump2version](https://pypi.org/project/bump2version/) for version
maintenance.
- This is fixed by the ``road_y`` parameter in ``World`` let you define a
custom height for the base ground.

### Changed
- ``docs/examples/strider.py`` has been updated to the latest version of leggedsnake 0.1.4.
- ``docs/examples/strider.py`` has been updated to the latest version of
leggedsnake 0.1.4.

### Fixed
- The full swarm representation in polar graph has been repaired in ``docs/examples/strider.py``.
- During a dynamic simulation, linkages with long legs could appear through the road.
- The documentation was not properly rendered because Napoleon (NumPy coding style) was not integrated.
- The full swarm representation in polar graph has been repaired in
``docs/examples/strider.py``.
- During a dynamic simulation, linkages with long legs could appear through the
road.
- The documentation was not properly rendered because Napoleon (NumPy coding
style) was not integrated.

## [0.1.3-alpha] - 2021-07-10
This package was lacking real documentation, it is fixed in this version.
### Added
- Sphinx documentation!
- Website hosted on GitHub pages, check [hugofara.github.io/leggedsnake](https://hugofara.github.io/leggedsnake/)!
- Website hosted on GitHub pages, check
[hugofara.github.io/leggedsnake](https://hugofara.github.io/leggedsnake/)!
- Expanded README with the quick links section.

### Changed
- Tests moved from ``leggedsnake/tests`` to ``tests/``.
- Examples moved from ``leggedsnake/examples/`` to ``docs/examples/``.
- I was testing my code on ``leggedsnake/examples/strider.py`` (old path) and that's why it was a big mess. I cleaned up that all. Sorry for the inconvenience!
- I was testing my code on ``leggedsnake/examples/strider.py`` (old path) and
that's why it was a big mess. I cleaned up that all. Sorry for the
inconvenience!

### Fixed
- A lot of outdated code in the ``leggedsnake/examples/strider.py``
- Changelog URL was broken in ``setup.cfg``.

## [0.1.2-alpha] - 2021-07-07
### Changed
- The ``step`` function execution speed has been increased by 25% when ``return_res`` is ``True``! Small performance improvement when ``return_res`` is ``False``.
- The ``step`` function execution speed has been increased by 25% when
``return_res`` is ``True``! Small performance improvement when ``return_res``
is ``False``.
- The ``size`` argument of ``step`` function is now known as ``witdh``.
- We now require pylinkage>=0.4.0.

Expand All @@ -75,8 +103,10 @@ This package was lacking real documentation, it is fixed in this version.

## [0.1.1-alpha] - 2021-06-26
### Added
- The example file ``examples/strider.py`` is now shipped with the Python package.
- ``leggedsnake/geneticoptimizer.py`` can now automatically switch to the built-in GA algorithm if PyGAD is not installed.
- The example file ``examples/strider.py`` is now shipped with the Python
package.
- ``leggedsnake/geneticoptimizer.py`` can now automatically switch to the
built-in GA algorithm if PyGAD is not installed.

### Changed
- ``setup.cfg`` metadata
Expand All @@ -87,11 +117,13 @@ This package was lacking real documentation, it is fixed in this version.
- Example videos in ``examples/images/``

### Changed
- Manny reforms in code style, to make the dynamic part naming conventions consistent with Pymunk.
- Manny reforms in code style, to make the dynamic part naming conventions
consistent with Pymunk.
- Images in the ``README.md``!

### Fixed
- You can now define linkages with an enormous number of legs. Systems with many should no longer break physics but your CPU instead :)
- You can now define linkages with an enormous number of legs. Systems with
many should no longer break physics but your CPU instead :)

## [0.0.3-alpha] - 2021-06-23
### Added
Expand All @@ -109,30 +141,35 @@ This package was lacking real documentation, it is fixed in this version.

### Changed
- ``.gitignore`` now ignores .txt files only in the leggedsnake folder.
- ``environment.yml`` more flexible (versions can be superior to the selected). pymunk>5.0.0 and pylinkage added.
- ``leggedsnake/utility.py`` not having zipfile or xml modules error encapsulation.
- ``environment.yml`` more flexible (versions can be superior to the selected).
pymunk>5.0.0 and pylinkage added.
- ``leggedsnake/utility.py`` not having zipfile or xml modules error
encapsulation.

### Fixed
- ``setup.cfg`` was not PyPi compatible. Removed mail (use GitHub!), we now explicitly say that ``README.md`` is markdown (PyPi is conservative)
- ``setup.cfg`` was not PyPi compatible. Removed mail (use GitHub!), we now
explicitly say that ``README.md`` is markdown (PyPi is conservative)

## [0.0.1-alpha] - 2021-06-22
Basic version, supporting Genetic Algorithm optimization, but with various problems.
Basic version, supporting Genetic Algorithm optimization, but with various
problems.
### Added
- ``CODE_OF_CONDUCT.md`` to help community
- ``LICENSE`` MIT License
- ``MANIFEST.in`` to include more files
- ``README.md`` as a very minimal version
- ``environment.yml`` with matplotlib, numpy, and pygad requirement
- ``examples/strider.py`` a complete demo with Strider linkage
- ``leggedsnake/__init__.py``
- ``leggedsnake/dynamiclinkage.py``
- ``leggedsnake/geneticoptimizer.py``
- ``leggedsnake/physicsengine.py``
- ``leggedsnake/show_evolution.py`` just a legacy package, no utility
- ``CODE_OF_CONDUCT.md`` to help community.
- ``LICENSE`` MIT License.
- ``MANIFEST.in`` to include more files.
- ``README.md`` as a very minimal version.
- ``environment.yml`` with matplotlib, numpy, and pygad requirement.
- ``examples/strider.py`` a complete demo with Strider linkage.
- ``leggedsnake/__init__.py``.
- ``leggedsnake/dynamiclinkage.py``.
- ``leggedsnake/geneticoptimizer.py``.
- ``leggedsnake/physicsengine.py``.
- ``leggedsnake/show_evolution.py`` just a legacy package, no utility.
- ``leggedsnake/tests/test_utility.py`` untested test case
- ``leggedsnake/utility.py`` contain some useful evaluation function (``step`` and ``stride``) and a broken GeoGebra interface.
- ``leggedsnake/utility.py`` contain some useful evaluation function (``step``
and ``stride``) and a broken GeoGebra interface.
- ``walker.py`` defines the ``Walker`` object.
- ``pyproject.toml``
- ``setup.cfg``
- ``setup.py`` empty, for compatibility purposes only
- ``pyproject.toml``.
- ``setup.cfg``.
- ``setup.py`` empty, for compatibility purposes only.
- ``tox.ini`` tox with Python 3.7 and 3.8
13 changes: 7 additions & 6 deletions docs/examples/strider.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,22 +538,23 @@ def evolutive_optimizer(linkage, dims=param, prev=None, pop=10, iters=10,
linkage.rebuild(prev)
linkage.step()
dna = 0, list(dims), list(linkage.get_coords())
o = ls.evolutionary_optimization(
out = ls.evolutionary_optimization(
dna=dna, prob=.07,
fitness=fitness,
iters=iters,
max_pop=pop,
init_pop=init_pop,
startnstop=startnstop,
fitness_args=[linkage]
fitness_args=(linkage,),
processes=1
)
if save:
file = open('Evolutive optimizer.txt', 'w')
# We only keep 10 best results
for i in range(min(10, len(o))):
file.write('{}\n{}\n{}\n----\n'.format(o[i][0], o[i][1], o[i][2]))
for i in range(min(10, len(out))):
file.write('{}\n{}\n{}\n----\n'.format(out[i][0], out[i][1], out[i][2]))
file.close()
return o
return out


def show_optimized(linkage, data, n_show=10, duration=5, symmetric=True):
Expand Down Expand Up @@ -605,7 +606,7 @@ def show_optimized(linkage, data, n_show=10, duration=5, symmetric=True):
save=False, startnstop=False
)
print(
"Fitness after evolutive optimization: {}".format(
"Fitness after genetic optimization: {}".format(
optimized_striders[0][0]
)
)
5 changes: 1 addition & 4 deletions leggedsnake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@

from .utility import step, stride
from .walker import Walker
from .geneticoptimizer import (
evolutionnary_optimization,
evolutionary_optimization,
)
from .geneticoptimizer import evolutionary_optimization
from .dynamiclinkage import (
Nail, PinUp, DynamicPivot, Motor,
DynamicLinkage,
Expand Down
Loading

0 comments on commit 51cf249

Please sign in to comment.