Cannot create multiple .txt files

Hello gamsworld,

once more I’m in desperate need of your help.

What I’m trying to do? I have a regular OR-problem (WLP) which runs smoothly in GAMS. I want to create several .txt-files using the put and putclose-commands in order to have a file for every decision variable. I use $exit after a putclose and before the declaration of a new file.

What’s the problem? Although I want (a total of) four files to be created by GAMS, only the first one is actually in my folder. The others do not seem to have been created.

Are there any visible error messages? No, not one.

Here’s the code I use for creating the output-files. I’ll skip the model itself.

Model TwoStageWLP /all/ ;

$include “twostagewlp.inc” ;

option optcr=0.0;

Solve TwoStageWLP using mip minimizing Z ;
display y.l;
display x_w.l;
display x.l;

file output1 / “objective.txt” /;
put output1;

put 'Value of Objective Function: ',Z.l;

putclose output1;

$exit

file output2 / “locations.txt” /;
put output2;

put ‘Locations of Warehouses’;
put / /;

loop(i,
if (y.l(i) = 1,
put 'Location of Warehouse: ', i.te(i) /
);
);

putclose output2;

$exit

file output3 / “transport_fac_ware.txt” /;
put output3;

put ‘Transport Quantities from Factories to Warehouses’;
put / /;

loop (h,
loop(i,
if (y.l(i) = 1 AND x_w.l(h,i) 0,
put h.te(h), ’ to ', i.te(i), x_w.l(h,i) /
);
);
);

putclose output3;

$exit

file output4 / “transport_ware_cust.txt” /;
put output4;

put ‘Transport Quantities from Warehouses to Customers’;
put / /;

loop (i,
loop(j,
if (y.l(i) = 1 AND x.l(i,j) 0,
put i.te(i), ’ to ', j.te(j), x.l(i,j) /
);
);
);

putclose output4;


Any help is appreciated. Thanks in advance! :slight_smile:

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Stefan,

The $exit is not good there. It means terminate the compilation of the source code at that point, and start executing the compiled code. It’s like you just deleted all the source following the $exit.

Without the $exit calls you should be OK.

-Steve


On Thu, Feb 27, 2014 at 4:02 PM, Stefan Heinemann wrote:

Hello gamsworld,

once more I’m in desperate need of your help.

What I’m trying to do? I have a regular OR-problem (WLP) which runs smoothly in GAMS. I want to create several .txt-files using the put and putclose-commands in order to have a file for every decision variable. I use $exit after a putclose and before the declaration of a new file.

What’s the problem? Although I want (a total of) four files to be created by GAMS, only the first one is actually in my folder. The others do not seem to have been created.

Are there any visible error messages? No, not one.

Here’s the code I use for creating the output-files. I’ll skip the model itself.

Model TwoStageWLP /all/ ;

$include “twostagewlp.inc” ;

option optcr=0.0;

Solve TwoStageWLP using mip minimizing Z ;
display y.l;
display x_w.l;
display x.l;

file output1 / “objective.txt” /;
put output1;

put 'Value of Objective Function: ',Z.l;

putclose output1;

$exit

file output2 / “locations.txt” /;
put output2;

put ‘Locations of Warehouses’;
put / /;

loop(i,
if (y.l(i) = 1,
put 'Location of Warehouse: ', i.te(i) /
);
);

putclose output2;

$exit

file output3 / “transport_fac_ware.txt” /;
put output3;

put ‘Transport Quantities from Factories to Warehouses’;
put / /;

loop (h,
loop(i,
if (y.l(i) = 1 AND x_w.l(h,i) 0,
put h.te(h), ’ to ', i.te(i), x_w.l(h,i) /
);
);
);

putclose output3;

$exit

file output4 / “transport_ware_cust.txt” /;
put output4;

put ‘Transport Quantities from Warehouses to Customers’;
put / /;

loop (i,
loop(j,
if (y.l(i) = 1 AND x.l(i,j) 0,
put i.te(i), ’ to ', j.te(j), x.l(i,j) /
);
);
);

putclose output4;


Any help is appreciated. Thanks in advance! :slight_smile:

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

Hi Steve,

thanks for your help. I removed the exit-codes, but included one after the last putclose. Now, everything is working. :slight_smile:

Thank you very much! :slight_smile:


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.