pyccea.cooperation package

class pyccea.cooperation.Collaboration[source]

Bases: ABC

An abstract class for a collaborative method between individuals from different subpopulations

Methods

build_context_vector(collaborators)

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

build_context_vector(collaborators)[source]

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

Parameters:
collaborators: list

A single individual from each subpopulation that will collaborate with an individual.

Returns:
context_vector: np.ndarray

Complete problem solution composed of one individual from each subpopulation.

class pyccea.cooperation.SingleBestCollaboration[source]

Bases: Collaboration

Set the best individual from each subpopulation as a collaborator to any individual.

Methods

build_context_vector(collaborators)

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

get_collaborators(subpop_idx, indiv_idx, ...)

Set the best individual from each subpopulation as a collaborator to the individual given as a parameter.

get_collaborators(subpop_idx: int, indiv_idx: int, current_subpops: list, current_best: dict)[source]

Set the best individual from each subpopulation as a collaborator to the individual given as a parameter.

Parameters:
subpop_idxint

Index of the subpopulation to which the individual belongs.

indiv_idxint

Index of the individual in its respective subpopulation. The vector that represents the individual is obtained from the current_subpops, where the individuals were evolved and not evaluated.

current_subpopslist

Individuals from all subpopulations of the current generation (will be evaluated).

current_bestdict

Current best individual of each subpopulation and its respective evaluation.

Returns:
collaboratorslist

A single individual from each subpopulation that will collaborate with the individual given as a parameter.

class pyccea.cooperation.SingleEliteCollaboration(sample_size: int, seed: int = None)[source]

Bases: Collaboration

Randomly selects the collaborator from among the best k individuals in the subpopulation.

Methods

build_context_vector(collaborators)

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

get_collaborators(subpop_idx, indiv_idx, ...)

Set the collaborators of the individual given as a parameter as random individuals among the k best individuals in each subpopulation in the previous generation.

get_collaborators(subpop_idx: int, indiv_idx: int, previous_subpops: list, current_subpops: list, fitness: list)[source]

Set the collaborators of the individual given as a parameter as random individuals among the k best individuals in each subpopulation in the previous generation.

In the scenario of n subpopulations, the elite collaboration method involves choosing n collaborators, with one selected from each subpopulation. Notably, the individual becomes their own collaborator within their specific subpopulation, while the remaining collaborators are chosen from the top k individuals in each respective subpopulation.

Parameters:
subpop_idxint

Index of the subpopulation to which the individual belongs.

indiv_idxint

Index of the individual in its respective subpopulation. The vector that represents the individual is obtained from the current_subpops, where the individuals were evolved and not evaluated.

previous_subpopslist

Individuals from all subpopulations in the previous generation (already evaluated).

current_subpopslist

Individuals from all subpopulations of the current generation (will be evaluated).

fitnesslist

Evaluation of the individuals in all subpopulations.

Returns:
collaboratorslist

A single individual from each subpopulation that will collaborate with the individual given as a parameter.

class pyccea.cooperation.SingleRandomCollaboration(seed: int = None)[source]

Bases: Collaboration

Set a random individual from each subpopulation as a collaborator to an individual.

Methods

build_context_vector(collaborators)

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

get_collaborators(subpop_idx, indiv_idx, ...)

Randomly find a single collaborator from each subpopulation in the previous generation for the individual in the current generation given as a parameter.

get_collaborators(subpop_idx: int, indiv_idx: int, previous_subpops: list, current_subpops: list)[source]

Randomly find a single collaborator from each subpopulation in the previous generation for the individual in the current generation given as a parameter.

Parameters:
subpop_idxint

Index of the subpopulation to which the individual belongs.

indiv_idxint

Index of the individual in its respective subpopulation.

previous_subpopslist

Individuals from all subpopulations in the previous generation (already evaluated).

current_subpopslist

Individuals from all subpopulations of the current generation (will be evaluated).

Returns:
collaboratorslist

A single individual from each subpopulation that will collaborate with the individual given as a parameter.

Submodules

pyccea.cooperation.best module

class pyccea.cooperation.best.SingleBestCollaboration[source]

