Re: [AMPL 6676] Writing to a text file

1,321 views
Skip to first unread message

victor.z...@gmail.com

unread,
Feb 25, 2013, 10:55:59 AM2/25/13
to am...@googlegroups.com
Use print instead:

  print Np > out file.txt;

HTH,
Victor


On Sun, Feb 24, 2013 at 12:22 PM, Parul Pandey <parul.p...@gmail.com> wrote:
Hi Everyone

I want to write my intermediate results to a text file and these results are to be read again by Ampl to solve my optimization problem. When I use display 


" display Np > out file.txt "  

the results are written to the file but they are of the form " Np =2" hence later when I try to read from the same file, I get the error 

"read" command error: expected a number


Could you please help me with the problem. I have looked extensively and used write command too but not able to solve this problem.


Thanks

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

sverkunoff

unread,
Feb 25, 2013, 2:33:49 PM2/25/13
to am...@googlegroups.com
you can also append your text file, format the file so that it's later convenient to read, and even make file name a parameter, for example:

print {s in 2..T, d in D, i in I}: {i_ in I} ac[s,d,i,i_]   >> (OutputFile);

prior to which you need something like 
param OutputFile symbolic := "output.out";


see more in section 12.4 of ampl book and in the appendix



Reply all
Reply to author
Forward
0 new messages