Closed maamani10 closed 1 year ago
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.
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
Thank you @ajnebro !
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?