cplexlpcompare
Compares two LP files created in cplex format and dumps differences to files.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Macros | Functions | Variables
lpcompare.cpp File Reference

Handles command line arguments and has the main method. More...

#include <vector>
#include <iostream>
#include "LPModel.h"
#include <boost/range/algorithm/set_algorithm.hpp>
#include <chrono>
#include <boost/program_options.hpp>
Include dependency graph for lpcompare.cpp:

Go to the source code of this file.

Macros

#define TIMING
 
#define INIT_TIMER   auto start = std::chrono::high_resolution_clock::now()
 
#define START_TIMER   start = std::chrono::high_resolution_clock::now()
 
#define STOP_TIMER()
 
#define STOP_TIMER_SEC()   (STOP_TIMER() / 60)
 

Functions

template<typename T >
void printCounts (std::string detail_name, std::vector< T > &vec, std::vector< T > &vecother)
 Prints count of a given detail for both models, including differences. More...
 
template<>
void printCounts (std::string detail_name, std::vector< lpcompare::Bound > &vec, std::vector< lpcompare::Bound > &vecother)
 printCounts specialization for Bounds, which will be sorted before set operations. More...
 
template<>
void printCounts (std::string detail_name, std::vector< lpcompare::Constraint > &vec, std::vector< lpcompare::Constraint > &vecother)
 printCounts specialization for Constraints, which will be sorted before set operations. More...
 
template<typename T >
void printCountsWithSort (std::string name, std::vector< T > &vec, std::vector< T > &vecother)
 Prints count of a given detail for both models, including differences. More...
 
void printStats (LPModel *model)
 Prints statistics for a model. More...
 
template<typename T >
void dumpdiff_if_requested (std::string detail_name, std::vector< T > &set1Except2, std::vector< T > &set2Except1)
 Dumps diffs to a file if dumping is requested. More...
 
void setup_options (int argc, char *argv[])
 Parses program arguments using boost program_options. More...
 
std::string get_dump_filename (std::string model, std::string detail)
 Creates a filename to dump differences into. More...
 
bool is_diffdumps_requested ()
 Checks if diff dumps are requested. More...
 
int main (int argc, char *argv[])
 

Variables

std::string first_filename
 Filename of the first LP model. More...
 
std::string second_filename
 Filename of the second LP model. More...
 
po::variables_map vm
 Variable map for boost::program_options. More...
 

Detailed Description

Handles command line arguments and has the main method.

Definition in file lpcompare.cpp.

Macro Definition Documentation

#define INIT_TIMER   auto start = std::chrono::high_resolution_clock::now()

Definition at line 36 of file lpcompare.cpp.

#define START_TIMER   start = std::chrono::high_resolution_clock::now()

Definition at line 37 of file lpcompare.cpp.

#define STOP_TIMER ( )
Value:
( \
std::chrono::duration_cast<std::chrono::milliseconds>( \
std::chrono::high_resolution_clock::now()-start \
).count())

Definition at line 38 of file lpcompare.cpp.

#define STOP_TIMER_SEC ( )    (STOP_TIMER() / 60)

Definition at line 42 of file lpcompare.cpp.

#define TIMING

Definition at line 33 of file lpcompare.cpp.

Function Documentation

template<typename T >
void dumpdiff_if_requested ( std::string  detail_name,
std::vector< T > &  set1Except2,
std::vector< T > &  set2Except1 
)

Dumps diffs to a file if dumping is requested.

Parameters
set1Except2List of elements that are in the first model but not in the second model.
set2Except1List of elements that are in the second model but not in the first model.

Definition at line 215 of file lpcompare.cpp.

Here is the call graph for this function:

std::string get_dump_filename ( std::string  model,
std::string  detail 
)

Creates a filename to dump differences into.

Parameters
modelModel name.
detailModel detail.
Returns
dump filename.

Definition at line 132 of file lpcompare.cpp.

bool is_diffdumps_requested ( )

Checks if diff dumps are requested.

Returns
true if diff dumps are requested.

Definition at line 141 of file lpcompare.cpp.

int main ( int  argc,
char *  argv[] 
)

Definition at line 145 of file lpcompare.cpp.

Here is the call graph for this function:

template<typename T >
void printCounts ( std::string  detail_name,
std::vector< T > &  vec,
std::vector< T > &  vecother 
)

Prints count of a given detail for both models, including differences.

Parameters
detail_nameGiven name of the detail.
vecList of elements that are in the first model.
vecotherList of elements that are in the second model.

Definition at line 271 of file lpcompare.cpp.

Here is the call graph for this function:

template<>
void printCounts ( std::string  detail_name,
std::vector< lpcompare::Bound > &  vec,
std::vector< lpcompare::Bound > &  vecother 
)

printCounts specialization for Bounds, which will be sorted before set operations.

Parameters
detail_nameGiven name of the detail.
vecList of elements that are in the first model.
vecotherList of elements that are in the second model.

Definition at line 384 of file lpcompare.cpp.

Here is the call graph for this function:

template<>
void printCounts ( std::string  detail_name,
std::vector< lpcompare::Constraint > &  vec,
std::vector< lpcompare::Constraint > &  vecother 
)

printCounts specialization for Constraints, which will be sorted before set operations.

Parameters
detail_nameGiven name of the detail.
vecList of elements that are in the first model.
vecotherList of elements that are in the second model.

Definition at line 371 of file lpcompare.cpp.

Here is the call graph for this function:

template<typename T >
void printCountsWithSort ( std::string  name,
std::vector< T > &  vec,
std::vector< T > &  vecother 
)

Prints count of a given detail for both models, including differences.

Performs in-place sorting of vec and vecother.

Parameters
detail_nameGiven name of the detail.
vecList of elements that are in the first model.
vecotherList of elements that are in the second model.

Definition at line 304 of file lpcompare.cpp.

Here is the call graph for this function:

void printStats ( LPModel model)

Prints statistics for a model.

Parameters
modelModel.

Definition at line 200 of file lpcompare.cpp.

void setup_options ( int  argc,
char *  argv[] 
)

Parses program arguments using boost program_options.

Parameters
argcargument count.
argvargument list.

Definition at line 89 of file lpcompare.cpp.

Variable Documentation

std::string first_filename

Filename of the first LP model.

Definition at line 78 of file lpcompare.cpp.

std::string second_filename

Filename of the second LP model.

Definition at line 79 of file lpcompare.cpp.

po::variables_map vm

Variable map for boost::program_options.

Definition at line 81 of file lpcompare.cpp.