AMPL Script / LP File Format

1,112 views
Skip to first unread message

bademhan

unread,
Dec 29, 2009, 8:57:34 PM12/29/09
to am...@googlegroups.com

Hello,

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.

Paul

unread,
Dec 30, 2009, 11:12:37 AM12/30/09
to AMPL Modeling Language
bademhan wrote:
> Hello,
>
> 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.
>

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

Robert Fourer

unread,
Dec 31, 2009, 11:25:42 AM12/31/09
to am...@googlegroups.com, bademhan

1. AMPL does not read CPLEX lp file format, which is intended for using
CPLEX without a modeling language (in the way that Paul's earlier post
suggests). To use existing lp files with AMPL I would suggest creating a
little program to extract the data from the files and write it as AMPL data
that can be used in conjunction with a simple AMPL model; this sort of thing
has been done for MPS format files.

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

ashish1...@gmail.com

unread,
May 3, 2014, 10:10:02 PM5/3/14
to am...@googlegroups.com, tu...@email.unc.edu
how can i use lp file created by zimpl software to run in a linux operating system  using cplex software????? please help

fbahr

unread,
May 4, 2014, 3:09:39 PM5/4/14
to am...@googlegroups.com, tu...@email.unc.edu, ashish1...@gmail.com
cplex -c "read a_problem_name.lp" "opt" "disp sol var -" "quit"

--fbahr

fbahr

unread,
May 5, 2014, 5:30:21 AM5/5/14
to am...@googlegroups.com, tu...@email.unc.edu, ashish1...@gmail.com
On Sun, May 4, 2014 at 9:33 PM, Ashish K... <ashish...@gmail.com> wrote:
> Hello... 
> I am very thankful for your help but i need to know how to run cplex in linux operating system. Does it need different file to run the linux compatible cplex IDE???

I'm not sure I completely understand your situation, but ...

1. To use CPLEX on a Linux machine, you (obviously) need to have a Linux-compatible version of CPLEX installed
    > http://www-01.ibm.com/support/docview.wss?uid=swg21444285
2. The IBM ILOG CPLEX Optimization Studio installation includes multiple solvers, an IDE (to model and solve OPL programs), a command line tool - oplrun - to execute OPL programs from your Linux shell and an interactive solver - cplex - to solve LP models (also to be accessed from command line).
3. If you have an LP file (e.g., generated by means of ZIMPL) and want to feed it to CPLEX, you need to pass it (as described) to the command line tool cplex.

--fbahr

PS: For more detailled CPLEX support you might want to visit https://www.ibm.com/developerworks/community/forums/html/forum?id=11111111-0000-0000-0000-000000002059
Reply all
Reply to author
Forward
0 new messages