You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear All,
I am using pygmo to solve an optimization problem. Could you please show me how to specify a number of evaluations (fevals) in each run. Thank you very much!
My code is as follows:
# Define pygmo classs
class alge_function:
# def __init__(self):
# self.starting = np.random.randint(1,5,16)
def fitness(self, x):
x = np.array(x, dtype=int) # to make integers
x = list(x)
fsr = look_up_function(x)
vec = [fsr[1], fsr[2], fsr[3], fsr[4], fsr[5], fsr[6], fsr[7], fsr[8], fsr[9], \
fsr[10], fsr[11], fsr[12], fsr[13], fsr[14], fsr[15], fsr[16], fsr[17], fsr[18]]
obj = -choquet_pwl_function(k, mu, vec)
return [obj]
def get_nix(self):
return 16
# bounds [1,4]
def get_bounds(self):
return ([1]*16, [4] * 16)
# Algorithm of gradient
def gradient(self, x):
return pg.estimate_gradient_h(lambda x: self.fitness(x), x)
# use "slsqp"- sequential least squares programming algorithm
start = time.time()
algo = pg.algorithm(uda = pg.mbh(pg.nlopt("slsqp"), stop = 20, perturb = .2))
algo.set_verbosity(1) # print dialog
# Formulate minimization problem
pop = pg.population(prob = alge_function(), size = 2)
pop.set_x(1,starting_point)
# Solve the problem
pop = algo.evolve(pop)
# Collect information
print("objective value: obj=", pop.champion_f[0])
The text was updated successfully, but these errors were encountered:
Stopping criterions depend on the uda used. In your case mbh with nlopd inner. For nlop look here to the attribute max_fevals: https://esa.github.io/pygmo2/algorithms.html#pygmo.nlopt.maxeval, for mbh you cannot define a maximum number of fevals, but you can log them and crop later if thats what you need.
Dear All,
I am using pygmo to solve an optimization problem. Could you please show me how to specify a number of evaluations (fevals) in each run. Thank you very much!
My code is as follows:
The text was updated successfully, but these errors were encountered: