Skip to content

Commit 3e1d3d7

Browse files
committed
[CP-SAT] disambiguate shaving parameters
1 parent 467091f commit 3e1d3d7

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

ortools/sat/cp_model_search.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,8 @@ absl::flat_hash_map<std::string, SatParameters> GetNamedParameters(
650650
new_params.set_search_branching(SatParameters::AUTOMATIC_SEARCH);
651651
new_params.set_use_probing_search(true);
652652
new_params.set_at_most_one_max_expansion_size(2);
653-
const double dtime = base_params.shaving_search_deterministic_time();
653+
// Use a small deterministic time to avoid spending too much time on
654+
// shaving by default. The probing workers will increase it as needed.
654655
new_params.set_shaving_search_deterministic_time(0.001);
655656
if (base_params.use_dual_scheduling_heuristics()) {
656657
AddExtraSchedulingPropagators(new_params);
@@ -660,8 +661,6 @@ absl::flat_hash_map<std::string, SatParameters> GetNamedParameters(
660661
new_params.set_linearization_level(0);
661662
strategies["probing_no_lp"] = new_params;
662663

663-
// Use the default deterministic time.
664-
new_params.set_shaving_search_deterministic_time(dtime);
665664
// We want to spend more time on the LP here.
666665
new_params.set_linearization_level(2);
667666
new_params.set_add_lp_constraints_lazily(false);

ortools/sat/integer_search.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "absl/log/check.h"
2626
#include "absl/log/log.h"
2727
#include "absl/log/vlog_is_on.h"
28-
#include "absl/meta/type_traits.h"
2928
#include "absl/random/distributions.h"
3029
#include "absl/strings/str_cat.h"
3130
#include "absl/types/span.h"
@@ -1950,9 +1949,9 @@ SatSolver::Status ContinuousProber::Probe() {
19501949

19511950
// Update the use_shaving_ parameter.
19521951
// TODO(user): Currently, the heuristics is that we alternate shaving and
1953-
// not shaving, unless use_shaving_in_probing_search is false.
1952+
// not shaving, unless shaving_deterministic_time_in_probing_search is <= 0.
19541953
use_shaving_ =
1955-
parameters_.use_shaving_in_probing_search() ? !use_shaving_ : false;
1954+
parameters_.shaving_deterministic_time_in_probing_search() > 0.0;
19561955
trail_index_at_start_of_iteration_ = new_trail_index;
19571956
integer_trail_index_at_start_of_iteration_ = new_integer_trail_index;
19581957

ortools/sat/parameters_validation.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ std::string ValidateParameters(const SatParameters& params) {
8888
TEST_IS_FINITE(restart_dl_average_ratio);
8989
TEST_IS_FINITE(restart_lbd_average_ratio);
9090
TEST_IS_FINITE(shared_tree_open_leaves_per_worker);
91+
TEST_IS_FINITE(shaving_deterministic_time_in_probing_search);
9192
TEST_IS_FINITE(shaving_search_deterministic_time);
9293
TEST_IS_FINITE(strategy_change_increase_ratio);
9394
TEST_IS_FINITE(symmetry_detection_deterministic_time_limit);

ortools/sat/sat_parameters.proto

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,10 @@ message SatParameters {
10541054
optional int32 probing_num_combinations_limit = 272 [default = 20000];
10551055

10561056
// Add a shaving phase (where the solver tries to prove that the lower or
1057-
// upper bound of a variable are infeasible) to the probing search.
1058-
optional bool use_shaving_in_probing_search = 204 [default = true];
1057+
// upper bound of a variable are infeasible) to the probing search. (<= 0
1058+
// disables it).
1059+
optional double shaving_deterministic_time_in_probing_search = 204
1060+
[default = 0.001];
10591061

10601062
// Specifies the amount of deterministic time spent of each try at shaving a
10611063
// bound in the shaving search.

0 commit comments

Comments
 (0)