diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f43cf5e8..0033a7c9 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -24,5 +24,10 @@ jobs: - name: Build run: cmake --build build --config ${{ matrix.build_type }} + # Every exported symbol must be public or carry the pslp_ prefix + - name: Check exported symbols + if: runner.os != 'Windows' + run: sh cmake/pslp_symbols.sh check build/libPSLP.* + - name: Run tests run: cd build && ctest -C ${{ matrix.build_type }} --verbose diff --git a/CMakeLists.txt b/CMakeLists.txt index cb8103d3..cae6c0bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,18 @@ target_include_directories(PSLP $ ) +# Prefix the internal symbols with pslp_, so that they cannot clash with the +# symbols of a program that embeds PSLP. The header is generated by +# cmake/pslp_symbols.sh and must be seen by every source file that uses an +# internal function, hence the forced include. +set(PSLP_NAMESPACE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/core/pslp_namespace.h) +if (MSVC) + set(PSLP_FORCE_INCLUDE /FI${PSLP_NAMESPACE_HEADER}) +else() + set(PSLP_FORCE_INCLUDE -include ${PSLP_NAMESPACE_HEADER}) +endif() +target_compile_options(PSLP PRIVATE ${PSLP_FORCE_INCLUDE}) + # Common compile options if (MSVC) target_compile_options(PSLP PRIVATE /W4) @@ -168,6 +180,8 @@ if(PSLP_BUILD_TESTING) ) target_compile_definitions(all_tests PRIVATE TESTING) + # the tests call internal functions, so they need the same renames + target_compile_options(all_tests PRIVATE ${PSLP_FORCE_INCLUDE}) add_test(NAME all_tests COMMAND all_tests) else() diff --git a/cmake/pslp_symbols.sh b/cmake/pslp_symbols.sh new file mode 100755 index 00000000..60932f25 --- /dev/null +++ b/cmake/pslp_symbols.sh @@ -0,0 +1,123 @@ +#!/bin/sh +# Keeps the symbols that libPSLP exports free of name clashes. +# +# Every function with external linkage that is not part of the public API +# (cmake/public_symbols.txt) gets the prefix pslp_ through the generated header +# include/core/pslp_namespace.h, which CMake force-includes into every source +# file of the library and of the tests. +# +# pslp_symbols.sh generate ... rewrite the header from the libraries +# pslp_symbols.sh check ... fail if a symbol is exported unprefixed +# +# After adding or removing a function that is not static, build the library +# and run 'generate' on it. To cover the functions that only exist in some +# configurations, pass both a Release build and a Debug build with +# -DPSLP_BUILD_TESTING=ON. + +set -eu + +prefix=pslp_ +here=$(cd "$(dirname "$0")" && pwd) +public="$here/public_symbols.txt" +header="$here/../include/core/pslp_namespace.h" + +usage() +{ + sed -n '2,15p' "$0" | sed 's/^# \{0,1\}//' + exit 2 +} + +# Prints the defined global symbols of the given libraries, one per line. +# Names that start with an underscore belong to the toolchain and are skipped. +exported() +{ + if [ "$(uname)" = Darwin ]; then + strip_underscore='s/^_//' # Mach-O puts an underscore before C names + else + strip_underscore='' + fi + for lib in "$@"; do + nm -g "$lib" + done | awk 'NF == 3 && $2 ~ /^[A-TV-Z]$/ { print $3 }' | + sed "$strip_underscore" | { grep -v '^_' || true; } | LC_ALL=C sort -u +} + +[ $# -ge 2 ] || usage +mode=$1 +shift +for lib in "$@"; do + if [ ! -f "$lib" ]; then + echo "pslp_symbols.sh: no such library: $lib" >&2 + exit 1 + fi +done + +case $mode in +generate) + names=$(exported "$@" | sed "s/^$prefix//" | + { grep -vxF -f "$public" || true; } | LC_ALL=C sort -u) + { + cat <<'EOF' +/* + * Copyright 2025-2026 Daniel Cederberg + * + * This file is part of the PSLP project (LP Presolver). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Generated by cmake/pslp_symbols.sh, do not edit by hand. + + Gives every internal function with external linkage the prefix pslp_, so + that the symbols of libPSLP cannot clash with those of a program or library + that embeds it. CMake force-includes this header into every source file of + the library and of the tests; the sources keep using the short names. The + public functions (PSLP_API.h) are not renamed. */ + +#ifndef PSLP_NAMESPACE_H +#define PSLP_NAMESPACE_H + +/* clang-format off */ +EOF + for name in $names; do + echo "#define $name $prefix$name" + done + printf '/* clang-format on */\n\n#endif /* PSLP_NAMESPACE_H */\n' + } >"$header" + echo "wrote $(echo "$names" | wc -l | tr -d ' ') names to $header" + ;; +check) + symbols=$(exported "$@") + bad=$(echo "$symbols" | grep -v "^$prefix" | grep -vxF -f "$public" || true) + missing=$(echo "$symbols" | LC_ALL=C sort -u | + LC_ALL=C comm -13 - "$public" || true) + status=0 + if [ -n "$bad" ]; then + echo "Exported without the $prefix prefix and not in public_symbols.txt:" + echo "$bad" | sed 's/^/ /' + echo "Make the function static, or rebuild and run" + echo " sh cmake/pslp_symbols.sh generate ..." + status=1 + fi + if [ -n "$missing" ]; then + echo "Listed in public_symbols.txt but not exported:" + echo "$missing" | sed 's/^/ /' + status=1 + fi + [ $status -eq 0 ] && echo "exported symbols OK ($(echo "$symbols" | wc -l | tr -d ' '))" + exit $status + ;; +*) + usage + ;; +esac diff --git a/cmake/public_symbols.txt b/cmake/public_symbols.txt new file mode 100644 index 00000000..105ad7ac --- /dev/null +++ b/cmake/public_symbols.txt @@ -0,0 +1,13 @@ +default_settings +free_presolver +free_presolver_reduced_problem +free_settings +map_original_sol_to_reduced +new_presolver +new_presolver_from_problem +postsolve +postsolve_dual_infeas_ray +postsolve_primal_infeas_ray +run_presolver +set_settings_false +set_settings_true diff --git a/include/core/Activity.h b/include/core/Activity.h index 833551a5..918621f4 100644 --- a/include/core/Activity.h +++ b/include/core/Activity.h @@ -149,13 +149,6 @@ Altered_Activity update_activity_coeff_change(Activity *act, double lb, double u double old_coeff, double new_coeff, ColTag cTag); -/* Updates the activity struct when a bound changes. */ -Altered_Activity update_act_bound_change(Activity *act, double coeff, - double old_bound, double new_bound, - bool finite_bound, bool lower, - const double *vals, const int *cols, - int len, const struct Bound *bounds); - void remove_finite_lb_from_activities(const struct ConstColView *col, Activity *acts, double bound); diff --git a/include/core/pslp_namespace.h b/include/core/pslp_namespace.h new file mode 100644 index 00000000..2597a8f5 --- /dev/null +++ b/include/core/pslp_namespace.h @@ -0,0 +1,260 @@ +/* + * Copyright 2025-2026 Daniel Cederberg + * + * This file is part of the PSLP project (LP Presolver). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Generated by cmake/pslp_symbols.sh, do not edit by hand. + + Gives every internal function with external linkage the prefix pslp_, so + that the symbols of libPSLP cannot clash with those of a program or library + that embeds it. CMake force-includes this header into every source file of + the library and of the tests; the sources keep using the short names. The + public functions (PSLP_API.h) are not renamed. */ + +#ifndef PSLP_NAMESPACE_H +#define PSLP_NAMESPACE_H + +/* clang-format off */ +#define ASSERT_INCREASING_I pslp_ASSERT_INCREASING_I +#define ASSERT_NO_ACTIVE_STON_ROWS pslp_ASSERT_NO_ACTIVE_STON_ROWS +#define ASSERT_NO_ZEROS_D pslp_ASSERT_NO_ZEROS_D +#define Activities_init pslp_Activities_init +#define Activity_init pslp_Activity_init +#define P_row_has_diagonal pslp_P_row_has_diagonal +#define bound_tightening_single_row pslp_bound_tightening_single_row +#define change_lhs_of_ineq pslp_change_lhs_of_ineq +#define change_rhs_of_ineq pslp_change_rhs_of_ineq +#define check_activities pslp_check_activities +#define clean_small_coeff_A pslp_clean_small_coeff_A +#define clean_state pslp_clean_state +#define colTagPtr_shrink pslp_colTagPtr_shrink +#define colour_refinement_free pslp_colour_refinement_free +#define colour_refinement_new pslp_colour_refinement_new +#define colour_refinement_run pslp_colour_refinement_run +#define colour_refinement_verify pslp_colour_refinement_verify +#define compute_chain_depths pslp_compute_chain_depths +#define compute_max_act_no_tags pslp_compute_max_act_no_tags +#define compute_max_act_one_tag pslp_compute_max_act_one_tag +#define compute_max_act_tags pslp_compute_max_act_tags +#define compute_min_act_no_tags pslp_compute_min_act_no_tags +#define compute_min_act_one_tag pslp_compute_min_act_one_tag +#define compute_min_act_tags pslp_compute_min_act_tags +#define compute_supp_and_coeff_hash pslp_compute_supp_and_coeff_hash +#define cone_type_info pslp_cone_type_info +#define cones_valid pslp_cones_valid +#define constraints_clean pslp_constraints_clean +#define constraints_new pslp_constraints_new +#define count_locks_one_column pslp_count_locks_one_column +#define count_rows pslp_count_rows +#define dPtr_shrink pslp_dPtr_shrink +#define delete_fixed_cols_from_problem pslp_delete_fixed_cols_from_problem +#define delete_inactive_cols_from_A_and_AT pslp_delete_inactive_cols_from_A_and_AT +#define delete_inactive_rows pslp_delete_inactive_rows +#define delete_inactive_rows_from_A pslp_delete_inactive_rows_from_A +#define delete_inactive_rows_from_AT pslp_delete_inactive_rows_from_AT +#define diagonal_P_add pslp_diagonal_P_add +#define diagonal_P_alloc pslp_diagonal_P_alloc +#define diagonal_only_P_entry pslp_diagonal_only_P_entry +#define dton_P_flags pslp_dton_P_flags +#define dton_accumulate_row pslp_dton_accumulate_row +#define dton_apply pslp_dton_apply +#define dton_cascade pslp_dton_cascade +#define dton_choose_subst pslp_dton_choose_subst +#define dton_choose_subst_qp pslp_dton_choose_subst_qp +#define dton_claim pslp_dton_claim +#define dton_compose pslp_dton_compose +#define dton_push_record pslp_dton_push_record +#define dton_rebuild_AT pslp_dton_rebuild_AT +#define dton_record pslp_dton_record +#define dton_reserve_records pslp_dton_reserve_records +#define dton_tighten_changed_columns pslp_dton_tighten_changed_columns +#define dton_tighten_columns pslp_dton_tighten_columns +#define dton_transfer_bounds pslp_dton_transfer_bounds +#define dton_update_AT pslp_dton_update_AT +#define dton_workspace_free pslp_dton_workspace_free +#define dton_workspace_init pslp_dton_workspace_init +#define dton_workspace_new pslp_dton_workspace_new +#define empty_cols_drained pslp_empty_cols_drained +#define find_parallel_rows pslp_find_parallel_rows +#define fix_col pslp_fix_col +#define fix_col_to_negative_inf pslp_fix_col_to_negative_inf +#define fix_col_to_positive_inf pslp_fix_col_to_positive_inf +#define fix_var_in_obj pslp_fix_var_in_obj +#define fold_apply pslp_fold_apply +#define fold_check pslp_fold_check +#define fold_detect pslp_fold_detect +#define fold_map_to_folded pslp_fold_map_to_folded +#define fold_maps_free pslp_fold_maps_free +#define fold_postsolve pslp_fold_postsolve +#define fold_problem pslp_fold_problem +#define fold_reason_string pslp_fold_reason_string +#define fold_start_colours pslp_fold_start_colours +#define fold_workspace_free pslp_fold_workspace_free +#define fold_workspace_new pslp_fold_workspace_new +#define free_activities pslp_free_activities +#define free_constraints pslp_free_constraints +#define free_locks pslp_free_locks +#define free_matrix pslp_free_matrix +#define free_objective pslp_free_objective +#define free_problem pslp_free_problem +#define free_solution pslp_free_solution +#define free_state pslp_free_state +#define free_work pslp_free_work +#define free_work_scratch pslp_free_work_scratch +#define get_max_abs pslp_get_max_abs +#define group_table_free pslp_group_table_free +#define group_table_reset pslp_group_table_reset +#define iPtr_shrink pslp_iPtr_shrink +#define implied_free_from_above_by_row pslp_implied_free_from_above_by_row +#define implied_free_from_below_by_row pslp_implied_free_from_below_by_row +#define is_fixing_negligible pslp_is_fixing_negligible +#define is_lb_implied_free pslp_is_lb_implied_free +#define is_ub_implied_free pslp_is_ub_implied_free +#define mark_P_row_inactive pslp_mark_P_row_inactive +#define matrix_add_to_diagonal pslp_matrix_add_to_diagonal +#define matrix_alloc pslp_matrix_alloc +#define matrix_alloc_diagonal pslp_matrix_alloc_diagonal +#define matrix_is_symmetric pslp_matrix_is_symmetric +#define matrix_new pslp_matrix_new +#define matrix_update_row pslp_matrix_update_row +#define matrix_valid_csr_input pslp_matrix_valid_csr_input +#define new_activities pslp_new_activities +#define new_locks pslp_new_locks +#define new_problem pslp_new_problem +#define new_rowtags pslp_new_rowtags +#define new_solution pslp_new_solution +#define new_state pslp_new_state +#define new_work pslp_new_work +#define objective_new pslp_objective_new +#define parallel_radix_sort_rows pslp_parallel_radix_sort_rows +#define polish_z pslp_polish_z +#define postsolve_info_free pslp_postsolve_info_free +#define postsolve_info_new pslp_postsolve_info_new +#define postsolver_map_to_reduced pslp_postsolver_map_to_reduced +#define postsolver_run pslp_postsolver_run +#define postsolver_run_dual_infeas_ray pslp_postsolver_run_dual_infeas_ray +#define postsolver_run_primal_infeas_ray pslp_postsolver_run_primal_infeas_ray +#define postsolver_update pslp_postsolver_update +#define print_double_array pslp_print_double_array +#define print_int_array pslp_print_int_array +#define print_matrix pslp_print_matrix +#define print_row_starts pslp_print_row_starts +#define problem_clean pslp_problem_clean +#define process_cones pslp_process_cones +#define process_soc_block pslp_process_soc_block +#define propagate_primal pslp_propagate_primal +#define radix_sort_by_key pslp_radix_sort_by_key +#define radix_sort_rows pslp_radix_sort_rows +#define radix_sort_rows_chunked pslp_radix_sort_rows_chunked +#define random_matrix_new pslp_random_matrix_new +#define recompute_n_infs pslp_recompute_n_infs +#define refine_apply_bucket pslp_refine_apply_bucket +#define refine_group_bucket pslp_refine_group_bucket +#define refine_push pslp_refine_push +#define remove_coeff pslp_remove_coeff +#define remove_dton_eq_rows pslp_remove_dton_eq_rows +#define remove_empty_cols pslp_remove_empty_cols +#define remove_empty_rows pslp_remove_empty_rows +#define remove_extra_space pslp_remove_extra_space +#define remove_finite_lb_from_activities pslp_remove_finite_lb_from_activities +#define remove_finite_ub_from_activities pslp_remove_finite_ub_from_activities +#define remove_parallel_cols pslp_remove_parallel_cols +#define remove_parallel_rows pslp_remove_parallel_rows +#define remove_redundant_bounds pslp_remove_redundant_bounds +#define remove_ston_cols pslp_remove_ston_cols +#define remove_ston_rows pslp_remove_ston_rows +#define remove_variables_with_close_bounds pslp_remove_variables_with_close_bounds +#define replace_row_A pslp_replace_row_A +#define retrieve_added_row pslp_retrieve_added_row +#define retrieve_added_rows pslp_retrieve_added_rows +#define retrieve_deleted_row pslp_retrieve_deleted_row +#define retrieve_rotated_to_p pslp_retrieve_rotated_to_p +#define rowTagPtr_shrink pslp_rowTagPtr_shrink +#define row_slots_init pslp_row_slots_init +#define run_debugger pslp_run_debugger +#define run_debugger_problem pslp_run_debugger_problem +#define run_debugger_stats_consistency_check pslp_run_debugger_stats_consistency_check +#define save_retrieval_added_row pslp_save_retrieval_added_row +#define save_retrieval_added_rows pslp_save_retrieval_added_rows +#define save_retrieval_bound_change_no_row pslp_save_retrieval_bound_change_no_row +#define save_retrieval_bound_change_the_row pslp_save_retrieval_bound_change_the_row +#define save_retrieval_deleted_row pslp_save_retrieval_deleted_row +#define save_retrieval_deleted_row_zk pslp_save_retrieval_deleted_row_zk +#define save_retrieval_eq_to_ineq pslp_save_retrieval_eq_to_ineq +#define save_retrieval_fixed_col pslp_save_retrieval_fixed_col +#define save_retrieval_fixed_col_inf pslp_save_retrieval_fixed_col_inf +#define save_retrieval_parallel_col pslp_save_retrieval_parallel_col +#define save_retrieval_parallel_row pslp_save_retrieval_parallel_row +#define save_retrieval_rhs_or_lhs_change pslp_save_retrieval_rhs_or_lhs_change +#define save_retrieval_rotated_to_p pslp_save_retrieval_rotated_to_p +#define save_retrieval_side_relaxed pslp_save_retrieval_side_relaxed +#define save_retrieval_sub_col pslp_save_retrieval_sub_col +#define save_retrieval_sub_col_dton pslp_save_retrieval_sub_col_dton +#define shrink_idx_vector pslp_shrink_idx_vector +#define simple_dual_fix pslp_simple_dual_fix +#define sort_ints pslp_sort_ints +#define sparse_accumulator_add pslp_sparse_accumulator_add +#define sparse_accumulator_clear pslp_sparse_accumulator_clear +#define sparse_accumulator_init pslp_sparse_accumulator_init +#define sub_diag_var_in_obj_dton pslp_sub_diag_var_in_obj_dton +#define sub_var_in_obj pslp_sub_var_in_obj +#define sub_var_in_obj_dton pslp_sub_var_in_obj_dton +#define thread_pool_bucket_offsets pslp_thread_pool_bucket_offsets +#define thread_pool_chunk_bounds pslp_thread_pool_chunk_bounds +#define thread_pool_chunk_bounds_by_prefix pslp_thread_pool_chunk_bounds_by_prefix +#define thread_pool_chunk_count pslp_thread_pool_chunk_count +#define thread_pool_free pslp_thread_pool_free +#define thread_pool_n_threads pslp_thread_pool_n_threads +#define thread_pool_new pslp_thread_pool_new +#define thread_pool_online_cpus pslp_thread_pool_online_cpus +#define thread_pool_resolve_n_threads pslp_thread_pool_resolve_n_threads +#define thread_pool_run pslp_thread_pool_run +#define transpose pslp_transpose +#define transpose_into pslp_transpose_into +#define update_activities_bound_change pslp_update_activities_bound_change +#define update_activities_fixed_col pslp_update_activities_fixed_col +#define update_activity_coeff_change pslp_update_activity_coeff_change +#define update_column_map pslp_update_column_map +#define update_lb pslp_update_lb +#define update_lb_with_row pslp_update_lb_with_row +#define update_locks_eq_to_ineq pslp_update_locks_eq_to_ineq +#define update_locks_ineq_to_eq pslp_update_locks_ineq_to_eq +#define update_ub pslp_update_ub +#define update_ub_with_row pslp_update_ub_with_row +#define verify_A_and_AT pslp_verify_A_and_AT +#define verify_A_and_AT_consistency pslp_verify_A_and_AT_consistency +#define verify_P pslp_verify_P +#define verify_activities pslp_verify_activities +#define verify_activity pslp_verify_activity +#define verify_doubleton_rows pslp_verify_doubleton_rows +#define verify_empty_cols pslp_verify_empty_cols +#define verify_empty_rows pslp_verify_empty_rows +#define verify_empty_when_finished pslp_verify_empty_when_finished +#define verify_locks pslp_verify_locks +#define verify_no_duplicates pslp_verify_no_duplicates +#define verify_no_duplicates_lists pslp_verify_no_duplicates_lists +#define verify_no_duplicates_ptr pslp_verify_no_duplicates_ptr +#define verify_no_duplicates_sort pslp_verify_no_duplicates_sort +#define verify_no_duplicates_sort_ptr pslp_verify_no_duplicates_sort_ptr +#define verify_problem_up_to_date pslp_verify_problem_up_to_date +#define verify_row_and_col_sizes pslp_verify_row_and_col_sizes +#define verify_row_states pslp_verify_row_states +#define verify_row_tags pslp_verify_row_tags +#define verify_ston_cols pslp_verify_ston_cols +#define verify_ston_rows pslp_verify_ston_rows +/* clang-format on */ + +#endif /* PSLP_NAMESPACE_H */ diff --git a/include/explorers/dton/DtonsEq_internal.h b/include/explorers/dton/DtonsEq_internal.h index 40d33731..289eade2 100644 --- a/include/explorers/dton/DtonsEq_internal.h +++ b/include/explorers/dton/DtonsEq_internal.h @@ -165,10 +165,6 @@ void dton_tighten_columns(struct Problem *prob); /* Same as dton_tighten_columns, but no full rescan */ void dton_tighten_changed_columns(struct Problem *prob, const DtonTargets *targets); -/* Applied to one one-sided two-entry row. The pushed column loses its bound on - the side the row implies. False when the row stays an inequality. */ -bool dton_tighten_dominated_row(struct Problem *prob, int i); - /* Reserves the round's per-record arrays for n_records records. False if an allocation fails. */ bool dton_reserve_records(DtonWorkspace *dton_work, size_t n_records); diff --git a/src/core/Activity.c b/src/core/Activity.c index 154e819a..b4d1ef17 100644 --- a/src/core/Activity.c +++ b/src/core/Activity.c @@ -403,11 +403,12 @@ static inline void add_to_activity(double *act, double delta, bool is_min, } } -Altered_Activity update_act_bound_change(Activity *act, double coeff, - double old_bound, double new_bound, - bool finite_bound, bool lower, - const double *vals, const int *cols, - int len, const Bound *bounds) +/* Updates the activity struct when a bound changes. */ +static Altered_Activity update_act_bound_change(Activity *act, double coeff, + double old_bound, double new_bound, + bool finite_bound, bool lower, + const double *vals, const int *cols, + int len, const Bound *bounds) { // --------------------------------------------------------------------- // If a lower bound has been updated diff --git a/src/core/Debugger.c b/src/core/Debugger.c index 7a054464..bbeae4ac 100644 --- a/src/core/Debugger.c +++ b/src/core/Debugger.c @@ -302,7 +302,7 @@ void verify_no_duplicates_ptr(const int *data, size_t len) } } -void verify_nonnegative_iVec(const iVec *vec) +static void verify_nonnegative_iVec(const iVec *vec) { for (size_t i = 0; i < vec->len; ++i) { diff --git a/src/core/Postsolver.c b/src/core/Postsolver.c index fb8354d2..0e0aaa39 100644 --- a/src/core/Postsolver.c +++ b/src/core/Postsolver.c @@ -323,9 +323,9 @@ void retrieve_added_rows(Solution *sol, int i, const int *rows, const double *va } } -void retrieve_bound_change(Solution *sol, int i, int j, const int *cols, - const double *vals, int len, bool implied_bound_is_upper, - double implied_bound) +static void retrieve_bound_change(Solution *sol, int i, int j, const int *cols, + const double *vals, int len, + bool implied_bound_is_upper, double implied_bound) { int k, ii; double aij = 1.0; @@ -383,7 +383,7 @@ void retrieve_bound_change(Solution *sol, int i, int j, const int *cols, sol->z[j] = 0.0; } -void retrieve_lhs_change(Solution *sol, int i, int j, double ratio) +static void retrieve_lhs_change(Solution *sol, int i, int j, double ratio) { assert(sol->y[i] != ROW_NOT_RETRIEVED); assert(sol->y[j] != ROW_NOT_RETRIEVED); @@ -399,7 +399,7 @@ void retrieve_lhs_change(Solution *sol, int i, int j, double ratio) } // as retrieve_lhs_change with the signs reversed -void retrieve_rhs_change(Solution *sol, int i, int j, double ratio) +static void retrieve_rhs_change(Solution *sol, int i, int j, double ratio) { assert(sol->y[i] != ROW_NOT_RETRIEVED); assert(sol->y[j] != ROW_NOT_RETRIEVED); @@ -414,7 +414,7 @@ void retrieve_rhs_change(Solution *sol, int i, int j, double ratio) sol->y[i] = 0.0; } -void retrieve_eq_to_ineq(Solution *sol, int row, double val) +static void retrieve_eq_to_ineq(Solution *sol, int row, double val) { assert(sol->y[row] != ROW_NOT_RETRIEVED); sol->y[row] += val; diff --git a/src/core/Presolver.c b/src/core/Presolver.c index 5bb2eddf..518abf97 100644 --- a/src/core/Presolver.c +++ b/src/core/Presolver.c @@ -70,7 +70,7 @@ enum Complexity MEDIUM = 1 << 0 }; -PresolveStats *init_stats(size_t n_rows, size_t n_cols, size_t nnz) +static PresolveStats *init_stats(size_t n_rows, size_t n_cols, size_t nnz) { PresolveStats *stats = (PresolveStats *) ps_calloc(1, sizeof(PresolveStats)); stats->n_rows_original = n_rows; @@ -210,7 +210,7 @@ typedef struct clean_up_scope Work *work; } clean_up_scope; -void presolver_clean_up(clean_up_scope scope) +static void presolver_clean_up(clean_up_scope scope) { free_matrix(scope.A); free_matrix(scope.AT); @@ -748,7 +748,7 @@ run_medium_explorers(Problem *prob, const Settings *stgs, PresolveStats *stats) return status; } -void populate_presolved_problem(Presolver *presolver) +static void populate_presolved_problem(Presolver *presolver) { ProblemData *reduced_prob = presolver->reduced_prob; Constraints *constraints = presolver->prob->constraints; diff --git a/src/explorers/Parallel_rows.c b/src/explorers/Parallel_rows.c index 12718128..9e308610 100644 --- a/src/explorers/Parallel_rows.c +++ b/src/explorers/Parallel_rows.c @@ -136,9 +136,9 @@ static inline int get_bin_size(int start, size_t n_rows, const int *rows, #ifndef NDEBUG // make sure that the rows in the same bin have the same coefficient // hash value and the same sparsity ID -void ASSERT_BIN_CORRECT(const int *coeff_hashes, const int *sparsity_IDs, - const int *rows, int bin_start, int bin_size, - const RowTag *row_tags, RowTag INACTIVE_TAG) +static void ASSERT_BIN_CORRECT(const int *coeff_hashes, const int *sparsity_IDs, + const int *rows, int bin_start, int bin_size, + const RowTag *row_tags, RowTag INACTIVE_TAG) { const int *bin_temp = rows + bin_start; int coeff_hash_start = coeff_hashes[bin_temp[0]]; @@ -152,8 +152,8 @@ void ASSERT_BIN_CORRECT(const int *coeff_hashes, const int *sparsity_IDs, } } -void VERIFY_PARALLEL_ROWS(const Matrix *A, const RowTag *rows_tags, - const int *parallel_rows, const iVec *group_starts) +static void VERIFY_PARALLEL_ROWS(const Matrix *A, const RowTag *rows_tags, + const int *parallel_rows, const iVec *group_starts) { int j, k, start, end, n_rows_this_group, len1; size_t i; diff --git a/src/explorers/dton/DtonsIneq.c b/src/explorers/dton/DtonsIneq.c index 06f11ee7..6dcf4860 100644 --- a/src/explorers/dton/DtonsIneq.c +++ b/src/explorers/dton/DtonsIneq.c @@ -92,7 +92,9 @@ static int dton_dominated_entry(const Problem *prob, const ConstRowView *row, return -1; } -bool dton_tighten_dominated_row(Problem *prob, int i) +/* Applied to one one-sided two-entry row. The pushed column loses its bound on + the side the row implies. False when the row stays an inequality. */ +static bool dton_tighten_dominated_row(Problem *prob, int i) { Constraints *constraints = prob->constraints; const Matrix *A = constraints->A;