Skip to main content

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? 

@mohammadansari  if you have all your solve statements in the same delegateToServer block, they will be executed in that order .

 

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


@mohammadansari You actually don't delegate the solve at all, you delegate the entire procedure run. 

If you want to do multiple solves within that procedure, feel free to do so.


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator