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