jMetalPy icon indicating copy to clipboard operation
jMetalPy copied to clipboard

Equality Constraints

Open magal1337 opened this issue 2 years ago • 6 comments

Hi Guys, Does anyone has any example on how to define a problem with some equality and inequality constraints? I read about Overall Constraint violations but can't figure out how to create an practical example...

magal1337 avatar Jun 22 '22 04:06 magal1337

You can find examples here: https://github.com/jMetal/jMetalPy/blob/main/jmetal/problem/multiobjective/unconstrained.py Some of the problems are defined in https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=996017

ajnebro avatar Jun 22 '22 08:06 ajnebro

About using equality constraints, I have never worked with problems having such kind of constraints, but I think that you can convert them into inequality constraints by using an epsilon value.

ajnebro avatar Jun 22 '22 08:06 ajnebro

Hi @ajnebro you mean something like: x + 3 = 0 to x + 3 - $e$ <= 0 and $e$ need to be a little less then (x+3) ???

magal1337 avatar Jun 22 '22 12:06 magal1337

I remember that someone mentioned that alternative (with a very low value of e, e.g., 0.00000001) in a paper. I don't know how effective it can be, but it is worth a try.

ajnebro avatar Jun 22 '22 13:06 ajnebro

Hi @magal1337 I recevied your message with the codes but I would need to know how to instantiate the problem:

if __name__ == "__main__":

    problem = RoutesOpt()

    algorithm = NSGAII(
        problem=problem,
        population_size=100,
        offspring_population_size=100,
        mutation=CompositeMutation([IntegerPolynomialMutation(0.01, 20), PolynomialMutation(0.01, 20.0)]),
        crossover=CompositeCrossover(
            [
                IntegerSBXCrossover(probability=1.0, distribution_index=20),
                SBXCrossover(probability=1.0, distribution_index=20),
            ]
        ),
        termination_criterion=StoppingByEvaluations(max_evaluations=25000),
        population_evaluator=SequentialEvaluator()
    )

    algorithm.run()

ajnebro avatar Jun 28 '22 07:06 ajnebro

Hi @ajnebro I actually figure out... the problem was that I was reversing the bounds for integer part xD. But Thanks for all support. Right Now the one Problem that Im having is that it is taking hours to solve my VRP with 57 nodes and 100 constraints and in general is not a feasible solution (Im having some sub routes that are not starting from warehouse). Problem that I wasnt having due to the fact that I was trying with small amount of nodes before.

magal1337 avatar Jun 28 '22 11:06 magal1337