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