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
Metadata
Release files for modde 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modde-0.0.4.tar.gz | 18.9 kB | Without provenance | Details for modde-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| modde-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for modde-0.0.4-py3-none-any.whl |
Total release size: 40.6 kB
Release files / modde-0.0.4.tar.gz
| Download URL | modde-0.0.4.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95f8182038ae928d60318bc4e25a2aea118e01fb55d133d5fbca0a46cd144fbc
|
|
BLAKE2b-256 checksum How to use checksums |
e351d838db1e16ce8dcdc494a93f12b15dd72773c81f31233d6a34baecbfe87c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.8
|
Release files / modde-0.0.4-py3-none-any.whl
| Download URL | modde-0.0.4-py3-none-any.whl |
|---|---|
| Size | 21.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1ca204b75076220e585f0009c8a5ac9c5ba4462c12f9f13667ea5d68004248b
|
|
BLAKE2b-256 checksum How to use checksums |
48e9cf52ed13c61880b4510a76a8e0fcf1fd5640129b0e8b5307293b8e48eebc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.8
|
Security for modde 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.