#include "svnversion.h"
#include <lurupa/globals.h>
#include <lurupa/Lurupa.h>
#include <lurupa/Lp.h>
#include <lr/Lr.h>
#include <ltdl.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <errno.h>
#include <iostream>
#include <new>
#include <time.h>
Classes | |
struct | Bound |
Information about a Bound. More... | |
struct | Certificate |
A certificate. More... | |
struct | Enclosure |
An enclosure. More... | |
struct | Lp_stats |
Information about an Lp. More... | |
Functions | |
void | compute_dual (Lurupa *lurupa, Lp *lp, Lp_stats *lp_stats) |
Compute dual certificate. | |
void | compute_lower (Lurupa *lurupa, Lp *lp, Lp_stats *lp_stats) |
Compute lower bound. | |
void | compute_primal (Lurupa *lurupa, Lp *lp, Lp_stats *lp_stats) |
Compute primal certificate. | |
void | compute_upper (Lurupa *lurupa, Lp *lp, Lp_stats *lp_stats) |
Compute upper bound. | |
int | main (int argc, char *argv[]) |
Command line main. | |
void | out_of_memory () |
Out of memory handler. | |
void | print_bound_stats (const Bound &bound, const Lp_stats &lp_stats) |
Print bound statistics. | |
void | print_brief_version (const Lurupa &lurupa, bool solver_module_set) |
Print brief version information. | |
void | print_model_data (const Lp_stats &lp_stats) |
Print model data. | |
void | print_usage (char *self, const Lurupa &lurupa, bool solver_module_set) |
Print usage information. | |
void | print_version (const Lurupa &lurupa, bool solver_module_set) |
Print version information. | |
void | process_solving_status (Lp_stats &lp_stats) |
Process solving statistics. | |
void | report_bound_quality (Lp_stats &lp_stats) |
Compute bound quality. | |
void | report_dual (Lp_stats &lp_stats) |
Report dual certificate. | |
void | report_lower (Lp *lp, Lp_stats &lp_stats) |
Report lower bound. | |
void | report_primal (Lp_stats &lp_stats) |
Report primal certificate. | |
void | report_upper (Lp *lp, Lp_stats &lp_stats) |
Report upper bound. | |
const char * | rounded_string (double x, int direction) |
Correctly round double to string. | |
void | start_timer (clock_t &pt, int &rt) |
Start timer. | |
void | stop_timer (clock_t &pt, int &rt) |
Stop timer. | |
const char * | timer_diff (clock_t start_pt, clock_t end_pt, int start_rt, int end_rt, double &pt_diff, double &rt_diff) |
Compute timer difference. | |
void | write_csv_table (const Lp_stats &lp_stats, FILE *csv) |
Write csv table. | |
void | write_latex_table (const Lp_stats &lp_stats, FILE *latex) |
Write LaTeX table. | |
void | write_tables (short tables, const Lp_stats &lp_stats, FILE *latex, FILE *csv) |
Write tables. | |
Variables | |
static const char * | copyright = "Copyright (C) 2006 Christian Keil" |
Copyright string. | |
static const char * | version = "Lurupa command line client 1.2" |
Version string. |
This is Lurupa's command line client. It uses the core logic and a user specified solver module to compute verified bounds for a linear program. The results and the time needed to compute them are displayed and written to disk in csv or LaTeX format.
Compute dual certificate.
Compute and time a dual certificate for primal infeasibility lp
.
[in] | lurupa | Lurupa reference used to compute certificate |
[in] | lp | the lp |
[out] | lp_stats | stores certificate status and time |
References Lp_stats::dual, Lurupa::dual_certificate(), Certificate::proc_time, Certificate::realtime, start_timer(), Certificate::status, stop_timer(), Certificate::time_status, and timer_diff().
Referenced by main().
Compute lower bound.
Compute and time a lower bound for the optimal value of lp
.
[in] | lurupa | Lurupa reference used to compute bound |
[in] | lp | the lp |
[out] | lp_stats | stores bound and time |
References Bound::iterations, Lp_stats::lower, Lurupa::lower_bound(), Bound::proc_time, Bound::realtime, start_timer(), Bound::status, stop_timer(), Bound::time_status, timer_diff(), and Bound::value.
Referenced by main().
Compute primal certificate.
Compute and time a primal certificate for dual infeasibility of lp
.
[in] | lurupa | Lurupa reference used to compute certificate |
[in] | lp | the lp |
[out] | lp_stats | stores certificate status and time |
References Lp_stats::primal, Lurupa::primal_certificate(), Certificate::proc_time, Certificate::realtime, start_timer(), Certificate::status, stop_timer(), Certificate::time_status, and timer_diff().
Referenced by main().
Compute upper bound.
Compute and time an upper bound for the optimal value of lp
.
[in] | lurupa | Lurupa reference used to compute bound |
[in] | lp | the lp |
[out] | lp_stats | stores bound and time |
References Bound::iterations, Bound::proc_time, Bound::realtime, start_timer(), Bound::status, stop_timer(), Bound::time_status, timer_diff(), Lp_stats::upper, Lurupa::upper_bound(), and Bound::value.
Referenced by main().
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Command line main.
Parse the command line arguments and call Lurupa appropriately. Print the results and write them to disk.
References Lp_stats::automatic, Enclosure::compute, Certificate::compute, Bound::compute, compute_dual(), compute_lower(), compute_primal(), compute_upper(), Lurupa::cond(), Lp_stats::condition, Lp_stats::dual, Lp_stats::is_maximize, l, Enclosure::lower, Lp_stats::lower, LU_T_CSV, LU_T_LATEX, matlab, Lp::maximize, Lp::name, Lp_stats::name, octave, Lp_stats::optimal_value, out_of_memory(), Lp_stats::path, Lp_stats::primal, print_brief_version(), print_model_data(), print_usage(), print_version(), process_solving_status(), Lurupa::read_lp(), Lurupa::report, report_bound_quality(), report_dual(), report_lower(), report_primal(), report_upper(), Lurupa::rho_d(), Lp_stats::rho_d, Lurupa::rho_p(), Lp_stats::rho_p, rounded_string(), Lurupa::set_alpha(), Report::set_csv_style(), Lurupa::set_eta(), Lurupa::set_inflate(), Lurupa::set_module(), Lurupa::set_module_options(), Report::set_verbosity(), Lurupa::solve_lp(), Lp_stats::solve_proc_time, Lp_stats::solve_realtime, Lp_stats::solve_time_status, ss_failure, ss_feasible, ss_infeasible, ss_unbounded, start_timer(), Lp_stats::status, stop_timer(), timer_diff(), Lp_stats::total_proc_time, Lp_stats::total_realtime, Lp_stats::total_time_status, Enclosure::upper, Lp_stats::upper, and write_tables().
Print bound statistics.
Print statistics about a computed bound. These include of course the bound itself along with the count of algorithm iterations needed, the time needed, the ratio of the time needed to compute the bounds and the time needed to compute the approximate optimal value, the status of the computed bound (e.g. bound successfully computed, no bound computed because of rank deficiency).
[in] | bound | the bound's statistics |
[in] | lp_stats | contains the time to solve the model |
References bound_status_string, Bound::iterations, Bound::proc_time, Bound::realtime, Lp_stats::solve_proc_time, Lp_stats::solve_realtime, Bound::status, and Bound::time_status.
Referenced by report_lower(), and report_upper().
void print_brief_version | ( | const Lurupa & | lurupa, | |
bool | solver_module_set | |||
) |
Print brief version information.
Print brief version information suitable for log output.
[in] | lurupa | Lurupa instance to print information about |
[in] | solver_module_set | whether a solver module is loaded |
References copyright, Lurupa::print_core_brief_version(), Lurupa::print_module_brief_version(), and version.
Referenced by main().
void print_model_data | ( | const Lp_stats & | lp_stats | ) |
Print model data.
Print the name and the optimization direction of the model to be processed.
[in] | lp_stats | contains the model's data |
References Lp_stats::is_maximize, and Lp_stats::name.
Referenced by main().
void print_usage | ( | char * | self, | |
const Lurupa & | lurupa, | |||
bool | solver_module_set | |||
) |
Print usage information.
Print usage information for the command line client; which parameters with which values are supported.
[in] | self | path to running program |
[in] | lurupa | Lurupa instance to access solver module |
[in] | solver_module_set | whether a solver module is loaded |
References Lurupa::print_module_options(), and version.
Referenced by main().
void print_version | ( | const Lurupa & | lurupa, | |
bool | solver_module_set | |||
) |
Print version information.
Print version information for the application parts.
[in] | lurupa | Lurupa instance to print information about |
[in] | solver_module_set | whether a solver module is loaded |
References copyright, Lurupa::print_core_version(), Lurupa::print_module_version(), and version.
Referenced by main().
void process_solving_status | ( | Lp_stats & | lp_stats | ) |
Process solving statistics.
Print statistics regarding the solving of the lp like the approximate optimal value, the time needed to compute it, the status of the lp-solver (e.g., the solver's judgement of the model's feasibility or timeout while solving the model). Set lp.lower.compute
and lp.upper.compute
to false if the lp-solver did not judge the model to be either feasible, infeasible, or unbounded, that is returned with any kind of error.
[in,out] | lp_stats | contains the solving statistics |
References Bound::compute, Lp_stats::lower, Lp_stats::optimal_value, Lp_stats::solve_proc_time, Lp_stats::solve_realtime, Lp_stats::solve_time_status, solver_status_string, ss_feasible, ss_infeasible, ss_unbounded, Lp_stats::status, and Lp_stats::upper.
Referenced by main().
void report_bound_quality | ( | Lp_stats & | lp_stats | ) |
Compute bound quality.
Compute and print the accuracy of the verified bounds. It is computed by
where and are the computed bounds or the approximate optimal value if one of the bounds could not be computed. Note that is computed from the bound values as they are computed and not from the printed ones. The printed values of the bounds are rounded to display a rigorous enclosure of the optimal value.
[in,out] | lp_stats | contains the verified bounds |
References Lp_stats::bound_quality, Bound::compute, Lp_stats::lower, Lp_stats::optimal_value, Lp_stats::upper, and Bound::value.
Referenced by main().
void report_dual | ( | Lp_stats & | lp_stats | ) |
Report dual certificate.
Report success and time of computing a dual certificate for an lp.
[in] | lp_stats | contains the certificate to report |
References bound_status_string, Lp_stats::dual, Certificate::proc_time, Certificate::realtime, Certificate::status, and Certificate::time_status.
Referenced by main().
Report lower bound.
Report value and stats of the lower bound on the optimal value of lp
.
[in] | lp | the lp |
[in] | lp_stats | the stats |
References Lp_stats::lower, Lp_stats::optimal_value, print_bound_stats(), rounded_string(), ss_feasible, Lp_stats::status, and Bound::value.
Referenced by main().
void report_primal | ( | Lp_stats & | lp_stats | ) |
Report primal certificate.
Report success and time of computing a primal certificate for an lp.
[in] | lp_stats | contains the certificate to report |
References bound_status_string, Lp_stats::primal, Certificate::proc_time, Certificate::realtime, Certificate::status, and Certificate::time_status.
Referenced by main().
Report upper bound.
Report value and stats of the upper bound on the optimal value of lp
.
[in] | lp | the lp |
[in] | lp_stats | the stats |
References Lp_stats::optimal_value, print_bound_stats(), rounded_string(), ss_feasible, Lp_stats::status, Lp_stats::upper, and Bound::value.
Referenced by main().
const char* rounded_string | ( | double | x, | |
int | direction | |||
) |
Correctly round double to string.
Generate a correctly rounded string representation of x
. The direction of rounding can be selected via direction
. Possible values are LR_RND_DOWN
, LR_RND_UP, LR_RND_NEAR, LR_RND_CHOP.
[in] | x | the double value to convert |
[in] | direction | direction of rounding |
Referenced by main(), report_lower(), and report_upper().
void start_timer | ( | clock_t & | pt, | |
int & | rt | |||
) |
Start timer.
Get realtime and process time counter values. These can be compared to the ones returned by stop_timer to compute the elapsed time.
[out] | pt | process time counter value |
[out] | rt | realtime counter value |
Referenced by compute_dual(), compute_lower(), compute_primal(), compute_upper(), and main().
void stop_timer | ( | clock_t & | pt, | |
int & | rt | |||
) |
Stop timer.
Get realtime and process time counter values. These can be compared to the ones returned by start_timer to compute the elapsed time.
[out] | pt | process time counter value |
[out] | rt | realtime counter value |
Referenced by compute_dual(), compute_lower(), compute_primal(), compute_upper(), and main().
const char* timer_diff | ( | clock_t | start_pt, | |
clock_t | end_pt, | |||
int | start_rt, | |||
int | end_rt, | |||
double & | pt_diff, | |||
double & | rt_diff | |||
) |
Compute timer difference.
Compute the elapsed realtime and process time verifying that no wrap around in the process time counter occured. If a wrap around occured or cannot be ruled out or the calls to the time routines failed, return a short string explaining what happened.
[in] | start_pt | process time counter value at start |
[in] | end_pt | process time counter value at end |
[in] | start_rt | realtime counter value at start |
[in] | end_rt | realtime counter value at end |
[out] | pt_diff | elapsed process time in seconds |
[out] | rt_diff | elapsed realtime in seconds |
Referenced by compute_dual(), compute_lower(), compute_primal(), compute_upper(), and main().
void write_csv_table | ( | const Lp_stats & | lp_stats, | |
FILE * | csv | |||
) |
Write csv table.
Write a line containing the gathered results with maximal precision to disk in csv format. This includes
[in] | lp_stats | contains the model's and bound's statistics |
[in] | csv | file to be written to |
References Lp_stats::bound_quality, bound_status_string, Bound::compute, Bound::iterations, Lp_stats::lower, Lp_stats::name, Lp_stats::optimal_value, Bound::proc_time, Bound::realtime, Lp_stats::solve_proc_time, Lp_stats::solve_realtime, solver_status_string, Bound::status, Lp_stats::status, Lp_stats::upper, and Bound::value.
Referenced by write_tables().
void write_latex_table | ( | const Lp_stats & | lp_stats, | |
FILE * | latex | |||
) |
Write LaTeX table.
Write a line containing the gathered results to disk in LaTeX table format with precision tailored to viewing. This consists of
[in] | lp_stats | contains the model's and bound's statistics |
[in] | latex | file to be written to |
References Lp_stats::bound_quality, bound_status_string, bs_verified, Bound::compute, Bound::iterations, Lp_stats::lower, Lp_stats::name, Lp_stats::optimal_value, Bound::proc_time, Bound::realtime, Lp_stats::solve_proc_time, Lp_stats::solve_realtime, solver_status_string, ss_feasible, Bound::status, Lp_stats::status, Lp_stats::upper, and Bound::value.
Referenced by write_tables().
void write_tables | ( | short | tables, | |
const Lp_stats & | lp_stats, | |||
FILE * | latex, | |||
FILE * | csv | |||
) |
Write tables.
Calls the routines to write LaTeX and csv tables as specified by tables.
[in] | tables | specifies the tables to be written (c.f. globals.h) |
[in] | lp_stats | contains the model's and bound's statistics |
[in] | latex | file to write LaTeX table to |
[in] | csv | file to write csv table to |
References LU_T_CSV, LU_T_LATEX, write_csv_table(), and write_latex_table().
Referenced by main().