-
Notifications
You must be signed in to change notification settings - Fork 86
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
multithreading / multiprocessing for optimization #343
Comments
Tried a workaround: Using 'memorise_fluid_properties=False' in the network config
solved the problem not completely, I still got strange values.
I still get strange outliers. May be the usage of static values like
generally is a bad idea. Instead you could define fluids as local class member Now I only can recreate the model for each function evaluation, which slows down things Update; Found out that recreating the model in case of any error helps - together with using thread local models:
So it seems that at some time an error occurs, and if you recreate the model in this case it helps. The
is required. Seems that sometimes a nan value is computed which leaves the model in "bad shape". |
Now I have uploded a python script to actually reproduce the issue: Execute https://github.com/dietmarwo/fast-cma-es/blob/master/examples/powerplant.py See the corresponding tutorial how to do parallel optmization with tespy: I noticed that BLAS parallelization as configured by anaconda actually harms the performance of tespy simulations.
for pygmo fitness which both speeds up the simulation and reduces CPU consumption. |
Dear @dietmarwo, thank you very much for reaching out, your investigations and suggestions are highly appreciated! I did not yet have the time to go through the code in detail, since I am currently working on TESPy in my free time only. Also, I do not have a lot of experience with multi-processing, so I will have a couple of questions, I guess. Generally, implementing parallel processing might require some refactoring changes in the back-end. However, these might be benefitial for further developing the software in any case. There are some parts, that I might have set up differently, if I restarted now. If you'd be interested to support or advise, please let me know. I will come back to this in a couple of weeks (will be in holidays :)) and I am looking forward to your improvement and example. Maybe we could link that from the documentation as well. Also, I would like to invite you to the user-meeting we are planning (https://tespy.readthedocs.io/en/main/regular_meeting.html). Best regards Francesco |
Hi Francesco, |
Did some experiments regarding
https://tespy.readthedocs.io/en/main/tutorials_examples.html#thermal-power-plant-efficiency-optimization
Using the given optimizer I noticed only 3% of my 16 core CPU were utilized. So I tried to apply an optimizer
capable of parallel function evaluation - but noticed strange results / exceptions. The following code
can be used to simulate the effect:
You see errors like
13:24:46-ERROR-Singularity in jacobian matrix, calculation aborted! Make sure your network does not have any linear dependencies in the parametrisation. Other reasons might be
-> given temperature with given pressure in two phase region, try setting enthalpy instead or provide accurate starting value for pressure.
-> given logarithmic temperature differences or kA-values for heat exchangers,
-> support better starting values.
-> bad starting value for fuel mass flow of combustion chamber, provide small (near to zero, but not zero) starting value.
As you can see, I create a separate model instance for each thread, but they seem not to be independent.
Why is that so? Is there anything I can do (setting a configuration parameter) to get this working?
For optimization for bigger models it would be nice if multi threaded execution would be supported.
Exceptions I can filter out, but unfortunately sometimes just wrong values are returned.
So I could "optimize" the powerplant to nearly 100% efficiency, but using the resulting x-value later
showed a "normal" efficiency.
My OS is Linux Mint 20.2 based on Ubuntu, python is anaconda for python 3.8.
The text was updated successfully, but these errors were encountered: