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 {
16  using System;
17  using System.Collections.Generic;
18 
19  public 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_.StartView = start;
28  interval_.SizeView = size;
29  interval_.EndView = 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_.StartView = start;
45  interval_.SizeView = size;
46  interval_.EndView = 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  {
61  get {
62  return interval_;
63  }
64  set {
65  interval_ = value;
66  }
67  }
68 
69  public override string ToString()
70  {
71  return model_.Constraints[index_].ToString();
72  }
73 
74  public string Name()
75  {
76  return model_.Constraints[index_].Name;
77  }
78 
79  private CpModelProto model_;
80  private int index_;
81  private IntervalConstraintProto interval_;
82  }
83 
84 } // namespace Google.OrTools.Sat
Some constraints supports linear expression instead of just using a reference to a variable.
Definition: CpModel.pb.cs:909
global::Google.OrTools.Sat.IntervalConstraintProto?? Interval
The interval constraint takes a start, end, and size, and forces start + size == end.
Definition: CpModel.pb.cs:5680
string Name
For debug/logging only.
Definition: CpModel.pb.cs:5272
pbc::RepeatedField< int > EnforcementLiteral
The constraint will be enforced iff all literals listed here are true.
Definition: CpModel.pb.cs:5302
This "special" constraint not only enforces (start + size == end) and (size >= 0) but can also be ref...
Definition: CpModel.pb.cs:2071
pbc::RepeatedField< global::Google.OrTools.Sat.ConstraintProto > Constraints
Definition: CpModel.pb.cs:8853
global::Google.OrTools.Sat.LinearExpressionProto SizeView
Definition: CpModel.pb.cs:2203
global::Google.OrTools.Sat.LinearExpressionProto StartView
EXPERIMENTAL: This will become the new way to specify an interval.
Definition: CpModel.pb.cs:2179
A constraint programming problem.
Definition: CpModel.pb.cs:8766
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)
global::Google.OrTools.Sat.LinearExpressionProto EndView
Definition: CpModel.pb.cs:2191