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
Iterations for a single time step are not synchronised on HELICS 3.2.1 #2408
Comments
I will take a close look and see if I can get the example running on my system |
I ran it, what am I looking for in regard to what it is showing vs what you would expect? |
Expected: The diverging time steps should be the same in both federates and the result should not change by repeating the simulation or by changing the delay in one of the federates. Below are some screenshots showing the diverging time steps for different simulations.
|
Are you able to test this with the develop branch. There was a minor fix related to iterations in a recent PR. I am not 100% sure it is related but is possibly connected. |
I have tested it with the "develop branch". The issue is still not resolved. I used the following command for the iteration: h.helicsFederateRequestTimeIterative(vfed, TimeStep, HelicsIterationRequest.HELICS_ITERATION_REQUEST_FORCE_ITERATION, out helics_iter_status); |
You should probably be using |
Force_iteration does not immediately grant iteration. At least in theory it behaves identically to iterate_if_needed except that in the case iterate_if_needed would have granted the next time step force_iteration will instead grant an additional iteration. |
That was not what I was seeing when I was working on the iteration example. I think we even discussed this at some point. |
I tried The reason could be that I have only two federates and they exchange data in both directions. If one is iterating, it means that it is also publishing new values at each iteration. Hence, the other federate should also be iterating and trying to get those latest values. However, there is no way that each federate knows the iteration number of the other federate. Is there a way that In the code shown below, I called the |
I think you want your time request *after* subscription and *before* publication. That should keep the iterations in sync. There is an example in his to set this up in the user guide (possibly develop branch)
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Getnet Ayele ***@***.***>
Sent: Wednesday, September 7, 2022 3:00:52 AM
To: GMLC-TDC/HELICS ***@***.***>
Cc: Schweitzer, Eran ***@***.***>; Comment ***@***.***>
Subject: Re: [GMLC-TDC/HELICS] Iterations for a single time step are not synchronised on HELICS 3.2.1 (Issue #2408)
Check twice before you click! This email originated from outside PNNL.
I tried iterate_if_needed option. The issue is still there. Relatively, the force_iteration looks slightly better.
The reason could be that I have only two federates and they exchange data in both directions. If one is iterating, it means that it is also publishing new values at each iteration. Hence, the other federate should also be iterating and trying to get those latest values. However, there is no way that each federate knows the iteration number of the other federate. Is there a way that helics counts the iteration of each federate internally for each time step?
In the code shown below, I called the helics_iteration_request_force_iteration just before each subscription and publication so that I can access the latest values available. If I remove those lines, the iteration misalignment gets worse.
[image]<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F101350215%2F188849640-5f779aa6-2cc1-4e8e-bb61-e6bb6a57a3dd.png&data=05%7C01%7Ceran.schweitzer%40pnnl.gov%7C658c861ecbad417f9b9308da90b7d989%7Cd6faa5f90ae240338c0130048a38deeb%7C0%7C0%7C637981416571215010%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=pe80A%2BcwwcUc7dr6F17wyuVLl8MHLeEGxWOI645b%2B0A%3D&reserved=0>
—
Reply to this email directly, view it on GitHub<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FGMLC-TDC%2FHELICS%2Fissues%2F2408%23issuecomment-1239177804&data=05%7C01%7Ceran.schweitzer%40pnnl.gov%7C658c861ecbad417f9b9308da90b7d989%7Cd6faa5f90ae240338c0130048a38deeb%7C0%7C0%7C637981416571215010%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MlePlqxYdycXjPw1AzOaduOBjBbRKu0iakO%2Bg3KbwyI%3D&reserved=0>, or unsubscribe<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGVYNC6JQINA4APMNOTKPFTV5BRVJANCNFSM55TIM3VQ&data=05%7C01%7Ceran.schweitzer%40pnnl.gov%7C658c861ecbad417f9b9308da90b7d989%7Cd6faa5f90ae240338c0130048a38deeb%7C0%7C0%7C637981416571215010%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SSrvHkPum3%2Ft%2BlAt8ZS5RcFbBvKKhDhAMGnOSS9eMgU%3D&reserved=0>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Can you try this again with the new 3.3.0 release? I am still working on translating the entire program into C to verify but there was a bug fixed that could be related in the new release since we last spoke. |
Would it be possible for you to provide some sort of log output for how the federates are moving through time and exchanging information?
|
@eranschweitzer The reference log files are taken from the simulation which gave me better results, but they do not necessarily mean that the iterations are synchronized. Let me know if you need further information about the log file or to run the dummy federates again. |
@Getnet-Ayele, thank you for sharing those.
There is some general information about how to structure iteration here, including a pseudo-code example. There is further an example on how to set up iteration here and the code is here. I would strongly encourage you to take a look at those examples and compare their structure to yours. |
@eranschweitzer, thank you for your detailed feedback! I will go through your suggestions and will let you know the outcome. |
@eranschweitzer and @eranschweitzer thank you again for your feedback. Following your suggestions, the iterations are now synchronised regardless of the delay between the federates. In addition to the order of publications, time_request, and subscriptions, I noticed that I was wrongly using:
Which are now replaced with:
The log file can be found here. Log.txt |
@eranschweitzer : Regarding the maximum iteration, In the absence of convergence, is the In my case, it was iterating beyond MAX_ITERATIONS. To overcome that I used |
I will look into that, It is possible some of the recent changes caused that property to not work correctly. |
Describe the bug
Iterations out of synchronization if the federates have different speeds.
What is the expected behavior?
Like the time step synchronization, iterations are supposed to be synchronized.
To Reproduce
Steps to reproduce the behavior:
Here is the dummy project:
https://github.com/Getnet-Ayele/HELICS_SAInt_DummyFederates
Environment (please complete the following information):
Additional context and information
(e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
The text was updated successfully, but these errors were encountered: