Skip to content

Commit 35607bf

Browse files
committed
bop: backport from main
1 parent 3a3066d commit 35607bf

File tree

4 files changed

+7
-27
lines changed

4 files changed

+7
-27
lines changed

ortools/bop/bop_fs.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ BopOptimizerBase::Status BopRandomFirstSolutionGenerator::Optimize(
337337
// to do any extra work in these cases since the sat_propagator_ will not be
338338
// used anymore.
339339
CHECK_EQ(0, sat_propagator_->AssumptionLevel());
340-
sat_propagator_->RestoreSolverToAssumptionLevel();
340+
(void)sat_propagator_->ResetToLevelZero();
341341
sat_propagator_->SetParameters(saved_params);
342342
sat_propagator_->ResetDecisionHeuristic();
343343
for (const auto [literal, weight] : saved_prefs) {
344344
sat_propagator_->SetAssignmentPreference(literal, weight);
345345
}
346346

347-
// This can be proved during the call to RestoreSolverToAssumptionLevel().
347+
// This can be proved during the call to ResetToLevelZero().
348348
if (sat_propagator_->ModelIsUnsat()) {
349349
// The solution is proved optimal (if any).
350350
learned_info->lower_bound = best_cost;

ortools/bop/bop_lns.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ BopOptimizerBase::Status BopAdaptiveLNSOptimizer::Optimize(
256256
auto sat_propagator_cleanup =
257257
::absl::MakeCleanup([initial_dt, this, &learned_info, &time_limit]() {
258258
if (!sat_propagator_->ModelIsUnsat()) {
259-
sat_propagator_->SetAssumptionLevel(0);
260-
sat_propagator_->RestoreSolverToAssumptionLevel();
259+
(void)sat_propagator_->ResetToLevelZero();
261260
ExtractLearnedInfoFromSatSolver(sat_propagator_, learned_info);
262261
}
263262
time_limit->AdvanceDeterministicTime(
@@ -327,14 +326,14 @@ BopOptimizerBase::Status BopAdaptiveLNSOptimizer::Optimize(
327326
// Restore to the assumption level.
328327
// This is call is important since all the fixed variable in the
329328
// propagator_ will be used to construct the local problem below.
330-
// Note that calling RestoreSolverToAssumptionLevel() might actually prove
329+
// Note that calling ResetToLevelZero() might actually prove
331330
// the infeasibility. It is important to check the UNSAT status afterward.
332331
if (!sat_propagator_->ModelIsUnsat()) {
333-
sat_propagator_->RestoreSolverToAssumptionLevel();
332+
(void)sat_propagator_->ResetToLevelZero();
334333
}
335334

336335
// Check if the problem is proved UNSAT, by previous the search or the
337-
// RestoreSolverToAssumptionLevel() call above.
336+
// ResetToLevelZero() call above.
338337
if (sat_propagator_->ModelIsUnsat()) {
339338
return problem_state.solution().IsFeasible()
340339
? BopOptimizerBase::OPTIMAL_SOLUTION_FOUND

ortools/bop/bop_ls.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ void SatWrapper::BacktrackAll() { sat_solver_->Backtrack(0); }
649649
std::vector<sat::Literal> SatWrapper::FullSatTrail() const {
650650
std::vector<sat::Literal> propagated_literals;
651651
const sat::Trail& trail = sat_solver_->LiteralTrail();
652+
propagated_literals.reserve(trail.Index());
652653
for (int trail_index = 0; trail_index < trail.Index(); ++trail_index) {
653654
propagated_literals.push_back(trail[trail_index]);
654655
}

ortools/bop/bop_solver.cc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ namespace {
4545

4646
using ::operations_research::glop::ColIndex;
4747
using ::operations_research::glop::DenseRow;
48-
49-
// Updates the problem_state when the solution is proved optimal or the problem
50-
// is proved infeasible.
51-
// Returns true when the problem_state has been changed.
52-
bool UpdateProblemStateBasedOnStatus(BopOptimizerBase::Status status,
53-
ProblemState* problem_state) {
54-
CHECK(nullptr != problem_state);
55-
56-
if (BopOptimizerBase::OPTIMAL_SOLUTION_FOUND == status) {
57-
problem_state->MarkAsOptimal();
58-
return true;
59-
}
60-
61-
if (BopOptimizerBase::INFEASIBLE == status) {
62-
problem_state->MarkAsInfeasible();
63-
return true;
64-
}
65-
66-
return false;
67-
}
6848
} // anonymous namespace
6949

7050
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)