DotNet Reference

DotNet Reference

IntervalVarArrayHelper.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 
15 {
16  using System;
17  using System.Collections.Generic;
18 
19  // IntervalVar[] helper class.
20  public static class IntervalVarArrayHelper
21  {
22  // get solver from array of interval variables
23  private static Solver GetSolver(IntervalVar[] vars)
24  {
25  if (vars == null || vars.Length <= 0)
26  throw new ArgumentException("Array <vars> cannot be null or empty");
27 
28  return vars[0].solver();
29  }
30  public static DisjunctiveConstraint Disjunctive(this IntervalVar[] vars,
31  String name)
32  {
33  Solver solver = GetSolver(vars);
34  return solver.MakeDisjunctiveConstraint(vars, name);
35  }
36  public static Constraint Cumulative(this IntervalVar[] vars,
37  long[] demands,
38  long capacity,
39  String name)
40  {
41  Solver solver = GetSolver(vars);
42  return solver.MakeCumulative(vars, demands, capacity, name);
43  }
44  public static Constraint Cumulative(this IntervalVar[] vars,
45  int[] demands,
46  long capacity,
47  String name)
48  {
49  Solver solver = GetSolver(vars);
50  return solver.MakeCumulative(vars, demands, capacity, name);
51  }
52  }
53 } // namespace Google.OrTools.ConstraintSolver
static DisjunctiveConstraint Disjunctive(this IntervalVar[] vars, String name)
Definition: Assignment.cs:11
static Constraint Cumulative(this IntervalVar[] vars, int[] demands, long capacity, String name)
DisjunctiveConstraint MakeDisjunctiveConstraint(IntervalVarVector intervals, string name)
Definition: IntervalVar.cs:18
static Constraint Cumulative(this IntervalVar[] vars, long[] demands, long capacity, String name)
Solver solver()
Constraint MakeCumulative(IntervalVarVector intervals, long[] demands, long capacity, string name)