OR-Tools  9.1
scheduling_cuts.h
Go to the documentation of this file.
1 // Copyright 2010-2021 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 #ifndef OR_TOOLS_SAT_SCHEDULING_CUTS_H_
15 #define OR_TOOLS_SAT_SCHEDULING_CUTS_H_
16 
17 #include <functional>
18 #include <string>
19 #include <utility>
20 #include <vector>
21 
22 #include "ortools/base/int_type.h"
24 #include "ortools/sat/cuts.h"
25 #include "ortools/sat/integer.h"
26 #include "ortools/sat/intervals.h"
29 #include "ortools/sat/model.h"
31 
32 namespace operations_research {
33 namespace sat {
34 
35 // For a given set of intervals and demands, we compute the maximum energy of
36 // each task and make sure it is less than the span of the intervals * its
37 // capacity.
38 //
39 // If an interval is optional, it contributes
40 // min_demand * min_size * presence_literal
41 // amount of total energy.
42 //
43 // If an interval is performed, it contributes either min_demand * size or
44 // demand * min_size. We choose the most violated formulation.
45 //
46 // The maximum energy is capacity * span of intervals at level 0.
48  const std::vector<IntervalVariable>& intervals,
49  const IntegerVariable capacity, const std::vector<IntegerVariable>& demands,
50  const std::vector<LinearExpression>& energies, Model* model);
51 
52 // For a given set of intervals and demands, we first compute the mandatory part
53 // of the interval as [start_max , end_min]. We use this to calculate mandatory
54 // demands for each start_max time points for eligible intervals.
55 // Since the sum of these mandatory demands must be smaller or equal to the
56 // capacity, we create a cut representing that.
57 //
58 // If an interval is optional, it contributes min_demand * presence_literal
59 // amount of demand to the mandatory demands sum. So the final cut is generated
60 // as follows:
61 // sum(demands of always present intervals)
62 // + sum(presence_literal * min_of_demand) <= capacity.
64  const std::vector<IntervalVariable>& intervals,
65  const IntegerVariable capacity, const std::vector<IntegerVariable>& demands,
66  Model* model);
67 
68 // Completion time cuts for the cumulative constraint. It is a simple relaxation
69 // where we replace a cumulative task with demand k and duration d by a
70 // no_overlap task with duration d * k / capacity_max.
72  const std::vector<IntervalVariable>& intervals,
73  const IntegerVariable capacity, const std::vector<IntegerVariable>& demands,
74  const std::vector<LinearExpression>& energies, Model* model);
75 
76 // For a given set of intervals in a cumulative constraint, we detect violated
77 // mandatory precedences and create a cut for these.
79  const std::vector<IntervalVariable>& intervals, IntegerVariable capacity,
80  const std::vector<IntegerVariable>& demands, Model* model);
81 
82 // Completion time cuts for the no_overlap_2d constraint. It actually generates
83 // the completion time cumulative cuts in both axis.
85  const std::vector<IntervalVariable>& x_intervals,
86  const std::vector<IntervalVariable>& y_intervals, Model* model);
87 
88 // For a given set of intervals, we first compute the min and max of all
89 // intervals. Then we create a cut that indicates that all intervals must fit
90 // in that span.
91 //
92 // If an interval is optional, it contributes min_size * presence_literal
93 // amount of demand to the mandatory demands sum. So the final cut is generated
94 // as follows:
95 // sum(sizes of always present intervals)
96 // + sum(presence_literal * min_of_size) <= span of all intervals.
98  const std::vector<IntervalVariable>& intervals, Model* model);
99 
100 // For a given set of intervals in a no_overlap constraint, we detect violated
101 // mandatory precedences and create a cut for these.
103  const std::vector<IntervalVariable>& intervals, Model* model);
104 
105 // For a given set of intervals in a no_overlap constraint, we detect violated
106 // area based cuts from Queyranne 93 [see note in the code] and create a cut for
107 // these.
109  const std::vector<IntervalVariable>& intervals, Model* model);
110 
111 } // namespace sat
112 } // namespace operations_research
113 
114 #endif // OR_TOOLS_SAT_SCHEDULING_CUTS_H_
CutGenerator CreateNoOverlapEnergyCutGenerator(const std::vector< IntervalVariable > &intervals, Model *model)
CutGenerator CreateCumulativeTimeTableCutGenerator(const std::vector< IntervalVariable > &intervals, const IntegerVariable capacity, const std::vector< IntegerVariable > &demands, Model *model)
CutGenerator CreateCumulativePrecedenceCutGenerator(const std::vector< IntervalVariable > &intervals, IntegerVariable capacity, const std::vector< IntegerVariable > &demands, Model *model)
GRBmodel * model
int64_t capacity
CutGenerator CreateNoOverlapPrecedenceCutGenerator(const std::vector< IntervalVariable > &intervals, Model *model)
Collection of objects used to extend the Constraint Solver library.
CutGenerator CreateNoOverlap2dCompletionTimeCutGenerator(const std::vector< IntervalVariable > &x_intervals, const std::vector< IntervalVariable > &y_intervals, Model *model)
CutGenerator CreateCumulativeCompletionTimeCutGenerator(const std::vector< IntervalVariable > &intervals, const IntegerVariable capacity, const std::vector< IntegerVariable > &demands, const std::vector< LinearExpression > &energies, Model *model)
CutGenerator CreateNoOverlapCompletionTimeCutGenerator(const std::vector< IntervalVariable > &intervals, Model *model)
CutGenerator CreateCumulativeEnergyCutGenerator(const std::vector< IntervalVariable > &intervals, const IntegerVariable capacity, const std::vector< IntegerVariable > &demands, const std::vector< LinearExpression > &energies, Model *model)