-
Notifications
You must be signed in to change notification settings - Fork 138
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
Inf fp get when keyword debug is True #9
Comments
Your code in and of itself looks just fine, but naturally, I can't test it myself without having access also to The only thing I can really recommend is that you add a little more of your own verbosity to each of the functions to narrow down where the error is surfacing from. When I have several functions like this that I need to keep track of, I find it helpful to prefix my printed string with a tag, like the command name or some other unique identifier, so I know where the message comes from, like this: print('[Drag_Coef] drag = {:}'.format(drag)) You may need to have a couple of extra lines of code to break up what you are doing, too. In other words, instead of drag = CST_Shape(...).Cd(...)[0] refactor it using more intermediate variables and add print statements between them, like tmp = CST_Shape(...)
print('[Drag_Coef] tmp = {:}'.format(tmp))
Cd = tmp.Cd(...)
print('[Drag_Coef] Cd = {:}'.format(Cd))
drag = Cd[0]
print('[Drag_Coef] drag = {:}'.format(drag)) It can feel tedious, but it works. I have no reason to believe you are getting bad input values from the optimizer, but it wouldn't hurt to print those out, too, just in case. If, after all this, you've found everything working correctly in your code, then we can dig deeper into pso to try and isolate what is causing the bad output. Which version of pyswarm are you using? By the way, why do you pass the kwarg |
Hi @tisimst , thanks for your suggestion, I may get where Inf comes. To be short: Here's what I do: So if this is the case,
Ps.
I think this is a very useful tool and will help pyswarm a lot if the code could integrate this, just use matplotlib and do not need any other unofficial dependency, though I'm not good at programming so just add some ugly codes to make it run. Get some hints from here. Currently my air_plot only works with plot fp and steps, but information from partial_output are also good candidates to plot. Question: |
Hi tisimst and others,
I've tried to use pyswarm to solve an engineering optimal problem but get Inf fp return when the debug keyworld in PSO is set to be true.
Here's a simple structure of my code:
To be short, it is a 8 variable optimal problem with two inequal constraints
But when I run this with PSO builtin debug mode, the fopt of each generation will always be inf:
Best after iteration 1: [-0.11882721 -0.02219953 -0.11879306 -0.11291183 0.19934821 0.24063626
0.1900103 0.07119408] inf
I'm really puzzled by this, one potential risk in my code is that some times drag in the Drag_Coefficient function or the lift in the Lift_Constraints function may get a bad return(a list with no answer) from other function, in that case will return a default value (like drag=1 in this case, since the predicted object value of drag is around 0.08, far less than 1, which also means that if I get a bad return from other function, I think that this sort of parameter is not good enough to be a candidate of the minimum, so just set a relative large value to eliminate it) , which may influnce the minimal searching. But I still don't know why it's Inf instead of a finite number.
Some hints? Really thanks.
Attach my codes for reference:
`
The text was updated successfully, but these errors were encountered: