109 const std::string kIndent(25,
' ');
111 bool new_lp_values =
false;
112 if (!learned_info.lp_values.empty()) {
113 if (lp_values_ != learned_info.lp_values) {
114 lp_values_ = learned_info.lp_values;
115 new_lp_values =
true;
116 VLOG(1) << kIndent +
"New LP values.";
120 bool new_binary_clauses =
false;
121 if (!learned_info.binary_clauses.empty()) {
122 const int old_num = binary_clause_manager_.
NumClauses();
124 const int num_vars = original_problem_.num_variables();
125 if (c.a.Variable() < num_vars && c.b.Variable() < num_vars) {
126 binary_clause_manager_.
Add(c);
129 if (binary_clause_manager_.
NumClauses() > old_num) {
130 new_binary_clauses =
true;
131 VLOG(1) << kIndent +
"Num binary clauses: "
136 bool new_solution =
false;
137 if (learned_info.solution.IsFeasible() &&
139 learned_info.solution.GetCost() < solution_.
GetCost())) {
140 solution_ = learned_info.solution;
142 VLOG(1) << kIndent +
"New solution.";
145 bool new_lower_bound =
false;
147 lower_bound_ = learned_info.lower_bound;
148 new_lower_bound =
true;
149 VLOG(1) << kIndent +
"New lower bound.";
156 parameters_.relative_gap_limit() *
167 int num_newly_fixed_variables = 0;
169 const VariableIndex
var(
literal.Variable().value());
170 if (
var >= original_problem_.num_variables()) {
174 if (is_fixed_[
var]) {
180 is_fixed_[
var] =
true;
182 ++num_newly_fixed_variables;
185 if (num_newly_fixed_variables > 0) {
186 int num_fixed_variables = 0;
187 for (
const bool is_fixed : is_fixed_) {
189 ++num_fixed_variables;
192 VLOG(1) << kIndent << num_newly_fixed_variables
193 <<
" newly fixed variables (" << num_fixed_variables <<
" / "
194 << is_fixed_.size() <<
").";
195 if (num_fixed_variables == is_fixed_.size()) {
198 for (VariableIndex
var(0);
var < is_fixed_.size(); ++
var) {
202 solution_ = fixed_solution;
206 VLOG(1) << kIndent <<
"Optimal";
213 bool known_status =
false;
222 const bool updated = new_lp_values || new_binary_clauses || new_solution ||
223 new_lower_bound || num_newly_fixed_variables > 0 ||
225 if (updated) ++update_stamp_;
231 for (VariableIndex
var(0);
var < is_fixed_.size(); ++
var) {
232 if (is_fixed_[
var]) {
233 learned_info.fixed_literals.push_back(
237 learned_info.solution = solution_;
239 learned_info.lp_values = lp_values_;