Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
diffn_cuts.h
Go to the documentation of this file.
1// Copyright 2010-2025 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_DIFFN_CUTS_H_
15#define OR_TOOLS_SAT_DIFFN_CUTS_H_
16
17#include <string>
18#include <vector>
19
20#include "ortools/sat/cuts.h"
21#include "ortools/sat/integer.h"
23#include "ortools/sat/model.h"
26
27namespace operations_research {
28namespace sat {
29
30// Completion time cuts for the no_overlap_2d constraint. It actually generates
31// the completion time cumulative cuts in both axis.
33 NoOverlap2DConstraintHelper* helper, Model* model);
34
35// Energetic cuts for the no_overlap_2d constraint.
36//
37// For a given set of rectangles, we compute the area of each rectangle
38// and make sure their sum is less than the area of the bounding interval.
39//
40// If an interval is optional, it contributes
41// min_size_x * min_size_y * presence_literal
42// amount of total area.
43//
44// If an interval is performed, we use the linear area formulation (if
45// possible), or the McCormick relaxation of the size_x * size_y.
46//
47// The maximum area is the area of the bounding rectangle of each intervals
48// at level 0.
50 NoOverlap2DConstraintHelper* helper, Model* model);
51
52// Internal methods and data structures, useful for testing.
53
54// Base event type for scheduling cuts.
56 DiffnBaseEvent(int t, const SchedulingConstraintHelper* x_helper);
57
58 // Cache of the intervals bound on the x direction.
59 IntegerValue x_start_min;
60 IntegerValue x_start_max;
61 IntegerValue x_end_min;
62 IntegerValue x_end_max;
63 IntegerValue x_size_min;
64 // Useful for no_overlap_2d or cumulative.
65 IntegerValue y_min = IntegerValue(0);
66 IntegerValue y_max = IntegerValue(0);
67 IntegerValue y_size_min;
68
69 // The energy min of this event.
70 IntegerValue energy_min;
71
72 // If non empty, a decomposed view of the energy of this event.
73 // First value in each pair is x_size, second is y_size.
74 std::vector<LiteralValueValue> decomposed_energy;
75};
76
77// Stores the event for a rectangle along the two axis x and y.
78// For a no_overlap constraint, y is always of size 1 between 0 and 1.
79// For a cumulative constraint, y is the demand that must be between 0 and
80// capacity_max.
81// For a no_overlap_2d constraint, y the other dimension of the rect.
83 DiffnCtEvent(int t, const SchedulingConstraintHelper* x_helper);
84
85 // The lp value of the end of the x interval.
87 double x_lp_end;
88
89 // Indicates if the events used the optional energy information from the
90 // model.
91 bool use_energy = false;
92
93 // Indicates if the cut is lifted, that is if it includes tasks that are not
94 // strictly contained in the current time window.
95 bool lifted = false;
96
97 // If we know that the size on y is fixed, we can use some heuristic to
98 // compute the maximum subset sums under the capacity and use that instead
99 // of the full capacity.
100 bool y_size_is_fixed = false;
101
102 std::string DebugString() const;
103};
104
105} // namespace sat
106} // namespace operations_research
107
108#endif // OR_TOOLS_SAT_DIFFN_CUTS_H_
CutGenerator CreateNoOverlap2dEnergyCutGenerator(NoOverlap2DConstraintHelper *helper, Model *model)
CutGenerator CreateNoOverlap2dCompletionTimeCutGenerator(NoOverlap2DConstraintHelper *helper, Model *model)
In SWIG mode, we don't want anything besides these top-level includes.
std::vector< LiteralValueValue > decomposed_energy
Definition diffn_cuts.h:74
IntegerValue x_start_min
Cache of the intervals bound on the x direction.
Definition diffn_cuts.h:59
DiffnBaseEvent(int t, const SchedulingConstraintHelper *x_helper)
Definition diffn_cuts.cc:55
IntegerValue y_min
Useful for no_overlap_2d or cumulative.
Definition diffn_cuts.h:65
IntegerValue energy_min
The energy min of this event.
Definition diffn_cuts.h:70
DiffnCtEvent(int t, const SchedulingConstraintHelper *x_helper)
AffineExpression x_end
The lp value of the end of the x interval.
Definition diffn_cuts.h:86