AMPL solver times

397 views
Skip to first unread message

adit...@gmail.com

unread,
Sep 6, 2021, 12:06:50 PM9/6/21
to AMPL Modeling Language
Hello Group Members,

I am using AMPL / BARON for one of my class project.

For my problem, I need to separately report the time AMPL took to load the model, and the time solver took to solve it.

I went through timing parameters listed in 'Table A-14: Built-in timing parameters' in AMPL manual (https://ampl.com/BOOK/CHAPTERS/24-refman.pdf#page=44) to understand this.

However, it is still not clear to me that which 'time options' I need to use. Kindly help me with the same.

Thanks,
Aditya
 

AMPL Google Group

unread,
Sep 6, 2021, 2:43:30 PM9/6/21
to AMPL Modeling Language
The time taken by the most recent call to a solver can be measured in either of two ways:
  • _solve_time = "CPU time" = the processor time used by the solver, not counting time taken by other processes that are also running
  • _solve_elapsed_time = "wall-clock time" = the time you had to wait between invoking "solve" and getting a solution back
For single-threaded solves (running on one processor core), _solve_time tends to be more accurate. For multi-threaded solves (running on more than one core in parallel), _solve_elapsed_time should be used. BARON runs single-threaded by default but can be made to run multi-threaded; search for "thread" in the BARON manual to learn more.

Also if you set outlev=1 in your baron_options string then BARON will display the CPU and wall-clock times in the summary at the end of its listing. These times do not include the overhead of the AMPL-BARON interface, and so they will be a little less than the times reported in _solve_time and _solve_elapsed_time.

AMPL runs single-threaded, so for the time spent in AMPL you should use _ampl_time. This is the time since the AMPL session began, so to find the time spent in AMPL for generating a problem file and processing results, you need to measure _ampl_time before and after a solve, and record the difference. For example, you could define "param ampl_start_time;" and then proceed like this:

let ampl_start_time := _ampl_time;
solve;
display _ampl_time - ampl_start_time;


In fact you can use "_ampl_time - ampl_start_time" in any AMPL statement where a number is appropriate.


--
Robert Fourer
am...@googlegroups.com
{#HS:1622908814-106184#}

adit...@gmail.com

unread,
Sep 6, 2021, 10:31:43 PM9/6/21
to AMPL Modeling Language
Thanks Robert for your useful answer. It is very clear.

I think for me the best option is outlev = 1 because I am only interested in the time BARON takes to solve the model, and not in the time AMPL takes to load the model in BARON.

Regards,
Aditya

Reply all
Reply to author
Forward
0 new messages