Esempio n. 1
0
#!/usr/bin/env python
# ------------------------------------------------------------------------------------------------------%
# Created by "Thieu Nguyen" at 10:11, 16/03/2020                                                        %
#                                                                                                       %
#       Email:      [email protected]                                                           %
#       Homepage:   https://www.researchgate.net/profile/Thieu_Nguyen6                                  %
#       Github:     https://github.com/thieunguyen5991                                                  %
#-------------------------------------------------------------------------------------------------------%

from opfunu.type_based.uni_modal import Functions
from mealpy.evolutionary_based.GA import BaseGA

t1 = Functions()

root_paras = {
    "problem_size": 30,
    "domain_range": [-15, 15],
    "print_train": True,
    "objective_func": t1._sum_squres__
}

## Setting parameters
epoch = 100
pop_size = 50
pc = 0.95
pm = 0.025

md = BaseGA(root_paras, epoch, pop_size, pc, pm)
best_position, best_fit, list_loss = md._train__()
print(best_fit)
Esempio n. 2
0
#!/usr/bin/env python
# ------------------------------------------------------------------------------------------------------%
# Created by "Thieu Nguyen" at 22:08, 22/05/2020                                                        %
#                                                                                                       %
#       Email:      [email protected]                                                           %
#       Homepage:   https://www.researchgate.net/profile/Thieu_Nguyen6                                  %
#       Github:     https://github.com/thieunguyen5991                                                  %
#-------------------------------------------------------------------------------------------------------%

from mealpy.evolutionary_based.GA import BaseGA
from opfunu.cec_basic.cec2014_nobias import *

## Setting parameters
objective_func = F1
problem_size = 100
domain_range = [-100, 100]
log = True

epoch = 100
pop_size = 50

md1 = BaseGA(objective_func, problem_size, domain_range, log, epoch, pop_size)
best_pos1, best_fit1, list_loss1 = md1._train__()
print(best_fit1)