How to display CPLEX solution time in log file?

2,760 views
Skip to first unread message

Prats

unread,
Jun 27, 2006, 11:04:04 PM6/27/06
to AMPL Modeling Language
Hello all,

I am sort of new to AMPL/CPLEX. For an integer program I am solving
using AMPL/CPLEX, I would like to automatically store the solution time
(something on the lines of "_solve_elapsed_time") in my log file. The
"display" command prints it on the "standard output," but how about in
a log file?

Thanks,
Prats

Steven Harrod

unread,
Jun 27, 2006, 11:39:08 PM6/27/06
to am...@googlegroups.com
try

display _solve_elapsed_time >your.log;

or

print _solve_elapsed_time >your.log;

--
Steven Harrod
College of Business/QAOM
University of Cincinnati
859 225 1572

Prats

unread,
Jun 28, 2006, 9:56:22 AM6/28/06
to AMPL Modeling Language
Both these commands tend to overwrite my log file. That is, on using
either of these commands, my log file only contains solution time and
does not contain any other screen output. I wish to have both the
screen output and solution time in my log file.

For your reference, here is my AMPL code:

reset;
option reset_initial_guesses 1;
option cplex_options 'timing=1 time=18000' 'lpdisplay=1' 'mipdisplay=2
mipinterval=500 mipstartvalue=1' 'logfile=paper3/repeat/zone_2000.txt';
model paper3/repeat/zonemod.mod;
data paper3/repeat/zone_2zones_2000orders.dat;
let totalcap := 250;
solve;
#display _solve_elapsed_time > paper3/repeat/zone_2000.txt;
close paper3/repeat/zone_2000.txt;

Any suggestions?
Prats

Steven Harrod

unread,
Jun 28, 2006, 10:33:53 AM6/28/06
to am...@googlegroups.com
Use a different log file for ampl than for cplex.

--
Steven Harrod
Applied Arts Ltd.
Lexington, KY
859 225 1572

Prats

unread,
Jun 28, 2006, 11:12:57 AM6/28/06
to AMPL Modeling Language
That seems to work. Thanks Steven!

Joseph

unread,
Jun 28, 2006, 3:46:30 PM6/28/06
to AMPL Modeling Language
If you really want that time in the same file you could use:

display _solve_elapsed_time >> your.log;

The ">>" does an append to the file and shouldn't overwrite. Tested it
on the ampl command line and it worked fine.

Joey

Prats

unread,
Jun 29, 2006, 4:39:23 PM6/29/06
to AMPL Modeling Language
This is better! Thanks Joey.

sema...@gmail.com

unread,
Jul 6, 2013, 10:19:47 AM7/6/13
to am...@googlegroups.com
hello

i am running cplex on command line and i would like to recover the solution time in an output file because this information is not printed in solution file.i tried display _ solve_elapsed_time but this option does not exist. is there any other solution ?

thanks

Robert Fourer

unread,
Jul 18, 2013, 11:13:49 AM7/18/13
to am...@googlegroups.com
This works for me:

ampl: display _solve_elapsed_time;
_solve_elapsed_time = 0.797

For writing to an output file you can use something simple like

print _solve_elapsed_time >yourfile.out;

Bob Fourer
am...@googlegroups.com

Marcelo Freitas da Silva

unread,
Jul 10, 2018, 11:15:43 AM7/10/18
to AMPL Modeling Language
how to print outlev, timming, threads and logfreq?
Reply all
Reply to author
Forward
0 new messages