improvements

This commit is contained in:
lperron@google.com
2012-01-16 10:30:41 +00:00
parent 2f48012fa3
commit 52210f822a
3 changed files with 13 additions and 1 deletions

View File

@@ -139,8 +139,16 @@ int solve_dimacs_assignment(int argc, char* argv[]) {
LOG(FATAL) << error_message;
}
if (!FLAGS_assignment_problem_output_file.empty()) {
PrintDimacsAssignmentProblem(*assignment,
// The following tail array management stuff is done in a generic
// way so we can plug in different types of graphs for which the
// TailArrayManager template can be instantiated, even though we
// know the type of the graph explicitly. In this way, the type of
// the graph can be switched just by changing the graph type in
// this file and making no other changes to the code.
TailArrayManager<ForwardStarGraph> tail_array_manager(graph);
PrintDimacsAssignmentProblem(*assignment, tail_array_manager,
FLAGS_assignment_problem_output_file);
tail_array_manager.ReleaseTailArrayIfForwardGraph();
}
CostValue hungarian_cost = 0.0;
bool hungarian_solved = false;

View File

@@ -37,6 +37,7 @@ static void WriteOrDie(const char* buffer,
void PrintDimacsAssignmentProblem(
const LinearSumAssignment<ForwardStarGraph>& assignment,
const TailArrayManager<ForwardStarGraph>& tail_array_manager,
const string& output_filename) {
FILE* output = fopen(output_filename.c_str(), "w");
const ForwardStarGraph& graph(assignment.Graph());
@@ -55,6 +56,8 @@ void PrintDimacsAssignmentProblem(
output);
}
tail_array_manager.BuildTailArrayFromAdjacencyListsIfForwardGraph();
for (ForwardStarGraph::ArcIterator arc_it(assignment.Graph());
arc_it.Ok();
arc_it.Next()) {

View File

@@ -20,6 +20,7 @@ template <typename GraphType> class LinearSumAssignment;
// http://lpsolve.sourceforge.net/5.5/DIMACS_asn.htm
void PrintDimacsAssignmentProblem(
const LinearSumAssignment<ForwardStarGraph>& assignment,
const TailArrayManager<ForwardStarGraph>& tail_array_manager,
const string& output_filename);
} // namespace operations_research