DotNet Reference

.Net Reference

IntervalVariables.cs
Go to the documentation of this file.
1// Copyright 2010-2021 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14namespace Google.OrTools.Sat
15{
16using System;
17using System.Collections.Generic;
18
19public class IntervalVar
20{
22 LinearExpressionProto end, int is_present_index, string name)
23 {
24 model_ = model;
25 index_ = model.Constraints.Count;
26 interval_ = new IntervalConstraintProto();
27 interval_.Start = start;
28 interval_.Size = size;
29 interval_.End = end;
30
32 ct.Interval = interval_;
33 ct.Name = name;
34 ct.EnforcementLiteral.Add(is_present_index);
35 model.Constraints.Add(ct);
36 }
37
39 LinearExpressionProto end, string name)
40 {
41 model_ = model;
42 index_ = model.Constraints.Count;
43 interval_ = new IntervalConstraintProto();
44 interval_.Start = start;
45 interval_.Size = size;
46 interval_.End = end;
47
49 ct.Interval = interval_;
50 ct.Name = name;
51 model_.Constraints.Add(ct);
52 }
53
54 public int GetIndex()
55 {
56 return index_;
57 }
58
60 {
62 }
63
65 {
67 }
68
70 {
72 }
73
75 {
76 get {
77 return interval_;
78 }
79 set {
80 interval_ = value;
81 }
82 }
83
84 public override string ToString()
85 {
86 return model_.Constraints[index_].ToString();
87 }
88
89 public string Name()
90 {
91 return model_.Constraints[index_].Name;
92 }
93
94 private CpModelProto model_;
95 private int index_;
96 private IntervalConstraintProto interval_;
97}
98
99} // namespace Google.OrTools.Sat
pbc::RepeatedField< int > EnforcementLiteral
The constraint will be enforced iff all literals listed here are true.
Definition: CpModel.pb.cs:4925
string Name
For debug/logging only.
Definition: CpModel.pb.cs:4895
global::Google.OrTools.Sat.IntervalConstraintProto?? Interval
The interval constraint takes a start, end, and size, and forces start + size == end.
Definition: CpModel.pb.cs:5254
A constraint programming problem.
Definition: CpModel.pb.cs:8645
pbc::RepeatedField< global::Google.OrTools.Sat.ConstraintProto > Constraints
Definition: CpModel.pb.cs:8729
This "special" constraint not only enforces (start + size == end) and (size >= 0) but can also be ref...
Definition: CpModel.pb.cs:1859
global::Google.OrTools.Sat.LinearExpressionProto Size
Definition: CpModel.pb.cs:1940
global::Google.OrTools.Sat.LinearExpressionProto End
Definition: CpModel.pb.cs:1928
global::Google.OrTools.Sat.LinearExpressionProto Start
IMPORTANT: For now, this constraint do not enforce any relations on the view, and a linear constraint...
Definition: CpModel.pb.cs:1916
IntervalConstraintProto Proto
IntervalVar(CpModelProto model, LinearExpressionProto start, LinearExpressionProto size, LinearExpressionProto end, int is_present_index, string name)
IntervalVar(CpModelProto model, LinearExpressionProto start, LinearExpressionProto size, LinearExpressionProto end, string name)
static LinearExpr RebuildLinearExprFromLinearExpressionProto(LinearExpressionProto proto, CpModelProto model)
Some constraints supports linear expression instead of just using a reference to a variable.
Definition: CpModel.pb.cs:699