That's exactly how it is done:
ampl [options] [file [file...]]
For a list of options give the command
ampl -?
Bob Fourer
4...@ampl.com
There's no way to pass the value of T through an ampl command-line argument,
but a value can be passed through an environment variable. Here's how I
would do it from a Windows DOS console:
C:\>set Tvalue=5
C:\>ampl
ampl: param T integer > 0;
ampl: let T := num($Tvalue);
ampl: display T;
T = 5
Environment variables become option strings inside of AMPL, and $Tvalue
refers to the value of option Tvalue. Something similar would work under
linux, depending on the shell you are using.
Without seeing the files I can't be entirely sure what is happening here. However I can say that when you give the statement
ampl example.run example.dat
AMPL first reads and processes all of the file example.run, and then reads and processes all of the files example.dat. So I would expect that by the time the data file is read, all the commands in the run file have already been executed, and AMPL receives no instructions for doing anything with the data (such as solving a problem).
You could of course put "data example.dat" inside the run file, and then execute only "ampl example.run". But if you need to control the choice of data file from the command line, then you will need to use a command like
ampl example1.run example.dat example2.run
where the run file has been broken into two parts, one with the commands to be executed before reading the data, and one with the commands to be executed after reading the data.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Akshay [aksha...@gmail.com]
Sent: Wednesday, March 30, 2011 11:08 PM
To: am...@googlegroups.com
Cc: 'Justin'; 4...@ampl.com
Subject: Re: RE: [AMPL 4507] Passing arguments to ampl script from linux prompt