I am trying to do a optimization using pygmo. I am facing an error from the pygmo package. It is basically a vector optimisation. I get the following error when i initiate the population: "TypeError: No registered converter was able to produce a C++ rvalue of type double from this Python object of type numpy.ndarray"
I have tried to remove the scipy command from my function but my function throws error.
class square_fit:
def fitness(self,rect_length):
sq_area = rect_width*rect_length
pulse_area =sc.integrate.simps(vge_reg, dx=0.1)
rmse = pulse_area-sq_area
return [sq_area,pulse_area,rmse]
def get_bounds(self):
return ([2.5],[3.633])
algo = pg.algorithm(uda = pg.nlopt('auglag'))
algo.extract(pg.nlopt).local_optimizer = pg.nlopt('var2')
algo.set_verbosity(200)
pop = pg.population(prob = square_fit(), size = 1) # error happens
pop.problem.c_tol = [1E-6] * 6
pop = algo.evolve(pop)
I want to know if i can do a optimization in pygmo by including command from other python packages like numpy or scipy in my cost function. what is c++rvalue and which variable is referred to as numpy.ndarray
I found the reason for this error. You just need to define the return type of the variables that are returned by the fitness function.