lurupa_cmd.cpp File Reference

Lurupa's command line client. More...

#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>

Include dependency graph for lurupa_cmd.cpp:


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.

Detailed Description

Lurupa's command line client.

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.

Author:
Christian Keil
Id
lurupa_cmd.cpp 533 2008-06-12 20:08:12Z keil

Function Documentation

void compute_dual ( Lurupa lurupa,
Lp lp,
Lp_stats lp_stats 
)

Compute dual certificate.

Compute and time a dual certificate for primal infeasibility lp.

Parameters:
[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().

void compute_lower ( Lurupa lurupa,
Lp lp,
Lp_stats lp_stats 
)

Compute lower bound.

Compute and time a lower bound for the optimal value of lp.

Parameters:
[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().

void compute_primal ( Lurupa lurupa,
Lp lp,
Lp_stats lp_stats 
)

Compute primal certificate.

Compute and time a primal certificate for dual infeasibility of lp.

Parameters:
[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().

void compute_upper ( Lurupa lurupa,
Lp lp,
Lp_stats lp_stats 
)

Compute upper bound.

Compute and time an upper bound for the optimal value of lp.

Parameters:
[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[] 
)

void print_bound_stats ( const Bound bound,
const Lp_stats lp_stats 
)

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).

Parameters:
[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.

Parameters:
[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.

Parameters:
[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.

Parameters:
[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.

Parameters:
[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.

Parameters:
[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

\[ \mu(a, b) = \frac{\lvert a - b \rvert} {\max \{1, \lvert a + b \rvert / 2\}}, \]

where $a$ and $b$ are the computed bounds or the approximate optimal value if one of the bounds could not be computed. Note that $\mu$ 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.

Parameters:
[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.

Parameters:
[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().

void report_lower ( Lp lp,
Lp_stats lp_stats 
)

Report lower bound.

Report value and stats of the lower bound on the optimal value of lp.

Parameters:
[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.

Parameters:
[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().

void report_upper ( Lp lp,
Lp_stats lp_stats 
)

Report upper bound.

Report value and stats of the upper bound on the optimal value of lp.

Parameters:
[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.

Parameters:
[in] x the double value to convert
[in] direction direction of rounding
Returns:
rounded string representation

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.

Parameters:
[out] pt process time counter value
[out] rt realtime counter value
See also:
stop_timer

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.

Parameters:
[out] pt process time counter value
[out] rt realtime counter value
See also:
start_timer

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.

Parameters:
[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
Returns:
time status string

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

  • name of the model
  • status of the solver solving the original model
  • approximate optimal value
  • time needed to compute the approximate value
  • verified lower bound's data
    • bound status
    • bound value
    • number of iterations to compute the bound
    • time needed to compute the bound
  • verified upper bound's data
    • bound status
    • bound value
    • number of iterations to compute the bound
    • time needed to compute the bound
  • relative accuracy of the bounds

Parameters:
[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

  • name of the model
  • approximate optimal solution or the solver status if solving failed
  • time needed to solve the model
  • verified lower bound's data
    • bound value or the bound status if its computation failed
    • number of algorithm iterations to compute the bound
    • ratio of the time needed to compute the bound and the time needed to solve the model
  • verified upper bound's data
    • bound value or the bound status if its computation failed
    • number of algorithm iterations to compute the bound
    • ratio of the time needed to compute the bound and the time needed to solve the model
  • relative accuracy of the bounds

Parameters:
[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.

Parameters:
[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().


Generated on Thu Jun 26 18:08:53 2008 for Lurupa by  doxygen 1.5.6