Hello everyone,
I am trying to generate random problems using gams, solve them and then save the solutions into different Excel files, .lst files and .gdx files.
I am trying to figure out how to change the file name and produce a .lst, .xls and .gdx files for each solve statement
The code I have below only uses the same file and I only have one Excel file of the last run
Scalar product ;
Scalar supplier ;
Scalar time ;
Sets i products / i0*i50 /
j suppliers / j0*j50 /
t time periods / t0*t50 /
sub_j(j) dynamic subset for j
sub_t(t) dynamic subset for t
sub_i(i) dynamic subset for i ;
Alias ( k , t ) ;
Parameter D( i , t ) ;
Parameter P( i , j ) ;
Parameter H( i ) ;
Parameter O( j ) ;
Variables x ( i , j , t )
y ( j , t )
R( i , t )
Z( i , j , t )
cost ;
Positive Variables x ,R, Z;
Binary Variable y ;
Equations obj objective function
con1 ( i , t ) ;
obj ..
cost =E= sum ( ( sub_i(i) , sub_j(j) , sub_t(t) ) ,P( i , j )* x ( i , j , t ))+sum ( ( sub_j(j) , sub_t(t) ) ,O( j )* y ( j , t ) )
+ sum ( ( sub_i(i) , sub_t(t) ) ,H( i ) * ( sum ( k$ ( ord ( t ) GE ord ( k ) ) , sum ( sub_j(j) , x ( i , j , k))-D( i , k ) ) ) ) ;
con1 ( sub_i(i) , sub_t(t) ) ..
R( i , t ) =E= sum ( k$ ( ord ( t ) GE ord ( k ) ) , sum ( sub_j(j) , x ( i , j , k))-D( i , k ) ) ;
display "---------------------formulation ----------------------";
option optcr =0;
option limrow =0;
option limcol =0;
Model Regular /all/;
for ( product = 1 to 3 by 1,
for( supplier = 1 to 3 by 1,
for ( time = 1 to 3 by 1,
sub_i(i) = ord(i) <= product;
sub_j(j) = ord(j) <= supplier;
sub_t(t) = ord(t) <= time;
D(sub_i,sub_t) = uniformint(10,20);
P(sub_i,sub_j) = uniformint(10,20);
H(sub_i) = uniformint(1,4);
O(sub_j) = uniformint(10,20);
Solve Regular minimizing cost using mip ;
execute_unload "output.gdx" sub_i, sub_j, sub_t, P, O, D ;
execute 'gdxxrw.exe output.gdx o=output.xls set=sub_i rng=A1 set=sub_j rng=A5 set=sub_t rng=A10 par=P rng=A15 par=O rng=A20 par=D rng=A25';
);
);
);
Any help would be appreciated!
Thanks