Package Containing Modular DE optimizer
Project description
Modular DE
This work-in-progress repository contains the code used to create a modular version of differential evolution.
Basic use-case: L-SHADE
To instantiate L-SHADE using modDE and optimize a function (using iohexperimenter), the following code can be used:
from modularde import ModularDE
import ioh
import numpy as np
f = ioh.get_problem(23, 1, 5)
lshade = ModularDE(f, base_sampler='uniform', mutation_base='target', mutation_reference='pbest', bound_correction='expc_center', crossover='bin', lpsr=True, lambda_ = 18*5, memory_size = 6, use_archive=True, init_stats=True, adaptation_method_F='shade', adaptation_method_CR='shade')
lshade.run()
To perform a larger benchmark experiment which includes tracking of internal parameters, the following can be used (note that running the full experiment with detailed tracking will use a significant amount of storage):
class LSHADE_interface():
def __init__(self, bound_corr):
self.bound_corr = bound_corr
self.lshade = None
def __call__(self, f):
self.lshade = ModularDE(f, base_sampler='uniform', mutation_base='target', mutation_reference='pbest', bound_correction = self.bound_corr, crossover='bin', lpsr=True, lambda_ = 18*f.meta_data.n_variables, memory_size = 6, use_archive=True, init_stats = True, adaptation_method_F='shade', adaptation_method_CR='shade')
self.lshade.run()
@property
def F(self):
if self.lshade is None:
return 0
return self.lshade.parameters.stats.curr_F
@property
def CR(self):
if self.lshade is None:
return 0
return self.lshade.parameters.stats.curr_CR
@property
def CS(self):
if self.lshade is None:
return 0
return self.lshade.parameters.stats.CS
@property
def ED(self):
if self.lshade is None:
return 0
return self.lshade.parameters.stats.ED
@property
def cumulative_corrected(self):
if self.lshade is None:
return 0
return self.lshade.parameters.stats.corr_so_far
@property
def corrected(self):
if self.lshade is None:
return 0
return self.lshade.parameters.stats.corrected
obj = LSHADE_interface('saturate')
exp = ioh.Experiment(algorithm = obj, #Set the optimization algorithm
fids = range(1,25), iids = [1,2,3,4,5], dims = [5,30], reps = 5, problem_type = 'Real', #Problem definitions
njobs = 12, logger_triggers = [ioh.logger.trigger.ALWAYS],#Enable paralellization
logged = True, folder_name = f'L-SHADE_sat', algorithm_name = f'L-SHADE', store_positions = True, #Logging specifications
experiment_attributes = {'SDIS' : 'Saturate'}, logged_attributes = ['corrected', 'cumulative_corrected', 'F', 'CR', 'CS', 'ED'], #Attribute tracking
merge_output = True, zip_output = True, remove_data = True #Only keep data as a single zip-file
)
exp()
The design of this package is heavily based on the Modular CMA-ES package: https://github.com/IOHprofiler/ModularCMAES
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file modde-0.0.4.tar.gz
.
File metadata
- Download URL: modde-0.0.4.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95f8182038ae928d60318bc4e25a2aea118e01fb55d133d5fbca0a46cd144fbc |
|
MD5 | 82eaeba2b617cef39704b4a8bff2b7e1 |
|
BLAKE2b-256 | e351d838db1e16ce8dcdc494a93f12b15dd72773c81f31233d6a34baecbfe87c |
File details
Details for the file modde-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: modde-0.0.4-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1ca204b75076220e585f0009c8a5ac9c5ba4462c12f9f13667ea5d68004248b |
|
MD5 | 2d33f47f09f00ea591b0a3cef431fb6e |
|
BLAKE2b-256 | 48e9cf52ed13c61880b4510a76a8e0fcf1fd5640129b0e8b5307293b8e48eebc |