Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
2d_distances_propagator.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_2D_DISTANCES_PROPAGATOR_H_
15#define OR_TOOLS_SAT_2D_DISTANCES_PROPAGATOR_H_
16
17#include <cstdint>
18#include <utility>
19#include <vector>
20
21#include "ortools/sat/integer.h"
22#include "ortools/sat/model.h"
26
27namespace operations_research {
28namespace sat {
29
30// This class implements a propagator for non_overlap_2d constraints that uses
31// the BinaryRelationsMaps to detect precedences between pairs of boxes and
32// detect a conflict if the precedences implies an overlap between the two
33// boxes. For doing this efficiently, it keep track of pairs of boxes that have
34// non-fixed precedences in the BinaryRelationsMaps and only check those in the
35// propagation.
37 public:
39
40 ~Precedences2DPropagator() override;
41
42 bool Propagate() final;
44
45 private:
46 void CollectPairsOfBoxesWithNonTrivialDistance();
47
48 std::vector<std::pair<int, int>> non_trivial_pairs_;
49
51 BinaryRelationsMaps* binary_relations_maps_;
52 SharedStatistics* shared_stats_;
53
54 int last_helper_inprocessing_count_ = -1;
55 int last_num_expressions_ = -1;
56
57 int64_t num_conflicts_ = 0;
58 int64_t num_calls_ = 0;
59
61 Precedences2DPropagator& operator=(const Precedences2DPropagator&) = delete;
62};
63
64} // namespace sat
65} // namespace operations_research
66
67#endif // OR_TOOLS_SAT_2D_DISTANCES_PROPAGATOR_H_
Precedences2DPropagator(NoOverlap2DConstraintHelper *helper, Model *model)
Simple class to add statistics by name and print them at the end.
In SWIG mode, we don't want anything besides these top-level includes.