-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5070deb
commit 3c9c8be
Showing
14 changed files
with
195 additions
and
119 deletions.
There are no files selected for viewing
Empty file.
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
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 |
---|---|---|
@@ -1,54 +1,56 @@ | ||
from typing import Any | ||
|
||
from openelm.environments.environments import BaseEnvironment, Genotype | ||
from openelm.map_elites import CVTMAPElites, MAPElites | ||
from openelm.algorithms.map_elites import CVTMAPElites, MAPElites | ||
from openelm.environments.base import BaseEnvironment, Genotype | ||
|
||
|
||
def load_env(env_name: str) -> Any: | ||
if env_name == "sodarace": | ||
from openelm.environments.sodarace_env import Sodarace | ||
from openelm.environments.sodaracer.sodarace import Sodarace | ||
|
||
return Sodarace | ||
elif env_name == "image_evolution": | ||
from openelm.environments.environments import ImageOptim | ||
from openelm.environments.base import ImageOptim | ||
|
||
return ImageOptim | ||
elif env_name == "match_string": | ||
from openelm.environments.environments import MatchString | ||
from openelm.environments.base import MatchString | ||
|
||
return MatchString | ||
elif env_name == "function_optim": | ||
from openelm.environments.environments import FunctionOptim | ||
from openelm.environments.base import FunctionOptim | ||
|
||
return FunctionOptim | ||
elif env_name == "p3_probsol": | ||
from openelm.environments.p3_env import P3ProbSol | ||
from openelm.environments.p3.p3 import P3ProbSol | ||
|
||
return P3ProbSol | ||
elif env_name == "p3_problem": | ||
from openelm.environments.p3_env import P3Problem | ||
from openelm.environments.p3.p3 import P3Problem | ||
|
||
return P3Problem | ||
elif env_name == "prompt_evolution": | ||
from openelm.environments.prompt_env import PromptEvolution | ||
from openelm.environments.prompt.prompt import PromptEvolution | ||
|
||
return PromptEvolution | ||
elif env_name == "qdaif": | ||
from openelm.environments.environments import PoetryEvolution | ||
from openelm.environments.poetry import PoetryEvolution | ||
|
||
return PoetryEvolution | ||
else: | ||
raise ValueError(f"Unknown environment {env_name}") | ||
|
||
|
||
QD_DICT: dict[str, Any] = { | ||
"mapelites": MAPElites, | ||
"cvtmapelites": CVTMAPElites, | ||
} | ||
def load_algorithm(algorithm_name: str) -> Any: | ||
if algorithm_name == "mapelites": | ||
return MAPElites | ||
elif algorithm_name == "cvtmapelites": | ||
return CVTMAPElites | ||
|
||
|
||
__all__ = [ | ||
"Genotype", | ||
"BaseEnvironment", | ||
"QD_DICT", | ||
"load_algorithm", | ||
"load_env", | ||
] |
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
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
Empty file.
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
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,25 @@ | ||
import numpy as np | ||
|
||
|
||
def get_image_target(name: str) -> np.ndarray: | ||
if name == "circle": | ||
target = np.zeros((32, 32, 3)) | ||
for y in range(32): | ||
for x in range(32): | ||
if (y - 16) ** 2 + (x - 16) ** 2 <= 100: # a radius-10 circle | ||
target[y, x] = np.array([255, 255, 0]) | ||
else: | ||
raise NotImplementedError(f"Image target {name} not implemented") | ||
return target | ||
|
||
|
||
IMAGE_SEED: str = """ | ||
def draw(): | ||
\tpic = np.zeros((32, 32, 3)) | ||
\tfor x in range(2, 30): | ||
\t\tfor y in range(2, 30): | ||
\t\t\tpic[x, y] = np.array([0, 0, 255]) | ||
\treturn pic | ||
""" | ||
|
||
NULL_SEED: str = "" |
Oops, something went wrong.