Skip to content

Commit

Permalink
dev: refactor problem structure
Browse files Browse the repository at this point in the history
  • Loading branch information
BillHuang2001 committed Aug 29, 2023
1 parent 3300b60 commit 3a4969d
Show file tree
Hide file tree
Showing 73 changed files with 48 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
CEC2022 Test Suit
=================

.. autoclass:: evox.problems.test_suit.CEC2022
.. autoclass:: evox.problems.test_suit.CEC2022TestSuit
:members:

.. autoclass:: evox.problems.test_suit.F1_CEC2022
Expand Down
9 changes: 3 additions & 6 deletions docs/source/api/problems/classic/dtlz.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
===========
DTLZ Family
===========

.. autoclass:: evox.problems.classic.DTLZ
:members:
==============
DTLZ Test Suit
==============

.. autoclass:: evox.problems.classic.DTLZ1
:members:
Expand Down
3 changes: 2 additions & 1 deletion docs/source/api/problems/classic/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Numerical Benchmarks
rastrigin
rosenbrock
sphere
zdt
zdt
cec2022
6 changes: 3 additions & 3 deletions docs/source/api/problems/classic/zdt.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===
ZDT
===
=============
ZDT Test Suit
=============

.. autoclass:: evox.problems.classic.ZDT1
:members:
Expand Down
5 changes: 2 additions & 3 deletions docs/source/api/problems/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Problems
.. toctree::
:maxdepth: 2

classic/index
numerical/index
neuroevolution/index
rl/index
test_suit/index
rl/index
8 changes: 0 additions & 8 deletions docs/source/api/problems/test_suit/index.rst

This file was deleted.

7 changes: 0 additions & 7 deletions src/evox/problems/classic/__init__.py

This file was deleted.

22 changes: 22 additions & 0 deletions src/evox/problems/numerical/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from .ackley import Ackley
from .rastrigin import Rastrigin
from .sphere import Sphere
from .zdt import ZDT1, ZDT2, ZDT3, ZDT4, ZDT6
from .griewank import Griewank
from .rosenbrock import Rosenbrock
from .dtlz import DTLZ1, DTLZ2, DTLZ3, DTLZ4, DTLZ5, DTLZ6, DTLZ7
from .cec2022_so import (
CEC2022TestSuit,
F1_CEC2022,
F2_CEC2022,
F3_CEC2022,
F4_CEC2022,
F5_CEC2022,
F6_CEC2022,
F7_CEC2022,
F8_CEC2022,
F9_CEC2022,
F10_CEC2022,
F11_CEC2022,
F12_CEC2022,
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def evaluate(self, state, X):
return F, state


class CEC2022:
class CEC2022TestSuit:
"""
Instantiation format: problem_instance = CEC2022.create(1)
i.e., problem_instance = F1_CEC2022()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@jit_class
class DTLZ(Problem):
class DTLZTestSuit(Problem):
"""DTLZ"""

def __init__(self, d=None, m=None, ref_num=1000):
Expand All @@ -30,7 +30,7 @@ def pf(self, state: chex.PyTreeDef):
return f, state


class DTLZ1(DTLZ):
class DTLZ1(DTLZTestSuit):
def __init__(self, d=None, m=None, ref_num=100):
if m is None:
self.m = 3
Expand Down Expand Up @@ -66,7 +66,7 @@ def evaluate(self, state: chex.PyTreeDef, X: chex.Array):
return f, state


class DTLZ2(DTLZ):
class DTLZ2(DTLZTestSuit):
def __init__(self, d=None, m=None, ref_num=1000):
if m is None:
self.m = 3
Expand Down Expand Up @@ -105,7 +105,7 @@ def pf(self, state: chex.PyTreeDef):
return f, state


class DTLZ3(DTLZ2):
class DTLZ3(DTLZTestSuit):
def __init__(self, d=None, m=None, ref_num=1000):
super().__init__(d, m, ref_num)

Expand Down Expand Up @@ -139,7 +139,7 @@ def evaluate(self, state: chex.PyTreeDef, X: chex.Array):
return f, state


class DTLZ4(DTLZ2):
class DTLZ4(DTLZTestSuit):
def __init__(self, d=None, m=None, ref_num=1000):
super().__init__(d, m, ref_num)

Expand All @@ -166,7 +166,7 @@ def evaluate(self, state: chex.PyTreeDef, X: chex.Array):
return f, state


class DTLZ5(DTLZ):
class DTLZ5(DTLZTestSuit):
def __init__(self, d=None, m=None, ref_num=1000):
if m is None:
self.m = 3
Expand Down Expand Up @@ -227,7 +227,7 @@ def pf(self, state: chex.PyTreeDef):
return f, state


class DTLZ6(DTLZ):
class DTLZ6(DTLZTestSuit):
def __init__(self, d=None, m=None, ref_num=1000):
if m is None:
self.m = 3
Expand Down Expand Up @@ -288,7 +288,7 @@ def pf(self, state: chex.PyTreeDef):
return f, state


class DTLZ7(DTLZ):
class DTLZ7(DTLZTestSuit):
def __init__(self, d=None, m=None, ref_num=1000):
if m is None:
self.m = 3
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _generic_zdt(f1, g, h, x):


@jit_class
class ZDT(Problem):
class ZDTTestSuit(Problem):
def __init__(self, n, ref_num=100):
self.n = n
self._zdt = None
Expand All @@ -28,7 +28,7 @@ def pf(self, state: chex.PyTreeDef):
return jnp.c_[x, 1 - jnp.sqrt(x)], state


class ZDT1(ZDT):
class ZDT1(ZDTTestSuit):
def __init__(self, n):
super().__init__(n)
f1 = lambda x: x[0]
Expand All @@ -37,7 +37,7 @@ def __init__(self, n):
self._zdt = partial(_generic_zdt, f1, g, h)


class ZDT2(ZDT):
class ZDT2(ZDTTestSuit):
def __init__(self, n):
super().__init__(n)
f1 = lambda x: x[0]
Expand All @@ -50,7 +50,7 @@ def pf(self, state: chex.PyTreeDef):
return jnp.c_[x, 1 - x**2], state


class ZDT3(ZDT):
class ZDT3(ZDTTestSuit):
def __init__(self, n):
super().__init__(n)
f1 = lambda x: x[0]
Expand All @@ -68,7 +68,7 @@ def pf(self, state: chex.PyTreeDef):
return pf, state


class ZDT4(ZDT):
class ZDT4(ZDTTestSuit):
def __init__(self, n):
super().__init__(n)
f1 = lambda x: x[0]
Expand All @@ -81,7 +81,7 @@ def __init__(self, n):
self._zdt = partial(_generic_zdt, f1, g, h)


class ZDT6(ZDT):
class ZDT6(ZDTTestSuit):
def __init__(self, n):
super().__init__(n)
f1 = lambda x: 1 - jnp.exp(-4 * x[0]) * jnp.sin(6 * jnp.pi * x[0])**6
Expand Down
15 changes: 0 additions & 15 deletions src/evox/problems/test_suit/__init__.py

This file was deleted.

0 comments on commit 3a4969d

Please sign in to comment.