![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
#include <capacity_model.h>
Public Member Functions | |
CapacityModel (CapacityWeight min, CapacityWeight max) | |
BaseInt | num_terms () const |
Returns the current number of terms in the constraint. | |
util_intops::StrongIntRange< CapacityTermIndex > | TermRange () const |
Returns the range of terms. | |
void | AddTerm (SubsetIndex subset, ElementIndex element, CapacityWeight weight) |
Adds a new term to the constraint. | |
ElementIndex | GetTermElementIndex (CapacityTermIndex term) const |
Returns the element, subset, or capacity of the given term. | |
SubsetIndex | GetTermSubsetIndex (CapacityTermIndex term) const |
CapacityWeight | GetTermCapacityWeight (CapacityTermIndex term) const |
void | SetMinimumCapacity (CapacityWeight min_capacity) |
void | SetMaximumCapacity (CapacityWeight max_capacity) |
CapacityWeight | GetMinimumCapacity () const |
Returns the lower/upper bounds for the constraint. | |
CapacityWeight | GetMaximumCapacity () const |
bool | ComputeFeasibility () const |
void | ReserveNumTerms (BaseInt num_terms) |
Reserves num_terms terms in the model. | |
void | ReserveNumTerms (CapacityTermIndex num_terms) |
CapacityConstraintProto | ExportModelAsProto () |
void | ImportModelFromProto (const CapacityConstraintProto &proto) |
Imports the model from a CapacityConstraintProto. |
Static Public Member Functions | |
static CapacityModel | WithMinimumWeight (CapacityWeight min) |
static CapacityModel | WithMaximumWeight (CapacityWeight max) |
Main class for describing a single capacity constraint in the context of a set-covering problem.
Definition at line 57 of file capacity_model.h.
|
inline |
Builds an empty capacity constraint.
Use either WithMinimumWeight or WithMaximumWeight to set only one of the two bounds.
At least one bound must be set. Otherwise, the constraint is vacuous.
Definition at line 63 of file capacity_model.h.
void operations_research::CapacityModel::AddTerm | ( | SubsetIndex | subset, |
ElementIndex | element, | ||
CapacityWeight | weight ) |
Adds a new term to the constraint.
Definition at line 27 of file capacity_model.cc.
bool operations_research::CapacityModel::ComputeFeasibility | ( | ) | const |
Returns true if the constraint is feasible, i.e. there is at least one assignment that satisfies the constraint.
A sum of zero terms is zero.
Compute the minimum and maximum constraint activations.
Definition at line 47 of file capacity_model.cc.
CapacityConstraintProto operations_research::CapacityModel::ExportModelAsProto | ( | ) |
Returns the model as a CapacityConstraintProto.
The function is not const because the terms need to be sorted for the representation as a protobuf to be canonical.
Definition at line 85 of file capacity_model.cc.
|
inline |
Definition at line 112 of file capacity_model.h.
|
inline |
Returns the lower/upper bounds for the constraint.
Definition at line 111 of file capacity_model.h.
|
inline |
Definition at line 101 of file capacity_model.h.
|
inline |
Returns the element, subset, or capacity of the given term.
Definition at line 95 of file capacity_model.h.
|
inline |
Definition at line 98 of file capacity_model.h.
void operations_research::CapacityModel::ImportModelFromProto | ( | const CapacityConstraintProto & | proto | ) |
Imports the model from a CapacityConstraintProto.
Definition at line 109 of file capacity_model.cc.
|
inline |
Returns the current number of terms in the constraint.
Definition at line 83 of file capacity_model.h.
|
inline |
Reserves num_terms terms in the model.
Definition at line 119 of file capacity_model.h.
|
inline |
Definition at line 123 of file capacity_model.h.
void operations_research::CapacityModel::SetMaximumCapacity | ( | CapacityWeight | max_capacity | ) |
Definition at line 42 of file capacity_model.cc.
void operations_research::CapacityModel::SetMinimumCapacity | ( | CapacityWeight | min_capacity | ) |
Sets the lower/upper bounds for the constraint. This will CHECK-fail if a capacity is a NaN.
Definition at line 37 of file capacity_model.cc.
|
inline |
Returns the range of terms.
Definition at line 86 of file capacity_model.h.
|
inlinestatic |
Definition at line 78 of file capacity_model.h.
|
inlinestatic |
Definition at line 74 of file capacity_model.h.