-
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
7 changed files
with
311 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,33 @@ | ||
from irace import ParameterSpace, Categorical, Real, Integer, Bool | ||
import irace.params as p | ||
from irace import ParameterSpace, Categorical, Real, Integer, Bool, Scenario, Experiment, irace | ||
|
||
parameter_space = ParameterSpace([ | ||
Categorical('algorithm', ['as', 'mmas', 'eas', 'ras', 'acs']), | ||
Categorical('localsearch', [0, 1, 2, 3]), | ||
Real('alpha', 0, 5), | ||
Real('beta', 0, 10), | ||
Real('rho', 0.01, 1), | ||
Integer('ants', 5, 100), | ||
Integer('nnls', 5, 50), | ||
Real('q0', 0, 1, condition=p.ValueOf('algorithm').eq('acs')), | ||
Integer('rasrank', 1, p.ValueOf('ants').min(10), condition=p.ValueOf('algorithm').eq('ras')), | ||
Integer('elistants', 1, p.ValueOf('ants')), | ||
Integer('nnls', 5, 50, condition=p.ValueOf('localsearch').isin([1, 2, 3])), | ||
Bool('dlb', condition=p.ValueOf('localsearch').isin([1, 2, 3])), | ||
], forbidden=[p.all(p.ValueOf('alpha').eq(0), p.ValueOf('beta').eq(0))]) | ||
|
||
scenario = Scenario( | ||
max_experiments=300, | ||
verbose=100, | ||
seed=42, | ||
) | ||
|
||
if __name__ == '__main__': | ||
parameter_space = ParameterSpace([ | ||
Categorical('algorithm', ['as', 'mmas', 'eas', 'ras', 'acs']), | ||
Categorical('localsearch', [0, 1, 2, 3]), | ||
Real('alpha', 0, 5), | ||
Real('beta', 0, 10), | ||
Real('rho', 0.01, 1), | ||
Integer('ants', 5, 100), | ||
Integer('nnls', 5, 50), | ||
Real('q0', 0, 1), | ||
Bool('dlb'), | ||
Integer('rasrank', 1, "ants"), | ||
Integer('elistants', 1, 750), | ||
]) | ||
|
||
def target_runner(experiment: Experiment, _) -> float: | ||
return experiment.configuration['alpha'] * experiment.configuration['beta'] | ||
|
||
|
||
if __name__ == '__main__': | ||
print(parameter_space) | ||
result = irace(target_runner, parameter_space, scenario, return_df=True) | ||
print(result) |
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,26 +1,13 @@ | ||
from dataclasses import dataclass | ||
from typing import Any, Optional | ||
|
||
|
||
@dataclass | ||
class Experiment: | ||
"""Metadata about the current experiment i.e. target runner execution.""" | ||
"""Metadata about the current experiment, i.e. target runner execution.""" | ||
|
||
configuration_id: str | ||
instance_id: Optional[str] | ||
instance: Optional[Any] | ||
seed: int | ||
bound: int | ||
configuration: dict[str, Any] | ||
|
||
def __init__( | ||
self, | ||
configuration_id: str, | ||
instance_id: Optional[str], | ||
instance: Optional[Any], | ||
seed: int, | ||
configuration: dict[str, Any], | ||
) -> None: | ||
self.configuration_id = configuration_id | ||
self.instance_id = instance_id | ||
self.seed = seed | ||
self.instance = instance | ||
self.configuration = configuration |
Oops, something went wrong.