read_table does not seem to search for files in "ampl_include" paths

55 views
Skip to first unread message

Cuong P. Nguyen

unread,
Nov 24, 2015, 9:57:16 AM11/24/15
to AMPL Modeling Language
I have defined paths to source code folder (where all *.mod files are located), and data folder (where all *.tab files are located, including mydata.tab file below)
option ampl_include 'C:\ampl_source_foler \
                     C:\ampl_data_foler'
;

 
then I was trying to load mydata.tab file, but it showed an error below. There was however no error in loading this table if I CD to the C:\ampl_data_foler path before executing the two commands below.
 
table mydata: [id], dat1, dat2;
read table mydata
;


Error at _cmdno 13 executing "read_table" command:


 
Error reading table mydata with table handler tab:

 
Cannot open "mydata.tab".

 

Victor Zverovich

unread,
Nov 24, 2015, 2:47:18 PM11/24/15
to am...@googlegroups.com

According to the AMPL book, ampl_include is used for include and similar statements rather than read data:

For include phrases as well as model, data, and commands commands, files with simple names, e.g., not involving a slash (/), are sought in directories (folders) specified by option ampl_include.

But you can specify the path to the .tab file in the table declaration:

  table mydata 'path/to/mydata.tab': [id], dat1, dat2;

or use a parameter if the path is used more than once:

  param data_path symbolic = 'path/to/data';
  table mydata (data_path & '/mydata.tab'): [id], dat1, dat2;

HTH,
Victor

--
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.
For more options, visit https://groups.google.com/d/optout.

Cuong Nguyen

unread,
Nov 24, 2015, 7:49:37 PM11/24/15
to am...@googlegroups.com
Thank you Victor 

You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/wOTuvQPtcvE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages