OR-Tools  8.2
scheduling_constraints.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_SCHEDULING_CONSTRAINTS_H_
15#define OR_TOOLS_SAT_SCHEDULING_CONSTRAINTS_H_
16
17#include <cstddef>
18#include <vector>
19
23#include "ortools/base/macros.h"
24#include "ortools/sat/integer.h"
26#include "ortools/sat/model.h"
29
30namespace operations_research {
31namespace sat {
32
33// This propagator enforces that the target variable is equal to the min of the
34// selected variables. This equation only holds if the enforcement literal is
35// true.
36//
37// This constraint expects that enforcement_literal <==> bool_or(selectors).
38std::function<void(Model*)> EqualMinOfSelectedVariables(
39 Literal enforcement_literal, AffineExpression target,
40 const std::vector<AffineExpression>& vars,
41 const std::vector<Literal>& selectors);
42
43// This propagator enforces that the target variable is equal to the max of the
44// selected variables. This equation only holds if the enforcement literal is
45// true.
46//
47// This constraint expects that enforcement_literal <==> bool_or(selectors).u
48std::function<void(Model*)> EqualMaxOfSelectedVariables(
49 Literal enforcement_literal, AffineExpression target,
50 const std::vector<AffineExpression>& vars,
51 const std::vector<Literal>& selectors);
52
53// This constraint enforces that the target interval is an exact cover of the
54// underlying intervals.
55//
56// It means start(span) is the min of the start of all performed intervals. Also
57// end(span) is the max of the end of all performed intervals.
58//
59// Furthermore, the following conditions also hold:
60// - If the target interval is present, then at least one interval variables
61// is present.
62// - if the target interval is absent, all intervals are absent.
63// - If one interval is present, the target interval is present too.
64std::function<void(Model*)> SpanOfIntervals(
65 IntervalVariable span, const std::vector<IntervalVariable>& intervals);
66} // namespace sat
67} // namespace operations_research
68
69#endif // OR_TOOLS_SAT_SCHEDULING_CONSTRAINTS_H_
std::function< void(Model *)> EqualMaxOfSelectedVariables(Literal enforcement_literal, AffineExpression target, const std::vector< AffineExpression > &exprs, const std::vector< Literal > &selectors)
std::function< void(Model *)> SpanOfIntervals(IntervalVariable span, const std::vector< IntervalVariable > &intervals)
std::function< void(Model *)> EqualMinOfSelectedVariables(Literal enforcement_literal, AffineExpression target, const std::vector< AffineExpression > &exprs, const std::vector< Literal > &selectors)
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...