Class IntervalVar
- Namespace
- OptalCP
- Assembly
- OptalCP.dll
Interval (task) variable for scheduling. Has start, end, length, and optional presence.
public class IntervalVar : ModelElement
- Inheritance
-
IntervalVar
- Inherited Members
Remarks
Interval variable is a task, action, operation, or any other interval with a start and an end. The start and the end of the interval are unknowns that the solver has to find. They could be accessed as integer expressions using IntervalVar.Start and IntervalVar.End. or using Model.Start and Model.End. In addition to the start and the end of the interval, the interval variable has a length (equal to end - start) that can be accessed using IntervalVar.Length or Model.Length.
The interval variable can be optional. In this case, the solver can decide to make the interval absent, which is usually interpreted as the fact that the interval doesn't exist, the task/action was not executed, or the operation was not performed. When the interval variable is absent, its start, end, and length are also absent. A boolean expression that represents the presence of the interval variable can be accessed using IntervalVar.Presence and Model.Presence.
Interval variables can be created using the function
Model.IntervalVar.
By default, interval variables are present (not optional).
To create an optional interval, specify optional: true in the
arguments of the function.
Example:
x, y and z
and we make sure that they don't overlap. Then, we minimize the maximum of
the end times of the three intervals (the makespan):
var model = new Model();
var x = model.IntervalVar(length: 10, name: "x");
var y = model.IntervalVar(length: 10, name: "y");
var z = model.IntervalVar(length: 10, name: "z");
model.NoOverlap(new[] { x, y, z });
model.Minimize(model.Max(new[] { x.End(), y.End(), z.End() }));
var result = model.Solve();
Example:
X represents the task.
It is not optional because the task X is mandatory. Interval variable
XA represents the task X when performed by worker A and
similarly XB represents the task X when performed by worker B.
Both XA and XB are optional because it is not known beforehand which
worker will perform the task. The constraint IntervalVar.Alternative links
X, XA and XB together and ensures that only one of XA and XB is present and that
X and the present interval are equal.
var model = new Model();
var X = model.IntervalVar(length: 10, name: "X");
var XA = model.IntervalVar(name: "XA", optional: true);
var XB = model.IntervalVar(name: "XB", optional: true);
model.Alternative(X, new[] { XA, XB });
var result = model.Solve();
Variables XA and XB can be used elsewhere in the model, e.g. to make sure
that each worker is assigned to at most one task at a time:
// Tasks of worker A don't overlap:
model.NoOverlap(new[] { XA /* ... other Worker A tasks */ });
// Tasks of worker B don't overlap:
model.NoOverlap(new[] { XB /* ... other Worker B tasks */ });
Properties
EndMax
The maximum end time of the interval variable.
public int EndMax { get; set; }
Property Value
Remarks
Gets or sets the maximum end time of the interval variable.
The initial value is set during construction by Model.IntervalVar.
Note: This property reflects the interval's domain in the model (before the solve), not in the solution.
The value must be in the range Model.IntervalMin to Model.IntervalMax.
Example:
var model = new Model();
var task = model.IntervalVar(length: 10, name: "task");
task.EndMax = 100;
Console.WriteLine(task.EndMax); // 100
See also:
EndMin
The minimum end time of the interval variable.
public int EndMin { get; set; }
Property Value
Remarks
Gets or sets the minimum end time of the interval variable.
The initial value is set during construction by Model.IntervalVar.
Note: This property reflects the interval's domain in the model (before the solve), not in the solution.
The value must be in the range Model.IntervalMin to Model.IntervalMax.
Example:
var model = new Model();
var task = model.IntervalVar(length: 10, name: "task");
Console.WriteLine(task.EndMin); // 10 (StartMin + length)
task.EndMin = 20;
Console.WriteLine(task.EndMin); // 20
See also:
LengthMax
The maximum length of the interval variable.
public int LengthMax { get; set; }
Property Value
Remarks
Gets or sets the maximum length of the interval variable.
The initial value is set during construction by Model.IntervalVar.
Note: This property reflects the interval's domain in the model (before the solve), not in the solution.
The value must be in the range 0 to Model.LengthMax.
Example:
var model = new Model();
var task = model.IntervalVar(length: 10, name: "task");
Console.WriteLine(task.LengthMax); // 10
task.LengthMax = 20;
Console.WriteLine(task.LengthMax); // 20
See also:
LengthMin
The minimum length of the interval variable.
public int LengthMin { get; set; }
Property Value
Remarks
Gets or sets the minimum length of the interval variable.
The initial value is set during construction by Model.IntervalVar.
Note: This property reflects the interval's domain in the model (before the solve), not in the solution.
The value must be in the range 0 to Model.LengthMax.
Example:
var model = new Model();
var task = model.IntervalVar(length: 10, name: "task");
Console.WriteLine(task.LengthMin); // 10
task.LengthMin = 5;
Console.WriteLine(task.LengthMin); // 5
See also:
Optional
Whether the interval variable is optional.
public bool Optional { get; set; }
Property Value
Remarks
Gets or sets whether the interval variable is optional:
True/ true: The interval is optional - the solver decides whether it is present or absent in the solution.False/ false: The interval is present - it must be scheduled in the solution.
To force an interval to be absent, make it optional and constrain its presence
to be false: model.enforce(~x.presence()) (Python),
model.enforce(x.presence().not()) (TypeScript), or
model.Enforce(!x.Presence()) (C#).
Note: This property reflects the presence status in the model (before the solve), not in the solution.
Example:
var model = new Model();
var task1 = model.IntervalVar(length: 10, name: "task1");
var task2 = model.IntervalVar(length: 10, optional: true, name: "task2");
Console.WriteLine(task1.Optional); // False (present by default)
Console.WriteLine(task2.Optional); // True (optional)
// Make task1 optional
task1.Optional = true;
Console.WriteLine(task1.Optional); // True
See also:
StartMax
The maximum start time of the interval variable.
public int StartMax { get; set; }
Property Value
Remarks
Gets or sets the maximum start time of the interval variable.
The initial value is set during construction by Model.IntervalVar.
Note: This property reflects the interval's domain in the model (before the solve), not in the solution.
The value must be in the range Model.IntervalMin to Model.IntervalMax.
Example:
var model = new Model();
var task = model.IntervalVar(length: 10, name: "task");
task.StartMax = 100;
Console.WriteLine(task.StartMax); // 100
See also:
StartMin
The minimum start time of the interval variable.
public int StartMin { get; set; }
Property Value
Remarks
Gets or sets the minimum start time of the interval variable.
The initial value is set during construction by Model.IntervalVar.
Note: This property reflects the interval's domain in the model (before the solve), not in the solution.
The value must be in the range Model.IntervalMin to Model.IntervalMax.
Example:
var model = new Model();
var task = model.IntervalVar(length: 10, name: "task");
Console.WriteLine(task.StartMin); // 0 (default)
task.StartMin = 5;
Console.WriteLine(task.StartMin); // 5
See also:
Methods
Alternative(IEnumerable<IntervalVar>)
Creates alternative constraints for the interval variable and provided options.
public Constraint Alternative(IEnumerable<IntervalVar> options)
Parameters
optionsIEnumerable<IntervalVar>The interval variables to choose from.
Returns
- Constraint
The alternative constraint.
Remarks
The alternative constraint requires that exactly one of the options intervals
is present when self is present. The selected option must have the same
start, end, and length as self. If self is absent, all options must be absent.
This is useful for modeling choices, such as assigning a task to one of several machines, where each option represents the task executed on a different machine.
This constraint is equivalent to Model.Alternative with self as the main interval.
End()
Creates an integer expression for the end time of the interval variable.
public IntExpr End()
Returns
- IntExpr
The resulting integer expression
Remarks
If the interval variable is absent, then the resulting expression is also absent.
Example:
y to start after the end of x with a delay of at least 10. In addition, we constrain the length of x to be less or equal to the length of y.
var model = new Model();
var x = model.IntervalVar(name: "x");
var y = model.IntervalVar(name: "y");
model.Enforce(x.End() + 10 <= y.Start());
model.Enforce(x.Length() <= y.Length());
When x or y is absent then value of both constraints above is absent and therefore they are satisfied.
See also:
EndAtEnd(IntervalVar, IntExpr)
Creates a precedence constraint between two interval variables.
public Constraint EndAtEnd(IntervalVar successor, IntExpr delay)
Parameters
successorIntervalVarThe successor interval variable.
delayIntExprThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.End() + delay == successor.End())
In other words, end of predecessor plus delay must be equal to end of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.EndAtEnd — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
EndAtEnd(IntervalVar, int)
Creates a precedence constraint between two interval variables.
public Constraint EndAtEnd(IntervalVar successor, int delay = 0)
Parameters
successorIntervalVarThe successor interval variable.
delayintThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.End() + delay == successor.End())
In other words, end of predecessor plus delay must be equal to end of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.EndAtEnd — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
EndAtStart(IntervalVar, IntExpr)
Creates a precedence constraint between two interval variables.
public Constraint EndAtStart(IntervalVar successor, IntExpr delay)
Parameters
successorIntervalVarThe successor interval variable.
delayIntExprThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.End() + delay == successor.Start())
In other words, end of predecessor plus delay must be equal to start of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.EndAtStart — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
EndAtStart(IntervalVar, int)
Creates a precedence constraint between two interval variables.
public Constraint EndAtStart(IntervalVar successor, int delay = 0)
Parameters
successorIntervalVarThe successor interval variable.
delayintThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.End() + delay == successor.Start())
In other words, end of predecessor plus delay must be equal to start of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.EndAtStart — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
EndBeforeEnd(IntervalVar, IntExpr)
Creates a precedence constraint between two interval variables.
public Constraint EndBeforeEnd(IntervalVar successor, IntExpr delay)
Parameters
successorIntervalVarThe successor interval variable.
delayIntExprThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.End() + delay <= successor.End())
In other words, end of predecessor plus delay must be less than or equal to end of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.EndBeforeEnd — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
EndBeforeEnd(IntervalVar, int)
Creates a precedence constraint between two interval variables.
public Constraint EndBeforeEnd(IntervalVar successor, int delay = 0)
Parameters
successorIntervalVarThe successor interval variable.
delayintThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.End() + delay <= successor.End())
In other words, end of predecessor plus delay must be less than or equal to end of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.EndBeforeEnd — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
EndBeforeStart(IntervalVar, IntExpr)
Creates a precedence constraint between two interval variables.
public Constraint EndBeforeStart(IntervalVar successor, IntExpr delay)
Parameters
successorIntervalVarThe successor interval variable.
delayIntExprThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.End() + delay <= successor.Start())
In other words, end of predecessor plus delay must be less than or equal to start of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.EndBeforeStart — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
EndBeforeStart(IntervalVar, int)
Creates a precedence constraint between two interval variables.
public Constraint EndBeforeStart(IntervalVar successor, int delay = 0)
Parameters
successorIntervalVarThe successor interval variable.
delayintThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.End() + delay <= successor.Start())
In other words, end of predecessor plus delay must be less than or equal to start of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.EndBeforeStart — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
ForbidEnd(IntStepFunction)
Constrains the end of an interval variable to not coincide with zero segments of a step function.
public Constraint ForbidEnd(IntStepFunction func)
Parameters
funcIntStepFunctionThe step function whose zero segments define forbidden end times.
Returns
- Constraint
The constraint forbidding the end point.
Remarks
This function is equivalent to:
I.e., the function value at the end of the interval variable cannot be zero.
@example A delivery task that must complete during business hours (not during lunch break):
var model = new Model();
// A 1-hour delivery task
var delivery = model.IntervalVar(length: 1, name: "delivery");
// Allowed end times: 1 = allowed, 0 = forbidden
var allowedEnds = model.StepFunction(new[] {
(0, 0), // Before 9h: forbidden
(9, 1), // 9h: business opens, allowed
(12, 0), // 12h: lunch break, forbidden
(13, 1), // 13h: lunch ends, allowed
(17, 0), // 17h: business closes, forbidden
});
// Delivery cannot end when allowedEnds is 0
delivery.ForbidEnd(allowedEnds);
model.Minimize(delivery.End());
var result = model.Solve();
// Delivery ends at 9 (starts at 8, ends at earliest allowed time)
See also:
- Model.ForbidEnd — for the equivalent function on Model.
- Model.ForbidStart — for similar function that constrains start an interval variable.
- Model.Eval — for evaluation of a step function.
ForbidExtent(IntStepFunction)
This function prevents the specified interval variable from overlapping with segments of the step function where the value is zero.
public Constraint ForbidExtent(IntStepFunction func)
Parameters
funcIntStepFunctionThe step function.
Returns
- Constraint
The constraint forbidding the extent (entire interval).
Remarks
This function prevents the specified interval variable from overlapping with segments of the step function where the value is zero. I.e., if \([s, e)\) is a segment of the step function where the value is zero, then the interval variable either ends before \(s\) (\(\mathtt{interval.end()} \le s\)) or starts after \(e\) (\(e \le \mathtt{interval.start()}\)).
@example A production task that cannot overlap with scheduled maintenance windows:
var model = new Model();
// A 3-hour production run
var production = model.IntervalVar(length: 3, name: "production");
// Machine availability: 1 = available, 0 = under maintenance
var availability = model.StepFunction(new[] {
(0, 1), // Initially available
(8, 0), // 8h: maintenance starts
(10, 1), // 10h: maintenance ends
});
// Production cannot overlap periods where availability is 0
production.ForbidExtent(availability);
model.Minimize(production.End());
var result = model.Solve();
// Production runs [0, 3) - finishes before maintenance window
See also:
- Model.ForbidExtent — for the equivalent function on Model.
- Model.ForbidStart — for similar functions that constrain the start/end of an interval variable.
- Model.ForbidEnd — for similar functions that constrain the start/end of an interval variable.
- Model.Eval — for evaluation of a step function.
ForbidStart(IntStepFunction)
Constrains the start of an interval variable to not coincide with zero segments of a step function.
public Constraint ForbidStart(IntStepFunction func)
Parameters
funcIntStepFunctionThe step function whose zero segments define forbidden start times.
Returns
- Constraint
The constraint forbidding the start point.
Remarks
This function is equivalent to:
I.e., the function value at the start of the interval variable cannot be zero.
@example A factory task that can only start during work hours (excluding breaks):
var model = new Model();
// A 2-hour task on a machine
var task = model.IntervalVar(length: 2, name: "task");
// Allowed start times: 1 = allowed, 0 = forbidden
var allowedStarts = model.StepFunction(new[] {
(0, 0), // Before 6h: forbidden
(6, 1), // 6h: shift starts, allowed
(10, 0), // 10h: break, forbidden
(11, 1), // 11h: break ends, allowed
(14, 0), // 14h: shift ends, forbidden
});
// Task cannot start when allowedStarts is 0
task.ForbidStart(allowedStarts);
model.Minimize(task.Start());
var result = model.Solve();
// Task starts at 6 (earliest allowed start time)
See also:
- Model.ForbidStart — for the equivalent function on Model.
- Model.ForbidEnd — for similar function that constrains end an interval variable.
- Model.Eval — for evaluation of a step function.
Length()
Creates an integer expression for the duration (end - start) of the interval variable.
public IntExpr Length()
Returns
- IntExpr
The resulting integer expression
Remarks
If the interval variable is absent, then the resulting expression is also absent.
Example:
y to start after the end of x with a delay of at least 10. In addition, we constrain the length of x to be less or equal to the length of y.
var model = new Model();
var x = model.IntervalVar(name: "x");
var y = model.IntervalVar(name: "y");
model.Enforce(x.End() + 10 <= y.Start());
model.Enforce(x.Length() <= y.Length());
When x or y is absent then value of both constraints above is absent and therefore they are satisfied.
See also:
- Model.Length — is equivalent function on Model.
Position(SequenceVar)
Creates an expression equal to the position of the interval on the sequence.
public IntExpr Position(SequenceVar sequence)
Parameters
sequenceSequenceVarThe sequence variable.
Returns
- IntExpr
The resulting integer expression
Remarks
Returns an integer expression representing the 0-based position of this interval in the given sequence. The position reflects the order in which intervals appear after applying the SequenceVar.NoOverlap constraint.
If this interval is absent, the position expression is also absent.
This method is equivalent to Model.Position with self as the interval.
Presence()
Creates a Boolean expression which is true if the interval variable is present.
public BoolExpr Presence()
Returns
- BoolExpr
A Boolean expression that is true if the interval variable is present in the solution.
Remarks
The resulting expression is never absent: it is true if the interval variable is present and false if the interval variable is absent.
This function is the same as Model.Presence, see its documentation for more details.
Example:
x and y must have the same presence status.
I.e. they must either be both *present* or both *absent*.
var model = new Model();
var x = model.IntervalVar(name: "x", optional: true, length: 10);
var y = model.IntervalVar(name: "y", optional: true, length: 10);
model.Enforce(x.Presence() == y.Presence());
See also:
- Model.Presence — is the equivalent function on Model.
Pulse(IntExpr)
Creates cumulative function (expression) pulse for the interval variable and specified height.
public CumulExpr Pulse(IntExpr height)
Parameters
heightIntExprThe height value.
Returns
- CumulExpr
The resulting cumulative expression
Remarks
Limitation: The height must be non-negative. Pulses with negative height are not supported.
This function is the same as Model.Pulse.
Example:
var task = model.IntervalVar(name: "task", length: 10);
var pulse = task.Pulse(5);
See also:
- Model.Pulse — for detailed documentation and examples.
Pulse(int)
Creates cumulative function (expression) pulse for the interval variable and specified height.
public CumulExpr Pulse(int height)
Parameters
heightintThe height value.
Returns
- CumulExpr
The resulting cumulative expression
Remarks
Limitation: The height must be non-negative. Pulses with negative height are not supported.
This function is the same as Model.Pulse.
Example:
var task = model.IntervalVar(name: "task", length: 10);
var pulse = task.Pulse(5);
See also:
- Model.Pulse — for detailed documentation and examples.
Span(IEnumerable<IntervalVar>)
Constrains the interval variable to span (cover) a set of other interval variables.
public Constraint Span(IEnumerable<IntervalVar> covered)
Parameters
coveredIEnumerable<IntervalVar>The set of interval variables to cover.
Returns
- Constraint
The span constraint.
Remarks
The span constraint ensures that self exactly covers all present intervals
in covered. Specifically, self starts at the minimum start time and ends
at the maximum end time of the present covered intervals. If all covered
intervals are absent, self must also be absent.
This is useful for modeling composite tasks or projects where a parent interval represents the overall duration of multiple sub-tasks.
This constraint is equivalent to Model.Span with self as the spanning interval.
Start()
Creates an integer expression for the start time of the interval variable.
public IntExpr Start()
Returns
- IntExpr
The resulting integer expression
Remarks
If the interval variable is absent, then the resulting expression is also absent.
Example:
y to start after the end of x with a delay of at least 10. In addition, we constrain the length of x to be less or equal to the length of y.
var model = new Model();
var x = model.IntervalVar(name: "x");
var y = model.IntervalVar(name: "y");
model.Enforce(x.End() + 10 <= y.Start());
model.Enforce(x.Length() <= y.Length());
When x or y is absent then value of both constraints above is absent and therefore they are satisfied.
See also:
- Model.Start — is equivalent function on Model.
StartAtEnd(IntervalVar, IntExpr)
Creates a precedence constraint between two interval variables.
public Constraint StartAtEnd(IntervalVar successor, IntExpr delay)
Parameters
successorIntervalVarThe successor interval variable.
delayIntExprThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.Start() + delay == successor.End())
In other words, start of predecessor plus delay must be equal to end of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.StartAtEnd — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
StartAtEnd(IntervalVar, int)
Creates a precedence constraint between two interval variables.
public Constraint StartAtEnd(IntervalVar successor, int delay = 0)
Parameters
successorIntervalVarThe successor interval variable.
delayintThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.Start() + delay == successor.End())
In other words, start of predecessor plus delay must be equal to end of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.StartAtEnd — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
StartAtStart(IntervalVar, IntExpr)
Creates a precedence constraint between two interval variables.
public Constraint StartAtStart(IntervalVar successor, IntExpr delay)
Parameters
successorIntervalVarThe successor interval variable.
delayIntExprThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.Start() + delay == successor.Start())
In other words, start of predecessor plus delay must be equal to start of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.StartAtStart — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
StartAtStart(IntervalVar, int)
Creates a precedence constraint between two interval variables.
public Constraint StartAtStart(IntervalVar successor, int delay = 0)
Parameters
successorIntervalVarThe successor interval variable.
delayintThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.Start() + delay == successor.Start())
In other words, start of predecessor plus delay must be equal to start of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.StartAtStart — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
StartBeforeEnd(IntervalVar, IntExpr)
Creates a precedence constraint between two interval variables.
public Constraint StartBeforeEnd(IntervalVar successor, IntExpr delay)
Parameters
successorIntervalVarThe successor interval variable.
delayIntExprThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.Start() + delay <= successor.End())
In other words, start of predecessor plus delay must be less than or equal to end of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.StartBeforeEnd — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
StartBeforeEnd(IntervalVar, int)
Creates a precedence constraint between two interval variables.
public Constraint StartBeforeEnd(IntervalVar successor, int delay = 0)
Parameters
successorIntervalVarThe successor interval variable.
delayintThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.Start() + delay <= successor.End())
In other words, start of predecessor plus delay must be less than or equal to end of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.StartBeforeEnd — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
StartBeforeStart(IntervalVar, IntExpr)
Creates a precedence constraint between two interval variables.
public Constraint StartBeforeStart(IntervalVar successor, IntExpr delay)
Parameters
successorIntervalVarThe successor interval variable.
delayIntExprThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.Start() + delay <= successor.Start())
In other words, start of predecessor plus delay must be less than or equal to start of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.StartBeforeStart — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
StartBeforeStart(IntervalVar, int)
Creates a precedence constraint between two interval variables.
public Constraint StartBeforeStart(IntervalVar successor, int delay = 0)
Parameters
successorIntervalVarThe successor interval variable.
delayintThe minimum delay between intervals.
Returns
- Constraint
The precedence constraint.
Remarks
Assuming that the current interval is predecessor, the constraint is the same as:
model.Enforce(predecessor.Start() + delay <= successor.Start())
In other words, start of predecessor plus delay must be less than or equal to start of successor.
When one of the two interval variables is absent, then the constraint is satisfied.
See also:
- Model.StartBeforeStart — is equivalent function on Model.
- IntervalVar.Start
- IntervalVar.End
StepAtEnd(IntExpr)
Creates cumulative function (expression) that changes value at end of the interval variable by the given height.
public CumulExpr StepAtEnd(IntExpr height)
Parameters
heightIntExprThe height value.
Returns
- CumulExpr
The resulting cumulative expression
Remarks
Creates cumulative function (expression) that changes value at end of the interval variable by the given height.
This function is the same as Model.StepAtEnd.
Example:
var task = model.IntervalVar(name: "task", length: 10);
var step = task.StepAtEnd(5);
See also:
- Model.StepAtEnd — for detailed documentation.
- IntervalVar.StepAtStart — for the opposite function.
StepAtEnd(int)
Creates cumulative function (expression) that changes value at end of the interval variable by the given height.
public CumulExpr StepAtEnd(int height)
Parameters
heightintThe height value.
Returns
- CumulExpr
The resulting cumulative expression
Remarks
Creates cumulative function (expression) that changes value at end of the interval variable by the given height.
This function is the same as Model.StepAtEnd.
Example:
var task = model.IntervalVar(name: "task", length: 10);
var step = task.StepAtEnd(5);
See also:
- Model.StepAtEnd — for detailed documentation.
- IntervalVar.StepAtStart — for the opposite function.
StepAtStart(IntExpr)
Creates cumulative function (expression) that changes value at start of the interval variable by the given height.
public CumulExpr StepAtStart(IntExpr height)
Parameters
heightIntExprThe height value.
Returns
- CumulExpr
The resulting cumulative expression
Remarks
Creates cumulative function (expression) that changes value at start of the interval variable by the given height.
This function is the same as Model.StepAtStart.
Example:
var task = model.IntervalVar(name: "task", length: 10);
var step = task.StepAtStart(5);
See also:
- Model.StepAtStart — for detailed documentation.
- IntervalVar.StepAtEnd — for the opposite function.
StepAtStart(int)
Creates cumulative function (expression) that changes value at start of the interval variable by the given height.
public CumulExpr StepAtStart(int height)
Parameters
heightintThe height value.
Returns
- CumulExpr
The resulting cumulative expression
Remarks
Creates cumulative function (expression) that changes value at start of the interval variable by the given height.
This function is the same as Model.StepAtStart.
Example:
var task = model.IntervalVar(name: "task", length: 10);
var step = task.StepAtStart(5);
See also:
- Model.StepAtStart — for detailed documentation.
- IntervalVar.StepAtEnd — for the opposite function.