Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <intervals.h>
Public Member Functions | |
SchedulingDemandHelper (absl::Span< const AffineExpression > demands, SchedulingConstraintHelper *helper, Model *model) | |
IntegerValue | DemandMin (int t) const |
IntegerValue | DemandMax (int t) const |
IntegerValue | LevelZeroDemandMin (int t) const |
bool | DemandIsFixed (int t) const |
void | AddDemandMinReason (int t) |
void | AddDemandMinReason (int t, IntegerValue min_demand) |
const std::vector< AffineExpression > & | Demands () const |
ABSL_MUST_USE_RESULT bool | AddLinearizedDemand (int t, LinearConstraintBuilder *builder) const |
void | CacheAllEnergyValues () |
IntegerValue | EnergyMin (int t) const |
IntegerValue | EnergyMax (int t) const |
bool | EnergyIsQuadratic (int t) const |
void | AddEnergyMinReason (int t) |
IntegerValue | EnergyMinInWindow (int t, IntegerValue window_start, IntegerValue window_end) |
void | AddEnergyMinInWindowReason (int t, IntegerValue window_start, IntegerValue window_end) |
ABSL_MUST_USE_RESULT bool | DecreaseEnergyMax (int t, IntegerValue value) |
const std::vector< std::vector< LiteralValueValue > > & | DecomposedEnergies () const |
void | OverrideLinearizedEnergies (absl::Span< const LinearExpression > energies) |
Visible for testing. | |
void | OverrideDecomposedEnergies (const std::vector< std::vector< LiteralValueValue > > &energies) |
std::vector< LiteralValueValue > | FilteredDecomposedEnergy (int index) |
void | InitDecomposedEnergies () |
Helper class for cumulative constraint to wrap demands and expose concept like energy.
In a cumulative constraint, an interval always has a size and a demand, but it can also have a set of "selector" literals each associated with a fixed size / fixed demands. This allows more precise energy estimation.
Definition at line 632 of file intervals.h.
operations_research::sat::SchedulingDemandHelper::SchedulingDemandHelper | ( | absl::Span< const AffineExpression > | demands, |
SchedulingConstraintHelper * | helper, | ||
Model * | model ) |
Hack: this can be called with and empty demand vector as long as OverrideEnergies() is called to define the energies.
We try to init decomposed energies. This is needed for the cuts that are created after we call InitAllDecomposedEnergies().
Definition at line 896 of file intervals.cc.
void operations_research::sat::SchedulingDemandHelper::AddDemandMinReason | ( | int | t | ) |
Definition at line 1048 of file intervals.cc.
void operations_research::sat::SchedulingDemandHelper::AddDemandMinReason | ( | int | t, |
IntegerValue | min_demand ) |
Definition at line 1056 of file intervals.cc.
void operations_research::sat::SchedulingDemandHelper::AddEnergyMinInWindowReason | ( | int | t, |
IntegerValue | window_start, | ||
IntegerValue | window_end ) |
Since we usually ask way less often for the reason, we redo the computation here.
Return simple reason right away if there is no decomposition or the simple energy is enough.
Should be the same in most cases.
Definition at line 1159 of file intervals.cc.
void operations_research::sat::SchedulingDemandHelper::AddEnergyMinReason | ( | int | t | ) |
We prefer these reason in order.
Definition at line 1065 of file intervals.cc.
bool operations_research::sat::SchedulingDemandHelper::AddLinearizedDemand | ( | int | t, |
LinearConstraintBuilder * | builder ) const |
Adds the linearized demand (either the affine demand expression, or the demand part of the decomposed energy if present) to the builder. It returns false and do not add any term to the builder.if any literal involved has no integer view.
Definition at line 1093 of file intervals.cc.
void operations_research::sat::SchedulingDemandHelper::CacheAllEnergyValues | ( | ) |
The "energy" is usually size * demand, but in some non-conventional usage it might have a more complex formula. In all case, the energy is assumed to be only consumed during the interval duration.
IMPORTANT: One must call CacheAllEnergyValues() for the values to be updated.
At level 0, it will filter false literals from decomposed energies.
Try to reduce the size of the decomposed energy vector.
Definition at line 976 of file intervals.cc.
|
inline |
Different optional representation of the energy of an interval.
Important: first value is size, second value is demand.
Definition at line 694 of file intervals.h.
bool operations_research::sat::SchedulingDemandHelper::DecreaseEnergyMax | ( | int | t, |
IntegerValue | value ) |
Important: This might not do anything depending on the representation of the energy we have.
Definition at line 1018 of file intervals.cc.
bool operations_research::sat::SchedulingDemandHelper::DemandIsFixed | ( | int | t | ) | const |
Definition at line 1014 of file intervals.cc.
IntegerValue operations_research::sat::SchedulingDemandHelper::DemandMax | ( | int | t | ) | const |
Definition at line 1009 of file intervals.cc.
IntegerValue operations_research::sat::SchedulingDemandHelper::DemandMin | ( | int | t | ) | const |
When defined, the interval will consume this much demand during its whole duration. Some propagator only relies on the "energy" and thus never uses this.
Definition at line 1004 of file intervals.cc.
|
inline |
Definition at line 650 of file intervals.h.
|
inline |
Definition at line 675 of file intervals.h.
|
inline |
Definition at line 674 of file intervals.h.
|
inline |
Definition at line 673 of file intervals.h.
IntegerValue operations_research::sat::SchedulingDemandHelper::EnergyMinInWindow | ( | int | t, |
IntegerValue | window_start, | ||
IntegerValue | window_end ) |
Returns the energy min in [start, end].
Note(user): These functions are not in O(1) if the decomposition is used, so we have to be careful in not calling them too often.
Definition at line 1149 of file intervals.cc.
std::vector< LiteralValueValue > operations_research::sat::SchedulingDemandHelper::FilteredDecomposedEnergy | ( | int | index | ) |
Returns the decomposed energy terms compatible with the current literal assignment. It must not be used to create reasons if not at level 0. It returns en empty vector if the decomposed energy is not available.
Important: first value is size, second value is demand.
CacheAllEnergyValues has already filtered false literals.
Scan and filter false literals.
Definition at line 1126 of file intervals.cc.
void operations_research::sat::SchedulingDemandHelper::InitDecomposedEnergies | ( | ) |
Init all decomposed energies. It needs probing to be finished. This happens after the creation of the helper.
For the special case were demands is empty.
Definition at line 917 of file intervals.cc.
|
inline |
Definition at line 644 of file intervals.h.
void operations_research::sat::SchedulingDemandHelper::OverrideDecomposedEnergies | ( | const std::vector< std::vector< LiteralValueValue > > & | energies | ) |
Definition at line 1143 of file intervals.cc.
void operations_research::sat::SchedulingDemandHelper::OverrideLinearizedEnergies | ( | absl::Span< const LinearExpression > | energies | ) |
Visible for testing.
Definition at line 1111 of file intervals.cc.