jMetalPy icon indicating copy to clipboard operation
jMetalPy copied to clipboard

Problem with NSGA-2

Open Andreas-SM opened this issue 2 years ago • 0 comments

Hey there! First of all, I would like to say that jMetalPy is an incredible project and it has been helping me for quite some time now. However, I have recently encountered a problem with the NSGA-2, which I am currently using to perform a constrained single-objective optimization. In my case, some instances of decision variables can sometimes raise an error within my cost function, which actually comes from a library I am using. This is why I had to make slight changes in my evaluation function:

` def evaluate(self, solution: FloatSolution) -> FloatSolution:

    try:
        result = self.func_exp(solution=solution)
    except:
        keys = []
        for i in range(0, self.number_of_constraints):
            keys.append(i)
        constraints = dict((el, -1) for el in keys)
        self.constraints_exp = constraints
        result = np.inf

    solution.objectives[0] = result


    self.__evaluate_constraints(solution)

    return solution`

This means that whenever an instance of decision variables raises an error in my code the result to this specific vector will be np.inf, since this is a minimization problem, and none of the constraints are fulfilled ("dummy fitness/points").

While evaluating several instances of my problem and using the BasicObserver class I noticed that some of the runs would generate an initial population filled with these dummy points. Most of the time the dummy points would be sorted as having the best fitness and the final solution would be completely wrong. What should I do?

Andreas-SM avatar Jul 23 '21 16:07 Andreas-SM