Bases: Collaboration

Set the best individual from each subpopulation as a collaborator to any individual.

Methods

build_context_vector(collaborators)

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

get_collaborators(subpop_idx, indiv_idx, ...)

Set the best individual from each subpopulation as a collaborator to the individual given as a parameter.

get_collaborators(subpop_idx: int, indiv_idx: int, current_subpops: list, current_best: dict)[source]

Set the best individual from each subpopulation as a collaborator to the individual given as a parameter.

Parameters:
subpop_idxint

Index of the subpopulation to which the individual belongs.

indiv_idxint

Index of the individual in its respective subpopulation. The vector that represents the individual is obtained from the current_subpops, where the individuals were evolved and not evaluated.

current_subpopslist

Individuals from all subpopulations of the current generation (will be evaluated).

current_bestdict

Current best individual of each subpopulation and its respective evaluation.

Returns:
collaboratorslist

A single individual from each subpopulation that will collaborate with the individual given as a parameter.

pyccea.cooperation.collaboration module

class pyccea.cooperation.collaboration.Collaboration[source]

Bases: ABC

An abstract class for a collaborative method between individuals from different subpopulations

Methods

build_context_vector(collaborators)

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

build_context_vector(collaborators)[source]

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

Parameters:
collaborators: list

A single individual from each subpopulation that will collaborate with an individual.

Returns:
context_vector: np.ndarray

Complete problem solution composed of one individual from each subpopulation.

pyccea.cooperation.elite module

class pyccea.cooperation.elite.SingleEliteCollaboration(sample_size: int, seed: int = None)[source]

Bases: Collaboration

Randomly selects the collaborator from among the best k individuals in the subpopulation.

Methods

build_context_vector(collaborators)

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

get_collaborators(subpop_idx, indiv_idx, ...)

Set the collaborators of the individual given as a parameter as random individuals among the k best individuals in each subpopulation in the previous generation.

get_collaborators(subpop_idx: int, indiv_idx: int, previous_subpops: list, current_subpops: list, fitness: list)[source]

Set the collaborators of the individual given as a parameter as random individuals among the k best individuals in each subpopulation in the previous generation.

In the scenario of n subpopulations, the elite collaboration method involves choosing n collaborators, with one selected from each subpopulation. Notably, the individual becomes their own collaborator within their specific subpopulation, while the remaining collaborators are chosen from the top k individuals in each respective subpopulation.

Parameters:
subpop_idxint

Index of the subpopulation to which the individual belongs.

indiv_idxint

Index of the individual in its respective subpopulation. The vector that represents the individual is obtained from the current_subpops, where the individuals were evolved and not evaluated.

previous_subpopslist

Individuals from all subpopulations in the previous generation (already evaluated).

current_subpopslist

Individuals from all subpopulations of the current generation (will be evaluated).

fitnesslist

Evaluation of the individuals in all subpopulations.

Returns:
collaboratorslist

A single individual from each subpopulation that will collaborate with the individual given as a parameter.

pyccea.cooperation.random module

class pyccea.cooperation.random.SingleRandomCollaboration(seed: int = None)[source]

Bases: Collaboration

Set a random individual from each subpopulation as a collaborator to an individual.

Methods

build_context_vector(collaborators)

Build a context vector, i.e., a complete problem solution composed of representative solutions from each subpopulation.

get_collaborators(subpop_idx, indiv_idx, ...)

Randomly find a single collaborator from each subpopulation in the previous generation for the individual in the current generation given as a parameter.

get_collaborators(subpop_idx: int, indiv_idx: int, previous_subpops: list, current_subpops: list)[source]

Randomly find a single collaborator from each subpopulation in the previous generation for the individual in the current generation given as a parameter.

Parameters:
subpop_idxint

Index of the subpopulation to which the individual belongs.

indiv_idxint

Index of the individual in its respective subpopulation.

previous_subpopslist

Individuals from all subpopulations in the previous generation (already evaluated).

current_subpopslist

Individuals from all subpopulations of the current generation (will be evaluated).

Returns:
collaboratorslist

A single individual from each subpopulation that will collaborate with the individual given as a parameter.