I save the post on how to solve multiple instances of a model iteratively. However, the question I have is how can it be done when using AIMMS Pro? Right now the problem is all instances are being sent out to the cloud at the same time. I want to run one instance, and then the other after that, and based on its results. Can something like this be done?
For example, in the below code - first model1 will be solved, then some postProcessing, and then model2 will be solved - all as part of the same job.
if not ProjectDeveloperMode() then
if pro::DelegateToServer( waitForCompletion : 1,
completionCallback : 'pro::session::LoadResultsCallBack' )
then return 1;
endif ;
endif ;
solve model1;
postProcessing;
solve model2;
I suppose you have some FOR loop and/or a delegateToServer block with the argument waitForCompletion set to 0. That will indeed create an asynchronous workflow where all the different solve statements will be started simultaneously.
Solve in a Loop — AIMMS How-To
The code in this example is below -
for i_fn do
sp_Workbook := sp_BatchExcelInputFolder + sp_InputFileNames(i_fn);
pr_ExecuteSingleRun(sp_Workbook);
endfor;
If you add the delegateToServer block inside the procedure pr_ExecuteSingleRun with waitForCompletion set to 0 - then that will create jobs for each i_fn simultaneously.
If you put the delegateToServer block outside the FOR loop, then the entire loop will be executed in the same job, one i_fn after another i_fn.
if not ProjectDeveloperMode() then if pro::DelegateToServer( waitForCompletion : 1, completionCallback : 'pro::session::LoadResultsCallBack' ) then return 1; endif ; endif ;
for i_fn do
sp_Workbook := sp_BatchExcelInputFolder + sp_InputFileNames(i_fn); pr_ExecuteSingleRun(sp_Workbook);
endfor;
Thank you Mohan. As you guessed, the problem is that I want to both solve consecutively, and also set the “wait for completion” value to 0, which it seems to be impossible. In other words, If it is possible to pass a function run to the cloud (including multiple consecutive runs), rather than just the solve statement.
Thanks
If you want to do multiple solves within that procedure, feel free to do so.
Reply
Sign up
Already have an account? Login
Please use your business or academic e-mail address to register
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.