-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:EMI-Group/evox
- Loading branch information
Showing
73 changed files
with
1,211 additions
and
815 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
======= | ||
LMOCSO | ||
======= | ||
|
||
.. autoclass:: evox.algorithms.LMOCSO | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,4 @@ Problems | |
:maxdepth: 2 | ||
|
||
numerical/index | ||
neuroevolution/index | ||
rl/index | ||
neuroevolution/index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
docs/source/api/problems/neuroevolution/reinforcement_learning/env_pool.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
======== | ||
Env Pool | ||
======== | ||
|
||
.. autoclass:: evox.problems.neuroevolution.reinforcement_learning.EnvPool | ||
:members: |
6 changes: 6 additions & 0 deletions
6
docs/source/api/problems/neuroevolution/reinforcement_learning/gym.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
=== | ||
Gym | ||
=== | ||
|
||
.. autoclass:: evox.problems.neuroevolution.reinforcement_learning.Gym | ||
:members: |
10 changes: 10 additions & 0 deletions
10
docs/source/api/problems/neuroevolution/reinforcement_learning/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
====================== | ||
Reinforcement Learning | ||
====================== | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
brax | ||
gym | ||
env_pool |
8 changes: 8 additions & 0 deletions
8
docs/source/api/problems/neuroevolution/supervised_learning/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
=================== | ||
Supervised Learning | ||
=================== | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
torchvision |
6 changes: 6 additions & 0 deletions
6
docs/source/api/problems/neuroevolution/supervised_learning/torchvision.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
=================== | ||
Torchvision Dataset | ||
=================== | ||
|
||
.. autoclass:: evox.problems.neuroevolution.supervised_learning.TorchvisionDataset | ||
:members: |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Working with state in EvoX | ||
|
||
EvoX is designed around the stateful computation. | ||
|
||
There are two most fundamental classes, namely {class}`Stateful <evox.Stateful>` and {class}`State <evox.State>`. | ||
|
||
All class that involves stateful computation are inherented from `Stateful`. In EvoX, `Algorithm`, `Problem`, `Operator` and workflows are all stateful. | ||
|
||
## The idea behind the design | ||
|
||
```{image} /_static/hierarchical_state.svg | ||
:alt: hierarchical state | ||
:width: 400px | ||
``` | ||
|
||
Here we have five different objects, and notice that they have a hierarchical structure. | ||
To work with such structure, at each level we must "lift the state" by managing the states of child components. | ||
So, the state at the `workflow` level must contains the state of both `algorithm` and `problem`, | ||
and since the state at the `algorithm` level must contains the state of both operators, | ||
the state `workflow` level actual need to handle states from all 5 components. | ||
|
||
However, it is frustrating to managing the hierarchy manually, and it is not good for modular design. | ||
To solve this problem, we introduce `Stateful` and `State`. | ||
|
||
## An overview of Stateful | ||
|
||
In a `Stateful` class, | ||
all immutable data are initialized in `__init__`, | ||
the initial mutable state is generated in `setup`, | ||
besides these two method and private methods(start with "\_"), | ||
all other methods are wrapped with `use_state`. | ||
|
||
```python | ||
class Foo(Stateful): | ||
def __init__(self,): # required | ||
pass | ||
|
||
def setup(self, key) -> State: # optional | ||
pass | ||
|
||
def stateful_func(self, state, args) -> State: # wrapped with use_state | ||
pass | ||
|
||
def _normal_func(self, args) -> vals: # not wrapped | ||
pass | ||
``` | ||
|
||
will be wrapped with `use_state` decorator. This decorator requires the method have the following signature: | ||
|
||
```python | ||
def func(self, state: State, ...) -> Tuple[..., State] | ||
``` | ||
|
||
which is common pattern in stateful computation. | ||
|
||
:::{warning} | ||
Currently, for all user defined private methods, the name of the method should starts with `_`. | ||
::: | ||
|
||
## An overview of State | ||
|
||
In EvoX `State` represents a tree of states, which stores the state of the current object and all child objects. | ||
|
||
## Combined together | ||
|
||
When combined together, | ||
they will automatically go 1 level down in the tree of states, | ||
and merge the subtree back to current level. | ||
|
||
So you could write code like this. | ||
|
||
```python | ||
class FooWorkflow(Stateful): | ||
... | ||
def step(self, state): | ||
population, state = self.algorithm.ask(state) | ||
fitness, state = self.problem.evaluate(state, population) | ||
... | ||
``` | ||
|
||
Notice that, when calling the method `step`, | ||
`state` is the state of the workflow, | ||
but when calling `self.algorithm.ask`, | ||
`state` behaves like the state of the algorithm, | ||
and after the call, the state of the algorithm is automatically merged back into the state of the workflow. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.