improvements
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user