opytimizer.optimizers.population.loa¶
Lion Optimization Algorithm.
-
class
opytimizer.optimizers.population.loa.
Lion
¶ A Lion class complements its inherited parent with additional information neeeded by the Lion Optimization Algorithm.
-
__init__
()¶ Initialization method.
Parameters: - n_variables – Number of decision variables.
- n_dimensions – Number of dimensions.
- lower_bound – Minimum possible values.
- upper_bound – Maximum possible values.
- position – Position array.
- fit – Fitness value.
-
best_position
¶ N-dimensional array of best positions.
-
p_fit
¶ Previous fitness value.
-
nomad
¶ Whether lion is nomad or not.
Type: bool
-
female
¶ Whether lion is female or not.
-
pride
¶ Index of pride.
-
group
¶ Index of hunting group.
-
-
class
opytimizer.optimizers.population.loa.
LOA
(params: Optional[Dict[str, Any]] = None)¶ An LOA class, inherited from Optimizer.
This is the designed class to define LOA-related variables and methods.
References
M. Yazdani and F. Jolai. Lion Optimization Algorithm (LOA): A nature-inspired metaheuristic algorithm. Journal of Computational Design and Engineering (2016).
-
__init__
(params: Optional[Dict[str, Any]] = None) → None¶ Initialization method.
Parameters: params – Contains key-value parameters to the meta-heuristics.
-
N
¶ Percentage of nomad lions.
-
P
¶ Number of prides.
-
S
¶ Percentage of female lions.
-
R
¶ Percentage of roaming lions.
-
I
¶ Immigrate rate.
-
Ma
¶ Mating probability.
-
Mu
¶ Mutation probability.
-
compile
(space: opytimizer.core.space.Space) → None¶ Compiles additional information that is used by this optimizer.
Parameters: space – A Space object containing meta-information.
-
_get_nomad_lions
(agents: List[opytimizer.optimizers.population.loa.Lion]) → List[opytimizer.optimizers.population.loa.Lion]¶ Gets all nomad lions.
Parameters: agents – Agents. Returns: A list of nomad lions. Return type: (List[Lion])
-
_get_pride_lions
(agents: List[opytimizer.optimizers.population.loa.Lion]) → List[List[opytimizer.optimizers.population.loa.Lion]]¶ Gets all non-nomad (pride) lions.
Parameters: agents – Agents. Returns: A list of lists, where each one indicates a particular pride with its lions. Return type: (List[List[Lion]])
-
_hunting
(prides: List[opytimizer.optimizers.population.loa.Lion], function: opytimizer.core.function.Function) → None¶ Performs the hunting procedure (s. 2.2.2).
Parameters: - prides – List of prides holding their corresponding lions.
- function – A Function object that will be used as the objective function.
-
_moving_safe_place
(prides: List[opytimizer.optimizers.population.loa.Lion]) → None¶ Move prides to safe locations (s. 2.2.3).
Parameters: prides – List of prides holding their corresponding lions.
-
_roaming
(prides: List[opytimizer.optimizers.population.loa.Lion], function: opytimizer.core.function.Function) → None¶ Performs the roaming procedure (s. 2.2.4).
Parameters: - prides – List of prides holding their corresponding lions.
- function – A Function object that will be used as the objective function.
-
_mating_operator
(agent: List[opytimizer.optimizers.population.loa.Lion], males: List[opytimizer.optimizers.population.loa.Lion], function: opytimizer.core.function.Function) → Tuple[opytimizer.optimizers.population.loa.Lion, opytimizer.optimizers.population.loa.Lion]¶ Wraps the mating operator.
Parameters: - agent – Current agent.
- males – List of males that will be breed.
- function – A Function object that will be used as the objective function.
Returns: A pair of offsprings that resulted from mating.
Return type:
-
_mating
(prides: List[opytimizer.optimizers.population.loa.Lion], function: opytimizer.core.function.Function) → opytimizer.optimizers.population.loa.Lion¶ Generates offsprings from mating (s. 2.2.5).
Parameters: - prides – List of prides holding their corresponding lions.
- function – A Function object that will be used as the objective function.
Returns: Cubs generated from the mating procedure.
Return type: (Lion)
-
_defense
(nomads: List[opytimizer.optimizers.population.loa.Lion], prides: List[List[opytimizer.optimizers.population.loa.Lion]], cubs: List[opytimizer.optimizers.population.loa.Lion]) → Tuple[List[opytimizer.optimizers.population.loa.Lion], List[List[opytimizer.optimizers.population.loa.Lion]]]¶ Performs the defense procedure (s. 2.2.6).
Parameters: - nomads – Nomad lions.
- prides – List of prides holding their corresponding lions.
- cubs – List of cubs holding their corresponding lions.
Returns: Both updated nomad and pride lions.
Return type:
-
_nomad_roaming
(nomads: List[opytimizer.optimizers.population.loa.Lion], function: opytimizer.core.function.Function) → None¶ Performs the roaming procedure for nomad lions (s. 2.2.4).
Parameters: - nomads – Nomad lions.
- function – A Function object that will be used as the objective function.
-
_nomad_mating
(nomads: List[opytimizer.optimizers.population.loa.Lion], function: opytimizer.core.function.Function) → List[opytimizer.optimizers.population.loa.Lion]¶ Generates offsprings from nomad lions mating (s. 2.2.5).
Parameters: - nomads – Nomad lions.
- function – A Function object that will be used as the objective function.
Returns: Updated nomad lions.
Return type: (List[Lion])
-
_nomad_attack
(nomads: List[opytimizer.optimizers.population.loa.Lion], prides: List[List[opytimizer.optimizers.population.loa.Lion]]) → Tuple[List[opytimizer.optimizers.population.loa.Lion], List[List[opytimizer.optimizers.population.loa.Lion]]]¶ Performs the nomad’s attacking procedure (s. 2.2.6).
Parameters: - nomads – Nomad lions.
- prides – List of prides holding their corresponding lions.
Returns: Both updated nomad and pride lions.
Return type:
-
_migrating
(nomads: List[opytimizer.optimizers.population.loa.Lion], prides: List[List[opytimizer.optimizers.population.loa.Lion]]) → Tuple[List[opytimizer.optimizers.population.loa.Lion], List[List[opytimizer.optimizers.population.loa.Lion]]]¶ Performs the nomad’s migration procedure (s. 2.2.7).
Parameters: - nomads – Nomad lions.
- prides – List of prides holding their corresponding lions.
Returns: Both updated nomad and pride lions.
Return type:
-
_equilibrium
(nomads: List[opytimizer.optimizers.population.loa.Lion], prides: List[List[opytimizer.optimizers.population.loa.Lion]], n_agents: List[opytimizer.core.agent.Agent]) → Tuple[List[opytimizer.optimizers.population.loa.Lion], List[List[opytimizer.optimizers.population.loa.Lion]]]¶ Performs the population’s equilibrium procedure (s. 2.2.8).
Parameters: - nomads – Nomad lions.
- prides – List of prides holding their corresponding lions.
Returns: Both updated nomad and pride lions.
Return type:
-
_check_prides_for_males
(prides: List[List[opytimizer.optimizers.population.loa.Lion]]) → None¶ Checks if there is at least one male per pride.
Parameters: prides – List of prides holding their corresponding lions.
-
update
(space: opytimizer.core.space.Space, function: opytimizer.core.function.Function) → None¶ Wraps Lion Optimization Algorithm over all agents and variables.
Parameters: - space – Space containing agents and update-related information.
- function – A Function object that will be used as the objective function.
-