I have 2 questions.
1. I have 100 problems in Cplex lp file format. Can I use AMPL to read
problems from an lp file?
2. Let's say that the names of my 100 problems are 1.dat, 1.mod, ...,
100.dat, 100.mod. I want to write an AMPL script which reads and solves the
problems one by one and for each problem stores the solution in a file and
also sets a limit of 3 hours for the solution time of each problem. I
appreciate if you can write a short script that does what I am looking for.
Thanks a lot...
--
View this message in context: http://old.nabble.com/AMPL-Script---LP-File-Format-tp26963125p26963125.html
Sent from the AMPL mailing list archive at Nabble.com.
AFAIK, you cannot import an LP file into AMPL. Then again, there
doesn't seem to be a good reason to do so, particularly since you
apparently do not need to modify the models before solving them. Why
not just write a shell script to run CPLEX against each file in turn?
There's a recent thread on one of the IBM/ILOG forums that contains a
sample shell script.
/Paul
2. AMPL does not allow the model to be changed within a "for" or "while"
loop, so you can't write a short script to read 100 different models. (If
you have one model with 100 different data files then it's possible to write
a loop using string expressions,
model a.mod;
option solver cplex;
option cplex_options 'timelimit 10800';
for {k in 1..100} {
reset data;
data (k & ".dat");
solve;
display X >(k & ".out");
}
substituting whatever "display" or "printf" statements you like for the one
shown.)
Bob Fourer
4...@ampl.com
cplex -c "read a_problem_name.lp" "opt" "disp sol var -" "quit"