It's easy to export to a csv file, by using csvdisplay instead of display. For example the command
csvdisplay Buy.lb,Buy,Buy.ub,cost >buydata.out;
produces a file buydata.out that contains these lines:
BEEF,0,0,100,3.19
CHK,0,0,100,2.59
FISH,0,0,100,2.29
HAM,0,0,100,2.89
MCH,0,46.66666666666666,100,1.89
MTL,0,1.5761812194954111e-15,100,1.99
SPG,0,8.429823983987501e-15,100,1.99
TUR,0,0,100,2.49
You can similarly redirect to a file the output of display, and of printf, which allows for detailed control over the format. Also you can write a text table with the commands
table buydata OUT: [FOOD],Buy.lb,Buy,Buy.ub,cost;
write table buydata;
which produces this file buydata.tab:
ampl.tab 1 4
FOOD Buy.lb Buy Buy.ub cost
BEEF 0 0 100 3.19
CHK 0 0 100 2.59
FISH 0 0 100 2.29
HAM 0 0 100 2.89
MCH 0 46.66666666666666 100 1.89
MTL 0 1.5761812194954111e-15 100 1.99
SPG 0 8.429823983987501e-15 100 1.99
TUR 0 0 100 2.49
For your example, to write a single value, the table statement should have the form "table ...: [], theobjective;". There's only a connection from AMPL tables to spreadsheets under Windows, however, so you won't be able to export directly to an xlsx file under MacOSX.
Bob Fourer
am...@googlegroups.com
=======