Skip to content
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

Improve oemof simulation runs #377

Merged
merged 4 commits into from
Oct 6, 2023
Merged

Conversation

henhuy
Copy link
Collaborator

@henhuy henhuy commented Oct 5, 2023

Changed following behaviour:

  • result is not stored if simulation with same parameters already exists (checked after simulating results - this prevents double entries if simulations with same parameters run in parallel)
  • result is not stored if optimization is infeasible

Infeasbile optimization run now throws an APIException error which is handled in digiplan here:
https://github.com/rl-institut-private/digiplan/blob/30ddeb9dc27c5e7042177ddf916c4065eb01ff5f/digiplan/static/js/results.js#L101

Note: I did not test whats happening on client side if simulation finishes with infeasible results! As SIMULATION_FINISHED event is fired with non valid simulation id this will lead to errors. Should be handled somehow - but I had not time to built an infeasible optimization problem...

@henhuy henhuy added the enhancement 🚀 New feature or request label Oct 5, 2023
@henhuy henhuy requested a review from nesnoj October 5, 2023 10:02
@henhuy henhuy self-assigned this Oct 5, 2023
@nesnoj
Copy link
Member

nesnoj commented Oct 6, 2023

Thank you @henhuy for this nice feature!
I tested and the termination works out when going back to settings. Also, the results are not stored in DB when system is infeasible 👍 .

One question: When going back to settings, the celery logs say

[2023-10-06 09:11:54,072: INFO/ForkPoolWorker-15] Starting simulation for scenario='scenario_2045'...
[2023-10-06 09:12:48,974: INFO/MainProcess] Terminating fcb417d1-3c44-412c-9d92-04829aed3a43 (Signals.SIGTERM)
[2023-10-06 09:13:04,788: INFO/MainProcess] Task django_oemof.simulation.simulate_scenario[110f179b-4c43-4b4b-96dd-7dc0de5e2cff] received

Sound good so far, but sometimes it says

[2023-10-06 09:13:11,219: INFO/ForkPoolWorker-17] Starting simulation for scenario='scenario_2045'...
[2023-10-06 09:13:21,900: INFO/MainProcess] Terminating 110f179b-4c43-4b4b-96dd-7dc0de5e2cff (Signals.SIGTERM)
[2023-10-06 09:13:21,901: ERROR/ForkPoolWorker-17] Constructing component 'TransformerBlock.relation_build' from data=None failed:
SystemExit: -241

or similar output in the 3rd line like Constructing component 'flow' from data=None failed or Constructing component 'GenericStorageBlock.balance' from data=None failed.
This does not seem to occur when the time between clicking on results tab and going back to settings is either quite short (a few seconds) or long (>30s). I guess in between the esys is build and that's why these errors appear....(?)

However, the opt. is terminated properly so I wouldn't bother too much. Or is the SystemExit a problem?

@henhuy
Copy link
Collaborator Author

henhuy commented Oct 6, 2023

I think pyomo gets interrupted by termination and thus this errors occurs.
If it does not affect further simulation runs, I wouldn't bother either...

@nesnoj
Copy link
Member

nesnoj commented Oct 6, 2023

I think pyomo gets interrupted by termination and thus this errors occurs. If it does not affect further simulation runs, I wouldn't bother either...

Ok, thx! :)

@nesnoj nesnoj merged commit 8a15027 into dev Oct 6, 2023
1 check passed
@nesnoj nesnoj deleted the fix/multiple_simulations_by_user branch October 6, 2023 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚀 New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants