@sree
Marcel already confirmed that your procedure looks good. Both the concerns you raised (scheduling the procedure itself and waiting while something is being executed) have been addressed in the Note at the bottom of the documentation.
ScheduleAt — AIMMS Function Reference
Can you let me know if something is still missing and we can update the docs ?
There is only a single thread in AIMMS that can execute procedures in the model, protected by a global AIMMS lock. So if some procedure is activated from within the IDE or the WebUI, and is still running, the scheduled procedure will wait until it can acquire the AIMMS lock, i.e. when the other procedure has completed.
Otherwise, your procedure looks just fine.
Thanks, @mohansx. I do have couple of quick follow ups after experimenting with ScheduleAt.
My polling procedure is as follows:
Procedure myPollingProcedure {
Body: {
prCheckStatus ;
if spStatus <> "Completed" then
ScheduleAt(MomentToString("%c%y-%m-%d %H:%M:%S", , CurrentToString("%c%y-%m-%d %H:%M:%S"), pPollInterval), 'myPollingProcedure') ;
pPollInterval := Min(30, 1.6 * pPollInterval) ;
else
// do other stuff
endif;
}
}
Basically, at the first call to myPollingProcedure, it checks the status and schedules another polling call in some interval. It seems to work fine. I hope scheduling the procedure that contains ScheduleAt() statement is not an issue.
I am not sure of any edge cases. I believe as long as I have ScheduleAt at the end of myPollingProcedure and pPollInterval is not smaller than time to execute statements that follow it (here, pPollInterval assignment), there shouldn’t be an issue. Is that right?
Also, I noticed that AIMMS queues the myPollingProcedure if AIMMS is busy running another procedure. If this is right, it may be worthwhile to update the documentation with this info. I observed this by adding another procedure with Delay(10) to mimic some busy set of operations or control flow and triggering its run before the next scheduled call of myPollingProcedure - AIMMS was waiting until Delay is complete. I am not sure if this behaviour is due to how Delay itself works though.
Hi @sree, yes ! I was asking to confirm my understanding, if you are looking for a similar functionality but with AIMMS procedures instead. The ScheduleAt example would’ve been my next response but Guido beat me to it :D
Take note that StringToCurrent and MomentToString return times in UTC timezone in AIMMS versions over 4.74 - AIMMS Release Notes — AIMMS Documentation
@mohansx, no, I wasn’t referring to MIP callback polling.
@gdiepen, ScheduleAt function is what I was looking for!
Do you mean you want to periodically scheduling the running of a procedure?
If so, you could try to use the ScheduleAt function. An example using this function can be found at https://how-to.aimms.com/Articles/404/404-clock.html
@Sree are you looking for functionality similar to the iteration or time callbacks in MIP solves where a procedure is executed periodically ?
Hey @Pratap Kumble, assume we are consuming a k-means clustering procedure via a REST API asynchronously -- we submit an async request with data using web::request_invoke_async() and get a response with ID or URL to query the k-means clustering status and results.
After receiving the response for initial request, we could update the string parameter corresponding to the Status Bar to indicate “Submitted Job”. To check if the k-means procedure has finished running, the user would have to run the callback/polling procedure using the ID/URL, correct? I was wondering if there is a way to setup a polling procedure that queries every X seconds for status and indicates it in the Status Bar as “Completed Job”. Does this help clarify?
Thanks,
Sree
HI @Sree,
I don’t completely understand what you mean by a “Poll Procedure”. Could you please help me understand?
If I read your workflow, would it be correct to assume that you want the Status Bar to update after a certain procedure or action is complete?
Just to clarify, the status bar is updated anytime the data in the string parameter used to specify the option is updated. You do not need to wait for any action as such. If the data in the string parameter is updated the Status Bar is also updated, just like any widget in the WebUI.
Hope this helps.
Thanks,
Pratap