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 
14 namespace Google.OrTools.Sat
15 {
23 public class IntervalVar
24 {
26  LinearExpressionProto end, int is_present_index, string name)
27  {
28  model_ = model;
29  index_ = model.Constraints.Count;
30  interval_ = new IntervalConstraintProto();
31  interval_.Start = start;
32  interval_.Size = size;
33  interval_.End = end;
34 
36  ct.Interval = interval_;
37  ct.Name = name;
38  ct.EnforcementLiteral.Capacity = 1;
39  ct.EnforcementLiteral.Add(is_present_index);
40  model.Constraints.Add(ct);
41  }
42 
44  LinearExpressionProto end, string name)
45  {
46  model_ = model;
47  index_ = model.Constraints.Count;
48  interval_ = new IntervalConstraintProto();
49  interval_.Start = start;
50  interval_.Size = size;
51  interval_.End = end;
52 
54  ct.Interval = interval_;
55  ct.Name = name;
56  model_.Constraints.Add(ct);
57  }
58 
60  public int GetIndex()
61  {
62  return index_;
63  }
64 
67  {
69  }
70 
73  {
75  }
76 
79  {
81  }
82 
85  {
86  get {
87  return interval_;
88  }
89  set {
90  interval_ = value;
91  }
92  }
93 
94  public override string ToString()
95  {
96  return model_.Constraints[index_].ToString();
97  }
98 
99  public string Name()
100  {
101  return model_.Constraints[index_].Name;
102  }
103 
104  private CpModelProto model_;
105  private int index_;
106  private IntervalConstraintProto interval_;
107 }
108 
109 } // namespace Google.OrTools.Sat
Some constraints supports linear expression instead of just using a reference to a variable.
Definition: CpModel.pb.cs:695
global::Google.OrTools.Sat.IntervalConstraintProto?? Interval
The interval constraint takes a start, end, and size, and forces start + size == end.
Definition: CpModel.pb.cs:5252
LinearExpr StartExpr()
The start expression of the interval
string Name
For debug/logging only.
Definition: CpModel.pb.cs:4893
pbc::RepeatedField< int > EnforcementLiteral
The constraint will be enforced iff all literals listed here are true.
Definition: CpModel.pb.cs:4923
This is not really a constraint.
Definition: CpModel.pb.cs:1863
global::Google.OrTools.Sat.LinearExpressionProto End
Definition: CpModel.pb.cs:1926
pbc::RepeatedField< global::Google.OrTools.Sat.ConstraintProto > Constraints
Definition: CpModel.pb.cs:8727
LinearExpr EndExpr()
The end expression of the interval
global::Google.OrTools.Sat.LinearExpressionProto Size
Definition: CpModel.pb.cs:1938
A constraint programming problem.
Definition: CpModel.pb.cs:8639
int GetIndex()
The Index of the interval in the model proto
Holds a linear expression: sum (ai * xi) + b.
IntervalConstraintProto Proto
The underlying interval 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)
global::Google.OrTools.Sat.LinearExpressionProto Start
Definition: CpModel.pb.cs:1914
static LinearExpr RebuildLinearExprFromLinearExpressionProto(LinearExpressionProto proto, CpModelProto model)
LinearExpr SizeExpr()
The size expression of the interval