Reputation: 830
i want to use a starting solution for pymoo in the algorithms NSGA2. For that I have the following code
intial_solution = ICSimulation.simulateDays_ConventionalControl()
algorithm = NSGA2(
pop_size=5,
n_offsprings=2,
sampling=FloatRandomSampling(),
crossover=SBX(prob=0.7, eta=20),
mutation=PM(eta=40),
eliminate_duplicates=True
)
algorithm.setup(problem, x0=intial_solution )
So i just create an initial_solution
by using an external file that returns an x
vector that is the vector of decision variables in pymoo for the evalutation. Then I add algorithm.setup(problem, x0=intial_solution )
. When adding this line, the algorithm does not seem to terminate or to generally show some outputs. Further, in the evaluation method I can clearly see, that the algorithm, even in the first iteration, does not use the inital_solution
as all solutions in the first iteration are just randomly generated as if there is no inital_solution
.
So I want to know, how can I tell pymoo to use the inital_solution
as a good starting point for the optimization instead of just radomly initiallyzing the inital solutions?
Reminder: Does anyone have an idea how to do this?
Upvotes: 1
Views: 494
Reputation: 540
The first iteration is randomly generated because you're setting sampling=FloatRandomSampling()
. You should give your array of the initial design space instead.
For more info see here: https://pymoo.org/customization/initialization.html
Try this:
intial_solution = ICSimulation.simulateDays_ConventionalControl()
algorithm = NSGA2(
pop_size=5,
n_offsprings=2,
sampling=intial_solution,
crossover=SBX(prob=0.7, eta=20),
mutation=PM(eta=40),
eliminate_duplicates=True
)
Upvotes: 0