Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
IntervalVarArrayHelper.cs
Go to the documentation of this file.
1// Copyright 2010-2024 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{
16using System;
17using System.Collections.Generic;
18
19// IntervalVar[] helper class.
20public static class IntervalVarArrayHelper
21{
22 // get solver from array of interval variables
23 private static Solver GetSolver(IntervalVar[] vars)
24 {
25 if (vars is 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, String name)
31 {
32 Solver solver = GetSolver(vars);
33 return solver.MakeDisjunctiveConstraint(vars, name);
34 }
35 public static Constraint Cumulative(this IntervalVar[] vars, long[] demands, long capacity, String name)
36 {
37 Solver solver = GetSolver(vars);
38 return solver.MakeCumulative(vars, demands, capacity, name);
39 }
40 public static Constraint Cumulative(this IntervalVar[] vars, int[] demands, long capacity, String name)
41 {
42 Solver solver = GetSolver(vars);
43 return solver.MakeCumulative(vars, demands, capacity, name);
44 }
45}
46} // namespace Google.OrTools.ConstraintSolver
static Constraint Cumulative(this IntervalVar[] vars, long[] demands, long capacity, String name)
static DisjunctiveConstraint Disjunctive(this IntervalVar[] vars, String name)
static Constraint Cumulative(this IntervalVar[] vars, int[] demands, long capacity, String name)
DisjunctiveConstraint MakeDisjunctiveConstraint(IntervalVarVector intervals, string name)
Definition Solver.cs:1735
Constraint MakeCumulative(IntervalVarVector intervals, long[] demands, long capacity, string name)
Definition Solver.cs:1749