Display format and elapsed time for executions (not for solve)

323 views
Skip to first unread message

pianoman

unread,
Sep 22, 2010, 2:14:32 AM9/22/10
to AMPL Modeling Language
Folks,

I have two questions regarding AMPL (might be basic.)

First, how to control the precision format, i.e., decimal points, of
"display command"? When I use "display command" to show all values of
variables after solving my LP using CPLEX, sometimes AMPL simply
displays some variables as zeros, which should have very small values.
So if I can increase decimal points of display command to like 10th
digits, I would be able to see the actual values of variables of
interest.

Second, is there a way to measure the elapsed time for some executions
(not involved with "solve") in AMPL, like "tic-toc" in MATLAB? (I'm
not looking for _solve_system_time, etc.) For example, if I'd like to
know CPU time for the for-loop statements, what should I do?

Any suggestions would be appreciated. Thanks!

Paul

unread,
Sep 22, 2010, 8:11:57 AM9/22/10
to AMPL Modeling Language
On Sep 22, 2:14 am, pianoman <pma...@gmail.com> wrote:

>
> First, how to control the precision format, i.e., decimal points, of
> "display command"? When I use "display command" to show all values of
> variables after solving my LP using CPLEX, sometimes AMPL simply
> displays some variables as zeros, which should have very small values.
> So if I can increase decimal points of display command to like 10th
> digits,  I would be able to see the actual values of variables of
> interest.

To print exact values:
option display_precision 0;
>
> Second, is there a way to measure the elapsed time for some executions
> (not involved with "solve") in AMPL, like "tic-toc" in MATLAB? (I'm
> not looking for _solve_system_time, etc.) For example, if I'd like to
> know CPU time for the for-loop statements, what should I do?

The best I can come up with is to print the time at the start and end
of the loop and figure it out manually. To print the time, I think
you'll need to shell out to the operating system. So something like
the following would work on Windows:

shell "time /T"; # display start time
# for loop here
shell "time /T"; # display end time

/Paul

Robert Fourer

unread,
Sep 22, 2010, 8:47:05 AM9/22/10
to am...@googlegroups.com, pianoman
To display with, say, 10 significant digits:

option display_precision 10;

To display with 10 digits after the decimal point:

option display_round 10;

And as Paul mentions, "option display_precision 0;" is specially interpreted
to use as much precision as is needed to display in decimal format the
computer's representation of the number.

Bob Fourer
4...@ampl.com

pianoman

unread,
Sep 22, 2010, 11:08:32 AM9/22/10
to AMPL Modeling Language
Thank you for your help! But if I use shell "time /T";, AMPL only
reports hour and minute based. For example, 11:03 AM and 11:04AM for
the test. I need to know more precise elapsed time during the
execution, like within the precision 1E-10. Is there any way to do
this in AMPL?

Thank you!

Paul

unread,
Sep 22, 2010, 2:34:37 PM9/22/10
to AMPL Modeling Language
On Sep 22, 11:08 am, pianoman <pma...@gmail.com> wrote:
> Thank you for your help! But if I use shell "time /T";, AMPL only
> reports hour and minute based. For example, 11:03 AM and 11:04AM for
> the test. I need to know more precise elapsed time during the
> execution, like within the precision 1E-10. Is there any way to do
> this in AMPL?

Not that I know of. :-(

/Paul
Reply all
Reply to author
Forward
0 new messages