Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Runtime API: issues with multiple runs and threading [closed]

asked 2020-11-22 07:49:18 -0600

Sergio Ortiz's avatar

updated 2020-11-22 07:57:39 -0600

Hi again,

I am having trouble using the new Runtime API (E+ version 9.4.0) in scenarios where multiple runs involving different threads are required such as training processes for reinforcement learning agents. My feeling is that there may be some issues with recent state manager features and its threading support. I will be providing a series of problematic usage scenarios to foster discussion and make issues visible - either in the API or in my understanding of it.

Scenario 1 - Concurrent runs using multiple threads using same API object

Using a single API instance to manage multiple runs can be problematic as executing a api.state_manager.reset_state while an execution is in progress causes an access violation - see Although this approach works well with sequential multiple runs, it is reasonable that it doesn't support multiple concurrent runs.

image description

However, I would have expected that the API supports creating multiple handles (api.state_manager.new_state) - one for each run. Unfortunately, when I try this I get a SetupTimePointers error (see example in Thus, my guess is that a single API instance cannot deal with multiple concurrent runs.

image description

Scenario 2 - Concurrent runs using multiple threads using different API objects

This scenario tries to overcome limitations by using different instances of the API - that is, one for each run. For this purpose I created a dictionary to associate the context (state) with the appropriate API object - see example in, and some stuff to manage concurrency and locking. As in the case above, the approach doesn't work well with concurrency. I tried even to create different output folders in case there were some clashes processing outputs with little success. I also attach outputs for a 1 instance successful run vs output from a failed test with 2 instances. Errors also varied - let me attach a couple of examples. image description

image description

I am opening a ticket in E+ support website but any help and support are welcome.

Best regards,

Source code and logs can be obtained here:

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Sergio Ortiz
close date 2022-03-25 13:08:37.248970


I am running into similar issues, any progress?

wpo14's avatar wpo14  ( 2022-03-15 16:32:15 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-03-25 13:07:02 -0600

Sergio Ortiz's avatar

Solved in more recent E+ versions

edit flag offensive delete link more

Question Tools



Asked: 2020-11-22 07:49:18 -0600

Seen: 325 times

Last updated: Mar 25 '22