Exemplo n.º 1
0
 def __init__(self, obj_func=None, lb=None, ub=None, verbose=True, epoch=750, pop_size=100, alpha=0.7, r1=2.35, **kwargs):
     BaseLCBO.__init__(self, obj_func, lb, ub, verbose, epoch, pop_size, r1, kwargs = kwargs)
     self.n1 = int(ceil(sqrt(self.pop_size)))                    # n best position in LCBO
     self.n2 = self.n1 + int((self.pop_size - self.n1) / 2)      # 50% for both 2 group left
     self.n_best = int(sqrt(self.pop_size))                      # n nest position in CE
     self.alpha = alpha                                          # alpha in CE
     self.epoch_ce = int(sqrt(epoch))                            # Epoch in CE
     self.means, self.stdevs = None, None
Exemplo n.º 2
0
 def __init__(self, objective_func=None, problem_size=50, domain_range=(-1, 1), log=True, epoch=750, pop_size=100, alpha=0.7, r1=2.35):
     BaseLCBO.__init__(self, objective_func, problem_size, domain_range, log, epoch, pop_size, r1)
     self.n1 = int(ceil(sqrt(self.pop_size)))                    # n best solution in LCBO
     self.n2 = self.n1 + int((self.pop_size - self.n1) / 2)      # 50% for both 2 group left
     self.n_best = int(sqrt(self.pop_size))                      # n nest solution in CE
     self.alpha = alpha                                          # alpha in CE
     self.epoch_ce = int(sqrt(epoch))                            # Epoch in CE
     self.means, self.stdevs = None, None
Exemplo n.º 3
0
from opfunu.cec_basic.cec2014_nobias import *
from mealpy.human_based.LCBO import BaseLCBO, LevyLCBO, ImprovedLCBO

## Setting parameters
obj_func = F11
# lb = [-15, -10, -3, -15, -10, -3, -15, -10, -3, -15, -10, -3, -15, -10, -3]
# ub = [15, 10, 3, 15, 10, 3, 15, 10, 3, 15, 10, 3, 15, 10, 3]
lb = [-100]
ub = [100]
problem_size = 2000
batch_size = 25
verbose = True
epoch = 1000
pop_size = 50

md1 = BaseLCBO(obj_func, lb, ub, problem_size, batch_size, verbose, epoch,
               pop_size)
best_pos1, best_fit1, list_loss1 = md1.train()
print(md1.solution[0])
print(md1.solution[1])
print(md1.loss_train)

md1 = LevyLCBO(obj_func, lb, ub, problem_size, batch_size, verbose, epoch,
               pop_size)
best_pos1, best_fit1, list_loss1 = md1.train()
print(md1.solution[0])
print(md1.solution[1])
print(md1.loss_train)

md1 = ImprovedLCBO(obj_func, lb, ub, problem_size, batch_size, verbose, epoch,
                   pop_size)
best_pos1, best_fit1, list_loss1 = md1.train()
Exemplo n.º 4
0
pop_size = 50

lb = [-1] * 30
ub = [1000] * 30

# A - Different way to provide lower bound and upper bound. Here are some examples:

## 1. When you have different lower bound and upper bound for each parameters
lb1 = [-3, -5, 1]
ub1 = [5, 10, 100]

md1 = ModifiedLCO(obj_func, lb, ub, verbose, epoch, pop_size)
best_pos1, best_fit1, list_loss1 = md1.train()
print(md1.solution[1])

md1 = BaseLCBO(obj_func, lb, ub, verbose, epoch, pop_size)
best_pos1, best_fit1, list_loss1 = md1.train()
print(md1.solution[1])

## 2. When you have same lower bound and upper bound for each parameters, then you can use:
##      + int or float: then you need to specify your problem size (number of dimensions)
problemSize = 10
lb2 = -5
ub2 = 10
md2 = BaseLCBO(obj_func,
               lb2,
               ub2,
               verbose,
               epoch,
               pop_size,
               problem_size=problemSize)  # Remember the keyword "problem_size"
Exemplo n.º 5
0
best_pos1, best_fit1, list_loss1 = md1._train__()
print(best_fit1)
print("========================================================")

md2 = CEBaseLCBO(objective_func, problem_size, domain_range, log, epoch, pop_size)
best_pos2, best_fit2, list_loss2 = md2._train__()
print(best_fit2)
print("========================================================")

md2 = CEBaseLCBONew(objective_func, problem_size, domain_range, log, epoch, pop_size)
best_pos2, best_fit2, list_loss2 = md2._train__()
print(best_fit2)
print("========================================================")


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

md2 = LevyLCBO(objective_func, problem_size, domain_range, log, epoch, pop_size)
best_pos2, best_fit2, list_loss2 = md2._train__()
print(best_fit2)
print("========================================================")

md2 = ImprovedLCBO(objective_func, problem_size, domain_range, log, epoch, pop_size)
best_pos2, best_fit2, list_loss2 = md2._train__()
print(best_fit2)
print("========================================================")

Exemplo n.º 6
0
#-------------------------------------------------------------------------------------------------------%

from opfunu.type_based.uni_modal import Functions
from mealpy.human_based.LCBO import BaseLCBO, LevyLCBO, ImprovedLCBO

t1 = Functions()

## Setting parameters
objective_func = t1._sum_squres__
problem_size = 3000
domain_range = [-15, 15]
log = True
epoch = 100
pop_size = 50

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

md2 = LevyLCBO(objective_func, problem_size, domain_range, log, epoch,
               pop_size)
best_pos2, best_fit2, list_loss2 = md2._train__()
print(best_fit2)
print("========================================================")

md3 = ImprovedLCBO(objective_func, problem_size, domain_range, log, epoch,
                   pop_size)
best_pos3, best_fit3, list_loss3 = md3._train__()
print(best_fit3)