DotNet Reference

.Net 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, int start_index, int size_index, int end_index, int is_present_index,
22  string name)
23  {
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 
31  ConstraintProto ct = new ConstraintProto();
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, int start_index, int size_index, int end_index, string name)
39  {
40  model_ = model;
41  index_ = model.Constraints.Count;
42  interval_ = new IntervalConstraintProto();
43  interval_.Start = start_index;
44  interval_.Size = size_index;
45  interval_.End = end_index;
46 
47  ConstraintProto ct = new ConstraintProto();
48  ct.Interval = interval_;
49  ct.Name = name;
50  model_.Constraints.Add(ct);
51  }
52 
53  public int GetIndex()
54  {
55  return index_;
56  }
57 
58  public IntervalConstraintProto Proto
59  {
60  get {
61  return interval_;
62  }
63  set {
64  interval_ = value;
65  }
66  }
67 
68  public override string ToString()
69  {
70  return model_.Constraints[index_].ToString();
71  }
72 
73  public string Name()
74  {
75  return model_.Constraints[index_].Name;
76  }
77 
78  private CpModelProto model_;
79  private int index_;
80  private IntervalConstraintProto interval_;
81  }
82 
83 } // namespace Google.OrTools.Sat
using System
Definition: Program.cs:14
IntervalVar(CpModelProto model, int start_index, int size_index, int end_index, int is_present_index, string name)
IntervalConstraintProto Proto
IntervalVar(CpModelProto model, int start_index, int size_index, int end_index, string name)