diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index b168df7240..9f8c1fb7a9 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -81,6 +81,8 @@ rapids_find_package(CUDAToolkit REQUIRED set(CUOPT_CXX_FLAGS "") set(CUOPT_CUDA_FLAGS "") +list(APPEND CUOPT_CXX_FLAGS -Werror=unused-parameter -Werror=unused-variable) + if (CMAKE_COMPILER_IS_GNUCXX) list(APPEND CUOPT_CXX_FLAGS -Werror -Wno-error=deprecated-declarations) endif (CMAKE_COMPILER_IS_GNUCXX) @@ -180,11 +182,11 @@ message("-- Host target architecture = '${CMAKE_SYSTEM_PROCESSOR}'") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr --expt-extended-lambda") list(APPEND CUOPT_CUDA_FLAGS --Werror=all-warnings - # Unused declarations are handled in a follow-up change. - --diag-suppress=177 -Werror=cross-execution-space-call -Wno-deprecated-declarations -Xcompiler=-Werror + -Xcompiler=-Werror=unused-parameter + -Xcompiler=-Werror=unused-variable --default-stream=per-thread) if ("${CMAKE_CUDA_HOST_COMPILER}" MATCHES "clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") list(APPEND CUOPT_CUDA_FLAGS -Xcompiler=-Wall) @@ -895,11 +897,19 @@ target_include_directories(cuopt_mathopt PRIVATE $<$:${BZIP2_INCLUDE_DIRS}> $<$:${ZLIB_INCLUDE_DIRS}> ) -# Adding Papilo as a system include messes up clang's include resolution if papilo is already installed as a conda package -target_include_directories(cuopt_mathopt PRIVATE - "${papilo_SOURCE_DIR}/src" - "${papilo_BINARY_DIR}" -) +# Clang must keep Papilo ahead of a possible conda installation. GNU can treat the fetched headers +# as system headers so project warning errors do not apply to third-party templates. +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_include_directories(cuopt_mathopt PRIVATE + "${papilo_SOURCE_DIR}/src" + "${papilo_BINARY_DIR}" + ) +else () + target_include_directories(cuopt_mathopt SYSTEM PRIVATE + "${papilo_SOURCE_DIR}/src" + "${papilo_BINARY_DIR}" + ) +endif () target_include_directories(cuopt_mathopt SYSTEM PRIVATE "${pslp_SOURCE_DIR}/include" "${dejavu_SOURCE_DIR}" @@ -970,11 +980,17 @@ target_compile_options(cuopt_objs # - include paths --------------------------------------------------------------------------------- message(STATUS "target include directories CUDSS_INCLUDES = ${CUDSS_INCLUDE}") -# Adding Papilo as a system include messes up clang's include resolution if papilo is already installed as a conda package -target_include_directories(cuopt_objs PRIVATE - "${papilo_SOURCE_DIR}/src" - "${papilo_BINARY_DIR}" -) +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_include_directories(cuopt_objs PRIVATE + "${papilo_SOURCE_DIR}/src" + "${papilo_BINARY_DIR}" + ) +else () + target_include_directories(cuopt_objs SYSTEM PRIVATE + "${papilo_SOURCE_DIR}/src" + "${papilo_BINARY_DIR}" + ) +endif () target_include_directories(cuopt_objs SYSTEM PRIVATE "${pslp_SOURCE_DIR}/include" diff --git a/cpp/src/barrier/sparse_cholesky.cuh b/cpp/src/barrier/sparse_cholesky.cuh index 71ba3c0e01..51fdd6d6bc 100644 --- a/cpp/src/barrier/sparse_cholesky.cuh +++ b/cpp/src/barrier/sparse_cholesky.cuh @@ -116,7 +116,7 @@ class sparse_cholesky_base_t { // Use cudaMallocAsync instead of the RMM pool until we reduce our memory footprint/fragmentation. // TODO: Still use RMM for smaller problems to benefit from their allocation optimizations. template -int cudss_device_alloc(void* ctx, void** ptr, size_t size, cudaStream_t stream) +int cudss_device_alloc([[maybe_unused]] void* ctx, void** ptr, size_t size, cudaStream_t stream) { int status = cudaMallocAsync(ptr, size, stream); if (status != cudaSuccess) { throw raft::cuda_error("Cuda error in cudss_device_alloc"); } @@ -124,7 +124,10 @@ int cudss_device_alloc(void* ctx, void** ptr, size_t size, cudaStream_t stream) } template -int cudss_device_dealloc(void* ctx, void* ptr, size_t size, cudaStream_t stream) +int cudss_device_dealloc([[maybe_unused]] void* ctx, + void* ptr, + [[maybe_unused]] size_t size, + cudaStream_t stream) { int status = cudaFreeAsync(ptr, stream); if (status != cudaSuccess) { throw raft::cuda_error("Cuda error in cudss_device_dealloc"); } diff --git a/cpp/src/barrier/sparse_matrix_kernels.cuh b/cpp/src/barrier/sparse_matrix_kernels.cuh index c736e67aa4..1b98c4e9e4 100644 --- a/cpp/src/barrier/sparse_matrix_kernels.cuh +++ b/cpp/src/barrier/sparse_matrix_kernels.cuh @@ -115,8 +115,8 @@ void initialize_cusparse_data(raft::handle_t const* handle, template void multiply_kernels(raft::handle_t const* handle, - device_csr_matrix_t& A, - device_csc_matrix_t& DAT, + [[maybe_unused]] device_csr_matrix_t& A, + [[maybe_unused]] device_csc_matrix_t& DAT, device_csr_matrix_t& ADAT, cusparse_info_t& cusparse_data) { diff --git a/cpp/src/branch_and_bound/branch_and_bound.cpp b/cpp/src/branch_and_bound/branch_and_bound.cpp index a320cc0602..136744efd7 100644 --- a/cpp/src/branch_and_bound/branch_and_bound.cpp +++ b/cpp/src/branch_and_bound/branch_and_bound.cpp @@ -50,7 +50,7 @@ #if SUBMIP_VERBOSE #define DEBUG_SUBMIP(fmt, ...) settings_.log.print_format(fmt, __VA_ARGS__); #else -#define DEBUG_SUBMIP(fmt, ...) +#define DEBUG_SUBMIP(...) CUOPT_LOG_DISABLED(__VA_ARGS__) #endif namespace cuopt::mathematical_optimization::mip { @@ -868,11 +868,10 @@ void branch_and_bound_t::set_final_solution(mip_solution_t& settings_.heuristic_preemption_callback(); } - f_t user_obj = compute_user_objective(original_lp_, upper_bound_.load()); - f_t user_bound = compute_user_objective(original_lp_, lower_bound); - f_t gap = std::abs(user_obj - user_bound); - f_t gap_rel = user_relative_gap(user_obj, user_bound); - bool is_maximization = original_lp_.obj_scale < 0.0; + f_t user_obj = compute_user_objective(original_lp_, upper_bound_.load()); + f_t user_bound = compute_user_objective(original_lp_, lower_bound); + f_t gap = std::abs(user_obj - user_bound); + f_t gap_rel = user_relative_gap(user_obj, user_bound); settings_.log.print_format("Explored {} nodes ({} simplex iterations) in {:.2f}s.", exploration_stats_.nodes_explored.load(), @@ -1342,9 +1341,9 @@ struct deterministic_diving_policy_t } } - void update_objective_estimate(mip_node_t* node, - const std::vector& fractional, - const std::vector& x) override + void update_objective_estimate([[maybe_unused]] mip_node_t* node, + [[maybe_unused]] const std::vector& fractional, + [[maybe_unused]] const std::vector& x) override { /* no-op */ } @@ -2410,7 +2409,7 @@ void branch_and_bound_t::solve_submip(diving_worker_t* worke submip_settings.set_simplex_solution_callback = nullptr; submip_settings.solution_callback = [this, &presolver, fixrate, &submip_stats, log_prefix, worker](const std::vector& solution, - f_t obj) { + [[maybe_unused]] f_t obj) { this->set_solution_from_submip( worker->leaf_problem, solution, presolver, submip_stats, fixrate, log_prefix); }; @@ -3196,13 +3195,13 @@ lp_status_t branch_and_bound_t::solve_root_relaxation( std::vector crushed_root_y; std::vector crushed_root_z; - f_t dual_res_inf = simplex::crush_dual_solution(original_problem_, - original_lp_, - new_slacks_, - root_crossover_soln_.y, - root_crossover_soln_.z, - crushed_root_y, - crushed_root_z); + [[maybe_unused]] f_t dual_res_inf = simplex::crush_dual_solution(original_problem_, + original_lp_, + new_slacks_, + root_crossover_soln_.y, + root_crossover_soln_.z, + crushed_root_y, + crushed_root_z); root_crossover_soln_.x = crushed_root_x; root_crossover_soln_.y = crushed_root_y; @@ -4494,7 +4493,7 @@ void branch_and_bound_t::run_deterministic_bfs_loop( bool is_child = (node->parent == worker.last_solved_node); worker.recompute_bounds_and_basis = !is_child; - node_status_t status = solve_node_deterministic(worker, node, search_tree); + solve_node_deterministic(worker, node, search_tree); worker.last_solved_node = node; worker.current_node = nullptr; @@ -4793,11 +4792,6 @@ void branch_and_bound_t::deterministic_process_worker_solutions( for (const auto* sol : all_solutions) { if (sol->objective < current_upper) { - f_t user_obj = compute_user_objective(original_lp_, sol->objective); - f_t user_lower = compute_user_objective(original_lp_, deterministic_lower); - i_t nodes_explored = exploration_stats_.nodes_explored.load(); - i_t nodes_unexplored = exploration_stats_.nodes_unexplored.load(); - search_strategy_t worker_type = get_worker_type(pool, sol->worker_id); report(original_lp_, feasible_solution_symbol(worker_type, settings_.diving_settings.show_type), diff --git a/cpp/src/branch_and_bound/pseudo_costs.cpp b/cpp/src/branch_and_bound/pseudo_costs.cpp index c4071bf3b8..d5f34584ed 100644 --- a/cpp/src/branch_and_bound/pseudo_costs.cpp +++ b/cpp/src/branch_and_bound/pseudo_costs.cpp @@ -305,7 +305,7 @@ void strong_branch_helper(i_t start, f_t start_time, const lp_problem_t& original_lp, const simplex_solver_settings_t& settings, - const std::vector& var_types, + [[maybe_unused]] const std::vector& var_types, const std::vector& fractional, const std::vector& root_soln, const std::vector& root_vstatus, @@ -466,21 +466,22 @@ void strong_branch_helper(i_t start, } template -std::pair trial_branching(const lp_problem_t& original_lp, - const simplex_solver_settings_t& settings, - const std::vector& var_types, - const std::vector& vstatus, - const std::vector& edge_norms, - const basis_update_mpf_t& basis_factors, - const std::vector& basic_list, - const std::vector& nonbasic_list, - i_t branch_var, - f_t branch_var_lower, - f_t branch_var_upper, - f_t upper_bound, - f_t start_time, - i_t iter_limit, - i_t& iter) +std::pair trial_branching( + const lp_problem_t& original_lp, + const simplex_solver_settings_t& settings, + [[maybe_unused]] const std::vector& var_types, + const std::vector& vstatus, + const std::vector& edge_norms, + const basis_update_mpf_t& basis_factors, + const std::vector& basic_list, + const std::vector& nonbasic_list, + i_t branch_var, + f_t branch_var_lower, + f_t branch_var_upper, + f_t upper_bound, + f_t start_time, + i_t iter_limit, + i_t& iter) { lp_problem_t child_problem = original_lp; child_problem.lower[branch_var] = branch_var_lower; @@ -1568,7 +1569,6 @@ i_t pseudo_costs_t::reliable_variable_selection( const i_t max_threshold = reliability_branching_settings.max_reliable_threshold; const i_t min_threshold = reliability_branching_settings.min_reliable_threshold; const f_t iter_factor = reliability_branching_settings.bnb_lp_factor; - const i_t iter_offset = reliability_branching_settings.bnb_lp_offset; const int64_t alpha = iter_factor * branch_and_bound_lp_iters; const int64_t max_reliability_iter = alpha + reliability_branching_settings.bnb_lp_offset; @@ -1930,7 +1930,7 @@ i_t pseudo_costs_t::reliable_variable_selection( concurrent_halt.store(1); } - f_t dual_simplex_elapsed = toc(dual_simplex_start_time); + [[maybe_unused]] f_t dual_simplex_elapsed = toc(dual_simplex_start_time); if (use_pdlp) { #pragma omp taskwait // Wait for the batch PDLP task to finish diff --git a/cpp/src/branch_and_bound/symmetry.hpp b/cpp/src/branch_and_bound/symmetry.hpp index 64ecbd6fd6..ec765baa52 100644 --- a/cpp/src/branch_and_bound/symmetry.hpp +++ b/cpp/src/branch_and_bound/symmetry.hpp @@ -338,7 +338,7 @@ class orbital_fixing_t { // Returns the number of free variables in conflicting orbits (orbits with // both zero and one sources). i_t orbital_fixing(mip_symmetry_t* symmetry, - const simplex::simplex_solver_settings_t& settings, + [[maybe_unused]] const simplex::simplex_solver_settings_t& settings, mip_node_t* node_ptr, simplex::lp_problem_t& problem, const std::vector& start_lower, @@ -1002,7 +1002,7 @@ std::unique_ptr> detect_symmetry( &result, &projected_count, &skipped_non_binary, - &max_generators](int n, const int* p, int nsupp, const int* supp) { + &max_generators](int, const int* p, int nsupp, const int* supp) { // Check if any support element is an original variable bool moves_variable = false; for (int s = 0; s < nsupp; s++) { diff --git a/cpp/src/cuts/cuts.cpp b/cpp/src/cuts/cuts.cpp index e9f51666dc..9ed3ae278e 100644 --- a/cpp/src/cuts/cuts.cpp +++ b/cpp/src/cuts/cuts.cpp @@ -60,9 +60,7 @@ enum class clique_cut_build_status_t : int8_t { NO_CUT = 0, CUT_ADDED = 1, INFEA std::fprintf(stderr, "\n"); \ std::fflush(stderr); \ } while (0) -#define CUTS_DEBUG_NOOP(...) \ - do { \ - } while (0) +#define CUTS_DEBUG_NOOP(...) CUOPT_LOG_DISABLED(__VA_ARGS__) #if DEBUG_CLIQUE_CUTS #define CLIQUE_CUTS_DEBUG(...) CUTS_DEBUG_LOG("[DEBUG_CLIQUE_CUTS]", __VA_ARGS__) @@ -2028,7 +2026,9 @@ bool flow_cover_generation_t::separate_single_node_flow_cover( template flow_cover_evaluation_t flow_cover_generation_t::evaluate_c_mir_flow_cover_inequality( - const flow_cover_context_t& context, f_t single_node_flow_b, f_t lambda) + [[maybe_unused]] const flow_cover_context_t& context, + f_t single_node_flow_b, + f_t lambda) { auto& scratch = *this; constexpr f_t min_mir_beta_fraction = 0.01; @@ -2135,7 +2135,9 @@ flow_cover_generation_t::evaluate_c_mir_flow_cover_inequality( template flow_cover_evaluation_t flow_cover_generation_t::evaluate_simple_generalized_flow_cover_inequality( - const flow_cover_context_t& context, f_t single_node_flow_b, f_t lambda) + [[maybe_unused]] const flow_cover_context_t& context, + f_t single_node_flow_b, + f_t lambda) { auto& scratch = *this; const f_t min_violation = static_cast(1e-6); @@ -2331,7 +2333,7 @@ i_t knapsack_generation_t::generate_knapsack_cut( const lp_problem_t& lp, const simplex_solver_settings_t& settings, csr_matrix_t& Arow, - const std::vector& new_slacks, + [[maybe_unused]] const std::vector& new_slacks, const std::vector& var_types, const std::vector& xstar, i_t knapsack_row, @@ -2690,8 +2692,8 @@ template void knapsack_generation_t::lift_knapsack_cut( const inequality_t& knapsack_inequality, const inequality_t& base_cut, - const std::vector& c1_partition, - const std::vector& c2_partition, + [[maybe_unused]] const std::vector& c1_partition, + [[maybe_unused]] const std::vector& c2_partition, inequality_t& lifted_cut, f_t start_time) { @@ -4099,8 +4101,6 @@ void cut_generation_t::generate_mir_cuts( variable_bounds_t& variable_bounds, f_t start_time) { - f_t mir_start_time = tic(); - constexpr bool verbose = false; complemented_mixed_integer_rounding_cut_t complemented_mir(lp, settings, new_slacks); strong_cg_cut_t cg(lp, var_types, xstar); @@ -4139,9 +4139,7 @@ void cut_generation_t::generate_mir_cuts( aggregated_mark[i] = 1; aggregated_rows.push_back(i); - const i_t row_nz = Arow.row_length(i); - const i_t slack = complemented_mir.slack_cols(i); - const f_t slack_value = xstar[slack]; + const i_t slack = complemented_mir.slack_cols(i); if (max_score <= 0.0) { break; } if (work_estimate > 2e9) { break; } @@ -4377,7 +4375,6 @@ void cut_generation_t::generate_gomory_cuts( f_t start_time) { tableau_equality_t tableau(lp, basis_update, nonbasic_list); - mixed_integer_gomory_cut_t gomory_cut; complemented_mixed_integer_rounding_cut_t complemented_mir(lp, settings, new_slacks); simplex_solver_settings_t variable_settings = settings; variable_settings.inside_submip = 1; @@ -4504,7 +4501,7 @@ i_t tableau_equality_t::generate_base_equality( basis_update_mpf_t& basis_update, const std::vector& xstar, const std::vector& basic_list, - const std::vector& nonbasic_list, + [[maybe_unused]] const std::vector& nonbasic_list, i_t i, inequality_t& inequality) { @@ -4728,9 +4725,9 @@ variable_bounds_t::variable_bounds_t(const lp_problem_t& lp, slack_map_.resize(lp.num_rows, -1); std::vector slack_coeff(lp.num_rows, 0.0); for (i_t j : new_slacks) { - const i_t col_start = lp.A.col_start[j]; - const i_t col_end = lp.A.col_start[j + 1]; - const i_t col_len = col_end - col_start; + const i_t col_start = lp.A.col_start[j]; + const i_t col_end = lp.A.col_start[j + 1]; + [[maybe_unused]] const i_t col_len = col_end - col_start; assert(col_len == 1); const i_t i = lp.A.i[col_start]; slack_map_[i] = j; @@ -4992,7 +4989,7 @@ variable_bounds_t::variable_bounds_t(const lp_problem_t& lp, template complemented_mixed_integer_rounding_cut_t::complemented_mixed_integer_rounding_cut_t( const lp_problem_t& lp, - const simplex_solver_settings_t& settings, + [[maybe_unused]] const simplex_solver_settings_t& settings, const std::vector& new_slacks) : is_slack_(lp.num_cols, 0), slack_rows_(lp.num_cols, -1), @@ -5092,7 +5089,6 @@ bool complemented_mixed_integer_rounding_cut_t::cut_generation_heurist const f_t x_j = transformed_xstar[j]; const f_t new_upper_j = new_upper(j); const f_t dist_upper = new_upper_j - x_j; - const f_t dist_lower = x_j; const bool between_bounds = x_j > 1e-6 && (new_upper_j == inf || dist_upper > 0.0); if (between_bounds && abs_aj > 1e-6) { deltas_to_try.push_back(abs_aj); } } @@ -5276,7 +5272,7 @@ bool complemented_mixed_integer_rounding_cut_t::cut_generation_heurist template bool complemented_mixed_integer_rounding_cut_t::scale_uncomplement_and_generate_cut( const std::vector& var_types, - const std::vector& transformed_xstar, + [[maybe_unused]] const std::vector& transformed_xstar, const std::vector& complemented_indices, const inequality_t& complemented_inequality, f_t delta, @@ -5316,8 +5312,7 @@ void complemented_mixed_integer_rounding_cut_t::remove_small_coefficie const std::vector& upper_bounds, inequality_t& cut) { - const i_t nz = cut.size(); - i_t removed = 0; + i_t removed = 0; for (i_t k = 0; k < cut.size(); k++) { const i_t j = cut.index(k); @@ -5755,7 +5750,6 @@ void complemented_mixed_integer_rounding_cut_t::substitute_slacks( // Remove slacks from the cut // So that the cut is only over the original variables bool found_slack = false; - i_t cut_nz = 0; std::vector cut_indices; cut_indices.reserve(cut.size()); if (work_estimate != nullptr) { *work_estimate += cut.size(); } @@ -5836,8 +5830,8 @@ void complemented_mixed_integer_rounding_cut_t::substitute_slacks( template f_t complemented_mixed_integer_rounding_cut_t::combine_rows( - const lp_problem_t& lp, - csr_matrix_t& Arow, + [[maybe_unused]] const lp_problem_t& lp, + [[maybe_unused]] csr_matrix_t& Arow, i_t xj, const inequality_t& pivot_row, inequality_t& inequality) @@ -5926,7 +5920,7 @@ strong_cg_cut_t::strong_cg_cut_t(const lp_problem_t& lp, template i_t strong_cg_cut_t::remove_continuous_variables_integers_nonnegative( const lp_problem_t& lp, - const simplex_solver_settings_t& settings, + [[maybe_unused]] const simplex_solver_settings_t& settings, const std::vector& var_types, inequality_t& inequality) { @@ -6043,7 +6037,7 @@ void strong_cg_cut_t::to_original_integer_variables(const lp_problem_t template i_t strong_cg_cut_t::generate_strong_cg_cut_integer_only( - const simplex_solver_settings_t& settings, + [[maybe_unused]] const simplex_solver_settings_t& settings, const std::vector& var_types, const inequality_t& inequality, inequality_t& cut) @@ -6226,7 +6220,7 @@ i_t add_cuts(const simplex_solver_settings_t& settings, lp_solution_t& solution, basis_update_mpf_t& basis_update, std::vector& basic_list, - std::vector& nonbasic_list, + [[maybe_unused]] std::vector& nonbasic_list, std::vector& vstatus, std::vector& edge_norms) diff --git a/cpp/src/dual_simplex/basis_solves.cpp b/cpp/src/dual_simplex/basis_solves.cpp index 66541c60ff..f3de934cff 100644 --- a/cpp/src/dual_simplex/basis_solves.cpp +++ b/cpp/src/dual_simplex/basis_solves.cpp @@ -30,7 +30,7 @@ i_t reorder_basic_list(const std::vector& q, std::vector& basic_list) } template -void get_basis_from_vstatus(i_t m, +void get_basis_from_vstatus([[maybe_unused]] i_t m, const std::vector& vstatus, std::vector& basis_list, std::vector& nonbasic_list, @@ -54,7 +54,7 @@ void get_basis_from_vstatus(i_t m, superbasic_list.push_back(j); } } - i_t num_super_basic = superbasic_list.size(); + [[maybe_unused]] i_t num_super_basic = superbasic_list.size(); assert(num_basic == m); } @@ -178,7 +178,7 @@ i_t factorize_basis(const csc_matrix_t& A, constexpr bool verbose = false; if (eliminate_singletons) { // TODO: We should see if we can find the singletons without explictly forming the matrix B - f_t fact_start = tic(); + [[maybe_unused]] f_t fact_start = tic(); csc_matrix_t B(A.m, A.m, 1); work_estimate += A.m; form_b(A, basic_list, B, work_estimate); @@ -558,7 +558,7 @@ i_t factorize_basis(const csc_matrix_t& A, // Check the diagonal entries of U for (i_t k = 0; k < m; ++k) { - const i_t col_end = U.col_start[k + 1] - 1; + [[maybe_unused]] const i_t col_end = U.col_start[k + 1] - 1; assert(U.i[col_end] == k); } @@ -677,7 +677,7 @@ i_t factorize_basis(const csc_matrix_t& A, template i_t basis_repair(const csc_matrix_t& A, - const simplex_solver_settings_t& settings, + [[maybe_unused]] const simplex_solver_settings_t& settings, const std::vector& lower, const std::vector& upper, const std::vector& deficient, @@ -779,8 +779,8 @@ i_t form_b(const csc_matrix_t& A, work_estimate += 3 * m; B.reallocate(Bnz); work_estimate += 2 * Bnz; - const i_t Bnz_check = Bnz; - Bnz = 0; + [[maybe_unused]] const i_t Bnz_check = Bnz; + Bnz = 0; for (i_t k = 0; k < m; ++k) { B.col_start[k] = Bnz; const i_t j = basic_list[k]; @@ -898,7 +898,7 @@ i_t b_solve(const csc_matrix_t& L, const std::vector& rhs, std::vector& solution) { - const i_t m = L.m; + [[maybe_unused]] const i_t m = L.m; assert(p.size() == m); assert(rhs.size() == m); assert(solution.size() == m); diff --git a/cpp/src/dual_simplex/basis_updates.cpp b/cpp/src/dual_simplex/basis_updates.cpp index f81962d054..126c4a117d 100644 --- a/cpp/src/dual_simplex/basis_updates.cpp +++ b/cpp/src/dual_simplex/basis_updates.cpp @@ -37,7 +37,7 @@ i_t basis_update_t::b_solve(const std::vector& rhs, std::vector& Lsol) const { raft::common::nvtx::range scope("LU::b_solve"); - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; assert(row_permutation_.size() == m); assert(rhs.size() == m); assert(solution.size() == m); @@ -62,7 +62,7 @@ i_t basis_update_t::b_solve(const sparse_vector_t& rhs, sparse_vector_t& solution, sparse_vector_t& Lsol) const { - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; assert(row_permutation_.size() == m); assert(rhs.n == m); assert(solution.n == m); @@ -100,7 +100,7 @@ i_t basis_update_t::b_transpose_solve(const std::vector& rhs, // 2. Solve L'*w = r for w // 3. Compute y = P'*w - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; assert(rhs.size() == m); assert(row_permutation_.size() == m); assert(solution.size() == m); @@ -132,7 +132,7 @@ i_t basis_update_t::b_transpose_solve(const sparse_vector_t& // 2. Solve L'*w = r for w // 3. Compute y = P'*w - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; assert(rhs.n == m); assert(solution.n == m); @@ -274,7 +274,7 @@ i_t basis_update_t::l_solve(sparse_vector_t& rhs) const // First solve // L0*x0 = b - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; f_t work_estimate = 0; i_t top = sparse_triangle_solve( @@ -360,7 +360,7 @@ i_t basis_update_t::l_transpose_solve(std::vector& rhs) const // L' = Rk^{-T} * Rk-1^{-T} * ... * R2^{-T} * R1^{-T} * L0^T // L'*y = c // Rk^{-T}* Rk-1^{-T} * ... * R2^{-T} * R1^{-T} * L0^T * y = c - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; for (i_t k = num_updates_ - 1; k >= 0; --k) { const i_t r = pivot_indices_[k]; assert(r < m); @@ -554,7 +554,7 @@ i_t basis_update_t::u_solve(std::vector& x) const // 1. Compute bprime = Q'*b // 2. Solve for y such that U*y = bprime // 3. Compute Q*y = x - const i_t m = U_.m; + [[maybe_unused]] const i_t m = U_.m; std::vector bprime(m); inverse_permute_vector(col_permutation_, x, bprime); @@ -625,7 +625,7 @@ i_t basis_update_t::u_transpose_solve(sparse_vector_t& rhs) // 1. Compute bprime = Q'*b // 2. Solve for y such that U'*y = bprime // 3. Compute Q*y = x - const i_t m = U_.m; + [[maybe_unused]] const i_t m = U_.m; sparse_vector_t bprime(1, 0); #ifdef CHECK_PERMUTATION std::vector rhs_dense(m); @@ -1278,8 +1278,8 @@ i_t basis_update_mpf_t::append_cuts(const csr_matrix_t& cuts i_t L_nz = L0_.col_start[m]; csc_matrix_t new_L(m + cuts_basic.m, m + cuts_basic.m, L_nz + V_nz + cuts_basic.m); work_estimate_ += (L_nz + V_nz + cuts_basic.m) + (m + cuts_basic.m); - i_t predicted_nz = L_nz + V_nz + cuts_basic.m; - L_nz = 0; + [[maybe_unused]] i_t predicted_nz = L_nz + V_nz + cuts_basic.m; + L_nz = 0; for (i_t j = 0; j < m; ++j) { new_L.col_start[j] = L_nz; const i_t col_start = L0_.col_start[j]; @@ -1355,7 +1355,7 @@ template void basis_update_mpf_t::gather_into_sparse_vector(i_t nz, sparse_vector_t& out) const { - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; out.i.clear(); out.x.clear(); out.i.reserve(nz); @@ -1379,8 +1379,8 @@ void basis_update_mpf_t::gather_into_sparse_vector(i_t nz, template void basis_update_mpf_t::solve_to_workspace(i_t top) const { - const i_t m = L0_.m; - i_t nz = 0; + [[maybe_unused]] const i_t m = L0_.m; + i_t nz = 0; for (i_t p = top; p < m; ++p) { const i_t i = xi_workspace_[p]; xi_workspace_[m + nz] = i; @@ -1425,7 +1425,7 @@ void basis_update_mpf_t::solve_to_sparse_vector(i_t top, template i_t basis_update_mpf_t::scatter_into_workspace(const sparse_vector_t& in) const { - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; // scatter pattern into xi_workspace_ i_t nz = in.i.size(); for (i_t k = 0; k < nz; ++k) { @@ -1565,7 +1565,7 @@ i_t basis_update_mpf_t::b_transpose_solve(const std::vector& rhs, std::vector& solution, std::vector& UTsol) const { - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; // P*B = L*U // B'*P' = U'*L' // We want to solve @@ -1736,7 +1736,7 @@ template i_t basis_update_mpf_t::l_transpose_solve(sparse_vector_t& rhs) const { total_sparse_L_transpose_++; - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; // L'*x = b // L0^T * x = T_0^-T * T_1^-T * ... * T_{num_updates_ - 1}^-T * b = b' @@ -1826,7 +1826,7 @@ template i_t basis_update_mpf_t::b_solve(const std::vector& rhs, std::vector& solution) const { - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; std::vector Lsol(m); work_estimate_ += m; return b_solve(rhs, solution, Lsol); @@ -1839,7 +1839,7 @@ i_t basis_update_mpf_t::b_solve(const std::vector& rhs, std::vector& Lsol, bool need_Lsol) const { - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; // P*B = L*U // B*x = b // P*B*x = P*b @@ -1895,8 +1895,8 @@ i_t basis_update_mpf_t::b_solve(const sparse_vector_t& rhs, sparse_vector_t& Lsol, bool need_Lsol) const { - const i_t m = L0_.m; - solution = rhs; + [[maybe_unused]] const i_t m = L0_.m; + solution = rhs; work_estimate_ += 2 * rhs.i.size(); solution.inverse_permute_vector(inverse_row_permutation_); work_estimate_ += 3 * rhs.i.size(); @@ -1989,7 +1989,7 @@ template i_t basis_update_mpf_t::u_solve(std::vector& rhs) const { total_dense_U_++; - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; // U*x = y simplex::upper_triangular_solve(U0_, rhs, work_estimate_); return 0; @@ -1999,7 +1999,7 @@ template i_t basis_update_mpf_t::u_solve(sparse_vector_t& rhs) const { total_sparse_U_++; - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; // U*x = y // Solve U0*x = y @@ -2014,7 +2014,7 @@ template i_t basis_update_mpf_t::l_solve(std::vector& rhs) const { total_dense_L_++; - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; // L*x = y // L0 * T0 * T1 * ... * T_{num_updates_ - 1} * x = y @@ -2112,15 +2112,15 @@ i_t basis_update_mpf_t::update(const std::vector& utilde, const std::vector& etilde, i_t leaving_index) { - const i_t m = L0_.m; + [[maybe_unused]] const i_t m = L0_.m; #ifdef PRINT_NUM_UPDATES printf("Update: num_updates_ %d\n", num_updates_); #endif // We are going to create a new matrix T = I + u*v^T - const i_t col_start = U0_.col_start[leaving_index]; - const i_t col_end = U0_.col_start[leaving_index + 1]; - std::vector u = utilde; + [[maybe_unused]] const i_t col_start = U0_.col_start[leaving_index]; + [[maybe_unused]] const i_t col_end = U0_.col_start[leaving_index + 1]; + std::vector u = utilde; work_estimate_ += 2 * utilde.size(); // u = utilde - U0(:, leaving_index) add_sparse_column(U0_, leaving_index, -1.0, u); @@ -2138,7 +2138,7 @@ i_t basis_update_mpf_t::update(const std::vector& utilde, printf("Update: S_start %d S_nz %d num updates %d S.n %d\n", S_start, S_nz, num_updates_, S_.n); #endif - i_t S_nz_start = S_nz; + [[maybe_unused]] i_t S_nz_start = S_nz; // Scatter u into S S_.append_column(u); @@ -2263,9 +2263,9 @@ void basis_update_mpf_t::l_multiply(std::vector& inout) const for (i_t k = num_updates_ - 1; k >= 0; --k) { // T_k = ( I + u v^T) // T_k * b = b + u * (v^T * b) = b + theta * u, theta = v^T b - const i_t u_col = 2 * k; - const i_t v_col = 2 * k + 1; - const f_t mu = mu_values_[k]; + const i_t u_col = 2 * k; + const i_t v_col = 2 * k + 1; + [[maybe_unused]] const f_t mu = mu_values_[k]; // dot = v^T b f_t dot = dot_product(v_col, inout); @@ -2288,9 +2288,9 @@ void basis_update_mpf_t::l_transpose_multiply(std::vector& inout) const f_t zero_tol = 1e-13; for (i_t k = 0; k < num_updates_; ++k) { - const i_t u_col = 2 * k; - const i_t v_col = 2 * k + 1; - const f_t mu = mu_values_[k]; + const i_t u_col = 2 * k; + const i_t v_col = 2 * k + 1; + [[maybe_unused]] const f_t mu = mu_values_[k]; // T_k = ( I + u v^T) // T_k^T = ( I + v u^T) diff --git a/cpp/src/dual_simplex/bound_flipping_ratio_test.cpp b/cpp/src/dual_simplex/bound_flipping_ratio_test.cpp index cb0964dc05..88f5967a11 100644 --- a/cpp/src/dual_simplex/bound_flipping_ratio_test.cpp +++ b/cpp/src/dual_simplex/bound_flipping_ratio_test.cpp @@ -18,8 +18,8 @@ template i_t bound_flipping_ratio_test_t::compute_breakpoints(std::vector& indicies, std::vector& ratios) { - i_t n = n_; - i_t m = m_; + [[maybe_unused]] i_t n = n_; + [[maybe_unused]] i_t m = m_; constexpr bool verbose = false; f_t pivot_tol = settings_.pivot_tol; const f_t dual_tol = settings_.dual_tol / 10; @@ -117,10 +117,10 @@ template i_t bound_flipping_ratio_test_t::compute_step_length(f_t& step_length, i_t& nonbasic_entering) { - const i_t m = m_; - const i_t n = n_; - const i_t nz = delta_z_indices_.size(); - constexpr bool verbose = false; + [[maybe_unused]] const i_t m = m_; + [[maybe_unused]] const i_t n = n_; + const i_t nz = delta_z_indices_.size(); + constexpr bool verbose = false; // Compute the initial set of breakpoints std::vector indicies(nz); @@ -204,7 +204,7 @@ void bound_flipping_ratio_test_t::heap_passes(const std::vector& { std::vector bare_idx(num_breakpoints); constexpr bool verbose = false; - const f_t dual_tol = settings_.dual_tol; + [[maybe_unused]] const f_t dual_tol = settings_.dual_tol; const f_t zero_tol = settings_.zero_tol; const std::vector& delta_z = delta_z_; const std::vector& nonbasic_list = nonbasic_list_; @@ -281,15 +281,15 @@ void bound_flipping_ratio_test_t::bucket_pass(const std::vector& const std::vector& current_ratios, i_t num_breakpoints, f_t& slope, - f_t& step_length, - i_t& nonbasic_entering, - i_t& entering_index) + [[maybe_unused]] f_t& step_length, + [[maybe_unused]] i_t& nonbasic_entering, + [[maybe_unused]] i_t& entering_index) { - const f_t dual_tol = settings_.dual_tol; - const f_t zero_tol = settings_.zero_tol; - const std::vector& delta_z = delta_z_; - const std::vector& nonbasic_list = nonbasic_list_; - const i_t N = num_breakpoints; + [[maybe_unused]] const f_t dual_tol = settings_.dual_tol; + [[maybe_unused]] const f_t zero_tol = settings_.zero_tol; + [[maybe_unused]] const std::vector& delta_z = delta_z_; + const std::vector& nonbasic_list = nonbasic_list_; + const i_t N = num_breakpoints; const i_t K = 400; // 0, -16, -15, ...., 0, 1, ...., 400 - 18 = 382 std::vector buckets(K, 0.0); diff --git a/cpp/src/dual_simplex/bounds_strengthening.cpp b/cpp/src/dual_simplex/bounds_strengthening.cpp index cac5515d8e..3e65c4780e 100644 --- a/cpp/src/dual_simplex/bounds_strengthening.cpp +++ b/cpp/src/dual_simplex/bounds_strengthening.cpp @@ -35,10 +35,10 @@ static inline bool check_infeasibility(f_t min_a, f_t max_a, f_t cnst_lb, f_t cn #define DEBUG_BOUND_STRENGTHENING 0 template -void print_bounds_stats(const std::vector& lower, - const std::vector& upper, - const simplex_solver_settings_t& settings, - const std::string msg) +void print_bounds_stats([[maybe_unused]] const std::vector& lower, + [[maybe_unused]] const std::vector& upper, + [[maybe_unused]] const simplex_solver_settings_t& settings, + [[maybe_unused]] const std::string msg) { #if DEBUG_BOUND_STRENGTHENING f_t lb_norm = 0.0; diff --git a/cpp/src/dual_simplex/crossover.cpp b/cpp/src/dual_simplex/crossover.cpp index e1ba272adf..088a9c449a 100644 --- a/cpp/src/dual_simplex/crossover.cpp +++ b/cpp/src/dual_simplex/crossover.cpp @@ -35,7 +35,7 @@ crossover_status_t return_to_status(int status) } template -void verify_basis(i_t m, i_t n, const std::vector& vstatus) +void verify_basis([[maybe_unused]] i_t m, i_t n, const std::vector& vstatus) { i_t num_basic = 0; i_t num_nonbasic = 0; @@ -64,14 +64,14 @@ void compare_vstatus_with_lists(i_t m, i_t n, const std::vector& basic_list, const std::vector& nonbasic_list, - const std::vector& vstatus) + [[maybe_unused]] const std::vector& vstatus) { for (i_t k = 0; k < m; ++k) { - const i_t j = basic_list[k]; + [[maybe_unused]] const i_t j = basic_list[k]; assert(vstatus[j] == variable_status_t::BASIC); } for (i_t k = 0; k < std::min(static_cast(nonbasic_list.size()), n - m); ++k) { - const i_t j = nonbasic_list[k]; + [[maybe_unused]] const i_t j = nonbasic_list[k]; assert(vstatus[j] == variable_status_t::NONBASIC_LOWER || vstatus[j] == variable_status_t::NONBASIC_UPPER || vstatus[j] == variable_status_t::NONBASIC_FREE || @@ -86,16 +86,16 @@ f_t dual_infeasibility(const lp_problem_t& lp, const std::vector& z) { raft::common::nvtx::range scope("DualSimplex::dual_infeasibility"); - const i_t n = lp.num_cols; - const i_t m = lp.num_rows; - i_t num_infeasible = 0; - f_t sum_infeasible = 0.0; - constexpr f_t tight_tol = 1e-6; - i_t lower_bound_inf = 0; - i_t upper_bound_inf = 0; - i_t free_inf = 0; - i_t non_basic_lower_inf = 0; - i_t non_basic_upper_inf = 0; + const i_t n = lp.num_cols; + [[maybe_unused]] const i_t m = lp.num_rows; + i_t num_infeasible = 0; + f_t sum_infeasible = 0.0; + constexpr f_t tight_tol = 1e-6; + i_t lower_bound_inf = 0; + i_t upper_bound_inf = 0; + i_t free_inf = 0; + i_t non_basic_lower_inf = 0; + i_t non_basic_upper_inf = 0; for (i_t j = 0; j < n; ++j) { if (vstatus[j] == variable_status_t::NONBASIC_FIXED) { @@ -697,8 +697,6 @@ f_t primal_ratio_test(const lp_problem_t& lp, i_t& basic_leaving_index, i_t& bound) { - const i_t m = lp.num_rows; - const i_t n = lp.num_cols; f_t step_length = 1.0; constexpr f_t pivot_tol = 1e-9; for (i_t k = 0; k < delta_xB.i.size(); ++k) { @@ -754,7 +752,6 @@ i_t primal_push(const lp_problem_t& lp, settings.log.debug("Primal push: superbasic %ld\n", superbasic_list.size()); std::vector& x = solution.x; - std::vector& y = solution.y; std::vector& z = solution.z; f_t last_print_time = tic(); @@ -1281,8 +1278,6 @@ crossover_status_t crossover(const lp_problem_t& lp, constexpr f_t basis_threshold = 1e-6; for (i_t j = 0; j < n; ++j) { if (vstatus[j] != variable_status_t::BASIC) { - const f_t lower_bound_slack = initial_solution.x[j] - lp.lower[j]; - const f_t upper_bound_slack = lp.upper[j] - initial_solution.x[j]; if (std::abs(lp.lower[j] - lp.upper[j]) < fixed_tolerance) { vstatus[j] = variable_status_t::NONBASIC_FIXED; } else if (solution.z[j] > -basis_threshold && lp.lower[j] > -inf) { @@ -1406,7 +1401,6 @@ crossover_status_t crossover(const lp_problem_t& lp, f_t primal_infeas = primal_infeasibility(lp, settings, vstatus, solution.x); f_t dual_infeas = dual_infeasibility(lp, settings, vstatus, solution.z); - f_t obj = compute_objective(lp, solution.x); f_t primal_res = primal_residual(lp, solution); f_t dual_res = dual_residual(lp, solution); diff --git a/cpp/src/dual_simplex/folding.cpp b/cpp/src/dual_simplex/folding.cpp index a56659b3ff..76f4e77624 100644 --- a/cpp/src/dual_simplex/folding.cpp +++ b/cpp/src/dual_simplex/folding.cpp @@ -74,7 +74,7 @@ void find_vertices_to_refine(const std::unordered_set& refining_color_verti } template -void compute_sums_of_refined_vertices(i_t refining_color, +void compute_sums_of_refined_vertices([[maybe_unused]] i_t refining_color, const std::unordered_set& refining_color_vertices, const std::vector& vertices_to_refine, const std::vector& offsets, @@ -108,7 +108,7 @@ void compute_sums(const csc_matrix_t& A, const csr_matrix_t& Arow, i_t num_row_colors, i_t num_col_colors, - i_t total_colors_seen, + [[maybe_unused]] i_t total_colors_seen, const std::vector& row_color_map, const std::vector& col_color_map, const color_t& refining_color, @@ -120,7 +120,7 @@ void compute_sums(const csc_matrix_t& A, std::vector& vertex_to_sum, std::vector& max_sum_by_color) { - i_t num_colors = num_row_colors + num_col_colors; + [[maybe_unused]] i_t num_colors = num_row_colors + num_col_colors; colors_to_update.clear(); vertices_to_refine.clear(); if (refining_color.row_or_column == kRow) { @@ -224,7 +224,7 @@ i_t find_colors_to_split(const std::vector& colors_to_update, template i_t split_colors(i_t color, - i_t refining_color, + [[maybe_unused]] i_t refining_color, int8_t side_being_split, std::vector& vertex_to_sum, std::map>& color_sums, @@ -233,7 +233,7 @@ i_t split_colors(i_t color, std::vector& color_stack, std::vector& color_in_stack, std::vector& color_map_B, - std::vector& marked_vertices, + [[maybe_unused]] std::vector& marked_vertices, std::vector>& vertices_to_refine_by_color, std::vector& min_sum_by_color, std::vector& max_sum_by_color, @@ -591,7 +591,7 @@ coloring_status_t color_graph(const csc_matrix_t& A, colors_per_refinement = static_cast(num_row_colors + num_col_colors) / static_cast(num_refinements); - i_t projected_colors = + [[maybe_unused]] i_t projected_colors = num_row_colors + num_col_colors + static_cast(colors_per_refinement * static_cast(color_stack.size())); diff --git a/cpp/src/dual_simplex/phase2.cpp b/cpp/src/dual_simplex/phase2.cpp index a5f10c3229..b1f0e3e898 100644 --- a/cpp/src/dual_simplex/phase2.cpp +++ b/cpp/src/dual_simplex/phase2.cpp @@ -869,7 +869,7 @@ bool update_primal_infeasibilities(const lp_problem_t& lp, const simplex_solver_settings_t& settings, const std::vector& basic_list, const std::vector& x, - i_t entering_index, + [[maybe_unused]] i_t entering_index, i_t leaving_index, std::vector& basic_change_list, std::vector& squared_infeasibilities, @@ -924,17 +924,18 @@ void clean_up_infeasibilities(std::vector& squared_infeasibilities, } template -i_t steepest_edge_pricing_with_infeasibilities(const lp_problem_t& lp, - const simplex_solver_settings_t& settings, - const std::vector& x, - const std::vector& dy_steepest_edge, - const std::vector& basic_mark, - std::vector& squared_infeasibilities, - std::vector& infeasibility_indices, - i_t& direction, - i_t& basic_leaving, - f_t& max_val, - f_t& work_estimate) +i_t steepest_edge_pricing_with_infeasibilities( + const lp_problem_t& lp, + [[maybe_unused]] const simplex_solver_settings_t& settings, + const std::vector& x, + const std::vector& dy_steepest_edge, + const std::vector& basic_mark, + std::vector& squared_infeasibilities, + std::vector& infeasibility_indices, + i_t& direction, + i_t& basic_leaving, + f_t& max_val, + f_t& work_estimate) { max_val = 0.0; i_t leaving_index = -1; @@ -1207,10 +1208,10 @@ template i_t flip_bounds(const lp_problem_t& lp, const simplex_solver_settings_t& settings, const std::vector& bounded_variables, - const std::vector& objective, + [[maybe_unused]] const std::vector& objective, const std::vector& z, const std::vector& delta_z_indices, - const std::vector& nonbasic_list, + [[maybe_unused]] const std::vector& nonbasic_list, i_t entering_index, std::vector& vstatus, std::vector& delta_x, @@ -1349,8 +1350,8 @@ i_t initialize_steepest_edge_norms(const lp_problem_t& lp, const i_t j = basic_list[k]; f_t init = -1.0; if (row_degree[mapping[k]] == 1) { - const i_t u = mapping[k]; - const f_t alpha = coeff[k]; + [[maybe_unused]] const i_t u = mapping[k]; + const f_t alpha = coeff[k]; // dy[u] = -1.0 / alpha; f_t my_init = 1.0 / (alpha * alpha); init = my_init; @@ -1430,7 +1431,7 @@ i_t initialize_steepest_edge_norms(const lp_problem_t& lp, } template -i_t update_steepest_edge_norms(const simplex_solver_settings_t& settings, +i_t update_steepest_edge_norms([[maybe_unused]] const simplex_solver_settings_t& settings, const std::vector& basic_list, const basis_update_mpf_t& ft, i_t direction, @@ -1444,7 +1445,7 @@ i_t update_steepest_edge_norms(const simplex_solver_settings_t& settin std::vector& delta_y_steepest_edge, f_t& work_estimate) { - const i_t delta_y_nz = delta_y_sparse.i.size(); + [[maybe_unused]] const i_t delta_y_nz = delta_y_sparse.i.size(); v_sparse.clear(); // B^T delta_y = - direction * e_basic_leaving_index // We want B v = - B^{-T} e_basic_leaving_index @@ -1456,8 +1457,8 @@ i_t update_steepest_edge_norms(const simplex_solver_settings_t& settin v_sparse.scatter(v); work_estimate += 2 * v_sparse.i.size(); - const i_t leaving_index = basic_list[basic_leaving_index]; - const f_t prev_dy_norm_squared = delta_y_steepest_edge[leaving_index]; + const i_t leaving_index = basic_list[basic_leaving_index]; + [[maybe_unused]] const f_t prev_dy_norm_squared = delta_y_steepest_edge[leaving_index]; #ifdef STEEPEST_EDGE_DEBUG const f_t err = std::abs(dy_norm_squared - prev_dy_norm_squared) / (1.0 + dy_norm_squared); if (err > 1e-3) { @@ -1550,11 +1551,11 @@ i_t compute_perturbation(const lp_problem_t& lp, f_t& sum_perturb, f_t& work_estimate) { - const i_t n = lp.num_cols; - const i_t m = lp.num_rows; - const f_t tight_tol = settings.tight_tol; - i_t num_perturb = 0; - sum_perturb = 0.0; + [[maybe_unused]] const i_t n = lp.num_cols; + [[maybe_unused]] const i_t m = lp.num_rows; + const f_t tight_tol = settings.tight_tol; + i_t num_perturb = 0; + sum_perturb = 0.0; for (i_t k = 0; k < delta_z_indices.size(); ++k) { const i_t j = delta_z_indices[k]; if (lp.upper[j] == inf && lp.lower[j] > -inf && z[j] < -tight_tol) { @@ -1747,7 +1748,7 @@ i_t compute_delta_x(const lp_problem_t& lp, i_t basic_leaving_index, i_t direction, const std::vector& basic_list, - const std::vector& delta_x_flip, + [[maybe_unused]] const std::vector& delta_x_flip, const sparse_vector_t& rhs_sparse, const std::vector& delta_z, const std::vector& x, @@ -1885,15 +1886,15 @@ f_t dual_infeasibility(const lp_problem_t& lp, f_t tight_tol, f_t dual_tol) { - const i_t n = lp.num_cols; - const i_t m = lp.num_rows; - i_t num_infeasible = 0; - f_t sum_infeasible = 0.0; - i_t lower_bound_inf = 0; - i_t upper_bound_inf = 0; - i_t free_inf = 0; - i_t non_basic_lower_inf = 0; - i_t non_basic_upper_inf = 0; + const i_t n = lp.num_cols; + [[maybe_unused]] const i_t m = lp.num_rows; + i_t num_infeasible = 0; + f_t sum_infeasible = 0.0; + i_t lower_bound_inf = 0; + i_t upper_bound_inf = 0; + i_t free_inf = 0; + i_t non_basic_lower_inf = 0; + i_t non_basic_upper_inf = 0; for (i_t j = 0; j < n; ++j) { if (vstatus[j] == variable_status_t::NONBASIC_FIXED) { continue; } @@ -2022,8 +2023,8 @@ f_t primal_infeasibility_breakdown(const lp_problem_t& lp, template f_t primal_infeasibility(const lp_problem_t& lp, - const simplex_solver_settings_t& settings, - const std::vector& vstatus, + [[maybe_unused]] const simplex_solver_settings_t& settings, + [[maybe_unused]] const std::vector& vstatus, const std::vector& x) { const i_t n = lp.num_cols; @@ -2325,8 +2326,8 @@ f_t amount_of_perturbation(const lp_problem_t& lp, const std::vector -void prepare_optimality(i_t info, - f_t orig_primal_infeas, +void prepare_optimality([[maybe_unused]] i_t info, + [[maybe_unused]] f_t orig_primal_infeas, const lp_problem_t& lp, const simplex_solver_settings_t& settings, basis_update_mpf_t& ft, @@ -2336,7 +2337,7 @@ void prepare_optimality(i_t info, const std::vector& vstatus, int phase, f_t start_time, - f_t max_val, + [[maybe_unused]] f_t max_val, i_t iter, const std::vector& x, std::vector& y, @@ -2347,10 +2348,10 @@ void prepare_optimality(i_t info, const i_t n = lp.num_cols; f_t work_estimate = 0; // Work in this function is not captured - sol.objective = compute_objective(lp, sol.x); - sol.user_objective = compute_user_objective(lp, sol.objective); - f_t perturbation = amount_of_perturbation(lp, objective); - f_t orig_perturbation = perturbation; + sol.objective = compute_objective(lp, sol.x); + sol.user_objective = compute_user_objective(lp, sol.objective); + f_t perturbation = amount_of_perturbation(lp, objective); + [[maybe_unused]] f_t orig_perturbation = perturbation; if (perturbation > 1e-6 && phase == 2) { // Try to remove perturbation std::vector unperturbed_y(m); @@ -2507,8 +2508,8 @@ dual_status_t dual_phase2(i_t phase, work_limit_context_t* work_unit_context) { PHASE2_NVTX_RANGE("DualSimplex::phase2"); - const i_t m = lp.num_rows; - const i_t n = lp.num_cols; + const i_t m = lp.num_rows; + [[maybe_unused]] const i_t n = lp.num_cols; std::vector basic_list(m); std::vector nonbasic_list; basis_update_mpf_t ft(m, settings.refactor_frequency); @@ -2700,7 +2701,7 @@ dual_status_t dual_phase2_with_advanced_basis(i_t phase, f_t steepest_edge_start = tic(); i_t status = phase2::initialize_steepest_edge_norms( lp, settings, start_time, basic_list, ft, delta_y_steepest_edge, phase2_work_estimate); - f_t steepest_edge_time = toc(steepest_edge_start); + [[maybe_unused]] f_t steepest_edge_time = toc(steepest_edge_start); if (status == CONCURRENT_HALT_RETURN) { return dual_status_t::CONCURRENT_LIMIT; } if (status == -1) { return dual_status_t::TIME_LIMIT; } } @@ -3421,20 +3422,21 @@ dual_status_t dual_phase2_with_advanced_basis(i_t phase, #endif timers.start_timer(); - f_t se_norms_start_work = ft.work_estimate(); - const i_t steepest_edge_status = phase2::update_steepest_edge_norms(settings, - basic_list, - ft, - direction, - delta_y_sparse, - steepest_edge_norm_check, - scaled_delta_xB_sparse, - basic_leaving_index, - entering_index, - v, - v_sparse, - delta_y_steepest_edge, - phase2_work_estimate); + f_t se_norms_start_work = ft.work_estimate(); + [[maybe_unused]] const i_t steepest_edge_status = + phase2::update_steepest_edge_norms(settings, + basic_list, + ft, + direction, + delta_y_sparse, + steepest_edge_norm_check, + scaled_delta_xB_sparse, + basic_leaving_index, + entering_index, + v, + v_sparse, + delta_y_steepest_edge, + phase2_work_estimate); #ifdef STEEPEST_EDGE_DEBUG if (steepest_edge_status == -1) { settings.log.printf("Num updates %d\n", ft.num_updates()); diff --git a/cpp/src/dual_simplex/phase2.hpp b/cpp/src/dual_simplex/phase2.hpp index daa946e019..e2dac55644 100644 --- a/cpp/src/dual_simplex/phase2.hpp +++ b/cpp/src/dual_simplex/phase2.hpp @@ -35,7 +35,7 @@ enum class dual_status_t { UNSET = 8 }; -static std::string dual_status_to_string(dual_status_t status) +[[maybe_unused]] static std::string dual_status_to_string(dual_status_t status) { switch (status) { case dual_status_t::OPTIMAL: return "OPTIMAL"; diff --git a/cpp/src/dual_simplex/presolve.cpp b/cpp/src/dual_simplex/presolve.cpp index 6e72b2e078..861774f23f 100644 --- a/cpp/src/dual_simplex/presolve.cpp +++ b/cpp/src/dual_simplex/presolve.cpp @@ -15,8 +15,8 @@ #include #include -#include #include +#include namespace cuopt::mathematical_optimization::simplex { @@ -304,7 +304,7 @@ i_t remove_fixed_variables(f_t fixed_tolerance, } template -i_t convert_less_than_to_equal(const user_problem_t& user_problem, +i_t convert_less_than_to_equal([[maybe_unused]] const user_problem_t& user_problem, std::vector& row_sense, lp_problem_t& problem, i_t& less_rows, @@ -458,7 +458,7 @@ i_t convert_less_than_to_equal(const user_problem_t& user_problem, } template -i_t convert_greater_to_less(const user_problem_t& user_problem, +i_t convert_greater_to_less([[maybe_unused]] const user_problem_t& user_problem, std::vector& row_sense, lp_problem_t& problem, i_t& greater_rows, @@ -479,8 +479,7 @@ i_t convert_greater_to_less(const user_problem_t& user_problem, for (i_t i = 0; i < problem.num_rows; i++) { if (row_sense[i] == 'G') { - i_t row_start = Arow.row_start[i]; - i_t row_end = Arow.row_start[i + 1]; + i_t row_end = Arow.row_start[i + 1]; for (i_t p = Arow.row_start[i]; p < row_end; p++) { Arow.x[p] *= -1; } @@ -663,7 +662,6 @@ i_t add_artifical_variables(lp_problem_t& problem, std::vector& new_slacks) { const i_t n = problem.num_cols; - const i_t m = problem.num_rows; const i_t num_artificial_vars = equality_rows.size() - range_rows.size(); const i_t num_cols = n + num_artificial_vars; i_t nnz = problem.A.col_start[n] + num_artificial_vars; @@ -1560,9 +1558,9 @@ void crush_primal_solution(const user_problem_t& user_problem, // Compute the value for each of the added slack variables for (i_t j : new_slacks) { - const i_t col_start = problem.A.col_start[j]; - const i_t col_end = problem.A.col_start[j + 1]; - const i_t diff = col_end - col_start; + const i_t col_start = problem.A.col_start[j]; + const i_t col_end = problem.A.col_start[j + 1]; + [[maybe_unused]] const i_t diff = col_end - col_start; assert(diff == 1); const i_t i = problem.A.i[col_start]; assert(solution[j] == 0.0); @@ -1601,9 +1599,9 @@ void crush_primal_solution_with_slack(const user_problem_t& user_probl constexpr bool verbose = false; // Compute the value for each of the added slack variables for (i_t j : new_slacks) { - const i_t col_start = problem.A.col_start[j]; - const i_t col_end = problem.A.col_start[j + 1]; - const i_t diff = col_end - col_start; + const i_t col_start = problem.A.col_start[j]; + const i_t col_end = problem.A.col_start[j + 1]; + [[maybe_unused]] const i_t diff = col_end - col_start; assert(diff == 1); const i_t i = problem.A.i[col_start]; assert(solution[j] == 0.0); @@ -1650,9 +1648,9 @@ f_t crush_dual_solution(const user_problem_t& user_problem, assert(user_problem.num_rows == problem.num_rows); for (i_t j : new_slacks) { - const i_t col_start = problem.A.col_start[j]; - const i_t col_end = problem.A.col_start[j + 1]; - const i_t diff = col_end - col_start; + const i_t col_start = problem.A.col_start[j]; + const i_t col_end = problem.A.col_start[j + 1]; + [[maybe_unused]] const i_t diff = col_end - col_start; assert(diff == 1); const i_t i = problem.A.i[col_start]; @@ -1790,9 +1788,7 @@ void uncrush_solution(const presolve_info_t& presolve_info, // 0 <= x, // 0 <= w - i_t reduced_cols = presolve_info.folding_info.D.n; i_t previous_cols = presolve_info.folding_info.D.m; - i_t reduced_rows = presolve_info.folding_info.C_s.m; i_t previous_rows = presolve_info.folding_info.C_s.n; std::vector xtilde(previous_cols); diff --git a/cpp/src/dual_simplex/primal.cpp b/cpp/src/dual_simplex/primal.cpp index 78c7107ca3..2efc6f019b 100644 --- a/cpp/src/dual_simplex/primal.cpp +++ b/cpp/src/dual_simplex/primal.cpp @@ -21,7 +21,7 @@ namespace { template void set_primal_variables_on_bounds(const lp_problem_t& lp, const simplex_solver_settings_t& settings, - const std::vector& z, + [[maybe_unused]] const std::vector& z, std::vector& vstatus, std::vector& x) { @@ -60,16 +60,16 @@ f_t dual_infeasibility(const lp_problem_t& lp, const std::vector& vstatus, const std::vector& z) { - const i_t n = lp.num_cols; - const i_t m = lp.num_rows; - i_t num_infeasible = 0; - f_t sum_infeasible = 0.0; - constexpr f_t tight_tol = 0; - i_t lower_bound_inf = 0; - i_t upper_bound_inf = 0; - i_t free_inf = 0; - i_t non_basic_lower_inf = 0; - i_t non_basic_upper_inf = 0; + const i_t n = lp.num_cols; + [[maybe_unused]] const i_t m = lp.num_rows; + i_t num_infeasible = 0; + f_t sum_infeasible = 0.0; + constexpr f_t tight_tol = 0; + i_t lower_bound_inf = 0; + i_t upper_bound_inf = 0; + i_t free_inf = 0; + i_t non_basic_lower_inf = 0; + i_t non_basic_upper_inf = 0; for (i_t j = 0; j < n; ++j) { if (lp.upper[j] == inf && lp.lower[j] > -inf && z[j] < -tight_tol) { @@ -153,19 +153,19 @@ i_t phase2_pricing(const lp_problem_t& lp, template i_t ratio_test(const lp_problem_t& lp, - const std::vector& vstatus, + [[maybe_unused]] const std::vector& vstatus, const std::vector& basic_list, std::vector& x, std::vector& delta_x, f_t& step_length, i_t& basic_leaving) { - const i_t m = lp.num_rows; - const i_t n = lp.num_cols; - basic_leaving = -1; - i_t leaving_index = -1; - f_t min_val = inf; - constexpr f_t pivot_tol = 1e-8; + const i_t m = lp.num_rows; + [[maybe_unused]] const i_t n = lp.num_cols; + basic_leaving = -1; + i_t leaving_index = -1; + f_t min_val = inf; + constexpr f_t pivot_tol = 1e-8; for (i_t k = 0; k < m; ++k) { const i_t j = basic_list[k]; if (delta_x[j] == 0.0) { continue; } diff --git a/cpp/src/dual_simplex/right_looking_lu.cpp b/cpp/src/dual_simplex/right_looking_lu.cpp index 6a717cd257..63cff5abb5 100644 --- a/cpp/src/dual_simplex/right_looking_lu.cpp +++ b/cpp/src/dual_simplex/right_looking_lu.cpp @@ -237,7 +237,7 @@ class trailing_matrix_t { assert(row_counts_.get_elements_with_count(nz).size() >= 0); nsearch_start = nsearch; for (const i_t i : row_counts_.get_elements_with_count(nz)) { - const i_t rdeg = row_counts_.get_count(i); + [[maybe_unused]] const i_t rdeg = row_counts_.get_count(i); assert(rdeg == nz); const i_t r_start = row_start_[i]; const i_t r_end = row_end_[i]; @@ -1006,10 +1006,10 @@ i_t right_looking_lu_row_permutation_only(const csc_matrix_t& A, // Factorize PAQ = LU, where A is m x n with m >= n, and P and Q are permutation matrices // We return the inverser row permutation vector pinv and the column permutation vector q - f_t factorization_start_time = tic(); - f_t work_estimate = 0; - const i_t n = A.n; - const i_t m = A.m; + f_t factorization_start_time = tic(); + [[maybe_unused]] f_t work_estimate = 0; + const i_t n = A.n; + const i_t m = A.m; assert(pinv.size() == m); assert(q.size() == n); (void)tol; // Unused; kept for API compatibility with right_looking_lu_row_permutation_only diff --git a/cpp/src/dual_simplex/singletons.cpp b/cpp/src/dual_simplex/singletons.cpp index 8b151337b7..a9511e9340 100644 --- a/cpp/src/dual_simplex/singletons.cpp +++ b/cpp/src/dual_simplex/singletons.cpp @@ -185,7 +185,6 @@ i_t find_singletons(const csc_matrix_t& A, std::vector Rj(nz); work_estimate += 3 * m + n + nz; - i_t max_queue_len = std::max(m, n); std::queue singleton_queue; // Compute Cdeg and Rdeg @@ -274,12 +273,12 @@ i_t find_singletons(const csc_matrix_t& A, #ifdef SINGLETON_DEBUG printf("Col singletons %d\n", col_singletons); #endif - i_t num_empty_cols = complete_permutation(singletons_found, Cdeg, col_perm); + [[maybe_unused]] i_t num_empty_cols = complete_permutation(singletons_found, Cdeg, col_perm); work_estimate += 2 * Cdeg.size(); #ifdef SINGLETON_DEBUG printf("Completed col perm. %d empty cols. Starting row perm\n", num_empty_cols); #endif - i_t num_empty_rows = complete_permutation(singletons_found, Rdeg, row_perm); + [[maybe_unused]] i_t num_empty_rows = complete_permutation(singletons_found, Rdeg, row_perm); work_estimate += 2 * Rdeg.size(); #ifdef SINGLETON_DEBUG printf("Empty rows %d Empty columns %d\n", num_empty_rows, num_empty_cols); diff --git a/cpp/src/dual_simplex/solve.cpp b/cpp/src/dual_simplex/solve.cpp index 7c239b91fd..abaf981cf6 100644 --- a/cpp/src/dual_simplex/solve.cpp +++ b/cpp/src/dual_simplex/solve.cpp @@ -174,8 +174,8 @@ lp_status_t solve_linear_program_advanced(const lp_problem_t& original work_limit_context_t* work_unit_context) { raft::common::nvtx::range scope("DualSimplex::solve_lp"); - const i_t m = original_lp.num_rows; - const i_t n = original_lp.num_cols; + const i_t m = original_lp.num_rows; + [[maybe_unused]] const i_t n = original_lp.num_cols; assert(m <= n); std::vector basic_list(m); std::vector nonbasic_list; @@ -416,7 +416,6 @@ lp_status_t solve_linear_program_with_barrier( cuopt::mathematical_optimization::barrier_cache_t* cache, const raft::handle_t* handle_ptr) { - lp_status_t status = lp_status_t::UNSET; simplex_solver_settings_t barrier_settings = settings; auto const* xf = (cache != nullptr && cache->c_dirty()) ? cache->transform() : nullptr; diff --git a/cpp/src/dual_simplex/solve.hpp b/cpp/src/dual_simplex/solve.hpp index f8966e29c1..d77ad555cd 100644 --- a/cpp/src/dual_simplex/solve.hpp +++ b/cpp/src/dual_simplex/solve.hpp @@ -40,7 +40,7 @@ enum class lp_status_t { UNSET = 10 }; -static std::string lp_status_to_string(lp_status_t status) +[[maybe_unused]] static std::string lp_status_to_string(lp_status_t status) { switch (status) { case lp_status_t::OPTIMAL: return "OPTIMAL"; diff --git a/cpp/src/grpc/client/solve_remote.cpp b/cpp/src/grpc/client/solve_remote.cpp index 6fbf49896e..74b5a7702c 100644 --- a/cpp/src/grpc/client/solve_remote.cpp +++ b/cpp/src/grpc/client/solve_remote.cpp @@ -194,7 +194,7 @@ std::unique_ptr> solve_mip_remote( // Set up incumbent callback forwarding if (has_incumbents) { CUOPT_LOG_INFO("solve_mip_remote - setting up inline incumbent callback forwarding"); - config.incumbent_callback = [&mip_callbacks](int64_t index, + config.incumbent_callback = [&mip_callbacks]([[maybe_unused]] int64_t index, double objective, const std::vector& solution) -> bool { // Forward incumbent to all user callbacks (invoked from main thread with GIL) diff --git a/cpp/src/grpc/server/grpc_service_impl.cpp b/cpp/src/grpc/server/grpc_service_impl.cpp index 142524bb92..fe434f39fb 100644 --- a/cpp/src/grpc/server/grpc_service_impl.cpp +++ b/cpp/src/grpc/server/grpc_service_impl.cpp @@ -14,7 +14,7 @@ class CuOptRemoteServiceImpl final : public cuopt::remote::CuOptRemoteService::S // Unary submit: the entire problem fits in a single gRPC message. // Serializes the request and delegates slot reservation + tracking to // submit_job_async (shared with the chunked path's submit_chunked_job_async). - Status SubmitJob(ServerContext* context, + Status SubmitJob([[maybe_unused]] ServerContext* context, const cuopt::remote::SubmitJobRequest* request, cuopt::remote::SubmitJobResponse* response) override { @@ -394,7 +394,7 @@ class CuOptRemoteServiceImpl final : public cuopt::remote::CuOptRemoteService::S // Begin a chunked result download: snapshot the result arrays into a // download session. The client calls GetResultChunk to fetch slices and // FinishChunkedDownload when done (which frees the session). - Status StartChunkedDownload(ServerContext* context, + Status StartChunkedDownload([[maybe_unused]] ServerContext* context, const cuopt::remote::StartChunkedDownloadRequest* request, cuopt::remote::StartChunkedDownloadResponse* response) override { @@ -447,7 +447,7 @@ class CuOptRemoteServiceImpl final : public cuopt::remote::CuOptRemoteService::S return Status::OK; } - Status GetResultChunk(ServerContext* context, + Status GetResultChunk([[maybe_unused]] ServerContext* context, const cuopt::remote::GetResultChunkRequest* request, cuopt::remote::GetResultChunkResponse* response) override { @@ -500,7 +500,7 @@ class CuOptRemoteServiceImpl final : public cuopt::remote::CuOptRemoteService::S return Status::OK; } - Status FinishChunkedDownload(ServerContext* context, + Status FinishChunkedDownload([[maybe_unused]] ServerContext* context, const cuopt::remote::FinishChunkedDownloadRequest* request, cuopt::remote::FinishChunkedDownloadResponse* response) override { diff --git a/cpp/src/io/experimental_mps_fast/hash_table_smallstr.hpp b/cpp/src/io/experimental_mps_fast/hash_table_smallstr.hpp index bf33d7e895..64ccfedb94 100644 --- a/cpp/src/io/experimental_mps_fast/hash_table_smallstr.hpp +++ b/cpp/src/io/experimental_mps_fast/hash_table_smallstr.hpp @@ -176,7 +176,7 @@ class smallstr_hash_table_t { #endif } - void print_build_probe_report(size_t n_rows) const + void print_build_probe_report([[maybe_unused]] size_t n_rows) const { #ifdef MPS_FAST_PERF_COUNTERS hash_build_probe_stats_t stats = build_probe_stats_; diff --git a/cpp/src/io/experimental_mps_fast/mps_section_scanner.cpp b/cpp/src/io/experimental_mps_fast/mps_section_scanner.cpp index 32cbf3a105..9923d5ff90 100644 --- a/cpp/src/io/experimental_mps_fast/mps_section_scanner.cpp +++ b/cpp/src/io/experimental_mps_fast/mps_section_scanner.cpp @@ -1,5 +1,5 @@ -// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights -// reserved. SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #include "mps_section_scanner.hpp" @@ -116,8 +116,8 @@ bool mps_phase_registry_t::ready(mps_phase_kind phase) const mps_phase_range_t mps_phase_registry_t::range(mps_phase_kind phase) const { - std::size_t idx = phase_index(phase); - bool is_ready = ready_[idx].load(std::memory_order_acquire); + std::size_t idx = phase_index(phase); + [[maybe_unused]] bool is_ready = ready_[idx].load(std::memory_order_acquire); assert(is_ready); return ranges_[idx]; } diff --git a/cpp/src/io/mps_writer.cpp b/cpp/src/io/mps_writer.cpp index d0eaa428c8..f6a81086c2 100644 --- a/cpp/src/io/mps_writer.cpp +++ b/cpp/src/io/mps_writer.cpp @@ -151,7 +151,6 @@ void mps_writer_t::write(const std::string& mps_file_path) else n_constraints = problem_.get_constraint_lower_bounds().size(); const auto& quadratic_constraints = problem_.get_quadratic_constraints(); - const i_t n_quadratic_constraints = static_cast(quadratic_constraints.size()); std::vector objective_coefficients(problem_.get_objective_coefficients().size()); std::vector constraint_lower_bounds(n_constraints); diff --git a/cpp/src/io/utilities/error.hpp b/cpp/src/io/utilities/error.hpp index 0055c889f6..f5043f0b6c 100644 --- a/cpp/src/io/utilities/error.hpp +++ b/cpp/src/io/utilities/error.hpp @@ -99,7 +99,6 @@ inline void mps_parser_expects_fatal(bool cond, error_type_t error_type, const c char msg[2048]; vsnprintf(msg, sizeof(msg), fmt, args); va_end(args); - std::string error_string = error_to_string(error_type); std::fprintf(stderr, "{\"MPS_PARSER_ERROR_TYPE\": \"%s\", \"msg\": \"%s\"}\n", error_to_string(error_type).c_str(), diff --git a/cpp/src/linear_algebra/sparse_matrix.cpp b/cpp/src/linear_algebra/sparse_matrix.cpp index 158fecefcf..d47116a1e1 100644 --- a/cpp/src/linear_algebra/sparse_matrix.cpp +++ b/cpp/src/linear_algebra/sparse_matrix.cpp @@ -59,7 +59,6 @@ i_t coo_to_csc(const std::vector& Ai, if (A.nz_max < Ai.size()) { A.reallocate(static_cast(Ai.size())); } i_t n = A.n; - i_t m = A.m; i_t nz = Aj.size(); std::vector workspace(n); @@ -152,7 +151,7 @@ i_t csc_matrix_t::load_a_column(i_t j, std::vector& Aj) const template void csc_matrix_t::append_column(const std::vector& x) { - const i_t m = this->m; + [[maybe_unused]] const i_t m = this->m; assert(x.size() == m); const i_t xsz = x.size(); i_t nz = this->col_start[this->n]; @@ -173,7 +172,7 @@ void csc_matrix_t::append_column(const std::vector& x) template void csc_matrix_t::append_column(const sparse_vector_t& x) { - const i_t m = this->m; + [[maybe_unused]] const i_t m = this->m; assert(x.n == m); i_t nz = this->col_start[this->n]; const i_t xnz = x.i.size(); @@ -473,8 +472,8 @@ void csc_matrix_t::print_matrix() const template void csc_matrix_t::compare(csc_matrix_t const& B) const { - auto my_nnz = this->col_start[this->n]; - auto B_nnz = B.col_start[B.n]; + [[maybe_unused]] auto my_nnz = this->col_start[this->n]; + [[maybe_unused]] auto B_nnz = B.col_start[B.n]; assert(my_nnz == B_nnz); assert(this->m == B.m); assert(this->n == B.n); @@ -573,7 +572,7 @@ i_t scatter(const csc_matrix_t& A, } template -i_t csc_matrix_t::check_matrix(std::string matrix_name) const +i_t csc_matrix_t::check_matrix([[maybe_unused]] std::string matrix_name) const { #ifdef CHECK_MATRIX std::vector row_marker(this->m, -1); @@ -778,8 +777,8 @@ template i_t csc_matrix_t::permute_rows(const std::vector& pinv, csc_matrix_t& C) const { - i_t m = this->m; - i_t n = this->n; + [[maybe_unused]] i_t m = this->m; + i_t n = this->n; assert(C.m == m); assert(C.n == n); @@ -806,8 +805,8 @@ i_t csc_matrix_t::permute_rows_and_cols(const std::vector& pinv, const std::vector& q, csc_matrix_t& C) const { - i_t m = this->m; - i_t n = this->n; + [[maybe_unused]] i_t m = this->m; + i_t n = this->n; assert(C.m == m); assert(C.n == n); @@ -921,7 +920,6 @@ f_t sparse_dot(const std::vector& xind, const i_t nx = xind.size(); const i_t col_start = Y.col_start[y_col]; const i_t col_end = Y.col_start[y_col + 1]; - const i_t ny = col_end - col_start; f_t dot = 0.0; for (i_t i = 0, k = col_start; i < nx && k < col_end;) { const i_t p = xind[i]; diff --git a/cpp/src/linear_algebra/sparse_matrix.hpp b/cpp/src/linear_algebra/sparse_matrix.hpp index 95ee0f0f32..5cea1ea183 100644 --- a/cpp/src/linear_algebra/sparse_matrix.hpp +++ b/cpp/src/linear_algebra/sparse_matrix.hpp @@ -252,8 +252,8 @@ i_t matrix_transpose_vector_multiply(const csc_matrix_t& A, f_t beta, std::vector& y) { - i_t m = A.m; - i_t n = A.n; + [[maybe_unused]] i_t m = A.m; + i_t n = A.n; assert(y.size() == n); assert(x.size() == m); diff --git a/cpp/src/linear_algebra/sparse_vector.cpp b/cpp/src/linear_algebra/sparse_vector.cpp index 17839b342f..607ea9252a 100644 --- a/cpp/src/linear_algebra/sparse_vector.cpp +++ b/cpp/src/linear_algebra/sparse_vector.cpp @@ -126,7 +126,7 @@ template void sparse_vector_t::inverse_permute_vector(const std::vector& p, sparse_vector_t& y) const { - i_t m = p.size(); + [[maybe_unused]] i_t m = p.size(); assert(n == m); i_t nz = i.size(); y.n = n; @@ -154,7 +154,6 @@ f_t sparse_vector_t::sparse_dot(const csc_matrix_t& Y, i_t y { const i_t col_start = Y.col_start[y_col]; const i_t col_end = Y.col_start[y_col + 1]; - const i_t ny = col_end - col_start; const i_t nx = i.size(); f_t dot = 0.0; for (i_t h = 0, k = col_start; h < nx && k < col_end;) { diff --git a/cpp/src/mip_heuristics/diversity/diversity_manager.cu b/cpp/src/mip_heuristics/diversity/diversity_manager.cu index 96165e6064..c2c0b85f59 100644 --- a/cpp/src/mip_heuristics/diversity/diversity_manager.cu +++ b/cpp/src/mip_heuristics/diversity/diversity_manager.cu @@ -892,7 +892,6 @@ diversity_manager_t::recombine_and_local_search(solution_t& offspring.get_quality(population.weights), offspring.get_feasible()); cuopt_assert(offspring.test_number_all_integer(), "All must be integers before LS"); - bool feasibility_before = offspring.get_feasible(); ls_config_t ls_config; ls_config.best_objective_of_parents = best_objective_of_parents; ls_config.at_least_one_parent_feasible = at_least_one_parent_feasible; diff --git a/cpp/src/mip_heuristics/diversity/recombiners/bound_prop_recombiner.cuh b/cpp/src/mip_heuristics/diversity/recombiners/bound_prop_recombiner.cuh index fca4821d4d..a2069498d6 100644 --- a/cpp/src/mip_heuristics/diversity/recombiners/bound_prop_recombiner.cuh +++ b/cpp/src/mip_heuristics/diversity/recombiners/bound_prop_recombiner.cuh @@ -173,7 +173,7 @@ class bound_prop_recombiner_t : public recombiner_t { constraint_prop.max_n_failed_repair_iterations = bp_recombiner_config_t::n_repair_iterations; rmm::device_uvector> probing_values(a.problem_ptr->n_variables, a.handle_ptr->get_stream()); - probing_config_t probing_config(a.problem_ptr->n_variables, a.handle_ptr); + probing_config_t probing_config(a.problem_ptr->n_variables); if (guiding_solution.get_feasible() && !a.problem_ptr->expensive_to_fix_vars) { this->compute_vars_to_fix(offspring, vars_to_fix, n_vars_from_other, n_vars_from_guiding); auto [fixed_problem, fixed_assignment, variable_map] = offspring.fix_variables(vars_to_fix); @@ -197,14 +197,12 @@ class bound_prop_recombiner_t : public recombiner_t { constraint_prop.single_rounding_only = true; constraint_prop.apply_round(offspring, lp_run_time_after_feasible, timer, probing_config); constraint_prop.single_rounding_only = false; - cuopt_func_call(bool feasible_after_bounds_prop = offspring.get_feasible()); offspring.handle_ptr->sync_stream(); offspring.problem_ptr = a.problem_ptr; fixed_assignment = std::move(offspring.assignment); offspring.assignment = std::move(old_assignment); offspring.handle_ptr->sync_stream(); offspring.unfix_variables(fixed_assignment, variable_map); - cuopt_func_call(bool feasible_after_unfix = offspring.get_feasible()); // May be triggered due to numerical issues // TODO: investigate further // cuopt_assert(feasible_after_unfix == feasible_after_bounds_prop, diff --git a/cpp/src/mip_heuristics/diversity/recombiners/sub_mip.cuh b/cpp/src/mip_heuristics/diversity/recombiners/sub_mip.cuh index 7990465b81..b047f270a5 100644 --- a/cpp/src/mip_heuristics/diversity/recombiners/sub_mip.cuh +++ b/cpp/src/mip_heuristics/diversity/recombiners/sub_mip.cuh @@ -86,7 +86,7 @@ class sub_mip_recombiner_t : public recombiner_t { static_cast(1), true); scaling.scale_problem(); - fixed_problem.presolve_data.reset_additional_vars(fixed_problem, offspring.handle_ptr); + fixed_problem.presolve_data.reset_additional_vars(fixed_problem); fixed_problem.presolve_data.initialize_var_mapping(fixed_problem, offspring.handle_ptr); trivial_presolve(fixed_problem); fixed_problem.check_problem_representation(true); diff --git a/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cuh b/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cuh index b71892b39d..28e80c323b 100644 --- a/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cuh +++ b/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cuh @@ -535,12 +535,12 @@ class fj_t { fj_settings_t* settings; - HDI f_t lower_excess_score(i_t cstr, f_t lhs, f_t c_lb) const + HDI f_t lower_excess_score([[maybe_unused]] i_t cstr, f_t lhs, f_t c_lb) const { return raft::min(lhs - c_lb, (f_t)0); } - HDI f_t upper_excess_score(i_t cstr, f_t lhs, f_t c_ub) const + HDI f_t upper_excess_score([[maybe_unused]] i_t cstr, f_t lhs, f_t c_ub) const { return raft::min(c_ub - lhs, (f_t)0); } @@ -568,7 +568,7 @@ class fj_t { // which may suffer from numerical errors and lead to very slight (~machine epsilon) // violations of the actual bounds. // Use a slightly tightened tolerance in FJ to account for this. - HDI f_t get_corrected_tolerance(i_t cstr, f_t c_lb, f_t c_ub) const + HDI f_t get_corrected_tolerance([[maybe_unused]] i_t cstr, f_t c_lb, f_t c_ub) const { f_t cstr_tolerance = get_cstr_tolerance( c_lb, c_ub, pb.tolerances.absolute_tolerance, pb.tolerances.relative_tolerance); diff --git a/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump_kernels.cu b/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump_kernels.cu index f50849fcff..773ac37218 100644 --- a/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump_kernels.cu +++ b/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump_kernels.cu @@ -499,7 +499,7 @@ DI bool save_best_solution(typename fj_t::climber_data_t::view_t& fj) cuopt_assert( *fj.weighted_violation_score <= *fj.max_cstr_weight * fj.pb.tolerances.absolute_tolerance, "Violated constraint and score mismatch"); - bool check_integer = fj.settings->mode != fj_mode_t::ROUNDING; + [[maybe_unused]] bool check_integer = fj.settings->mode != fj_mode_t::ROUNDING; cuopt_func_call(check_feasibility(fj, check_integer)); } // return whether it is an improving local minimum diff --git a/cpp/src/mip_heuristics/feasibility_jump/fj_cpu.cu b/cpp/src/mip_heuristics/feasibility_jump/fj_cpu.cu index 807ad8d729..63c6a344fe 100644 --- a/cpp/src/mip_heuristics/feasibility_jump/fj_cpu.cu +++ b/cpp/src/mip_heuristics/feasibility_jump/fj_cpu.cu @@ -64,8 +64,7 @@ void finalize_fj_cpu_host_initialization( const typename mip_solver_settings_t::tolerances_t& tolerances); template -thrust::tuple get_mtm_for_bound(const typename fj_t::climber_data_t::view_t& fj, - i_t var_idx, +thrust::tuple get_mtm_for_bound(i_t var_idx, i_t cstr_idx, f_t cstr_coeff, f_t bound, @@ -989,10 +988,7 @@ static void update_weights(fj_cpu_climber_t& fj_cpu) } template -static void apply_move(fj_cpu_climber_t& fj_cpu, - i_t var_idx, - f_t delta, - bool localmin = false) +static void apply_move(fj_cpu_climber_t& fj_cpu, i_t var_idx, f_t delta) { timing_raii_t timer(fj_cpu.apply_move_times); CPUFJ_NVTX_RANGE("CPUFJ::apply_move"); @@ -1402,14 +1398,8 @@ static thrust::tuple find_lift_move( // Process each bound separately, as both are satified and may both be finite // otherwise range constraints aren't correctly handled for (auto [bound, sign] : {std::make_tuple(c_lb, -1), std::make_tuple(c_ub, 1)}) { - auto [delta, slack] = get_mtm_for_bound(fj_cpu.view, - var_idx, - cstr_idx, - cstr_coeff, - bound, - sign, - fj_cpu.h_assignment, - fj_cpu.h_lhs); + auto [delta, slack] = get_mtm_for_bound( + var_idx, cstr_idx, cstr_coeff, bound, sign, fj_cpu.h_assignment, fj_cpu.h_lhs); if (cstr_coeff * sign < 0) { if (is_integer_var(fj_cpu, var_idx)) delta = ceil(delta); @@ -2007,7 +1997,7 @@ void cpufj_solve(fj_cpu_climber_t* fj_cpu, f_t in_time_limit, double w } if (score > fj_staged_score_t::zero() && !should_perturb) { - apply_move(*fj_cpu, move.var_idx, move.value, false); + apply_move(*fj_cpu, move.var_idx, move.value); // Track move types if (is_lift) fj_cpu->n_lift_moves_window++; if (is_mtm_viol) fj_cpu->n_mtm_viol_moves_window++; @@ -2024,15 +2014,15 @@ void cpufj_solve(fj_cpu_climber_t* fj_cpu, f_t in_time_limit, double w two_opt_move_t two_opt_move; if (!should_perturb) two_opt_move = find_two_opt_move(*fj_cpu); if (two_opt_move.score > fj_staged_score_t::zero()) { - apply_move(*fj_cpu, two_opt_move.first.var_idx, two_opt_move.first.value, true); - apply_move(*fj_cpu, two_opt_move.second.var_idx, two_opt_move.second.value, true); + apply_move(*fj_cpu, two_opt_move.first.var_idx, two_opt_move.first.value); + apply_move(*fj_cpu, two_opt_move.second.var_idx, two_opt_move.second.value); fj_cpu->n_mtm_viol_moves_window += 2; } else { thrust::tie(move, score) = find_mtm_move_viol(*fj_cpu, 1, true); // pick a single random violated constraint i_t var_idx = move.var_idx >= 0 ? move.var_idx : 0; f_t delta = move.var_idx >= 0 ? move.value : 0; - apply_move(*fj_cpu, var_idx, delta, true); + apply_move(*fj_cpu, var_idx, delta); } ++local_mins; ++fj_cpu->n_local_minima_window; @@ -2162,7 +2152,7 @@ void fj_cpu_worker_t::run_async(f_t time_limit, double work_unit_limit { if (!is_initialized) return; - auto& fj_ptr = fj_cpu; + [[maybe_unused]] auto& fj_ptr = fj_cpu; #pragma omp task shared(fj_cpu, is_initialized, fj_ptr) firstprivate(time_limit, work_unit_limit) \ priority(CUOPT_DEFAULT_TASK_PRIORITY) default(none) depend(out : fj_ptr) { @@ -2186,7 +2176,7 @@ void fj_cpu_worker_t::stop() preemption_flag = true; - auto& fj_ptr = fj_cpu; + [[maybe_unused]] auto& fj_ptr = fj_cpu; #pragma omp taskwait depend(in : fj_ptr) is_initialized = false; fj_cpu.reset(); diff --git a/cpp/src/mip_heuristics/feasibility_jump/fj_cpu_binary_preprocess.cu b/cpp/src/mip_heuristics/feasibility_jump/fj_cpu_binary_preprocess.cu index ffed26751a..ef7b4d6672 100644 --- a/cpp/src/mip_heuristics/feasibility_jump/fj_cpu_binary_preprocess.cu +++ b/cpp/src/mip_heuristics/feasibility_jump/fj_cpu_binary_preprocess.cu @@ -122,12 +122,10 @@ fj_bin_scan_t fj_bin_scan(const fj_cpu_climber_t& c, fj_bin_setup_time } } - const auto& offsets = c.problem->offsets; - const auto& reverse_offsets = c.problem->reverse_offsets; - const auto& reverse_constraints = c.problem->reverse_constraints; - const auto& coeffs = c.problem->coefficients; - const auto& cstr_lb = c.problem->cstr_lb; - const auto& cstr_ub = c.problem->cstr_ub; + const auto& offsets = c.problem->offsets; + const auto& coeffs = c.problem->coefficients; + const auto& cstr_lb = c.problem->cstr_lb; + const auto& cstr_ub = c.problem->cstr_ub; double max_abs_coefficient = 0; std::vector row_values; diff --git a/cpp/src/mip_heuristics/feasibility_jump/load_balancing.cuh b/cpp/src/mip_heuristics/feasibility_jump/load_balancing.cuh index 52038d1a67..4fb034a65f 100644 --- a/cpp/src/mip_heuristics/feasibility_jump/load_balancing.cuh +++ b/cpp/src/mip_heuristics/feasibility_jump/load_balancing.cuh @@ -207,7 +207,7 @@ __global__ void load_balancing_compute_workid_mappings( cuopt_assert(idx >= 0 && idx < var_indices.size(), "invalid index"); i_t var_idx = var_indices[idx]; cuopt_assert(var_idx >= 0 && var_idx < fj.pb.n_variables, "invalid var_idx"); - uint32_t subworkid = *ptr - (workid + 1); + [[maybe_unused]] uint32_t subworkid = *ptr - (workid + 1); auto [offset_begin, offset_end] = fj.pb.reverse_range_for_var(var_idx); diff --git a/cpp/src/mip_heuristics/local_search/local_search.cu b/cpp/src/mip_heuristics/local_search/local_search.cu index 2548a804e9..945950b350 100644 --- a/cpp/src/mip_heuristics/local_search/local_search.cu +++ b/cpp/src/mip_heuristics/local_search/local_search.cu @@ -202,7 +202,7 @@ void local_search_t::start_cpufj_deterministic(mip::branch_and_bound_t // Set up callback to send solutions to B&B with work unit timestamps deterministic_cpu_fj->improvement_callback = - [&bb](f_t obj, const std::vector& h_vec, double work_units) { + [&bb]([[maybe_unused]] f_t obj, const std::vector& h_vec, double work_units) { bb.queue_external_solution_deterministic(h_vec, work_units); }; @@ -680,8 +680,6 @@ void local_search_t::reset_alpha_and_save_solution( solution_t& solution, problem_t* old_problem_ptr, population_t* population_ptr, - i_t i, - i_t last_improved_iteration, rmm::device_uvector& best_solution, f_t& best_objective) { @@ -715,7 +713,6 @@ void local_search_t::reset_alpha_and_save_solution( template void local_search_t::reset_alpha_and_run_recombiners( solution_t& solution, - problem_t* old_problem_ptr, population_t* population_ptr, i_t i, i_t last_improved_iteration, @@ -795,13 +792,8 @@ bool local_search_t::run_fp(solution_t& solution, if (is_feasible) { CUOPT_LOG_DEBUG("Found feasible in FP with obj %f. Continue with FJ!", solution.get_objective()); - reset_alpha_and_save_solution(solution, - old_problem_ptr, - population_ptr, - i, - last_improved_iteration, - best_solution, - best_objective); + reset_alpha_and_save_solution( + solution, old_problem_ptr, population_ptr, best_solution, best_objective); last_improved_iteration = i; } // if not feasible, it means it is a cycle @@ -819,22 +811,12 @@ bool local_search_t::run_fp(solution_t& solution, if (is_feasible) { CUOPT_LOG_DEBUG("Found feasible during restart with obj %f. Continue with FJ!", solution.get_objective()); - reset_alpha_and_save_solution(solution, - old_problem_ptr, - population_ptr, - i, - last_improved_iteration, - best_solution, - best_objective); + reset_alpha_and_save_solution( + solution, old_problem_ptr, population_ptr, best_solution, best_objective); last_improved_iteration = i; } else { - reset_alpha_and_run_recombiners(solution, - old_problem_ptr, - population_ptr, - i, - last_improved_iteration, - best_solution, - best_objective); + reset_alpha_and_run_recombiners( + solution, population_ptr, i, last_improved_iteration, best_solution, best_objective); } } } diff --git a/cpp/src/mip_heuristics/local_search/local_search.cuh b/cpp/src/mip_heuristics/local_search/local_search.cuh index e22d7e2d0e..ed20420ccd 100644 --- a/cpp/src/mip_heuristics/local_search/local_search.cuh +++ b/cpp/src/mip_heuristics/local_search/local_search.cuh @@ -91,7 +91,6 @@ class local_search_t { void resize_to_new_problem(); void resize_to_old_problem(problem_t* old_problem_ptr); void reset_alpha_and_run_recombiners(solution_t& solution, - problem_t* old_problem_ptr, population_t* population_ptr, i_t i, i_t last_unimproved_iteration, @@ -100,8 +99,6 @@ class local_search_t { void reset_alpha_and_save_solution(solution_t& solution, problem_t* old_problem_ptr, population_t* population_ptr, - i_t i, - i_t last_unimproved_iteration, rmm::device_uvector& best_solution, f_t& best_objective); diff --git a/cpp/src/mip_heuristics/local_search/rounding/constraint_prop.cu b/cpp/src/mip_heuristics/local_search/rounding/constraint_prop.cu index f64545e8c8..a638cc7eeb 100644 --- a/cpp/src/mip_heuristics/local_search/rounding/constraint_prop.cu +++ b/cpp/src/mip_heuristics/local_search/rounding/constraint_prop.cu @@ -1171,7 +1171,8 @@ template bool constraint_prop_t::handle_fixed_vars( solution_t& sol, problem_t* original_problem, - const std::tuple, std::vector, std::vector>& var_probe_vals, + [[maybe_unused]] const std::tuple, std::vector, std::vector>& + var_probe_vals, size_t* set_count_ptr, rmm::device_uvector& unset_vars) { diff --git a/cpp/src/mip_heuristics/local_search/rounding/constraint_prop.cuh b/cpp/src/mip_heuristics/local_search/rounding/constraint_prop.cuh index 89ab15b737..4a338d8901 100644 --- a/cpp/src/mip_heuristics/local_search/rounding/constraint_prop.cuh +++ b/cpp/src/mip_heuristics/local_search/rounding/constraint_prop.cuh @@ -31,7 +31,7 @@ struct repair_stats_t { template struct probing_config_t { - probing_config_t(i_t n_vars, const raft::handle_t* handle_ptr) : probing_values(n_vars) {} + probing_config_t(i_t n_vars) : probing_values(n_vars) {} bool use_balanced_probing = false; i_t n_of_fixed_from_first = 0; i_t n_of_fixed_from_second = 0; diff --git a/cpp/src/mip_heuristics/logger.cuh b/cpp/src/mip_heuristics/logger.cuh index d202fe5a1f..70c43e44c6 100644 --- a/cpp/src/mip_heuristics/logger.cuh +++ b/cpp/src/mip_heuristics/logger.cuh @@ -20,37 +20,37 @@ namespace cuopt::mathematical_optimization::mip { #if (CUOPT_LOG_ACTIVE_LEVEL <= RAPIDS_LOGGER_LOG_LEVEL_TRACE) #define DEVICE_LOG_TRACE(...) printf(__VA_ARGS__) #else -#define DEVICE_LOG_TRACE(...) void(0) +#define DEVICE_LOG_TRACE(...) CUOPT_LOG_DISABLED(__VA_ARGS__) #endif #if (CUOPT_LOG_ACTIVE_LEVEL <= RAPIDS_LOGGER_LOG_LEVEL_DEBUG) #define DEVICE_LOG_DEBUG(...) printf(__VA_ARGS__) #else -#define DEVICE_LOG_DEBUG(...) void(0) +#define DEVICE_LOG_DEBUG(...) CUOPT_LOG_DISABLED(__VA_ARGS__) #endif #if (CUOPT_LOG_ACTIVE_LEVEL <= RAPIDS_LOGGER_LOG_LEVEL_INFO) #define DEVICE_LOG_INFO(...) printf(__VA_ARGS__) #else -#define DEVICE_LOG_INFO(...) void(0) +#define DEVICE_LOG_INFO(...) CUOPT_LOG_DISABLED(__VA_ARGS__) #endif #if (CUOPT_LOG_ACTIVE_LEVEL <= RAPIDS_LOGGER_LOG_LEVEL_WARN) #define DEVICE_LOG_WARN(...) printf(__VA_ARGS__) #else -#define DEVICE_LOG_WARN(...) void(0) +#define DEVICE_LOG_WARN(...) CUOPT_LOG_DISABLED(__VA_ARGS__) #endif #if (CUOPT_LOG_ACTIVE_LEVEL <= RAPIDS_LOGGER_LOG_LEVEL_ERROR) #define DEVICE_LOG_ERROR(...) printf(__VA_ARGS__) #else -#define DEVICE_LOG_ERROR(...) void(0) +#define DEVICE_LOG_ERROR(...) CUOPT_LOG_DISABLED(__VA_ARGS__) #endif #if (CUOPT_LOG_ACTIVE_LEVEL <= RAPIDS_LOGGER_LOG_LEVEL_CRITICAL) #define DEVICE_LOG_CRITICAL(...) printf(__VA_ARGS__) #else -#define DEVICE_LOG_CRITICAL(...) void(0) +#define DEVICE_LOG_CRITICAL(...) CUOPT_LOG_DISABLED(__VA_ARGS__) #endif } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/presolve/bhw_coeff_reduce.cpp b/cpp/src/mip_heuristics/presolve/bhw_coeff_reduce.cpp index 598918f67e..3321c7ed43 100644 --- a/cpp/src/mip_heuristics/presolve/bhw_coeff_reduce.cpp +++ b/cpp/src/mip_heuristics/presolve/bhw_coeff_reduce.cpp @@ -481,7 +481,7 @@ papilo::PresolveStatus BHWCoeffReduce::execute(const papilo::Problem& const papilo::Num& num, papilo::Reductions& reductions, const papilo::Timer& timer, - int& reason_of_infeasibility) + [[maybe_unused]] int& reason_of_infeasibility) { const auto& constraint_matrix = problem.getConstraintMatrix(); const auto& lhs_values = constraint_matrix.getLeftHandSides(); diff --git a/cpp/src/mip_heuristics/presolve/bhw_coeff_reduce.hpp b/cpp/src/mip_heuristics/presolve/bhw_coeff_reduce.hpp index d334bf399f..5495ac966d 100644 --- a/cpp/src/mip_heuristics/presolve/bhw_coeff_reduce.hpp +++ b/cpp/src/mip_heuristics/presolve/bhw_coeff_reduce.hpp @@ -11,6 +11,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" // ignore boost error for pip wheel build #pragma GCC diagnostic ignored "-Wnarrowing" +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #include #include @@ -73,7 +74,7 @@ class BHWCoeffReduce : public papilo::PresolveMethod { const papilo::Num& num, papilo::Reductions& reductions, const papilo::Timer& timer, - int& reason_of_infeasibility) override; + [[maybe_unused]] int& reason_of_infeasibility) override; private: bhw_shape_cache_t shape_cache_; diff --git a/cpp/src/mip_heuristics/presolve/bounds_presolve.cu b/cpp/src/mip_heuristics/presolve/bounds_presolve.cu index 0c84d26fa0..19b77dfc08 100644 --- a/cpp/src/mip_heuristics/presolve/bounds_presolve.cu +++ b/cpp/src/mip_heuristics/presolve/bounds_presolve.cu @@ -261,7 +261,6 @@ template termination_criterion_t bound_presolve_t::solve(problem_t& pb) { timer_t timer(settings.time_limit); - auto& handle_ptr = pb.handle_ptr; copy_input_bounds(pb); return bound_update_loop(pb, timer); } diff --git a/cpp/src/mip_heuristics/presolve/conditional_bound_strengthening.cu b/cpp/src/mip_heuristics/presolve/conditional_bound_strengthening.cu index 14258e6b16..a25897f780 100644 --- a/cpp/src/mip_heuristics/presolve/conditional_bound_strengthening.cu +++ b/cpp/src/mip_heuristics/presolve/conditional_bound_strengthening.cu @@ -48,7 +48,7 @@ void conditional_bound_strengthening_t::resize(problem_t& pr // is computing by chunks, i.e. subset of rows at a time try { select_constraint_pairs_device(problem); - } catch (std::bad_alloc& e) { + } catch (std::bad_alloc&) { select_constraint_pairs_host(problem); } async_fill(locks_per_constraint, 0, problem.handle_ptr->get_stream()); @@ -97,7 +97,7 @@ void spgemm_cusparse([[maybe_unused]] rmm::device_uvector& offsetsA, cusparseSpMatDescr_t matA, matB, matC; cusparseSpGEMMAlg_t alg = CUSPARSE_SPGEMM_ALG1; - rmm::device_buffer dBuffer1(0, stream), dBuffer2(0, stream), dBuffer3(0, stream); + rmm::device_buffer dBuffer1(0, stream), dBuffer2(0, stream); float alpha = 1.0f; float beta = 0.0f; diff --git a/cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cu b/cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cu index a8e6997572..0ed0ca298f 100644 --- a/cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cu +++ b/cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cu @@ -283,7 +283,7 @@ void remove_small_cliques(clique_table_t& clique_table, cuopt::timer_t size_t i = 0; size_t old_idx = 0; std::vector index_mapping(clique_table.first.size(), -1); - auto it = std::remove_if(clique_table.first.begin(), clique_table.first.end(), [&](auto& clique) { + auto it = std::remove_if(clique_table.first.begin(), clique_table.first.end(), [&](auto&) { bool res = false; if (to_delete[old_idx]) { res = true; @@ -674,8 +674,8 @@ void find_initial_cliques(user_problem_t& problem, cuopt::timer_t& timer, omp_atomic_t* signal_extend) { - cuopt::timer_t stage_timer(std::numeric_limits::infinity()); #ifdef DEBUG_CLIQUE_TABLE + cuopt::timer_t stage_timer(std::numeric_limits::infinity()); double t_fill = 0.; double t_coeff = 0.; double t_sort = 0.; diff --git a/cpp/src/mip_heuristics/presolve/gf2_presolve.cpp b/cpp/src/mip_heuristics/presolve/gf2_presolve.cpp index c0963e5a34..4dad961d16 100644 --- a/cpp/src/mip_heuristics/presolve/gf2_presolve.cpp +++ b/cpp/src/mip_heuristics/presolve/gf2_presolve.cpp @@ -162,12 +162,13 @@ gf2_status_t gf2_solve(std::vector>& A, } template -papilo::PresolveStatus GF2Presolve::execute(const papilo::Problem& problem, - const papilo::ProblemUpdate& problemUpdate, - const papilo::Num& num, - papilo::Reductions& reductions, - const papilo::Timer& timer, - int& reason_of_infeasibility) +papilo::PresolveStatus GF2Presolve::execute( + const papilo::Problem& problem, + [[maybe_unused]] const papilo::ProblemUpdate& problemUpdate, + const papilo::Num& num, + papilo::Reductions& reductions, + [[maybe_unused]] const papilo::Timer& timer, + [[maybe_unused]] int& reason_of_infeasibility) { const auto& constraint_matrix = problem.getConstraintMatrix(); const auto& lhs_values = constraint_matrix.getLeftHandSides(); diff --git a/cpp/src/mip_heuristics/presolve/gf2_presolve.hpp b/cpp/src/mip_heuristics/presolve/gf2_presolve.hpp index 19fdd0bcac..56ceb48009 100644 --- a/cpp/src/mip_heuristics/presolve/gf2_presolve.hpp +++ b/cpp/src/mip_heuristics/presolve/gf2_presolve.hpp @@ -11,6 +11,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" // ignore boost error for pip wheel build #pragma GCC diagnostic ignored "-Wnarrowing" +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #include #include @@ -47,11 +48,11 @@ class GF2Presolve : public papilo::PresolveMethod { } papilo::PresolveStatus execute(const papilo::Problem& problem, - const papilo::ProblemUpdate& problemUpdate, + [[maybe_unused]] const papilo::ProblemUpdate& problemUpdate, const papilo::Num& num, papilo::Reductions& reductions, - const papilo::Timer& timer, - int& reason_of_infeasibility) override; + [[maybe_unused]] const papilo::Timer& timer, + [[maybe_unused]] int& reason_of_infeasibility) override; private: struct gf2_constraint_t { diff --git a/cpp/src/mip_heuristics/presolve/semi_continuous.cu b/cpp/src/mip_heuristics/presolve/semi_continuous.cu index a7295b0036..9df5c3dbc6 100644 --- a/cpp/src/mip_heuristics/presolve/semi_continuous.cu +++ b/cpp/src/mip_heuristics/presolve/semi_continuous.cu @@ -152,10 +152,9 @@ bool reformulate_semi_continuous(optimization_problem_t& op_problem, op_problem.set_variable_upper_bounds(var_ub.data(), var_ub.size()); } - const i_t n_orig = op_problem.get_n_variables(); - const i_t n_sc = static_cast(sc_indices.size()); - const auto* handle_ptr = op_problem.get_handle_ptr(); - const f_t big_m = settings.semi_continuous_big_m; + const i_t n_orig = op_problem.get_n_variables(); + const i_t n_sc = static_cast(sc_indices.size()); + const f_t big_m = settings.semi_continuous_big_m; if (used_fallback_big_m != nullptr) { used_fallback_big_m->assign(n_orig, uint8_t{0}); } CUOPT_LOG_INFO("Reformulating %d semi-continuous variables before presolve", n_sc); diff --git a/cpp/src/mip_heuristics/presolve/single_lock_dual_aggregation.cpp b/cpp/src/mip_heuristics/presolve/single_lock_dual_aggregation.cpp index 554fb86ccc..ceb158dac3 100644 --- a/cpp/src/mip_heuristics/presolve/single_lock_dual_aggregation.cpp +++ b/cpp/src/mip_heuristics/presolve/single_lock_dual_aggregation.cpp @@ -444,7 +444,7 @@ papilo::PresolveStatus SingleLockDualAggregation::execute( const papilo::Num& num, papilo::Reductions& reductions, const papilo::Timer& timer, - int& reason_of_infeasibility) + [[maybe_unused]] int& reason_of_infeasibility) { const int ncols = problem.getNCols(); const auto& options = problemUpdate.getPresolveOptions(); diff --git a/cpp/src/mip_heuristics/presolve/single_lock_dual_aggregation.hpp b/cpp/src/mip_heuristics/presolve/single_lock_dual_aggregation.hpp index 5cc5049ac1..a8328b92ad 100644 --- a/cpp/src/mip_heuristics/presolve/single_lock_dual_aggregation.hpp +++ b/cpp/src/mip_heuristics/presolve/single_lock_dual_aggregation.hpp @@ -10,6 +10,7 @@ #if !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" // ignore boost error for pip wheel build +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #include #include @@ -36,7 +37,7 @@ class SingleLockDualAggregation : public papilo::PresolveMethod { const papilo::Num& num, papilo::Reductions& reductions, const papilo::Timer& timer, - int& reason_of_infeasibility) override; + [[maybe_unused]] int& reason_of_infeasibility) override; }; } // namespace cuopt::mathematical_optimization::mip diff --git a/cpp/src/mip_heuristics/presolve/third_party_presolve.cpp b/cpp/src/mip_heuristics/presolve/third_party_presolve.cpp index 7bf7bd76d6..316e06e290 100644 --- a/cpp/src/mip_heuristics/presolve/third_party_presolve.cpp +++ b/cpp/src/mip_heuristics/presolve/third_party_presolve.cpp @@ -71,8 +71,6 @@ void normalize_for_presolve(io::mps_data_model_t const& mps, bool maximize, std::vector& obj_coeffs, f_t& objective_offset, - std::vector& var_lb, - std::vector& var_ub, std::vector& constr_lb, std::vector& constr_ub) { @@ -120,7 +118,7 @@ papilo::Problem build_papilo_problem(io::mps_data_model_t const& std::vector constr_ub(mps.get_constraint_upper_bounds()); f_t objective_offset = mps.get_objective_offset(); normalize_for_presolve( - mps, maximize, obj_coeffs, objective_offset, var_lb, var_ub, constr_lb, constr_ub); + mps, maximize, obj_coeffs, objective_offset, constr_lb, constr_ub); const auto& coefficients = mps.get_constraint_matrix_values(); const auto& indices = mps.get_constraint_matrix_indices(); @@ -785,9 +783,6 @@ void set_presolve_methods( template void set_presolve_options(papilo::Presolve& presolver, - problem_category_t category, - f_t absolute_tolerance, - f_t relative_tolerance, f_t time_limit, bool dual_postsolve, i_t num_cpu_threads, @@ -807,7 +802,6 @@ template void set_presolve_parameters( papilo::Presolve& presolver, problem_category_t category, - int nrows, int ncols, int max_badgesize, std::optional> const& method_allowlist = std::nullopt) @@ -859,7 +853,7 @@ third_party_presolve_status_t third_party_presolve_t::apply_pslp( std::vector constr_ub(mps.get_constraint_upper_bounds()); f_t objective_offset = mps.get_objective_offset(); normalize_for_presolve( - mps, maximize_, obj_coeffs, objective_offset, var_lb, var_ub, constr_lb, constr_ub); + mps, maximize_, obj_coeffs, objective_offset, constr_lb, constr_ub); if (var_lb.empty()) { var_lb.assign(n_cols, -std::numeric_limits::infinity()); } if (var_ub.empty()) { var_ub.assign(n_cols, std::numeric_limits::infinity()); } const auto& coefficients = mps.get_constraint_matrix_values(); @@ -913,8 +907,8 @@ third_party_presolve_status_t third_party_presolve_t::apply_papilo( papilo::Problem& papilo_problem, problem_category_t category, bool dual_postsolve, - f_t absolute_tolerance, - f_t relative_tolerance, + [[maybe_unused]] f_t absolute_tolerance, + [[maybe_unused]] f_t relative_tolerance, double time_limit, i_t num_cpu_threads, i_t max_rounds, @@ -936,20 +930,10 @@ third_party_presolve_status_t third_party_presolve_t::apply_papilo( if (category == problem_category_t::MIP) { dual_postsolve = false; } papilo::Presolve papilo_presolver; set_presolve_methods(papilo_presolver, category, dual_postsolve, reduction_allowlist_); - set_presolve_options(papilo_presolver, - category, - absolute_tolerance, - relative_tolerance, - time_limit, - dual_postsolve, - num_cpu_threads, - max_rounds); - set_presolve_parameters(papilo_presolver, - category, - original_n_cons, - original_n_vars, - max_badgesize, - reduction_allowlist_); + set_presolve_options( + papilo_presolver, time_limit, dual_postsolve, num_cpu_threads, max_rounds); + set_presolve_parameters( + papilo_presolver, category, original_n_vars, max_badgesize, reduction_allowlist_); papilo_presolver.setVerbosityLevel(papilo::VerbosityLevel::kQuiet); CUOPT_LOG_DEBUG( "PRESOLVE_PAPILO_BUDGET rounds=%d badge_cap=%d tlim=%g", max_rounds, max_badgesize, time_limit); @@ -1223,18 +1207,11 @@ third_party_presolve_status_t third_party_presolve_t::apply_to_subprob papilo::Presolve papilo_presolver; set_presolve_methods( papilo_presolver, problem_category_t::MIP, dual_postsolve, reduction_allowlist_); - set_presolve_options(papilo_presolver, - problem_category_t::MIP, - settings.primal_tol, - settings.dual_tol, - time_limit, - dual_postsolve, - num_threads, - -1); + set_presolve_options(papilo_presolver, time_limit, dual_postsolve, num_threads, -1); // Node presolve already runs under a finite time limit, so it keeps the unbounded round count and // uncapped badge; the budgets apply to root presolve only. set_presolve_parameters( - papilo_presolver, problem_category_t::MIP, orig_rows, orig_cols, -1, reduction_allowlist_); + papilo_presolver, problem_category_t::MIP, orig_cols, -1, reduction_allowlist_); // Disable papilo logs papilo_presolver.setVerbosityLevel(papilo::VerbosityLevel::kQuiet); diff --git a/cpp/src/mip_heuristics/problem/presolve_data.cuh b/cpp/src/mip_heuristics/problem/presolve_data.cuh index cae3a498e7..28f8341ad1 100644 --- a/cpp/src/mip_heuristics/problem/presolve_data.cuh +++ b/cpp/src/mip_heuristics/problem/presolve_data.cuh @@ -96,7 +96,7 @@ class presolve_data_t { postsolve_reconstructions.clear(); } - void reset_additional_vars(const problem_t& problem, const raft::handle_t* handle_ptr) + void reset_additional_vars(const problem_t& problem) { variable_offsets.assign(problem.n_variables, 0); additional_var_used.assign(problem.n_variables, false); diff --git a/cpp/src/mip_heuristics/problem/problem_helpers.cuh b/cpp/src/mip_heuristics/problem/problem_helpers.cuh index 00093330ca..0c4a27120d 100644 --- a/cpp/src/mip_heuristics/problem/problem_helpers.cuh +++ b/cpp/src/mip_heuristics/problem/problem_helpers.cuh @@ -318,7 +318,7 @@ static bool check_bounds_sanity(const mip::problem_t& problem) check_constraint_bounds_sanity(problem); } -static void check_cusparse_status(cusparseStatus_t status) +[[maybe_unused]] static void check_cusparse_status(cusparseStatus_t status) { if (status != CUSPARSE_STATUS_SUCCESS) { throw std::runtime_error("CUSPARSE error: " + std::string(cusparseGetErrorString(status))); diff --git a/cpp/src/mip_heuristics/root_heuristics.hpp b/cpp/src/mip_heuristics/root_heuristics.hpp index b9645579b5..6aa9dd60c2 100644 --- a/cpp/src/mip_heuristics/root_heuristics.hpp +++ b/cpp/src/mip_heuristics/root_heuristics.hpp @@ -58,13 +58,13 @@ struct cut_pass_heuristics_t { halt_ = true; if (submip_worker_) { - diving_worker_t* worker = submip_worker_.get(); + [[maybe_unused]] diving_worker_t* worker = submip_worker_.get(); #pragma omp taskwait depend(in : *worker) submip_worker_.reset(); } for (auto& worker : diving_workers_) { - diving_worker_t* w = worker.get(); + [[maybe_unused]] diving_worker_t* w = worker.get(); #pragma omp taskwait depend(in : *w) worker.reset(); } @@ -107,7 +107,7 @@ struct cut_pass_heuristics_t { } diving_worker_t* create_diving_worker( - i_t cut_pass, + [[maybe_unused]] i_t cut_pass, const simplex::lp_problem_t& lp, const simplex::simplex_solver_settings_t& settings, const mip_node_t& root_node, diff --git a/cpp/src/mip_heuristics/structural/early_structural.cu b/cpp/src/mip_heuristics/structural/early_structural.cu index 0f64e49eff..d537b59c86 100644 --- a/cpp/src/mip_heuristics/structural/early_structural.cu +++ b/cpp/src/mip_heuristics/structural/early_structural.cu @@ -89,7 +89,7 @@ void early_structural_t::start() task_launched_ = true; // OpenMP depend clauses require a variable or array element. - auto* task_token = &preemption_flag_; + [[maybe_unused]] auto* task_token = &preemption_flag_; CUOPT_LOG_DEBUG("Launching early structural task for %s", active_->name()); #pragma omp task priority(CUOPT_DEFAULT_TASK_PRIORITY) depend(out : *task_token) this->run(); @@ -100,7 +100,7 @@ void early_structural_t::stop() { if (!task_launched_) { return; } - auto* task_token = &preemption_flag_; + [[maybe_unused]] auto* task_token = &preemption_flag_; preemption_flag_.store(true); #pragma omp taskwait depend(in : *task_token) task_launched_ = false; diff --git a/cpp/src/pdlp/cpu_optimization_problem.cpp b/cpp/src/pdlp/cpu_optimization_problem.cpp index 98f82a6faf..b6d9d467b4 100644 --- a/cpp/src/pdlp/cpu_optimization_problem.cpp +++ b/cpp/src/pdlp/cpu_optimization_problem.cpp @@ -737,7 +737,7 @@ void cpu_optimization_problem_t::write_to_mps(const std::string& mps_f static_cast(Q_indices_.size()), Q_offsets_.data(), static_cast(Q_offsets_.size()), - false); + is_symmetrized); } if (!quadratic_constraints_.empty()) { diff --git a/cpp/src/pdlp/distributed_pdlp/distributed_algorithms.cu b/cpp/src/pdlp/distributed_pdlp/distributed_algorithms.cu index ba141b413f..51d9f8db84 100644 --- a/cpp/src/pdlp/distributed_pdlp/distributed_algorithms.cu +++ b/cpp/src/pdlp/distributed_pdlp/distributed_algorithms.cu @@ -164,8 +164,7 @@ void multi_gpu_engine_t::distributed_pock_chambolle_scaling(f_t alpha, // Mirrors single GPU scaling template void multi_gpu_engine_t::distributed_scaling(pdlp_hyper_params_t const& hyper_params, - i_t n_global_vars, - bool inside_mip) + i_t n_global_vars) { raft::common::nvtx::range scope("distributed_scaling"); @@ -413,8 +412,8 @@ void multi_gpu_engine_t::distributed_compute_initial_primal_weight( template void multi_gpu_engine_t::distributed_bound_objective_rescaling(F_TYPE); \ template void multi_gpu_engine_t::distributed_ruiz_inf_scaling(int, int); \ template void multi_gpu_engine_t::distributed_pock_chambolle_scaling(F_TYPE, int); \ - template void multi_gpu_engine_t::distributed_scaling( \ - pdlp_hyper_params_t const&, int, bool); \ + template void multi_gpu_engine_t::distributed_scaling(pdlp_hyper_params_t const&, \ + int); \ template F_TYPE multi_gpu_engine_t::distributed_max_singular_value_squared( \ int, int, F_TYPE); \ template void multi_gpu_engine_t::distributed_compute_initial_step_size( \ diff --git a/cpp/src/pdlp/distributed_pdlp/distributed_utils.cu b/cpp/src/pdlp/distributed_pdlp/distributed_utils.cu index 62461553a0..28d9baf186 100644 --- a/cpp/src/pdlp/distributed_pdlp/distributed_utils.cu +++ b/cpp/src/pdlp/distributed_pdlp/distributed_utils.cu @@ -23,8 +23,7 @@ std::vector> create_rank_data_from_parts( const std::vector& A_t_values, i_t nb_parts, i_t nb_cstr, - i_t nb_vars, - i_t nnz) + i_t nb_vars) { std::vector> rank_data(nb_parts, rank_data_t(nb_parts)); cuopt_expects(static_cast(parts.size()) == nb_cstr + nb_vars, @@ -257,7 +256,6 @@ template std::vector> create_rank_data_from_parts& A_t_values, int nb_parts, int nb_cstr, - int nb_vars, - int nnz); + int nb_vars); } // namespace cuopt::mathematical_optimization::pdlp diff --git a/cpp/src/pdlp/distributed_pdlp/distributed_utils.hpp b/cpp/src/pdlp/distributed_pdlp/distributed_utils.hpp index a96a5178f9..7a0bdd1a46 100644 --- a/cpp/src/pdlp/distributed_pdlp/distributed_utils.hpp +++ b/cpp/src/pdlp/distributed_pdlp/distributed_utils.hpp @@ -23,7 +23,6 @@ std::vector> create_rank_data_from_parts( const std::vector& A_t_values, i_t nb_parts, i_t nb_cstr, - i_t nb_vars, - i_t nnz); + i_t nb_vars); } // namespace cuopt::mathematical_optimization::pdlp diff --git a/cpp/src/pdlp/distributed_pdlp/multi_gpu_engine.hpp b/cpp/src/pdlp/distributed_pdlp/multi_gpu_engine.hpp index da22ee556e..569d1381fb 100644 --- a/cpp/src/pdlp/distributed_pdlp/multi_gpu_engine.hpp +++ b/cpp/src/pdlp/distributed_pdlp/multi_gpu_engine.hpp @@ -481,9 +481,7 @@ struct multi_gpu_engine_t { // - Pock-Chambolle scaling -> same // - per-shard apply_cummulative_scaling_to_problem() // - global bound/objective rescaling via distributed_bound_objective_rescaling - void distributed_scaling(pdlp_hyper_params_t const& hyper_params, - i_t n_global_vars, - bool inside_mip); + void distributed_scaling(pdlp_hyper_params_t const& hyper_params, i_t n_global_vars); // Distributed sigma_max(A)^2 via power iteration (used to seed the initial // step size). Returns the square of the largest singular value of the scaled diff --git a/cpp/src/pdlp/optimization_problem.cu b/cpp/src/pdlp/optimization_problem.cu index 98efded26e..43cab04c29 100644 --- a/cpp/src/pdlp/optimization_problem.cu +++ b/cpp/src/pdlp/optimization_problem.cu @@ -191,7 +191,7 @@ void optimization_problem_t::set_quadratic_objective_matrix( i_t size_indices, const i_t* Q_offsets, i_t size_offsets, - bool validate_positive_semi_definite) + [[maybe_unused]] bool validate_positive_semi_definite) { cuopt_expects(Q_values != nullptr, error_type_t::ValidationError, "Q_values cannot be null"); cuopt_expects( diff --git a/cpp/src/pdlp/pdlp.cu b/cpp/src/pdlp/pdlp.cu index 9f3365d59c..625e977f2a 100644 --- a/cpp/src/pdlp/pdlp.cu +++ b/cpp/src/pdlp/pdlp.cu @@ -523,8 +523,7 @@ pdlp_solver_t::pdlp_solver_t( h_A_t_values, settings.num_gpus, n_cstr, - n_vars, - nnz); + n_vars); // ----- 5. Per-shard settings ----- pdlp_solver_settings_t sub_pdlp_settings = settings; @@ -3264,7 +3263,7 @@ void pdlp_solver_t::scale_problem() // Scale problem then free scratch buffers raft::common::nvtx::range fun_scope("pdlp_solver_t::scale_problem"); if (is_distributed_master()) { - multi_gpu_engine->distributed_scaling(settings_.hyper_params, primal_size_h_, inside_mip_); + multi_gpu_engine->distributed_scaling(settings_.hyper_params, primal_size_h_); // Free per-shard scratch: no further scaling passes happen after this point. multi_gpu_engine->for_each_shard([](auto& shard) { diff --git a/cpp/src/pdlp/restart_strategy/pdlp_restart_strategy.cu b/cpp/src/pdlp/restart_strategy/pdlp_restart_strategy.cu index dc58066fc5..5278d13983 100644 --- a/cpp/src/pdlp/restart_strategy/pdlp_restart_strategy.cu +++ b/cpp/src/pdlp/restart_strategy/pdlp_restart_strategy.cu @@ -886,7 +886,7 @@ void pdlp_restart_strategy_t::cupdlpx_restart( rmm::device_uvector& primal_step_size, rmm::device_uvector& dual_step_size, rmm::device_uvector& best_primal_weight, - const std::vector& should_restart) + [[maybe_unused]] const std::vector& should_restart) { raft::common::nvtx::range fun_scope("cupdlpx_restart"); diff --git a/cpp/src/pdlp/solve.cu b/cpp/src/pdlp/solve.cu index 38202c6b51..171f73d9d3 100644 --- a/cpp/src/pdlp/solve.cu +++ b/cpp/src/pdlp/solve.cu @@ -859,15 +859,13 @@ optimization_problem_solution_t run_pdlp(mip::problem_t& pro "Single-precision PDLP is not supported in batch mode."); auto start_solver = std::chrono::high_resolution_clock::now(); - timer_t timer_pdlp(timer.remaining_time()); - auto sol = run_pdlp_solver(problem, settings, timer, is_batch_mode); + auto sol = run_pdlp_solver(problem, settings, timer, is_batch_mode); // Negate dual variables and reduced costs for maximization problems if (problem.maximize) { adjust_dual_solution_and_reduced_cost( sol.get_dual_solution(), sol.get_reduced_cost(), problem.handle_ptr->get_stream()); problem.handle_ptr->sync_stream(); } - auto pdlp_solve_time = timer_pdlp.elapsed_time(); sol.set_solve_time(timer.elapsed_time()); CUOPT_LOG_CONDITIONAL_INFO(!settings.inside_mip, "PDLP finished"); if (sol.get_termination_status() != pdlp_termination_status_t::ConcurrentLimit) { @@ -1285,8 +1283,8 @@ static size_t max_memory_batch_size(const optimization_problem_t& prob { size_t st_free_mem, st_total_mem; RAFT_CUDA_TRY(cudaMemGetInfo(&st_free_mem, &st_total_mem)); - const double free_mem = static_cast(st_free_mem); - const double total_mem = static_cast(st_total_mem); + const double free_mem = static_cast(st_free_mem); + [[maybe_unused]] const double total_mem = static_cast(st_total_mem); while (memory_max_batch_size > 0) { const double mem_est = batch_pdlp_memory_estimator(problem, @@ -1353,8 +1351,8 @@ static optimization_problem_solution_t run_batch_pdlp_splitting( collect_solutions); size_t st_free_mem, st_total_mem; RAFT_CUDA_TRY(cudaMemGetInfo(&st_free_mem, &st_total_mem)); - const double free_mem = static_cast(st_free_mem); - const double total_mem = static_cast(st_total_mem); + const double free_mem = static_cast(st_free_mem); + [[maybe_unused]] const double total_mem = static_cast(st_total_mem); #ifdef BATCH_VERBOSE_MODE std::cout << "Memory estimate: " << memory_estimate << std::endl; @@ -1571,8 +1569,6 @@ optimization_problem_solution_t run_concurrent( bool is_batch_mode) { CUOPT_LOG_CONDITIONAL_INFO(!settings.inside_mip, "Running concurrent (showing only PDLP log)\n"); - timer_t timer_concurrent(timer.remaining_time()); - // Copy the settings so that we can set the concurrent halt pointer pdlp_solver_settings_t settings_pdlp(settings); @@ -1717,7 +1713,8 @@ optimization_problem_solution_t run_concurrent( dispatch_concurrent_solvers(); } else { // Stand-alone LP: stand up a local team sized for 1 dispatcher + 1 per spawned task. - const int num_workers = 1 + (settings.inside_mip ? 0 : 1) + (enable_barrier ? 1 : 0); + [[maybe_unused]] const int num_workers = + 1 + (settings.inside_mip ? 0 : 1) + (enable_barrier ? 1 : 0); #pragma omp parallel num_threads(num_workers) default(shared) { #pragma omp single diff --git a/cpp/src/pdlp/utilities/cython_solve.cu b/cpp/src/pdlp/utilities/cython_solve.cu index 739297fe94..b44c56516c 100644 --- a/cpp/src/pdlp/utilities/cython_solve.cu +++ b/cpp/src/pdlp/utilities/cython_solve.cu @@ -292,8 +292,10 @@ static int compute_max_thread( } std::pair>, double> solve_batch_remote( - std::vector*> data_models, - cuopt::mathematical_optimization::solver_settings_t* solver_settings) + [[maybe_unused]] std::vector< + cuopt::mathematical_optimization::io::data_model_view_t*> data_models, + [[maybe_unused]] cuopt::mathematical_optimization::solver_settings_t* + solver_settings) { cuopt_expects( false, @@ -325,7 +327,7 @@ std::pair>, double> call_batch_solve( auto start_solver = std::chrono::high_resolution_clock::now(); // Limit parallelism as too much stream overlap gets too slow - const int max_thread = compute_max_thread(data_models); + [[maybe_unused]] const int max_thread = compute_max_thread(data_models); if (solver_settings->get_parameter(CUOPT_METHOD) == CUOPT_METHOD_CONCURRENT) { CUOPT_LOG_INFO("Concurrent mode not supported for batch solve. Using PDLP instead. "); diff --git a/cpp/src/routing/crossovers/ox_recombiner.cuh b/cpp/src/routing/crossovers/ox_recombiner.cuh index 7da8ba5f58..c5a570aefc 100644 --- a/cpp/src/routing/crossovers/ox_recombiner.cuh +++ b/cpp/src/routing/crossovers/ox_recombiner.cuh @@ -349,8 +349,7 @@ struct OX { std::vector>> tmp_routes; std::unordered_set routes_to_remove; std::unordered_set vehicle_ids_to_remove; - const auto& dimensions_info = A.problem->dimensions_info; - int i = routes_number; + int i = routes_number; if (optimal_routes_search) { i = optimal_routes_number; } int end_index = offspring.size() - 1; [[maybe_unused]] double cost_n, cost_p, total_delta = 0.; @@ -420,9 +419,6 @@ struct OX { A.remove_routes(std::vector(routes_to_remove.begin(), routes_to_remove.end())); std::vector> tmp_node_info; - auto vehicle_ids_to_remove_vec = - std::vector(vehicle_ids_to_remove.begin(), vehicle_ids_to_remove.end()); - for (auto const& [bucket, tmp_route] : tmp_routes) { for (auto const& node : tmp_route) { tmp_node_info.push_back(A.problem->get_node_info_of_node(node)); @@ -645,7 +641,6 @@ struct OX { d_path_cost.resize((problem_size + 1) * row_size, A.sol.sol_handle->get_stream()); d_predecessor.resize((problem_size + 1) * row_size, A.sol.sol_handle->get_stream()); d_predecessor_vehicle.resize((problem_size + 1) * row_size, A.sol.sol_handle->get_stream()); - auto max_val = std::numeric_limits::max(); async_fill(d_path_cost, std::numeric_limits::max(), A.sol.sol_handle->get_stream()); async_fill(d_predecessor, -1, A.sol.sol_handle->get_stream()); async_fill(d_predecessor_vehicle, -1, A.sol.sol_handle->get_stream()); @@ -658,8 +653,6 @@ struct OX { constexpr auto const TPB = 128; auto min_cost_of_last_column = std::numeric_limits::max(); auto cost_of_last_column = std::numeric_limits::max(); - const auto& dimensions_info = A.problem->dimensions_info; - cuopt::device_copy( d_vehicle_availability, vehicle_availability, A.sol.sol_handle->get_stream()); diff --git a/cpp/src/routing/crossovers/srex_recombiner.hpp b/cpp/src/routing/crossovers/srex_recombiner.hpp index ffdc09130d..58e88f8927 100644 --- a/cpp/src/routing/crossovers/srex_recombiner.hpp +++ b/cpp/src/routing/crossovers/srex_recombiner.hpp @@ -1,6 +1,6 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ @@ -68,7 +68,6 @@ struct srex { ret = (s.from_a.size() > s.from_b.size()) ? false : true; auto& guiding = (ret == false) ? a : b; - auto& other = (ret == true) ? a : b; auto& guiding_ids = (ret == false) ? s.from_a : s.from_b; auto& other_ids = (ret == true) ? s.from_a : s.from_b; diff --git a/cpp/src/routing/diversity/diverse_solver.hpp b/cpp/src/routing/diversity/diverse_solver.hpp index 67bf300084..d519a4a21b 100644 --- a/cpp/src/routing/diversity/diverse_solver.hpp +++ b/cpp/src/routing/diversity/diverse_solver.hpp @@ -1025,9 +1025,8 @@ struct solve { bool improved = true; while (improved) { - int k = max_iterations_without_improvement; - improved = false; - double quality_before = p.best_quality(); + int k = max_iterations_without_improvement; + improved = false; while (k-- > 0) { fflush(f.file_ptr); if (improvement_timer.check_time_limit()) return; @@ -1126,8 +1125,6 @@ struct solve { } std::uniform_int_distribution dist(0, recombine_options.size() - 1); - const auto& dimensions_info = a.problem->dimensions_info; - // Pick a random element from set auto recombiner_it = std::begin(recombine_options); std::advance(recombiner_it, dist(rng)); @@ -1231,9 +1228,6 @@ struct solve { benchmark_print("Empty file!\n"); throw std::invalid_argument("Empty file!"); } - std::string s; - std::stringstream ss(lines[0]); - std::vector>>> inst_data; std::set added_node_ids; // Note that the BKS search is currently supported only for homogenous case, @@ -1306,7 +1300,7 @@ struct solve { try { solution sol = load_solution(entry.path(), routes_number); solutions.emplace_back(std::move(sol)); - } catch (const std::invalid_argument& e) { + } catch (const std::invalid_argument&) { printf("skipping file\n"); continue; } @@ -1320,7 +1314,7 @@ struct solve { try { solution sol = load_solution(entry.path(), routes_number); solutions.emplace_back(std::move(sol)); - } catch (const std::invalid_argument& e) { + } catch (const std::invalid_argument&) { printf("error loading BKS file\n"); continue; } diff --git a/cpp/src/routing/ges/execute_insertion.cuh b/cpp/src/routing/ges/execute_insertion.cuh index fbeec209c8..fe5421c502 100644 --- a/cpp/src/routing/ges/execute_insertion.cuh +++ b/cpp/src/routing/ges/execute_insertion.cuh @@ -1,6 +1,6 @@ /* clang-format off */ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* clang-format on */ @@ -35,7 +35,6 @@ DI void execute_insert(typename solution_t::view_t& view, request_id_t const& request_location, const request_info_t* request_id) { - const auto& dimensions_info = view.problem.dimensions_info; cuopt_assert(__popc(__activemask() == 1), "execute_insert should be called by a single thread"); auto request_node = view.get_request(request_id); diff --git a/cpp/src/routing/ges/squeeze.cuh b/cpp/src/routing/ges/squeeze.cuh index 64fc8ea264..38540f8ad4 100644 --- a/cpp/src/routing/ges/squeeze.cuh +++ b/cpp/src/routing/ges/squeeze.cuh @@ -28,10 +28,9 @@ __device__ void find_squeeze_pos(typename solution_t::view_t& { __shared__ double reduction_buf[2 * raft::WarpSize]; __shared__ i_t reduction_idx; - const auto& dimensions_info = solution.problem.dimensions_info; - auto request_node = solution.get_request(request); - auto gl_route = solution.routes[route_id]; - auto sh_route = route_t::view_t::create_shared_route( + auto request_node = solution.get_request(request); + auto gl_route = solution.routes[route_id]; + auto sh_route = route_t::view_t::create_shared_route( shmem, gl_route, gl_route.get_num_nodes()); __syncthreads(); sh_route.copy_from(gl_route); diff --git a/cpp/src/routing/local_search/compute_insertions.cu b/cpp/src/routing/local_search/compute_insertions.cu index 87ed71fde1..7ddad980f5 100644 --- a/cpp/src/routing/local_search/compute_insertions.cu +++ b/cpp/src/routing/local_search/compute_insertions.cu @@ -385,8 +385,6 @@ __device__ i_t find_request_insertion(typename solution_t::vi auto other_route_id = solution.route_node_map.get_route_id(node_id); cuopt_assert(other_route_id >= 0 || insert_unserviced, "Other route id cannot be -1, it must have been filtered!"); - const auto& dimensions_info = solution.problem.dimensions_info; - auto request_node = other_route_id >= 0 ? solution.routes[other_route_id].get_request_node(solution.route_node_map, request_id) diff --git a/cpp/src/routing/local_search/fill_gpu_graph.cu b/cpp/src/routing/local_search/fill_gpu_graph.cu index 036b84fcfa..c4a79c2e80 100644 --- a/cpp/src/routing/local_search/fill_gpu_graph.cu +++ b/cpp/src/routing/local_search/fill_gpu_graph.cu @@ -84,14 +84,11 @@ __global__ void fill_graph_kernel(typename solution_t::view_t template __global__ void fill_intra_candidates(typename solution_t::view_t solution, typename move_candidates_t::view_t move_candidates, - int64_t seed) + [[maybe_unused]] int64_t seed) { __shared__ double shmem[raft::WarpSize * 2]; __shared__ i_t reduction_idx; - i_t route_id = blockIdx.x; - raft::random::PCGenerator thread_rng(seed + (threadIdx.x + blockIdx.x * blockDim.x), - uint64_t(route_id * (threadIdx.x + blockIdx.x * blockDim.x)), - 0); + i_t route_id = blockIdx.x; double thread_best_cost = std::numeric_limits::max(); i_t thread_best_node_id = -1; i_t counter = 1; diff --git a/cpp/src/routing/local_search/local_search.cu b/cpp/src/routing/local_search/local_search.cu index 08f72970b7..0585e91f0b 100644 --- a/cpp/src/routing/local_search/local_search.cu +++ b/cpp/src/routing/local_search/local_search.cu @@ -138,7 +138,7 @@ bool local_search_t::run_cross_search(solution_t template > bool local_search_t::run_fast_search(solution_t& sol, - bool full_set) + [[maybe_unused]] bool full_set) { raft::common::nvtx::range fun_scope("run_fast_search"); diff --git a/cpp/src/routing/local_search/move_candidates/move_candidates.cuh b/cpp/src/routing/local_search/move_candidates/move_candidates.cuh index d009209226..913f07de62 100644 --- a/cpp/src/routing/local_search/move_candidates/move_candidates.cuh +++ b/cpp/src/routing/local_search/move_candidates/move_candidates.cuh @@ -201,7 +201,6 @@ class cand_matrix_t { { cuopt_assert(sink < matrix_width, "Sink should be smaller than matrix_width!"); cuopt_assert(source < matrix_height, "Source should be smaller than matrix_height!"); - cand_t cand; i_t idx = source * matrix_width + sink; return get_candidate(idx); } diff --git a/cpp/src/routing/local_search/prize_collection.cu b/cpp/src/routing/local_search/prize_collection.cu index a47a28b5a1..ce99ec14bd 100644 --- a/cpp/src/routing/local_search/prize_collection.cu +++ b/cpp/src/routing/local_search/prize_collection.cu @@ -145,7 +145,6 @@ __global__ void execute_moves(typename solution_t::view_t sol insertion_locations.id() = curr_route_cand.pickup_insertion; ejected_request.id() = curr_route_cand.ejected_node_id; insertion_request.id() = curr_route_cand.inserted_node_id; - double cost = curr_route_cand.cost; if constexpr (REQUEST == request_t::PDP) { if (ejected_request.pickup < solution.get_num_orders()) { ejected_request.delivery = solution.problem.order_info.pair_indices[ejected_request.pickup]; diff --git a/cpp/src/routing/local_search/sliding_tsp.cu b/cpp/src/routing/local_search/sliding_tsp.cu index 90f42a1303..fe2105c194 100644 --- a/cpp/src/routing/local_search/sliding_tsp.cu +++ b/cpp/src/routing/local_search/sliding_tsp.cu @@ -140,9 +140,6 @@ __global__ void find_sliding_moves_tsp( } __syncthreads(); - const double excess_limit = - s_route.get_weighted_excess(move_candidates.weights) * ls_excess_multiplier_route; - sliding_tsp_cand_t sliding_tsp_cand = is_sliding_tsp_uinitialized_t::init_data(); double cost_delta, selection_delta; diff --git a/cpp/src/routing/local_search/sliding_window.cu b/cpp/src/routing/local_search/sliding_window.cu index 7b545a0021..fd37c9b177 100644 --- a/cpp/src/routing/local_search/sliding_window.cu +++ b/cpp/src/routing/local_search/sliding_window.cu @@ -694,9 +694,8 @@ __global__ void kernel_perform_sliding_window( extern __shared__ i_t shmem[]; // Each block handles a different starting point for the window // +1 to skip depot - const bool depot_included = solution.problem.order_info.depot_included; - const i_t node_idx = blockIdx.x / blocks_per_node; - const auto node_info = move_candidates.nodes_to_search.sampled_nodes_to_search[node_idx]; + const i_t node_idx = blockIdx.x / blocks_per_node; + const auto node_info = move_candidates.nodes_to_search.sampled_nodes_to_search[node_idx]; cuopt_assert(node_info.node() < solution.get_num_orders() + solution.n_routes * after_depot_insertion_multiplier, diff --git a/cpp/src/routing/route/pdp_route.cuh b/cpp/src/routing/route/pdp_route.cuh index 449a2e182f..f56a87ef38 100644 --- a/cpp/src/routing/route/pdp_route.cuh +++ b/cpp/src/routing/route/pdp_route.cuh @@ -61,7 +61,7 @@ class request_route_t::size() * route_size * sizeof(NodeInfo); diff --git a/cpp/src/routing/util_kernels/set_nodes_data.cuh b/cpp/src/routing/util_kernels/set_nodes_data.cuh index a871bb4652..dc9955639e 100644 --- a/cpp/src/routing/util_kernels/set_nodes_data.cuh +++ b/cpp/src/routing/util_kernels/set_nodes_data.cuh @@ -86,7 +86,6 @@ __device__ void set_nodes_data_of_single_route( typename route_t::view_t& route) { const auto& order_info = problem.order_info; - const auto& fleet_info = problem.fleet_info; i_t n_nodes_route = route.get_num_nodes(); const i_t vehicle_id = route.get_vehicle_id(); const i_t route_id = route.get_id(); @@ -129,7 +128,6 @@ __device__ void set_nodes_data_of_single_route( typename route_t::view_t& route) { const auto& order_info = problem.order_info; - const auto& fleet_info = problem.fleet_info; i_t n_nodes_route = route.get_num_nodes(); const i_t vehicle_id = route.get_vehicle_id(); const i_t route_id = route.get_id(); diff --git a/cpp/src/routing/utilities/cython.cu b/cpp/src/routing/utilities/cython.cu index 7c1e0170e3..57c6284866 100644 --- a/cpp/src/routing/utilities/cython.cu +++ b/cpp/src/routing/utilities/cython.cu @@ -106,7 +106,7 @@ std::vector> call_batch_solve( std::vector> list(size); // Use OpenMP for parallel execution - const int max_thread = std::min(static_cast(size), omp_get_max_threads()); + [[maybe_unused]] const int max_thread = std::min(static_cast(size), omp_get_max_threads()); rmm::cuda_stream_pool stream_pool(size, rmm::cuda_stream::flags::non_blocking); int device_id = raft::resource::get_device_id(*(data_models[0]->get_handle_ptr())); diff --git a/cpp/src/utilities/logger.hpp b/cpp/src/utilities/logger.hpp index 7c9f952d48..cd84c46ada 100644 --- a/cpp/src/utilities/logger.hpp +++ b/cpp/src/utilities/logger.hpp @@ -13,6 +13,8 @@ #include +#include + #include #include #include @@ -24,6 +26,44 @@ #include #include +// The generated logger macros discard arguments for compile-time-disabled levels. Keep those +// expressions in an unreachable branch so they are parsed and count as uses without being +// evaluated, matching the behavior of Abseil's compile-time-disabled logging. +#define CUOPT_LOG_DISABLED(...) \ + do { \ + if (false) { ::cuopt::detail::ignore_unused(__VA_ARGS__); } \ + } while (false) + +#if CUOPT_LOG_ACTIVE_LEVEL > RAPIDS_LOGGER_LOG_LEVEL_TRACE +#undef CUOPT_LOG_TRACE +#define CUOPT_LOG_TRACE(...) CUOPT_LOG_DISABLED(__VA_ARGS__) +#endif + +#if CUOPT_LOG_ACTIVE_LEVEL > RAPIDS_LOGGER_LOG_LEVEL_DEBUG +#undef CUOPT_LOG_DEBUG +#define CUOPT_LOG_DEBUG(...) CUOPT_LOG_DISABLED(__VA_ARGS__) +#endif + +#if CUOPT_LOG_ACTIVE_LEVEL > RAPIDS_LOGGER_LOG_LEVEL_INFO +#undef CUOPT_LOG_INFO +#define CUOPT_LOG_INFO(...) CUOPT_LOG_DISABLED(__VA_ARGS__) +#endif + +#if CUOPT_LOG_ACTIVE_LEVEL > RAPIDS_LOGGER_LOG_LEVEL_WARN +#undef CUOPT_LOG_WARN +#define CUOPT_LOG_WARN(...) CUOPT_LOG_DISABLED(__VA_ARGS__) +#endif + +#if CUOPT_LOG_ACTIVE_LEVEL > RAPIDS_LOGGER_LOG_LEVEL_ERROR +#undef CUOPT_LOG_ERROR +#define CUOPT_LOG_ERROR(...) CUOPT_LOG_DISABLED(__VA_ARGS__) +#endif + +#if CUOPT_LOG_ACTIVE_LEVEL > RAPIDS_LOGGER_LOG_LEVEL_CRITICAL +#undef CUOPT_LOG_CRITICAL +#define CUOPT_LOG_CRITICAL(...) CUOPT_LOG_DISABLED(__VA_ARGS__) +#endif + /* * Defined inline with hidden visibility so each library that links this header owns its own * logger instance. This is not optional: an inline function's static local is emitted as an diff --git a/cpp/src/utilities/macros.cuh b/cpp/src/utilities/macros.cuh index 53eb98ae55..d26a9824cb 100644 --- a/cpp/src/utilities/macros.cuh +++ b/cpp/src/utilities/macros.cuh @@ -12,11 +12,17 @@ // 1) light // 2) medium // 3) heavy -#ifdef ASSERT_MODE -#include #include namespace cuopt::detail { +// Keep expressions in disabled diagnostics visible to the compiler without evaluating them. +// constexpr functions are callable from CUDA device code with --expt-relaxed-constexpr, which is +// enabled for cuOpt builds. +template +constexpr void ignore_unused(Ts&&...) +{ +} + // handle the argument processing through the C++ parser instead of the preprocessor // since it chokes on colons in template arguments. // (e.g. cuopt_assert(std::is_same_v, "message")). @@ -28,10 +34,16 @@ constexpr bool assert_msg(T&& cond, const char (&)[N]) } } // namespace cuopt::detail +#ifdef ASSERT_MODE +#include + #define cuopt_assert(...) assert(::cuopt::detail::assert_msg(__VA_ARGS__)) #define cuopt_func_call(...) __VA_ARGS__; #else -#define cuopt_assert(...) +#define cuopt_assert(...) \ + do { \ + if (false) { ::cuopt::detail::ignore_unused(__VA_ARGS__); } \ + } while (false) #define cuopt_func_call(...) ; #endif diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 41031de5c3..26286c77af 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -95,8 +95,19 @@ function(ConfigureTest CMAKE_TEST_NAME) "${CUOPT_TEST_DIR}/../src" "${CUOPT_TEST_DIR}/../src/io" "${CUOPT_TEST_DIR}" - "${papilo_SOURCE_DIR}/src" - "${papilo_BINARY_DIR}" + ) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_include_directories(${CMAKE_TEST_NAME} PRIVATE + "${papilo_SOURCE_DIR}/src" + "${papilo_BINARY_DIR}" + ) + else() + target_include_directories(${CMAKE_TEST_NAME} SYSTEM PRIVATE + "${papilo_SOURCE_DIR}/src" + "${papilo_BINARY_DIR}" + ) + endif() + target_include_directories(${CMAKE_TEST_NAME} SYSTEM PRIVATE "${pslp_SOURCE_DIR}/include" ) target_include_directories(${CMAKE_TEST_NAME} SYSTEM PRIVATE "${dejavu_SOURCE_DIR}") diff --git a/cpp/tests/linear_programming/pdlp_test.cu b/cpp/tests/linear_programming/pdlp_test.cu index f85e3690c9..cd1d57a50a 100644 --- a/cpp/tests/linear_programming/pdlp_test.cu +++ b/cpp/tests/linear_programming/pdlp_test.cu @@ -2510,7 +2510,6 @@ TEST(pdlp_class, simple_batch_different_objectives_and_offsets) solver_settings.method = cuopt::mathematical_optimization::method_t::PDLP; solver_settings.presolver = presolver_t::None; - const int n_vars = op_problem.get_n_variables(); const auto& original_obj = op_problem.get_objective_coefficients(); // Two climbers: (original_obj, offset=3.5) and (2x objective, offset=-7.0) @@ -2568,7 +2567,6 @@ TEST(pdlp_class, simple_batch_different_constraint_bounds) solver_settings.method = cuopt::mathematical_optimization::method_t::PDLP; solver_settings.presolver = presolver_t::None; - const int n_constrs = op_problem.get_n_constraints(); const auto& original_lower_bounds = op_problem.get_constraint_lower_bounds(); const auto& original_upper_bounds = op_problem.get_constraint_upper_bounds(); @@ -2636,8 +2634,7 @@ TEST(pdlp_class, simple_batch_everything_different) solver_settings.method = cuopt::mathematical_optimization::method_t::PDLP; solver_settings.presolver = presolver_t::None; - const int n_vars = op_problem.get_n_variables(); - const int n_constrs = op_problem.get_n_constraints(); + const int n_vars = op_problem.get_n_variables(); const auto& original_obj = op_problem.get_objective_coefficients(); const auto& original_lower_bounds = op_problem.get_constraint_lower_bounds(); @@ -3089,9 +3086,6 @@ TEST(pdlp_class, DISABLED_cupdlpx_infeasible_detection_batch_afiro_new_bounds) constexpr int batch_size = 5; - const std::vector& variable_lower_bounds = op_problem.get_variable_lower_bounds(); - const std::vector& variable_upper_bounds = op_problem.get_variable_upper_bounds(); - for (size_t i = 0; i < batch_size; i++) { solver_settings.new_bounds.push_back({static_cast(i), 1, 7.0, 8.0}); } @@ -4377,10 +4371,9 @@ TEST(pdlp_class, shared_sb_view_all_infeasible) cuopt::mathematical_optimization::io::mps_data_model_t op_problem = cuopt::mathematical_optimization::io::read_mps(path, true); - const std::vector fractional = {1, 2, 4}; - const std::vector root_soln_x = {0.891, 0.109, 0.636429}; - const int n_fractional = fractional.size(); - const int batch_size = n_fractional; + const std::vector fractional = {1, 2, 4}; + const int n_fractional = fractional.size(); + const int batch_size = n_fractional; auto solver_settings = pdlp_solver_settings_t{}; solver_settings.method = cuopt::mathematical_optimization::method_t::PDLP; @@ -4712,8 +4705,7 @@ TEST(pdlp_class, batch_with_optimal_size_query) solver_settings.method = cuopt::mathematical_optimization::method_t::PDLP; solver_settings.presolver = presolver_t::None; - const int n_vars = op_problem.get_n_variables(); - const int n_constrs = op_problem.get_n_constraints(); + const int n_vars = op_problem.get_n_variables(); const auto& original_obj = op_problem.get_objective_coefficients(); const auto& original_lb = op_problem.get_constraint_lower_bounds(); diff --git a/cpp/tests/linear_programming/unit_tests/presolve_test.cu b/cpp/tests/linear_programming/unit_tests/presolve_test.cu index f8ba6432fe..92cb27a42a 100644 --- a/cpp/tests/linear_programming/unit_tests/presolve_test.cu +++ b/cpp/tests/linear_programming/unit_tests/presolve_test.cu @@ -325,7 +325,6 @@ TEST(pslp_presolve, postsolve_accuracy_larger_problem) const auto& orig_constr_lb = mps_data_model.get_constraint_lower_bounds(); const auto& orig_constr_ub = mps_data_model.get_constraint_upper_bounds(); const int orig_n_vars = mps_data_model.get_n_variables(); - const int orig_n_constraints = mps_data_model.get_n_constraints(); // Solve with PSLP presolve auto solver_settings = pdlp_solver_settings_t{}; @@ -471,8 +470,7 @@ TEST(pslp_presolve, postsolve_multiple_problems) auto mps_data_model = cuopt::mathematical_optimization::io::read_mps(path, name == "afiro_original"); - const int orig_n_vars = mps_data_model.get_n_variables(); - const int orig_n_constraints = mps_data_model.get_n_constraints(); + const int orig_n_vars = mps_data_model.get_n_variables(); auto solver_settings = pdlp_solver_settings_t{}; solver_settings.method = cuopt::mathematical_optimization::method_t::PDLP; diff --git a/cpp/tests/linear_programming/utilities/pdlp_test_utilities.cuh b/cpp/tests/linear_programming/utilities/pdlp_test_utilities.cuh index cff05578fe..68c823b293 100644 --- a/cpp/tests/linear_programming/utilities/pdlp_test_utilities.cuh +++ b/cpp/tests/linear_programming/utilities/pdlp_test_utilities.cuh @@ -26,7 +26,7 @@ namespace cuopt::mathematical_optimization::test { constexpr double tolerance = 1e-6f; -static std::string make_path_absolute(const std::string& file) +[[maybe_unused]] static std::string make_path_absolute(const std::string& file) { std::string rel_file{}; // assume relative paths are relative to RAPIDS_DATASET_ROOT_DIR @@ -52,9 +52,9 @@ static cuopt::mathematical_optimization::optimization_problem_solution_t -static void assign_device_uvector_from_host(rmm::device_uvector& target, - const std::vector& src, - cuda::stream_ref stream) +[[maybe_unused]] static void assign_device_uvector_from_host(rmm::device_uvector& target, + const std::vector& src, + cuda::stream_ref stream) { target.resize(src.size(), stream); raft::copy(target.data(), src.data(), src.size(), stream); @@ -115,7 +115,7 @@ solve_lp_batch_fixed( } // Compute on the CPU x * c to check that the returned objective value is correct -static void test_objective_sanity( +[[maybe_unused]] static void test_objective_sanity( const cuopt::mathematical_optimization::io::mps_data_model_t& op_problem, const rmm::device_uvector& primal_solution, double objective_value, @@ -140,7 +140,7 @@ static void test_objective_sanity( } // Compute on the CPU x * c to check that the returned objective value is correct -static void test_objective_sanity( +[[maybe_unused]] static void test_objective_sanity( const cuopt::mathematical_optimization::io::mps_data_model_t& op_problem, const std::vector& primal_solution, double objective_value, @@ -167,7 +167,7 @@ static void test_objective_sanity( // Check that it corresponds to the bound resdiual // Check that it respect the absolute/relative tolerance // Check that the primal variables respected the variable bounds -static void test_constraint_sanity( +[[maybe_unused]] static void test_constraint_sanity( const cuopt::mathematical_optimization::io::mps_data_model_t& op_problem, const optimization_problem_solution_t::additional_termination_information_t& termination_information, diff --git a/cpp/tests/mip/block_bve_test.cu b/cpp/tests/mip/block_bve_test.cu index c1aca2f690..a8e3c1967c 100644 --- a/cpp/tests/mip/block_bve_test.cu +++ b/cpp/tests/mip/block_bve_test.cu @@ -178,8 +178,8 @@ End template static void with_mip_omp_team(F&& f) { - const int num_threads = std::max(2, omp_get_max_threads()); - const int saved_max_active_levels = omp_get_max_active_levels(); + [[maybe_unused]] const int num_threads = std::max(2, omp_get_max_threads()); + const int saved_max_active_levels = omp_get_max_active_levels(); if (saved_max_active_levels < 2) { omp_set_max_active_levels(2); } #pragma omp parallel num_threads(num_threads) { diff --git a/cpp/tests/mip/mip_utils.cuh b/cpp/tests/mip/mip_utils.cuh index 29d4732d42..78d8747805 100644 --- a/cpp/tests/mip/mip_utils.cuh +++ b/cpp/tests/mip/mip_utils.cuh @@ -14,7 +14,7 @@ namespace cuopt::mathematical_optimization::test { -static void test_variable_bounds( +[[maybe_unused]] static void test_variable_bounds( const cuopt::mathematical_optimization::io::mps_data_model_t& problem, const rmm::device_uvector& solution, const cuopt::mathematical_optimization::mip_solver_settings_t settings) @@ -42,7 +42,7 @@ static void test_variable_bounds( EXPECT_TRUE(result); } -static void test_variable_bounds( +[[maybe_unused]] static void test_variable_bounds( const cuopt::mathematical_optimization::io::mps_data_model_t& problem, const std::vector& solution, const cuopt::mathematical_optimization::mip_solver_settings_t settings) @@ -70,7 +70,7 @@ static void test_variable_bounds( } template -static double combine_finite_abs_bounds(f_t lower, f_t upper) +[[maybe_unused]] static double combine_finite_abs_bounds(f_t lower, f_t upper) { f_t val = f_t(0); if (isfinite(upper)) { val = raft::max(val, raft::abs(upper)); } @@ -93,7 +93,7 @@ struct violation { } }; -static void test_constraint_sanity_per_row( +[[maybe_unused]] static void test_constraint_sanity_per_row( const cuopt::mathematical_optimization::io::mps_data_model_t& op_problem, const rmm::device_uvector& solution, double abs_tolerance, @@ -104,8 +104,6 @@ static void test_constraint_sanity_per_row( const std::vector& offsets = op_problem.get_constraint_matrix_offsets(); const std::vector& constraint_lower_bounds = op_problem.get_constraint_lower_bounds(); const std::vector& constraint_upper_bounds = op_problem.get_constraint_upper_bounds(); - const std::vector& variable_lower_bounds = op_problem.get_variable_lower_bounds(); - const std::vector& variable_upper_bounds = op_problem.get_variable_upper_bounds(); std::vector residual(constraint_lower_bounds.size(), 0.0); auto h_solution = cuopt::host_copy(solution, solution.stream()); // CSR SpMV @@ -127,7 +125,7 @@ static void test_constraint_sanity_per_row( } } -static void test_constraint_sanity_per_row( +[[maybe_unused]] static void test_constraint_sanity_per_row( const cuopt::mathematical_optimization::io::mps_data_model_t& op_problem, const std::vector& solution, double abs_tolerance, @@ -158,7 +156,7 @@ static void test_constraint_sanity_per_row( } } -static std::tuple test_mps_file( +[[maybe_unused]] static std::tuple test_mps_file( std::string test_instance, double time_limit = 1, bool heuristics_only = true, diff --git a/cpp/tests/mip/multi_probe_test.cu b/cpp/tests/mip/multi_probe_test.cu index 61be30e15c..92058db4e8 100644 --- a/cpp/tests/mip/multi_probe_test.cu +++ b/cpp/tests/mip/multi_probe_test.cu @@ -33,7 +33,7 @@ namespace cuopt::mathematical_optimization::test { inline auto make_async() { return rmm::mr::cuda_async_memory_resource(); } -static void init_handler(const raft::handle_t* handle_ptr) +[[maybe_unused]] static void init_handler(const raft::handle_t* handle_ptr) { // Init cuBlas / cuSparse context here to avoid having it during solving time RAFT_CUBLAS_TRY(raft::linalg::detail::cublassetpointermode( diff --git a/cpp/tests/mip/unit_test.cu b/cpp/tests/mip/unit_test.cu index 20865b93ff..5a55da6e39 100644 --- a/cpp/tests/mip/unit_test.cu +++ b/cpp/tests/mip/unit_test.cu @@ -167,11 +167,9 @@ TEST_P(MILPTestParams, TestSampleMILP) TEST_P(MILPTestParams, TestSingleVarMILP) { - bool maximize = std::get<0>(GetParam()); - int scaling = std::get<1>(GetParam()); - bool heuristics_only = std::get<2>(GetParam()); - auto expected_termination_status = std::get<3>(GetParam()); - + bool maximize = std::get<0>(GetParam()); + int scaling = std::get<1>(GetParam()); + bool heuristics_only = std::get<2>(GetParam()); raft::handle_t handle; auto problem = create_single_var_milp_problem(maximize); diff --git a/cpp/tests/routing/utilities/test_utilities.hpp b/cpp/tests/routing/utilities/test_utilities.hpp index 1543f91426..18c6734f53 100644 --- a/cpp/tests/routing/utilities/test_utilities.hpp +++ b/cpp/tests/routing/utilities/test_utilities.hpp @@ -264,7 +264,6 @@ void load_pickup(const std::string& fileName, Route& route) std::ifstream infile(fileName.c_str()); cuopt_assert(infile.is_open(), "File cannot be opened."); - std::string str; long dump; infile >> route.n_vehicles; diff --git a/cpp/tests/utilities/base_fixture.hpp b/cpp/tests/utilities/base_fixture.hpp index 31d7923dfa..7fdb675e2f 100644 --- a/cpp/tests/utilities/base_fixture.hpp +++ b/cpp/tests/utilities/base_fixture.hpp @@ -93,7 +93,7 @@ inline auto parse_test_options(int argc, char** argv) "rmm_mode", "RMM allocation mode", cxxopts::value()->default_value("pool")); return options.parse(argc, argv); - } catch (const std::exception& e) { + } catch (const std::exception&) { cuopt_assert(false, "Error parsing command line options"); }