Closed AndreasH96 closed 5 months ago
Is there any progress with this inquiry: is it possible to set the initial population?
Thank you.
Hi,
I'm using jMetalPy to solve the VRP (meaning that I'm using PermutationSolutions
). I have implemented a version of the Cheapest Insertion algorithm, and I'm currently using it as my initial solution. First, I run the Cheapest Insertion algorithm to get an initial solution. Then I set the variables
field to this solution in create_solution.
So, to set the initial solution, one has to create either extend the Problem
class used or change its create_solution
function to set the solution variables.
I hope this helps!
Could you please show any examples that how to extend the problem
class or create_solution
function in order to use your own initial solution ?
@AndreasH96
Could you please show any examples that how to extend the
problem
class orcreate_solution
function in order to use your own initial solution ? @AndreasH96
Hi @CryoARIUM , I was extending the PermutationProblem class, here is a minimalistic example of how I did it. It was a while since I did this but I hope this solves your problem? I stored parameters in a dictionary called problemData and passed it to the customized class.
class VRP(PermutationProblem):
def __init__(self,problemData):
super(VRP,self).__init__()
self.object_directions=[self.MINIMIZE,self.MINIMIZE]
self.number_of_objectives = problemData['objective_amount']
self.objective_labels = problemData['objective_labels']
self.number_of_constraints = problemData['constraint_amount']
self.number_of_variables = problemData['number_of_cities']
def create_solution(self) -> PermutationSolution:
new_solution = PermutationSolution(number_of_variables=self.number_of_variables,
number_of_objectives=self.number_of_objectives,
number_of_constraints=self.number_of_constraints)
new_solution.variables = customInitialSolution(<input>)
return new_solution
@AndreasH96 Thank you for your reply ! I would like to use my own initial solutions. Your code help me to extend problem class. I will try my own problem with my initial solutions.
Hi, First of all, thank you for a great tool. I have one question about the status of the generation of initial solutions; I'm using your tool to solve a Multi-Depot VRP. I'm currently using a simple "cheapest-arc"-ish initial solution. I saw that in https://jmetal.readthedocs.io/en/latest/autoconfiguration.html there is a parameter called
createInitialSolutions
in the NSGA-II. It seems like this is only the case for the java version. What is the status of initial solutions for python?Best Regards