Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::CapacityModel Class Reference

#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)

Detailed Description

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.

Constructor & Destructor Documentation

◆ CapacityModel()

operations_research::CapacityModel::CapacityModel ( CapacityWeight min,
CapacityWeight max )
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.

Member Function Documentation

◆ AddTerm()

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.

◆ ComputeFeasibility()

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.

◆ ExportModelAsProto()

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.

◆ GetMaximumCapacity()

CapacityWeight operations_research::CapacityModel::GetMaximumCapacity ( ) const
inline

Definition at line 112 of file capacity_model.h.

◆ GetMinimumCapacity()

CapacityWeight operations_research::CapacityModel::GetMinimumCapacity ( ) const
inline

Returns the lower/upper bounds for the constraint.

Definition at line 111 of file capacity_model.h.

◆ GetTermCapacityWeight()

CapacityWeight operations_research::CapacityModel::GetTermCapacityWeight ( CapacityTermIndex term) const
inline

Definition at line 101 of file capacity_model.h.

◆ GetTermElementIndex()

ElementIndex operations_research::CapacityModel::GetTermElementIndex ( CapacityTermIndex term) const
inline

Returns the element, subset, or capacity of the given term.

Definition at line 95 of file capacity_model.h.

◆ GetTermSubsetIndex()

SubsetIndex operations_research::CapacityModel::GetTermSubsetIndex ( CapacityTermIndex term) const
inline

Definition at line 98 of file capacity_model.h.

◆ ImportModelFromProto()

void operations_research::CapacityModel::ImportModelFromProto ( const CapacityConstraintProto & proto)

Imports the model from a CapacityConstraintProto.

Definition at line 109 of file capacity_model.cc.

◆ num_terms()

BaseInt operations_research::CapacityModel::num_terms ( ) const
inline

Returns the current number of terms in the constraint.

Definition at line 83 of file capacity_model.h.

◆ ReserveNumTerms() [1/2]

void operations_research::CapacityModel::ReserveNumTerms ( BaseInt num_terms)
inline

Reserves num_terms terms in the model.

Definition at line 119 of file capacity_model.h.

◆ ReserveNumTerms() [2/2]

void operations_research::CapacityModel::ReserveNumTerms ( CapacityTermIndex num_terms)
inline

Definition at line 123 of file capacity_model.h.

◆ SetMaximumCapacity()

void operations_research::CapacityModel::SetMaximumCapacity ( CapacityWeight max_capacity)

Definition at line 42 of file capacity_model.cc.

◆ SetMinimumCapacity()

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.

◆ TermRange()

util_intops::StrongIntRange< CapacityTermIndex > operations_research::CapacityModel::TermRange ( ) const
inline

Returns the range of terms.

Definition at line 86 of file capacity_model.h.

◆ WithMaximumWeight()

CapacityModel operations_research::CapacityModel::WithMaximumWeight ( CapacityWeight max)
inlinestatic

Definition at line 78 of file capacity_model.h.

◆ WithMinimumWeight()

CapacityModel operations_research::CapacityModel::WithMinimumWeight ( CapacityWeight min)
inlinestatic

Definition at line 74 of file capacity_model.h.


The documentation for this class was generated from the following files: