metaheuristic_designer.benchmarks package#
Submodules#
- metaheuristic_designer.benchmarks.benchmark_funcs module
- metaheuristic_designer.benchmarks.classic_problems module
- metaheuristic_designer.benchmarks.img_funcs module
- metaheuristic_designer.benchmarks.ioh_wrapper module
Module contents#
Benchmarking objective functions provided by the library to test algorithms.
- class MaxOnes(dimension, mode='max', constraint_handler=None)[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(population_matrix)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class DiophantineEq(dimension, coeff, target, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class SleepTest(dimension, sleep_time=2, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class Sphere(dimension, mode='min', constraint_handler=None)[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class HighCondElliptic(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class BentCigar(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class Discus(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class Rosenbrock(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class Ackley(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class Weierstrass(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class Griewank(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class Rastrigin(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class ModSchwefel(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class Katsuura(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class HappyCat(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class HGBat(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class ExpandedGriewankPlusRosenbrock(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class ExpandedShafferF6(dimension, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class SumPowell(dimension, mode='min', lim_min=-1, lim_max=1)[source]#
Bases:
ObjectiveFuncSum of Powell function
- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class N4XinSheYang(dimension, mode='min', lim_min=-10, lim_max=10)[source]#
Bases:
ObjectiveFuncN4 Xin-She Yang function
- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class ImgApprox(img_dim, reference, mode=None, img_name='', diff_func='MSE', name=None)[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class ImgEntropy(img_dim, nbins=10, mode=None)[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class ImgStd(img_dim, mode=None)[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- class ThreeSAT(clauses)[source]#
Bases:
ObjectiveFuncThis is the 3-SAT problem that consist in finding if a logical expression given in 3CNF (conjunctive normal form with 3 variables per clause) is satisfiable, in other words, if there is a combination of boolean variables that makes it true.
Format based on https://www.cs.ubc.ca/%7Ehoos/SATLIB/benchm.html
- Parameters:
- clauses: ndarray
A representation of the clauses that defines the logical expression, this will be a matrix of size (n,3), where each component is the index (starting at 1) of the variable in this clause, negation is represented as negative numbers.
For example, the expression (¬a ∨ b ∨ ¬c) ∧ (a ∨ ¬b ∨ d) is represented as [[-1, 2, -3], [1, -2, 4]]
- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Calculates the percentage of clauses satisfied in the logical expression.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
from_cnf_file
- class BinKnapsack(cost, value, max_weight)[source]#
Bases:
ObjectiveFuncThis is the 0-1 Knapsack problem that consist in choosing from set of elements which have a certain cost and value to maximize the value without reaching a weight threshold.
- Parameters:
- cost: ndarray
The cost associated to each of the elements.
- value: ndarray
The value associated to each of the elements.
- max_weight: float
The maximum weight.
- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)Calculates the total value of the selection of elements.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
repair_solution
- objective(solution)[source]#
Calculates the total value of the selection of elements. If the weight is higher than the maximum weight, the value is replaced by the negative weight of the elements.
- Parameters:
- solution: ndarray
A binary vector deciding whether to choose or not each element.
- Returns:
- value: float
The total value of the objects.
- class MaxClique(adjacency_matrix)[source]#
Bases:
ObjectiveFuncThis is the Maximum clique problem which consists on finding the size of the largest subgraph that has all its nodes interconnected (a clique).
- Parameters:
- adjacency_matrix: ndarray
The adjacency matrix of the graph.
- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solution)repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- objective(solution)[source]#
- Parameters:
- solution: ndarray
A sequence of nodes that will be read from left to right, starting from the first node that creates a clique of size 0, checking if adding a new node from the sequence produces a clique of a larger size. If this is not the case the algorithm ends.
- Returns:
- clique_size: int
The size of the clique generated with this sequence
- class TSP(adjacency_matrix, name=None, mode='min')[source]#
Bases:
ObjectiveFunc- Attributes:
paramsAccess parameter values by attribute-style lookup.
- Parameters:
adjacency_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])
name (str)
mode (str)
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
from_csv(problem_path[, name, mode])Constructs the objective function from a .csv file.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(solutions)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- classmethod from_csv(problem_path, name=None, mode='min')[source]#
Constructs the objective function from a .csv file.
- Parameters:
- problem_pathPath
Path to the .csv file containing the weights of each edge. The expected format of the file is a table with 3 columns: Edge 1, Edge 2, Weights
- namestr, optional
Name to use when showing the user which function is being optimized, by default None
- modestr, optional
Optimization mode to use, by default “min”
- Returns:
- An object of type TSP (Objective function on vectors)
- Parameters:
problem_path (Path)
name (str | None)
mode (str)
- objective(solutions)[source]#
Implementation of the objective function.
- Return type:
ndarray[tuple[int],floating] |ndarray[tuple[int],integer] |ndarray[tuple[int],uint8|bool]- Parameters:
- solution: Any
The solution for which the fitness will be calculated.
- Returns:
- objective_value: VectorLike | ScalarLike
Value of the objective function given a solution.
- Parameters:
solutions (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])
- class IOHObjective(fid, dimension, instance=1, problem_class=None, compact_name=False)[source]#
Bases:
ObjectiveFuncAdapts an IOH benchmark problem to the ObjectiveFunc interface.
- Parameters:
- fidint or str
BBOB function ID (1-24) or name (e.g.
"Sphere").- dimensionint
Problem dimensionality.
- instanceint, optional
Problem instance (default 1).
- problem_classProblemClass, optional
IOH problem type (default
ProblemClass.BBOB).- ioh_optionsdict, optional
Extra keyword arguments passed to
ioh.get_problem.- compact_namestr, optional
Use a shortened name for the benchmark when compact_name is True.
- Attributes:
paramsAccess parameter values by attribute-style lookup.
- Parameters:
fid (int | str)
dimension (int)
instance (int)
problem_class (None)
compact_name (bool)
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(x)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
attach_logger
detach_logger
- class BBOBObjective(fid, dimension, instance, compact_name=None)[source]#
Bases:
IOHObjective- Attributes:
paramsAccess parameter values by attribute-style lookup.
Methods
__call__(population)Shorthand for executing the objective function on a vector.
add_parameter_constraints(...)Attach extra constraint handlers for extended encodings (e.g., PSO).
calculate_fitness(population)Evaluate fitness for the whole population.
get_params()Return a copy of the current parameter dictionary.
get_state()Return a dictionary with the current configuration.
objective(x)Implementation of the objective function.
repair_population(population)Transforms an invalid vector into one that satisfies the restrictions of the problem.
restart()Reset the evaluation counter to zero.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Re-evaluate all stored parameters at the current progress.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
attach_logger
detach_logger