C++ Reference
C++ Reference: CP-SAT
Detailed Description
Represents a Interval variable.
An interval variable is both a constraint and a variable. It is defined by three objects: start, size, and end. All three can be an integer variable, a constant, or an affine expression.
It is a constraint because, internally, it enforces that start + size == end.
It is also a variable as it can appear in specific scheduling constraints: NoOverlap, NoOverlap2D, Cumulative.
Optionally, a presence literal can be added to this constraint. This presence literal is understood by the same constraints. These constraints ignore interval variables with precence literals assigned to false. Conversely, these constraints will also set these presence literals to false if they cannot fit these intervals into the schedule.
It can only be constructed via CpModelBuilder.NewIntervalVar().
Definition at line 445 of file cp_model.h.
Public Member Functions | |
| IntervalVar () | |
| A default constructed IntervalVar can be used to mean not defined yet. More... | |
| IntervalVar | WithName (const std::string &name) |
| Sets the name of the variable. More... | |
| std::string | Name () const |
| Returns the name of the interval (or the empty string if not set). More... | |
| LinearExpr | StartExpr () const |
| Returns the start linear expression. More... | |
| LinearExpr | SizeExpr () const |
| Returns the size linear expression. More... | |
| LinearExpr | EndExpr () const |
| Returns the end linear expression. More... | |
| BoolVar | PresenceBoolVar () const |
| Returns a BoolVar indicating the presence of this interval. More... | |
| bool | operator== (const IntervalVar &other) const |
| Equality test with another interval variable. More... | |
| bool | operator!= (const IntervalVar &other) const |
| Difference test with another interval variable. More... | |
| std::string | DebugString () const |
| Returns a debug string. More... | |
| int | index () const |
| Returns the index of the interval constraint in the model. More... | |
Constructor & Destructor Documentation
◆ IntervalVar()
| IntervalVar | ( | ) |
A default constructed IntervalVar can be used to mean not defined yet.
However, it shouldn't be passed to any of the functions in this file. Doing so will crash in debug mode and will result in an invalid model in opt mode.
Member Function Documentation
◆ DebugString()
| std::string DebugString | ( | ) | const |
Returns a debug string.
◆ EndExpr()
| LinearExpr EndExpr | ( | ) | const |
Returns the end linear expression.
Note that this rebuilds the expression each time this method is called.
◆ index()
|
inline |
Returns the index of the interval constraint in the model.
Definition at line 492 of file cp_model.h.
◆ Name()
| std::string Name | ( | ) | const |
Returns the name of the interval (or the empty string if not set).
◆ operator!=()
|
inline |
Difference test with another interval variable.
Definition at line 484 of file cp_model.h.
◆ operator==()
|
inline |
Equality test with another interval variable.
Definition at line 479 of file cp_model.h.
◆ PresenceBoolVar()
| BoolVar PresenceBoolVar | ( | ) | const |
Returns a BoolVar indicating the presence of this interval.
It returns CpModelBuilder.TrueVar() if the interval is not optional.
◆ SizeExpr()
| LinearExpr SizeExpr | ( | ) | const |
Returns the size linear expression.
Note that this rebuilds the expression each time this method is called.
◆ StartExpr()
| LinearExpr StartExpr | ( | ) | const |
Returns the start linear expression.
Note that this rebuilds the expression each time this method is called.
◆ WithName()
| IntervalVar WithName | ( | const std::string & | name | ) |
Sets the name of the variable.
The documentation for this class was generated from the following file: