Solved

Looping Execution Array

  • 18 October 2022
  • 2 replies
  • 69 views

Badge +3

Hello,

I'm trying to do some sensitivity runs where I scale a parameter each run and resolve.

The problem is I can't seem to very simply make an array to loop over to scale the parameter.

 

Basically this:

FOR x in [50, 75, 100] DO

   y = x * z;

   solve LP;

ENDFOR

 

Just creating the array and looping through it is giving me trouble. I don't know the best way - import the array as a parameter? Then it gets mad it doesn't have an index? But it doesn't even really have an index. Then x has to be a declared parameter as well?

Is there an easy way to do this or maybe it's because AIMMS isn't made for scripts? I can't seem to find a syntax guide that talks about declaring an array parameter.

Thanks for helping a noob!

icon

Best answer by Chris Kuip 18 October 2022, 17:43

View original

2 replies

Userlevel 5
Badge +7

Hi,

 

You are almost there: just replace [ ] with { } in your code.

 

I created small example:

Here x is declared as an index with range Integers, and y and z are two parameters.

This gives the following listing file:

For your convenience, I've attached the AIMMS 4.88 project.

With kind regards,

 

Chris.

Badge +3

Thanks Chris! That did it.

Reply


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

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