-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
12 changed files
with
199 additions
and
41 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
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
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,33 @@ | ||
from pymoo.operators.crossover.sbx import SBX # type: ignore | ||
from pymoo.operators.mutation.pm import PM # type: ignore | ||
from pymoo.operators.sampling.lhs import LHS # type: ignore | ||
|
||
def select_operator(operation, | ||
config, | ||
**kwargs): | ||
""" | ||
Selects either the default operator or a custom operator based on the condition. | ||
""" | ||
if kwargs is not None: | ||
kwargs = {} | ||
|
||
if config.operators[operation] is None: | ||
if operation == "mut": | ||
operator = PM | ||
if "prob" not in kwargs: | ||
kwargs["prob"] = config.prob_mutation | ||
if "eta" not in kwargs: | ||
kwargs["eta"] = config.eta_mutation | ||
elif operation == "cx": | ||
operator = SBX | ||
if "prob" not in kwargs: | ||
kwargs["prob"] = config.prob_crossover | ||
if "eta" not in kwargs: | ||
kwargs["eta"] = config.eta_crossover | ||
elif operation == "init": | ||
operator = LHS | ||
elif operation == "dup": | ||
return True | ||
else: | ||
operator = config.operators[operation] | ||
return operator(**kwargs) # Passes the keyword arguments to the operator |
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 +1 @@ | ||
__version__ = "0.1.6" | ||
__version__ = "0.1.7" |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "OpenSBT" | ||
version = "0.1.6" | ||
version = "0.1.7" | ||
authors = [ | ||
{name = "Lev Sorokin", email = "[email protected]"}, | ||
] | ||
|
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,66 @@ | ||
import os | ||
from pathlib import Path | ||
import subprocess | ||
from typing import Dict | ||
import pymoo | ||
import time | ||
|
||
from examples.carla.carla_simulation import CarlaSimulator | ||
from opensbt.experiment.experiment import Experiment | ||
from opensbt.model_ga.individual import IndividualSimulated | ||
from tests import test_base | ||
pymoo.core.individual.Individual = IndividualSimulated | ||
|
||
from opensbt.model_ga.population import PopulationExtended | ||
pymoo.core.population.Population = PopulationExtended | ||
|
||
from opensbt.model_ga.result import SimulationResult | ||
pymoo.core.result.Result = SimulationResult | ||
|
||
from opensbt.model_ga.problem import SimulationProblem | ||
pymoo.core.problem.Problem = SimulationProblem | ||
|
||
from opensbt.algorithm.nsga2_optimizer import NsgaIIOptimizer | ||
from opensbt.evaluation.critical import CriticalAdasDistanceVelocity | ||
from opensbt.experiment.search_configuration import DefaultSearchConfiguration | ||
from opensbt.evaluation.fitness import FitnessMinDistanceVelocityFrontOnly | ||
from opensbt.problem.adas_problem import ADASProblem | ||
|
||
from opensbt.experiment.experiment_store import experiments_store | ||
from default_experiments import * | ||
import logging as log | ||
|
||
class TestDefaultExperiments(): | ||
|
||
@staticmethod | ||
def test_dummy_experiments_no_args(): | ||
""" Go over all predefined experiments and run them. Right now only experiments are tested that | ||
do not require GPU access. I.e., CARLA based experiments are not tested. """ | ||
|
||
store : Dict[str, Experiment] = experiments_store.get_store() | ||
|
||
assert len(store) > 0 | ||
|
||
for name, exp in store.items(): | ||
print(exp.problem) | ||
if exp.problem.is_simulation() and exp.problem.simulate_function == CarlaSimulator.simulate: | ||
continue | ||
log.info("Starting experiment:", name) | ||
if os.path.exists('.\\venv\\Scripts\\Activate'): | ||
venv_path = '.\\venv\\Scripts\\Activate &&' | ||
prefix = ['cmd', '/c'] | ||
elif os.path.exists('.\\venv\\bin\\activate'): | ||
venv_path = '.\\venv\\bin\\activate &&' | ||
prefix = ["source"] | ||
else: | ||
venv_path = "" | ||
prefix = [""] | ||
|
||
result = subprocess.run( prefix + [f'{venv_path} python', | ||
'run.py', "-e", name], | ||
shell=True, | ||
capture_output=True, | ||
text=True) | ||
log.info("Finished experiment") | ||
|
||
assert result.returncode == 0 |
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