OR-Tools 7.2
Main Page
Namespaces
Classes
Files
File List
File Members
ortools
sat
csharp
Constraints.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
Constraint
20
{
21
public
Constraint
(
CpModelProto
model)
22
{
23
index_ = model.
Constraints
.Count;
24
constraint_ =
new
ConstraintProto
();
25
model.
Constraints
.Add(constraint_);
26
}
27
28
public
void
OnlyEnforceIf
(
ILiteral
lit)
29
{
30
constraint_.
EnforcementLiteral
.Add(lit.
GetIndex
());
31
}
32
33
public
void
OnlyEnforceIf
(
ILiteral
[] lits)
34
{
35
foreach
(
ILiteral
lit
in
lits) {
36
constraint_.
EnforcementLiteral
.Add(lit.
GetIndex
());
37
}
38
}
39
40
public
int
Index
41
{
42
get
{
return
index_; }
43
}
44
45
public
ConstraintProto
Proto
46
{
47
get
{
return
constraint_; }
48
set
{ constraint_ = value; }
49
}
50
51
private
int
index_;
52
private
ConstraintProto
constraint_;
53
}
54
55
}
// namespace Google.OrTools.Sat
Google.OrTools.Sat.Constraint.Index
int Index
Definition:
Constraints.cs:41
Google.OrTools.Sat.Constraint.Constraint
Constraint(CpModelProto model)
Definition:
Constraints.cs:21
Google.OrTools.Sat.Constraint.Proto
ConstraintProto Proto
Definition:
Constraints.cs:46
Google.OrTools.Sat.ConstraintProto.EnforcementLiteral
pbc::RepeatedField< int > EnforcementLiteral
The constraint will be enforced iff all literals listed here are true.
Definition:
CpModel.pb.cs:3329
Google.OrTools.Sat.ILiteral
Definition:
IntegerExpressions.cs:42
Google.OrTools.Sat.ILiteral.GetIndex
int GetIndex()
Google.OrTools.Sat.Constraint
Definition:
Constraints.cs:19
Google.OrTools.Sat.CpModelProto.Constraints
pbc::RepeatedField< global::Google.OrTools.Sat.ConstraintProto > Constraints
Definition:
CpModel.pb.cs:5270
Collections
Google.OrTools.Sat.CpModelProto
A constraint programming problem.
Definition:
CpModel.pb.cs:5198
Google.OrTools.Sat.ConstraintProto
Next id: 27
Definition:
CpModel.pb.cs:3186
Google.OrTools.Sat.Constraint.OnlyEnforceIf
void OnlyEnforceIf(ILiteral[] lits)
Definition:
Constraints.cs:33
Google.OrTools.Sat
Definition:
CpModel.pb.cs:12
Google.OrTools.Sat.Constraint.OnlyEnforceIf
void OnlyEnforceIf(ILiteral lit)
Definition:
Constraints.cs:28