I am using the PyGMO package for Python, for multi-objective optimisation. I am unable to fix the dimension of the fitness function in the constructor, and the documentation is not very descriptive either. I am wondering if anyone here has had experience with PyGMO in the past: this could be fairly simple.
I try to construct a minimum example below:
from PyGMO.problem import base
from PyGMO import algorithm, population
import numpy as np
import matplotlib.pyplot as plt
def __init__(self, fdim=2):
NUM_PARAMS = 4
def _objfun_impl(self, K):
E1 = K + K
E2 = K + K
return (E1, E2, )
if __name__ == '__main__':
prob = my_problem() # Create the problem
algo = algorithm.sms_emoa(gen=100)
pop = population(prob, 50)
pop = algo.evolve(pop)
F = np.array([ind.cur_f for ind in pop]).T
ValueError: ..\..\src\problem\base.cpp,584: fitness dimension was changed inside objfun_impl().
I modified their example and this seemed to work for me.
#(...) def __init__(self, fdim=2): NUM_PARAMS = 4 # We call the base constructor as 'dim' dimensional problem, with 0 integer parts and 2 objectives. super(my_problem, self).__init__(NUM_PARAMS,0,fdim) self.set_bounds(0.01, 100) #(...)