Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <constraint_violation.h>
Public Member Functions | |
CompiledReservoirConstraint (LinearExpressionProto capacity, std::vector< std::optional< int > > is_active, std::vector< LinearExpressionProto > times, std::vector< LinearExpressionProto > demands) | |
int64_t | ComputeViolation (absl::Span< const int64_t > solution) final |
void | PerformMove (int, int64_t, absl::Span< const int64_t > solution_with_new_value) final |
Updates the violation with the new value. | |
int64_t | ViolationDelta (int var, int64_t, absl::Span< const int64_t > solution_with_new_value) final |
Returns the delta if var changes from old_value to solution[var]. | |
std::vector< int > | UsedVariables (const CpModelProto &model_proto) const final |
Public Member Functions inherited from operations_research::sat::CompiledConstraint | |
CompiledConstraint ()=default | |
virtual | ~CompiledConstraint ()=default |
void | InitializeViolation (absl::Span< const int64_t > solution) |
Recomputes the violation of the constraint from scratch. | |
int64_t | violation () const |
The cached violation of this constraint. | |
Additional Inherited Members | |
Protected Member Functions inherited from operations_research::sat::CompiledConstraint | |
Protected Attributes inherited from operations_research::sat::CompiledConstraint | |
int64_t | violation_ |
This can be used to encode reservoir or a cumulative constraints for LS. We have a set of event time, and we use for overal violation the sum of overload over time.
This version support an incremental computation when just a few events changes, which is roughly O(n) instead of O(n log n) which makes it significantly faster than recomputing and sorting the profile on each ViolationDelta().
Definition at line 591 of file constraint_violation.h.
|
inline |
Definition at line 593 of file constraint_violation.h.
|
inlinefinalvirtual |
Implements operations_research::sat::CompiledConstraint.
Definition at line 610 of file constraint_violation.h.
|
inlinefinalvirtual |
Updates the violation with the new value.
Reimplemented from operations_research::sat::CompiledConstraint.
Definition at line 615 of file constraint_violation.h.
|
finalvirtual |
Returns the sorted vector of variables used by this constraint. This is used to known when a violation might change, and is only called once during initialization, so speed is not to much of a concern here.
The global proto is needed to resolve interval variables reference.
Implements operations_research::sat::CompiledConstraint.
Definition at line 2240 of file constraint_violation.cc.
|
inlinefinalvirtual |
Returns the delta if var changes from old_value to solution[var].
Reimplemented from operations_research::sat::CompiledConstraint.
Definition at line 623 of file constraint_violation.h.