DotNet Reference

DotNet Reference

IntervalVariables.cs
Go to the documentation of this file.
1 // Copyright 2010-2018 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 {
21  public IntervalVar(CpModelProto model,
22  int start_index, int size_index, int end_index,
23  int is_present_index, string name) {
24  model_ = model;
25  index_ = model.Constraints.Count;
26  interval_ = new IntervalConstraintProto();
27  interval_.Start = start_index;
28  interval_.Size = size_index;
29  interval_.End = end_index;
30 
32  ct.Interval = interval_;
33  ct.Name = name;
34  ct.EnforcementLiteral.Add(is_present_index);
35  model.Constraints.Add(ct);
36  }
37 
38  public IntervalVar(CpModelProto model,
39  int start_index, int size_index, int end_index,
40  string name) {
41  model_ = model;
42  index_ = model.Constraints.Count;
43  interval_ = new IntervalConstraintProto();
44  interval_.Start = start_index;
45  interval_.Size = size_index;
46  interval_.End = end_index;
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  get { return interval_; }
61  set { interval_ = value; }
62  }
63 
64  public override string ToString()
65  {
66  return model_.Constraints[index_].ToString();
67  }
68 
69  public string Name()
70  {
71  return model_.Constraints[index_].Name;
72  }
73 
74  private CpModelProto model_;
75  private int index_;
76  private IntervalConstraintProto interval_;
77 }
78 
79 } // namespace Google.OrTools.Sat
override string ToString()
pbc::RepeatedField< int > EnforcementLiteral
The constraint will be enforced iff all literals listed here are true.
Definition: CpModel.pb.cs:3711
int End
Definition: CpModel.pb.cs:1557
string Name
For debug/logging only.
Definition: CpModel.pb.cs:3682
int Size
Definition: CpModel.pb.cs:1568
int GetIndex()
This "special" constraint not only enforces (start + size == end) but can also be referred by other c...
Definition: CpModel.pb.cs:1506
A constraint programming problem.
Definition: CpModel.pb.cs:5663
IntervalVar(CpModelProto model, int start_index, int size_index, int end_index, int is_present_index, string name)
IntervalConstraintProto Proto
int Start
Definition: CpModel.pb.cs:1546
Next id: 29
Definition: CpModel.pb.cs:3562
pbc::RepeatedField< global::Google.OrTools.Sat.ConstraintProto > Constraints
Definition: CpModel.pb.cs:5736
IntervalVar(CpModelProto model, int start_index, int size_index, int end_index, string name)
string Name()
global::Google.OrTools.Sat.IntervalConstraintProto?? Interval
The interval constraint takes a start, end, and size, and forces start + size == end.
Definition: CpModel.pb.cs:4040
Definition: CpModel.pb.cs:12