Skip to content

Commit 09aa8c9

Browse files
Fix obj constant on max. Fix undefined memory access at root (#52)
This PR fixes two bugs discovered while testing the AMPL interface: 1) We weren't correctly calculating the objective constant when presolve eliminated variables on a maximization problem. Thanks to Alice for the quick fix! 2) We had an undefined memory access on the number of nodes and simplex iterations when solving a MIP at the root node. --------- Co-authored-by: Ramakrishnap <42624703+rgsl888prabhu@users.noreply.github.com>
1 parent 5314217 commit 09aa8c9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

cpp/src/dual_simplex/branch_and_bound.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,10 @@ mip_status_t branch_and_bound_t<i_t, f_t>::solve(mip_solution_t<i_t, f_t>& solut
463463
global_variables::mutex_upper.unlock();
464464
// We should be done here
465465
uncrush_primal_solution(original_problem, original_lp, incumbent.x, solution.x);
466-
solution.objective = incumbent.objective;
467-
solution.lower_bound = lower_bound;
466+
solution.objective = incumbent.objective;
467+
solution.lower_bound = lower_bound;
468+
solution.nodes_explored = 0;
469+
solution.simplex_iterations = root_relax_soln.iterations;
468470
settings.log.printf("Optimal solution found at root node. Objective %.16e. Time %.2f.\n",
469471
compute_user_objective(original_lp, root_objective),
470472
toc(start_time));

cpp/src/linear_programming/utilities/logger_init.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class init_logger_t {
3737
// TODO save the defaul sink and restore it
3838
cuopt::default_logger().sinks().push_back(
3939
std::make_shared<rapids_logger::basic_file_sink_mt>(log_file, true));
40+
cuopt::default_logger().set_pattern("%v");
41+
cuopt::default_logger().flush_on(rapids_logger::level_enum::info);
4042
}
4143
}
4244
~init_logger_t() { cuopt::reset_default_logger(); }

cpp/src/mip/presolve/trivial_presolve.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ void update_from_csr(problem_t<i_t, f_t>& pb)
234234

235235
// update objective_offset
236236
pb.presolve_data.objective_offset +=
237+
pb.presolve_data.objective_scaling_factor *
237238
thrust::transform_reduce(handle_ptr->get_thrust_policy(),
238239
thrust::counting_iterator<i_t>(0),
239240
thrust::counting_iterator<i_t>(pb.n_variables),

0 commit comments

Comments
 (0)