główny algorytm w funkcji
This commit is contained in:
parent
3ff8b95999
commit
fc54101f4e
@ -1,18 +1,16 @@
|
||||
import random
|
||||
import math
|
||||
import statistics
|
||||
import time
|
||||
|
||||
### prawdopodobieństwo mutacji
|
||||
mutation_prob = 0.02
|
||||
mutation_prob = 0.03
|
||||
### ilość osobników w pokoleniu, powinna być parzysta
|
||||
generation_size = 30
|
||||
generation_size = 20
|
||||
### liczba pokoleń
|
||||
number_of_generations = 100
|
||||
number_of_generations = 30
|
||||
### liczba paczek
|
||||
number_of_packages = 15
|
||||
number_of_packages = 45
|
||||
### liczba regałów
|
||||
number_of_racks = 5
|
||||
number_of_racks = 70
|
||||
### jak bardzo promowane są osobniki wykorzystujące całą pojemność regału
|
||||
amount_of_promotion = 3
|
||||
|
||||
@ -95,13 +93,8 @@ def mutation(individual):
|
||||
individual[locus] = random.randint(0,number_of_racks-1)
|
||||
return individual
|
||||
|
||||
### lista paczek, indeks to id paczki, wartość w liście to jej waga
|
||||
packages = [random.randint(2,9) for i in range(number_of_packages)]
|
||||
### lista regałów, indeks to id regału, wartość w liście to jego pojemność
|
||||
racks = [random.randint(10,20) for i in range(number_of_racks)]
|
||||
# print(packages)
|
||||
# print(racks)
|
||||
|
||||
def gen_alg(number_of_generations, generation_size, mutation_prob, amount_of_promotion):
|
||||
### WŁAŚCIWY ALGORYTM
|
||||
generation = first_gen()
|
||||
global_maximum = -math.inf
|
||||
@ -147,3 +140,11 @@ for generation_index in range(number_of_generations):
|
||||
global_maximum = local_maximum
|
||||
generation = descendants
|
||||
print('maximum globalne: ', global_maximum)
|
||||
|
||||
### lista paczek, indeks to id paczki, wartość w liście to jej waga
|
||||
packages = [random.randint(1,10) for i in range(number_of_packages)]
|
||||
### lista regałów, indeks to id regału, wartość w liście to jego pojemność
|
||||
racks = [random.randint(15,18) for i in range(number_of_racks)]
|
||||
# print(packages)
|
||||
# print(racks)
|
||||
gen_alg(number_of_generations, generation_size, mutation_prob, amount_of_promotion)
|
||||
|
Loading…
Reference in New Issue
Block a user