jMetalPy icon indicating copy to clipboard operation
jMetalPy copied to clipboard

constraint programming

Open maamani10 opened this issue 5 years ago • 3 comments

hi and tnx for great project. can u explain if our model have multiple constraint and objective function how we can implement it and use Jmetalpy?

maamani10 avatar Oct 20 '20 07:10 maamani10

Hi,

I don't know if this will be helpful but I'm currently using JmetalPy for my masters project. I'm solving a vehicle routing problem and I'm implementing the constraints through simply increasing the cost with a large value if the constraint is not met. This makes the algorithm deny the solution. I guess this is somewhat of a workaround but it seems to work for now.

Here is an example, I have a list of lists named paths and I've got a set of nodes callet permutation. This constraint checks so that all the nodes are visited by some path.

if not self.__allVisited(permutation,paths):
       fitness += 10e10 


solution.objectives[0]  = fitness

In my case I want to minimize the cost, if you would want to maximize a fitness value I guess you could subtract a large number instead.

If someone has a better solution for this I would appreciate it, but this seems to be working for now as I said.

AndreasH96 avatar Feb 05 '21 12:02 AndreasH96

The constraing handling mechanism used in jMetalPy is the same used in jMetal, which is described here: https://jmetal.readthedocs.io/en/latest/constraints.html

ajnebro avatar Feb 05 '21 15:02 ajnebro

Thank you @ajnebro !

AndreasH96 avatar Feb 05 '21 15:02 AndreasH96