Closed miraclema999 closed 11 months ago
What about simply setting the objective(s) to a very large value, e.g. 1e12 or so? I am not exactly what you are trying to do in your code, but for the algorithm, it would be also okay to consider a solution simply as infeasible if the evaluation fails (also referred to as death penalty). This might be the cleanest way of implementing this.
If you know before running your third-party code a solution will fail, you can also filter them out beforehand.
The fact is, bacause of the insteability of the simulation software, it is impossible to decide which solution will fail. And the solution of the same variables may be OK if I run it again. So if I set the objectives to a very large value, I wonder the algorithm will not consider the solutions in the following generations, and that will affect the final search space I think. I am not sure my assumption is right or wrong? If the large penalty of these solutions doesn't affect the final searching space, I think it is a cleanest way.
It sounds to me that your problem is not that sometimes you don't have a solution (because the simulation crashes) but more that your evaluation function is non-deterministic. You are right that NSGA-II makes the assumption that you have a deterministic function and will not re-evaluate a solution for this reason.
What about adding retry if it fails and just assuming after n attempts it truly fails?
Hello @miraclema999 , I would suggest you to create surrogate model for the simulation if possible.
What about adding retry if it fails and just assuming after n attempts it truly fails?
Sorry for the late reply. I agree with your suggestion. This way will not affect the number of solutions in each generation. To be honest, I'm not doing well in scripting, can you tell me how to modify this script, to let it retry the generation? Thank you
Hello @miraclema999 , I would suggest you to create surrogate model for the simulation if possible.
Thank you bro, did you mean that I switch to another algorithm?
@miraclema999 I meant creating surrogate model with the samples from simulation software and replace it, and finally verify the result with simulation software. Here is the explanation of surrogate model on wikipedia. And here are some mainly steps:
I am using pymoo linking with simulation tools to optimize building forms to find near pareto front solutions accounting for daylighting and energy consumption, and the data exchange is by csv files, the core code run in Rhinoceros. Since the simulation tools are not steady, there will be individual solutions that cannot retrieve one or two objective value ( if I run the simulation again the value may be retrieved). So I mark these objective values to be 'None'. To handle situations where certain objective values are marked as 'None' due to the nature of my simulation tools, and I want to avoid discarding these solutions entirely, I should implement a mechanism to keep track of these solutions and give them a chance in the subsequent generations. My code is below, I use Vectorized Matrix Operation for parallelization, and the optimization is step by step, controled by the existence of an external txt file. I also use a callback to store solutions of every generation. The question is:
if np.any(fitness_values == None): continue
to skip solutions, is it the right way?