OR-Tools  8.1
cumulative.h
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 #ifndef OR_TOOLS_SAT_CUMULATIVE_H_
15 #define OR_TOOLS_SAT_CUMULATIVE_H_
16 
17 #include <functional>
18 #include <vector>
19 
20 #include "ortools/sat/integer.h"
21 #include "ortools/sat/intervals.h"
22 #include "ortools/sat/model.h"
23 
24 namespace operations_research {
25 namespace sat {
26 
27 // Adds a cumulative constraint on the given intervals, the associated demands
28 // and the capacity expressions.
29 //
30 // Each interval represents a task to be scheduled in time such that the task
31 // consumes the resource during the time range [lb, ub) where lb and ub
32 // respectively represent the lower and upper bounds of the corresponding
33 // interval variable. The amount of resource consumed by the task is the value
34 // of its associated demand variable.
35 //
36 // The cumulative constraint forces the set of task to be scheduled such that
37 // the sum of the demands of all the tasks that overlap any time point cannot
38 // exceed the capacity of the resource.
39 //
40 // This constraint assumes that an interval can be optional or have a size
41 // of zero. The demands and the capacity can be any non-negative number.
42 //
43 // Optimization: If one already have an helper constructed from the interval
44 // variable, it can be passed as last argument.
45 std::function<void(Model*)> Cumulative(
46  const std::vector<IntervalVariable>& vars,
47  const std::vector<AffineExpression>& demands, AffineExpression capacity,
48  SchedulingConstraintHelper* helper = nullptr);
49 
50 // Adds a simple cumulative constraint. See the comment of Cumulative() above
51 // for a definition of the constraint. This is only used for testing.
52 //
53 // This constraint assumes that task demands and the resource capacity are fixed
54 // to non-negative number.
55 std::function<void(Model*)> CumulativeTimeDecomposition(
56  const std::vector<IntervalVariable>& vars,
57  const std::vector<AffineExpression>& demands, AffineExpression capacity,
58  SchedulingConstraintHelper* helper = nullptr);
59 
60 } // namespace sat
61 } // namespace operations_research
62 
63 #endif // OR_TOOLS_SAT_CUMULATIVE_H_
model.h
operations_research
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
Definition: dense_doubly_linked_list.h:21
intervals.h
operations_research::sat::Cumulative
std::function< void(Model *)> Cumulative(const std::vector< IntervalVariable > &vars, const std::vector< AffineExpression > &demands, AffineExpression capacity, SchedulingConstraintHelper *helper)
Definition: cumulative.cc:35
operations_research::sat::CumulativeTimeDecomposition
std::function< void(Model *)> CumulativeTimeDecomposition(const std::vector< IntervalVariable > &vars, const std::vector< AffineExpression > &demands, AffineExpression capacity, SchedulingConstraintHelper *helper)
Definition: cumulative.cc:154
capacity
int64 capacity
Definition: routing_flow.cc:129
integer.h