moead_framework.algorithm.abstract_moead.AbstractMoead

class moead_framework.algorithm.abstract_moead.AbstractMoead(problem, max_evaluation, number_of_weight_neighborhood, aggregation_function, weight_file, termination_criteria=None, genetic_operator=None, parent_selector=None, mating_pool_selector=None, sps_strategy=None, offspring_generator=None, number_of_weight=None, number_of_objective=None)[source]

Bases: object

Abstract class to implement a new algorithm based on MOEA/D in the framework

https://moead-framework.github.io/framework/html/tuto.html#implement-your-own-algorithm

__init__(problem, max_evaluation, number_of_weight_neighborhood, aggregation_function, weight_file, termination_criteria=None, genetic_operator=None, parent_selector=None, mating_pool_selector=None, sps_strategy=None, offspring_generator=None, number_of_weight=None, number_of_objective=None)[source]

Constructor of the algorithm.

Parameters
  • problem – {Problem} problem to optimize

  • max_evaluation – {integer} maximum number of evaluation

  • number_of_weight_neighborhood – {integer} size of the neighborhood.

  • aggregation_function – {AggregationFunction}

  • weight_file – {string} path of the weight file. Each line represent a weight vector, each column represent a coordinate. An exemple is available here: https://github.com/moead-framework/data/blob/master/weights/SOBOL-2objs-10wei.ws

  • termination_criteria – Optional – {TerminationCriteria} The default component is {MaxEvaluation}

  • genetic_operator – Optional – {GeneticOperator} The default operator depends of the problem type (combinatorial / numerical)

  • parent_selector – Optional – {ParentSelector} The default operator depends of the number of solution required by the genetic operator

  • mating_pool_selector – Optional – {MatingPoolSelector} The default selector is {ClosestNeighborsSelector}

  • sps_strategy – Optional – {SpsStrategy} The default strategy is {SpsAllSubproblems}

  • offspring_generator – Optional – {OffspringGenerator} The default generator is {OffspringGeneratorGeneric}

  • number_of_weight – Deprecated – {integer} number of weight vector used to decompose the problem. Deprecated, remove in the next major release.

  • number_of_objective – Deprecated – {integer} number of objective in the problem. Deprecated, remove in the next major release.

Methods

__init__(problem, max_evaluation, …[, …])

Constructor of the algorithm.

generate_closest_weight_vectors()

Generate all neighborhood for each solution in the population

generate_offspring(population)

Generate a new offspring.

get_sub_problems_to_visit()

Select sub-problems to visit for the next generation.

init_z()

Initialize the reference point z

initial_population()

Initialize the population of solution

mating_pool_selection(sub_problem)

Select the set of solutions where future parents solutions will be selected according to the current sub-problem visited

optimize_sub_problem(sub_problem_index)

Execute the process to optimize the sub-problem currently iterated

repair(solution)

Repair the solution in parameter.

run([checkpoint])

Execute the algorithm.

update_current_sub_problem(sub_problem)

Update the attribute current_sub_problem

update_solutions(solution, …)

Update solutions of the population and of the external archive ep

update_z(solution)

Update the reference point z with coordinates of the solution in parameter if coordinates are better.

generate_closest_weight_vectors()[source]

Generate all neighborhood for each solution in the population

Returns

{list<List<Integer>>} List of sub-problem (neighborhood) for each solution

generate_offspring(population)[source]

Generate a new offspring. This function calls the component OffspringGenerator

Parameters

population – {list<OneDimensionSolution>} set of solutions (parents) used to generate the offspring

Returns

{OneDimensionSolution} offspring

get_sub_problems_to_visit()[source]

Select sub-problems to visit for the next generation. This function calls the component SpsStrategy

Returns

{list} indexes of sub-problems

init_z()[source]

Initialize the reference point z

Returns

initial_population()[source]

Initialize the population of solution

Returns

{List<OneDimensionSolution>}

mating_pool_selection(sub_problem)[source]

Select the set of solutions where future parents solutions will be selected according to the current sub-problem visited

Parameters

sub_problem – {integer} index of the sub-problem currently visited

Returns

{list} indexes of sub-problems

optimize_sub_problem(sub_problem_index)[source]

Execute the process to optimize the sub-problem currently iterated

Parameters

sub_problem_index – {integer} index of the sub-problem iterated

Returns

repair(solution)[source]

Repair the solution in parameter.

Parameters

solution – {OneDimensionSolution}

Returns

{OneDimensionSolution} the repaired solution

run(checkpoint=None)[source]

Execute the algorithm.

Parameters

checkpoint – {function} The default value is None. The checkpoint can be used to save data during the process. The function required one parameter of type {AbstractMoead}

Returns

list<{OneDimensionSolution}> All non-dominated solutions found by the algorithm

Example:

>>> from moead_framework.algorithm.combinatorial import Moead
>>> from moead_framework.tool.result import save_population
>>> moead = Moead(...)
>>>
>>> def checkpoint(moead_algorithm: AbstractMoead):
>>>     if moead_algorithm.current_eval % 10 == 0 :
>>>     filename = "non_dominated_solutions-eval" + str(moead_algorithm.current_eval) + ".txt"
>>>     save_population(file_name=filename, population=moead_algorithm.ep)
>>>
>>> population = moead.run(checkpoint)
update_current_sub_problem(sub_problem)[source]

Update the attribute current_sub_problem

Parameters

sub_problem – {integer} index of sub-problem

Returns

update_solutions(solution, aggregation_function, sub_problem)[source]

Update solutions of the population and of the external archive ep

Parameters
  • solution – {OneDimensionSolution} the candidate solution also called offspring

  • aggregation_function – {AggregationFunction} Aggregation function used to compare solution in a multi-objective context

  • sub_problem – {integer} index of the sub-problem currently visited

Returns

update_z(solution)[source]

Update the reference point z with coordinates of the solution in parameter if coordinates are better.

Parameters

solutionOneDimensionSolution solution used to update the reference point

Returns