-
Notifications
You must be signed in to change notification settings - Fork 0
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
e384271
commit aeb1e95
Showing
11,230 changed files
with
11,716 additions
and
1,753,833 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
src/marl-qd-code | ||
src/pyenv-marl-qd/* |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,72 @@ | ||
class Agent: | ||
def __init__(self, name, squad, set_, tree, manual_policy, to_optimize): | ||
self._name = name | ||
self._squad = squad | ||
self._set = set_ | ||
self._tree = tree.deep_copy() if tree is not None else None | ||
self._manual_policy = manual_policy | ||
self._to_optimize = to_optimize | ||
self._score = [] | ||
|
||
def get_name(self): | ||
return self._name | ||
|
||
def get_squad(self): | ||
return self._squad | ||
|
||
def get_set(self): | ||
return self._set | ||
|
||
def to_optimize(self): | ||
return self._to_optimize | ||
|
||
def get_tree(self): | ||
return self._tree.deep_copy() | ||
|
||
def get_output(self, observation): | ||
if self._to_optimize: | ||
return self._tree.get_output(observation) | ||
else: | ||
return self._manual_policy.get_output(observation) | ||
|
||
def set_reward(self, reward): | ||
self._tree.set_reward(reward) | ||
self._score[-1] = reward | ||
|
||
def get_score_statistics(self, params): | ||
score_values = [score_dict[key] for score_dict in self._score for key in score_dict] | ||
return getattr(np, f"{params['type']}")(a=score_values, **params['params'])#Can't compare dicts with > | ||
|
||
def new_episode(self): | ||
self._score.append(0) | ||
|
||
def has_policy(self): | ||
return not self._manual_policy is None | ||
|
||
def __str__(self): | ||
return f"Name: {self._name}; Squad: {self._squad}; Set: {self._set}; Optimize: {str(self._to_optimize)}" | ||
|
||
class CoachAgent(Agent): | ||
def __init__(self, name, squad, set_, tree, manual_policy, to_optimize): | ||
super().__init__(name, squad, set_, tree, manual_policy, to_optimize) | ||
|
||
def get_output(self, observation): | ||
return super().get_output(observation) | ||
|
||
def set_reward(self, reward): | ||
return super().set_reward(reward) | ||
|
||
def get_score_statistics(self, params): | ||
return super().get_score_statistics(params) | ||
|
||
def new_episode(self): | ||
return super().new_episode() | ||
|
||
def has_policy(self): | ||
return super().has_policy() | ||
|
||
def __str__(self): | ||
return super().__str__() | ||
|
||
def select_team(self): | ||
pass |
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,13 @@ | ||
from .common import * | ||
from .continuous_optimization import * | ||
from .genetic_algorithm import * | ||
from .genetic_programming import * | ||
from .grammatical_evolution import * | ||
from .individuals import * | ||
from .map_elites import * | ||
from .map_elites_ge import * | ||
from .map_elites_Pyribs import * | ||
from .mapElitesCMA_pyRibs import * | ||
from .mapElitesCMA import * | ||
from .mapElitesCMA_pyRibs_GE import * | ||
|
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+9.57 KB
src/QD_MARL/algorithms/__pycache__/continuous_optimization.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+32.9 KB
src/QD_MARL/algorithms/__pycache__/grammatical_evolution.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+37.1 KB
src/QD_MARL/algorithms/__pycache__/mapElitesCMA_pyRibs.cpython-311.pyc
Binary file not shown.
Binary file added
BIN
+20.8 KB
src/QD_MARL/algorithms/__pycache__/mapElitesCMA_pyRibs_GE.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,49 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
src.common | ||
~~~~~~~~~~ | ||
This module contains common utilities for optimizers | ||
:copyright: (c) 2021 by Leonardo Lucio Custode. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
||
|
||
class OptMetaClass(type): | ||
_registry = {} | ||
|
||
def __new__(meta, name, bases, class_dict): | ||
cls = type.__new__(meta, name, bases, class_dict) | ||
OptMetaClass._registry[cls.__name__] = cls | ||
return cls | ||
|
||
@staticmethod | ||
def get(class_name): | ||
""" | ||
Retrieves the class associated to the string | ||
:class_name: The name of the class | ||
:returns: A class | ||
""" | ||
return OptMetaClass._registry[class_name] | ||
|
||
|
||
class ContinuousOptimizationMetaClass(type): | ||
_registry = {} | ||
|
||
def __init__(cls, clsname, bases, methods): | ||
super().__init__(clsname, bases, methods) | ||
ContinuousOptimizationMetaClass._registry[cls.__name__] = cls | ||
|
||
@staticmethod | ||
def get(class_name): | ||
""" | ||
Retrieves the class associated to the string | ||
:class_name: The name of the class | ||
:returns: A class | ||
""" | ||
return ContinuousOptimizationMetaClass._registry[class_name] | ||
|
File renamed without changes.
Oops, something went wrong.