-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to store set of parameters when optimization crashes? #9
Comments
Hi, |
Hello.
The above code will store all the parameters if the optimization calls the objective function in series and I would get all parameters in |
So, the important question is what happens when your simulation fails. If you can control that failure inside of your objective function (say, simulation returns some kind of error code that you can capture), then you can make your function look like this: def fun(par):
...
if errorcode == 'Simulation fails': # or whatever it is
return 0.
else:
return abs(det) # determinant or whatever tells how poor your matrices are I hope you understand that failure of your simulation is a side effect that has nothing to do with optimization itself. So you need to control that side effect somehow. The objective function needs to be returning some value, no matter if simulation works or fails. If failure of the simulation is causing some bad issues (memory/system crush etc) that you cannot control, then you need to go the guts of the I strongly recommend you going the first way if possible - making your objective function immune to the failure of the simulations. |
As for what you propose (saving a current set of parameters into a global list), that's a good idea, but I'm not sure how this will interfere with parallelism that is used in |
The simulation is not easy to track because I am running nested simulations (two different types) with a large number of variables, and the optimization parameters are indirectly (not directly) affecting the simulation that's producing errors...it's the first simulation that produces some output that goes into the second simulation input. Simple question: How would you store all the parameters that the blackbox optimization is using in parallel? |
You can try your idea (with the global list). If the parallelism is not very crucial, you can set Also, you can make your objective function simply print the current set of parameters on the screen. I think this should work well even when you have parallelism. Finally, as I mentioned, you can go inside of |
I have already tried what you are suggesting, but it doesn't help. For instance, I print the parameters on screen, but I wouldn't know which set of parameters is causing the error because each core is running the code in parallel and I have no idea which (and how many) set of parameters are clubbed together for each core. That is important to narrow down to the set that's causing the problem. Latest update: I did save the parameters that the optimization uses for all scenarios by some ad-hoc, and inefficient method, and I didn't seem to have any error when I ran the simulation on those set of parameters individually outside the optimization process. Therefore, it's possible there is some problem with the optimization code itself... |
Dear Paul, How can I include constraints in |
The code doesn't support constraints. |
Hello.
I am running some simulations and I am trying to optimize for some parameter. The simulation fails sometimes when I give a large value of m, n (say m=n=100) by giving an error related to a singular matrix. I want to find out for what parameters I am getting this singular matrix. Is there any way I can find the parameters for which the optimization is failing? It would work for me even if I can store all the parameters before optimization crashes due to a singular matrix error for a particular scenario. Thanks.
The text was updated successfully, but these errors were encountered: