From 22d2fee64a84965e704910a595fddd8d32fc3057 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Thu, 30 Sep 2021 13:33:32 +0200 Subject: [PATCH] polish --- examples/cpp/vector_bin_packing_solver.cc | 3 +-- ortools/packing/arc_flow_solver.cc | 22 +++------------------- ortools/packing/arc_flow_solver.h | 3 +-- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/examples/cpp/vector_bin_packing_solver.cc b/examples/cpp/vector_bin_packing_solver.cc index c98c82f3ac..cde2415571 100644 --- a/examples/cpp/vector_bin_packing_solver.cc +++ b/examples/cpp/vector_bin_packing_solver.cc @@ -77,8 +77,7 @@ void ParseAndSolve(const std::string& filename, const std::string& solver, packing::vbp::VectorBinPackingSolution solution = packing::SolveVectorBinPackingWithArcFlow(data, solver_type, params, absl::GetFlag(FLAGS_time_limit), - absl::GetFlag(FLAGS_threads), - /*log_statistics=*/true); + absl::GetFlag(FLAGS_threads)); if (!solution.bins().empty()) { for (int b = 0; b < solution.bins_size(); ++b) { LOG(INFO) << "Bin " << b; diff --git a/ortools/packing/arc_flow_solver.cc b/ortools/packing/arc_flow_solver.cc index e42e682f65..93939822d4 100644 --- a/ortools/packing/arc_flow_solver.cc +++ b/ortools/packing/arc_flow_solver.cc @@ -72,8 +72,7 @@ double ConvertVectorBinPackingProblem(const vbp::VectorBinPackingProblem& input, vbp::VectorBinPackingSolution SolveVectorBinPackingWithArcFlow( const vbp::VectorBinPackingProblem& problem, MPSolver::OptimizationProblemType solver_type, - const std::string& mip_params, double time_limit, int num_threads, - bool log_statistics) { + const std::string& mip_params, double time_limit, int num_threads) { ArcFlowGraph graph; const double arc_flow_time = ConvertVectorBinPackingProblem(problem, &graph); @@ -169,23 +168,8 @@ vbp::VectorBinPackingSolution SolveVectorBinPackingWithArcFlow( solution.set_status(vbp::INFEASIBLE); } - const bool has_solution = - result_status == MPSolver::OPTIMAL || result_status == MPSolver::FEASIBLE; - if (log_statistics) { - absl::PrintF("%-12s: %s\n", "Status", - MPSolverResponseStatus_Name( - static_cast(result_status)) - .c_str()); - absl::PrintF("%-12s: %15.15e\n", "Objective", - has_solution ? solver.Objective().Value() : 0.0); - absl::PrintF("%-12s: %15.15e\n", "BestBound", - has_solution ? solver.Objective().BestBound() : 0.0); - absl::PrintF("%-12s: %d\n", "Iterations", solver.iterations()); - absl::PrintF("%-12s: %d\n", "Nodes", solver.nodes()); - absl::PrintF("%-12s: %-6.4g\n", "Time", solution.solve_time_in_seconds()); - } - - if (has_solution) { + if (result_status == MPSolver::OPTIMAL || + result_status == MPSolver::FEASIBLE) { // Create the arc flow graph with the flow quantity in each arc. struct NextCountItem { int next = -1; diff --git a/ortools/packing/arc_flow_solver.h b/ortools/packing/arc_flow_solver.h index 394b81cfe4..8d67f8614e 100644 --- a/ortools/packing/arc_flow_solver.h +++ b/ortools/packing/arc_flow_solver.h @@ -23,8 +23,7 @@ namespace packing { vbp::VectorBinPackingSolution SolveVectorBinPackingWithArcFlow( const vbp::VectorBinPackingProblem& problem, MPSolver::OptimizationProblemType solver_type, - const std::string& mip_params, double time_limit, int num_threads, - bool log_statistics); + const std::string& mip_params, double time_limit, int num_threads); } // namespace packing } // namespace operations_research