Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
cumulative.h
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
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"
22#include "ortools/sat/model.h"
23
24namespace operations_research {
25namespace 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.
45std::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.
55std::function<void(Model*)> CumulativeTimeDecomposition(
56 const std::vector<IntervalVariable>& vars,
57 const std::vector<AffineExpression>& demands, AffineExpression capacity,
58 SchedulingConstraintHelper* helper = nullptr);
59
60// Another testing code, same assumptions as the CumulativeTimeDecomposition().
61std::function<void(Model*)> CumulativeUsingReservoir(
62 const std::vector<IntervalVariable>& vars,
63 const std::vector<AffineExpression>& demands, AffineExpression capacity,
64 SchedulingConstraintHelper* helper = nullptr);
65
66} // namespace sat
67} // namespace operations_research
68
69#endif // OR_TOOLS_SAT_CUMULATIVE_H_
std::function< void(Model *)> CumulativeUsingReservoir(const std::vector< IntervalVariable > &vars, const std::vector< AffineExpression > &demands, AffineExpression capacity, SchedulingConstraintHelper *helper)
Another testing code, same assumptions as the CumulativeTimeDecomposition().
std::function< void(Model *)> CumulativeTimeDecomposition(const std::vector< IntervalVariable > &vars, const std::vector< AffineExpression > &demands, AffineExpression capacity, SchedulingConstraintHelper *helper)
std::function< void(Model *)> Cumulative(const std::vector< IntervalVariable > &vars, const std::vector< AffineExpression > &demands, AffineExpression capacity, SchedulingConstraintHelper *helper)
Definition cumulative.cc:42
In SWIG mode, we don't want anything besides these top-level includes.