Skip to content

Commit

Permalink
[CP-SAT] fix scheduling bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Jul 24, 2024
1 parent 30fe3c2 commit 1cedb55
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 166 deletions.
1 change: 1 addition & 0 deletions ortools/sat/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,7 @@ cc_library(
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/types:span",
],
)

Expand Down
4 changes: 2 additions & 2 deletions ortools/sat/clause.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ bool ClauseManager::AddClause(absl::Span<const Literal> literals, Trail* trail,
return AttachAndPropagate(clause, trail);
}

SatClause* ClauseManager::AddRemovableClause(
const std::vector<Literal>& literals, Trail* trail, int lbd) {
SatClause* ClauseManager::AddRemovableClause(absl::Span<const Literal> literals,
Trail* trail, int lbd) {
SatClause* clause = SatClause::Create(literals);
clauses_.push_back(clause);
if (add_clause_callback_ != nullptr) add_clause_callback_(lbd, literals);
Expand Down
2 changes: 1 addition & 1 deletion ortools/sat/clause.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class ClauseManager : public SatPropagator {

// Same as AddClause() for a removable clause. This is only called on learned
// conflict, so this should never have all its literal at false (CHECKED).
SatClause* AddRemovableClause(const std::vector<Literal>& literals,
SatClause* AddRemovableClause(absl::Span<const Literal> literals,
Trail* trail, int lbd);

// Lazily detach the given clause. The deletion will actually occur when
Expand Down
3 changes: 2 additions & 1 deletion ortools/sat/cumulative_energy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "absl/container/inlined_vector.h"
#include "absl/log/check.h"
#include "absl/types/span.h"
#include "ortools/base/iterator_adaptors.h"
#include "ortools/base/logging.h"
#include "ortools/sat/2d_orthogonal_packing.h"
Expand Down Expand Up @@ -238,7 +239,7 @@ bool CumulativeEnergyConstraint::Propagate() {

CumulativeIsAfterSubsetConstraint::CumulativeIsAfterSubsetConstraint(
IntegerVariable var, AffineExpression capacity,
const std::vector<int>& subtasks, const std::vector<IntegerValue>& offsets,
const std::vector<int>& subtasks, absl::Span<const IntegerValue> offsets,
SchedulingConstraintHelper* helper, SchedulingDemandHelper* demands,
Model* model)
: var_to_push_(var),
Expand Down
3 changes: 2 additions & 1 deletion ortools/sat/cumulative_energy.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <utility>
#include <vector>

#include "absl/types/span.h"
#include "ortools/sat/2d_orthogonal_packing.h"
#include "ortools/sat/integer.h"
#include "ortools/sat/intervals.h"
Expand Down Expand Up @@ -92,7 +93,7 @@ class CumulativeIsAfterSubsetConstraint : public PropagatorInterface {
CumulativeIsAfterSubsetConstraint(IntegerVariable var,
AffineExpression capacity,
const std::vector<int>& subtasks,
const std::vector<IntegerValue>& offsets,
absl::Span<const IntegerValue> offsets,
SchedulingConstraintHelper* helper,
SchedulingDemandHelper* demands,
Model* model);
Expand Down
2 changes: 1 addition & 1 deletion ortools/sat/diophantine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int64_t Gcd(const absl::Span<const int64_t> coeffs) {

} // namespace

void ReduceModuloBasis(const std::vector<std::vector<absl::int128>>& basis,
void ReduceModuloBasis(absl::Span<const std::vector<absl::int128>> basis,
const int elements_to_consider,
std::vector<absl::int128>& v) {
DCHECK(!basis.empty());
Expand Down
2 changes: 1 addition & 1 deletion ortools/sat/diophantine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace operations_research::sat {
// such a way that for a pivot P of the basis and the correspond entry x of v at
// the end of the reduction, we have
// -floor(|P|/2) <= v < ceil(|P|/2).
void ReduceModuloBasis(const std::vector<std::vector<absl::int128>>& basis,
void ReduceModuloBasis(absl::Span<const std::vector<absl::int128>> basis,
int elements_to_consider, std::vector<absl::int128>& v);

// Returns an ordering of the indices of coefficients such that the GCD of its
Expand Down
Loading

0 comments on commit 1cedb55

Please sign in to comment.