Esempio n. 1
0
## 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()
print(md1.solution[0])
Esempio n. 2
0
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"
best_pos1, best_fit1, list_loss1 = md2.train()
print(md2.solution[1])

##      + array: 2 ways
lb3 = [-5]
ub3 = [10]
md3 = BaseLCBO(obj_func,
               lb3,
               ub3,
               verbose,
               epoch,
               pop_size,
               problem_size=problemSize)  # Remember the keyword "problem_size"
best_pos1, best_fit1, list_loss1 = md3.train()
print(md3.solution[1])