29 parameters_(*
model->GetOrCreate<SatParameters>()) {
31 pseudo_costs_.resize(num_vars);
34 void PseudoCosts::UpdateCostForVar(IntegerVariable
var,
double new_cost) {
35 if (
var >= pseudo_costs_.size()) {
41 pseudo_costs_[
var].AddData(new_cost);
45 const std::vector<VariableBoundChange>& bound_changes,
46 const IntegerValue obj_bound_improvement) {
48 if (obj_bound_improvement == IntegerValue(0))
return;
52 if (decision.lower_bound_change == IntegerValue(0))
continue;
54 const double current_pseudo_cost =
56 UpdateCostForVar(decision.var, current_pseudo_cost);
63 const double epsilon = 1e-6;
65 double best_cost = -std::numeric_limits<double>::infinity();
68 for (IntegerVariable positive_var(0); positive_var < pseudo_costs_.size();
70 const IntegerVariable negative_var =
NegationOf(positive_var);
72 const IntegerValue lb = integer_trail_.
LowerBound(positive_var);
73 const IntegerValue ub = integer_trail_.
UpperBound(positive_var);
74 if (lb >= ub)
continue;
76 parameters_.pseudo_cost_reliability_threshold()) {
81 const double current_merged_cost =
85 if (current_merged_cost > best_cost) {
86 chosen_var = positive_var;
87 best_cost = current_merged_cost;
101 std::vector<PseudoCosts::VariableBoundChange> bound_changes;
107 encoder->GetAllIntegerLiterals(
Literal(decision))) {
109 if (integer_trail->IsCurrentlyIgnored(l.var))
continue;
111 var_bound_change.
var = l.var;
113 l.bound - integer_trail->LowerBound(l.var);
114 bound_changes.push_back(var_bound_change);
117 return bound_changes;