Reporting the Computation Time to a file and Creating a .sol File

81 views
Skip to first unread message

Abdulaziz Alghosh

unread,
Apr 28, 2017, 6:22:12 AM4/28/17
to AMPL Modeling Language

Hello fellows,

I am a beginner with AMPL and i need your help with two issues :


1- Since i am using CPLEXAMP as a solver i had to write mipdisplay= 2 in order to get the Computation time of CPLEX. Consequently, the computation time and a lot of Information will be showed on the Command Line Screen and it would be better for me to get the Computation Time in another way like exporting it to a file to be able of reading it automatically.

please note that taking all these printed info from the command line screen to a Log File will not be so helpful since it would be better to scan a well formatted file like text or xml one rather than a log file (like when i have to get the optimality gap and obejctive values).

2- the second issue is the .sol file which is supposed to be created based on setting the 'wantsol' CPLEX option as following:  'wantsol =1 '. Even though, i did not get it (note : as i know the .sol file would contain all the variables in a well-indexed fashion and their values other than exporting them to several files)

Instead of the .sol file, i created the solution.xml file via the 'endsol' CPLEX option ( ' endsol = filename '').  This xml file has a bunch of useful information like the optimality gap (epInt) and the objective value but unfortunately no Computation Time, furthermore, it shows the variables and constraints in an awful layout which i could not interpret it.


I will be thankful if you can advise me with another way to export the computation time into a specific file and an action to create a .sol file

Thanks in advance and BR

Abdul

Robert Fourer

unread,
Apr 29, 2017, 11:29:15 AM4/29/17
to am...@googlegroups.com
CPLEX does not have an option to produce a formatted text file with all the information that is in the MIP soltuion log. Thus in general there is no alternative to parsing the log file. There are exceptions however for some timing and bound information.

For MIP solves, the AMPL built-in parameter _solve_elapsed_time gives a useful timing for the most recent solve. (There is also a built-in parameter _solve_time but it gives the total CPU time over all threads, and so is not useful unless you are restricting your CPLEX runs to a single thread.)

If you add return_mipgap=3 to your cplex_options string then xxx.relmipgap and xxx.absmipgap -- where xxx is replaced by the name of your objective function -- will contain the relative and absolute gap between the lower and upper bounds on the optimal solution at the point where CPLEX stopped. See the return_mipgap entry at http://ampl.com/products/solvers/solvers-we-sell/cplex/options/ for a full description of this option. Similarly if you add the single-word option bestbound to your cplex_options string, then xxx.bestbound will contain the best lower bound (if minimizing) or upper bound (if maximizing) determined by the CPLEX run. (The best upper bound (if minimizing) or lower bound (if maximizing) is given by the objective value xxx that CPLEX returns.)

The .sol file format is only for sending solutions from solvers back to AMPL. It is not useful for extracting information yourself, and thus wantsol=1 does not appear to have any value in your situation.

The format of the CPLEX xml file produced by the endsol option is determined by IBM. To see the file clearly, try opening it in a browser window.

Bob Fourer
am...@googlegroups.com

=======

Abdulaziz Alghosh

unread,
Apr 30, 2017, 6:19:04 AM4/30/17
to AMPL Modeling Language, 4...@ampl.com
Hi Bob,

thanks a lot for your detailed answer.

BR
Abdul
Reply all
Reply to author
Forward
0 new messages