# Array in Gams...

 1 I am solving a same mixed integer problem several times (I am using different scenarios for each mixed integer program so that the optimal values of each mixed integer program are different) and trying to store optimal values of each mixed integer program in an array. The following is the code that I wrote and I checked it is working properly: parameters f=1 and u=10 are defined. while ((f le u), Solve scheduling using mip maximizing objvalue; display objvalue.l; *** NEED some sentence(s) to store the objective values in an array ****. f = f+1; );  Is there any way to store each optimal value in an array? Thank you very much in advance. asked 13 Feb '14, 15:58 Mike390 21●4 accept rate: 0% fbahr ♦ 4.6k●7●16

 5 Define a parameter with its size equal to the number of scenarios (in your case 10) outside a loop. Then, set its values within the loop accordingly. The general template would as follows: //outside the loop set f scenarios/f1*f10/; parameter log(f); //the loop loop(f, //Solve the problem log(f) = z.l; );  answered 13 Feb '14, 16:13 Ehsan ♦ 4.8k●3●11●22 accept rate: 16% fbahr ♦ 4.6k●7●16 Ehsan, Thank you very much. It's working well now (13 Feb '14, 16:36) Mike390
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×51
×2