swimpy.optimization¶
A collection of Evolutionary Multiobjective Optimization Algorithms.
The algorithm implementation is provided by the evoalgos package. This module implements them for SWIM.
The algorithms are described here: https://ls11-www.cs.tu-dortmund.de/people/swessing/evoalgos/doc/algo.html
To run the algorithm either via SLURM (sbatch jobfiles) or python native multiprocessing, import any of the algorithms in your settings.py file and execute them as a project method. Refer to the docs of the __call__ method for help.
- class swimpy.optimization._EvoalgosSwimProblem(project)[source]¶
The evoalgos.Problem to be run with any of the algorithms provided.
- __call__(parameters=None, objectives=None, population_size=10, max_generations=10, output=None, restart=False, test=None, prefix=None, keep_clones=False, **kwargs)[source]¶
Run the optimisation algorithm.
- Parameters
parameters (dict of {'name': (lower, upper)}) – Dictionary of parameter names and upper and lower boundaries as values (by default) or any other values to determine their initial value if the
create_start_population
method is overridden. This is only a keyword parameter to allow setting it via the settings file.objectives (list of strings or dict of strings) – Performance indicators passed to project.run. Only strings are accepted. Pass a dict to redefine names.
population_size (int) – Population size the algorithm is run with. By default this is also the
num_offspring
argument to the algorithm.max_generation (int) – Maximum number of iterations the algorithm is run with.
output (string path, optional) – Output .csv file with saved parameters and performances for each generation and individual (default: [<prefix>_]<algorithm>_populations.csv).
test (bool | None) – Only run tests before running algorithm if True, dont run them if False and run them before running the algorithm if None (default).
prefix (str, optional) – A prefix to use for run tags and project clones. Defaults to algorithm name.
restart (bool) – Attempt to restart the algorithm if output exists.
keep_clones (bool) – Do not remove the project clones when completed and run the final population in them.
kwargs – Any overriding parameter parsed to the algorithm (for details see the algorithm descriptions at: https://ls11-www.cs.tu-dortmund.de/people/swessing/evoalgos/doc/algo.html)
- Returns
<browser.Run> – A run instance with the mean objective values as indicators, the mean parameter values of the last generation and the output file attached.
Settings
——–
All keyword arguements (<plugin>_<kwarg> = value)
- algorithm = None¶
Default algorithm
- batch_evaluate(individuals)[source]¶
Evaluate/run a batch of individuals/projects in parallel.
- Parameters
individuals (list of <evoalgos.Individual>s) –
- create_individual(parameters, **kwargs)[source]¶
Create a single evoalgos individual with parameters and bounds.
- create_start_population()[source]¶
Create the initial population out of the parameter boundaries.
- Returns
- Return type
list of evoalgos.individual.SBXIndividual s
- mean_generation_time()[source]¶
Calculate the average time taken for a generation to finish.
- Returns
- Return type
datetime.timedelta
- nanval = 2e+31¶
Value to use if nan is returned by objective function
- observe_population(ea, initial=False)[source]¶
Evoalgos function to write the population to the output file.
The function only takes the algorithm instance as first argument and doesnt return anything.
- output_attribute_columns = ['generation', 'id_number', 'clone', 'birthgeneration']¶
Attributes of individuals written to output
- run_tests(quiet=False)[source]¶
Execute a series of tests before running the algorithm.
Tests:
creates clone
calls self.set_parameters
runs clone
checks if returned run contains the same number of indicators as self.indicators
checks if retrived_objectives return same number of values as self.objectives
- set_parameters(clonedproject, parameters)[source]¶
Default parameter setting in method for convenient overriding.
- Parameters
clonedproject (<swimpy.Project>) – Instance of the cloned project.
parameters (dict) – Parameters to set.
- time_safty_factor = 3¶
factor to multiply the average runtime for job time out estimation