Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
2d_packing_brute_force.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_2D_PACKING_BRUTE_FORCE_H_
15#define OR_TOOLS_SAT_2D_PACKING_BRUTE_FORCE_H_
16
17#include <utility>
18#include <vector>
19
20#include "absl/types/span.h"
22#include "ortools/sat/integer.h"
23
24namespace operations_research {
25namespace sat {
26
27// Try to solve the Orthogonal Packing Problem by enumeration of all possible
28// solutions. It will try to preprocess the problem into a smaller one and will
29// only try to solve it if it the reduced problem has `max_complexity` or less
30// items.
31// Warning: do not call this with a too many items and a large value of
32// `max_complexity` or it will run forever.
34 enum class Status {
37 kTooBig,
38 };
39
41 // Only non-empty if status==kFoundSolution.
42 std::vector<Rectangle> positions_for_solution;
43};
44
46 absl::Span<const IntegerValue> sizes_x,
47 absl::Span<const IntegerValue> sizes_y,
48 std::pair<IntegerValue, IntegerValue> bounding_box_size,
49 int max_complexity);
50
51// Note that functions taking a Span<PermutableItems> are free to permute them
52// as they see fit unless documented otherwise.
54 IntegerValue size_x;
55 IntegerValue size_y;
56 // Position of the item in the original input.
57 int index;
58 Rectangle position;
59};
60
61// Exposed for testing
62bool Preprocess(absl::Span<PermutableItem>& items,
63 std::pair<IntegerValue, IntegerValue>& bounding_box_size,
64 int max_complexity);
65
66} // namespace sat
67} // namespace operations_research
68
69#endif // OR_TOOLS_SAT_2D_PACKING_BRUTE_FORCE_H_
BruteForceResult BruteForceOrthogonalPacking(absl::Span< const IntegerValue > sizes_x, absl::Span< const IntegerValue > sizes_y, std::pair< IntegerValue, IntegerValue > bounding_box_size, int max_complexity)
bool Preprocess(absl::Span< PermutableItem > &items, std::pair< IntegerValue, IntegerValue > &bounding_box_size, int max_complexity)
Exposed for testing.
In SWIG mode, we don't want anything besides these top-level includes.
std::vector< Rectangle > positions_for_solution
Only non-empty if status==kFoundSolution.
int index
Position of the item in the original input.