initial_population_02
The function generates a random population. Combinatorial variables generator.
initial_population_02(n_population, n_dimensions, seed=None)
Input variables
Name | Description | Type |
---|---|---|
n_population | Number of population | Integer |
n_dimensions | Problem dimension | Integer |
seed | Random seed. Default is None | Integer or None |
x_pop | Population design variables | List |
Output variables
Name | Description | Type |
---|---|---|
x_pop | Population design variables | List |
Example 1
Use the initial_population_02
function to generate a new population (five agents) considering the three dimensional combinatorial problem.
# Import
# pip install metapy-toolbox or pip install --upgrade metapy-toolbox
from metapy_toolbox import initial_population_02 # or import *
# Data
nPop = 5
d = 3
# Call function
population = initial_population_02(nPop, d)
# Output details
print('particle 0: ', population[0])
print('particle 1: ', population[1])
print('particle 2: ', population[2])
print('particle 3: ', population[3])
print('particle 4: ', population[4])
particle 0: [1, 0, 2]
particle 1: [2, 1, 0]
particle 2: [2, 1, 0]
particle 3: [2, 0, 1]
particle 4: [2, 1, 0]