Google OR-Tools
v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
binpacking_2d_parser.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_PACKING_BINPACKING_2D_PARSER_H_
15
#define OR_TOOLS_PACKING_BINPACKING_2D_PARSER_H_
16
17
#include <string>
18
#include <vector>
19
20
#include "absl/strings/string_view.h"
21
#include "
ortools/base/types.h
"
22
#include "
ortools/packing/multiple_dimensions_bin_packing.pb.h
"
23
24
namespace
operations_research
{
25
namespace
packing
{
26
27
// A BinPacking parser.
28
// It supports the following file format:
29
// - 2bp:
30
// see http://or.dei.unibo.it/library/two-dimensional-bin-packing-problem
31
// - Binpacking with conflicts:
32
// see http://or.dei.unibo.it/library/bin-packing-problem-conflicts
33
//
34
// The generated problems have the following characteristics:
35
//
36
// You have one box with n dimensions. The size of the box is stored in the
37
// field box_shape().
38
// You need to fit items into this box. Each item has the same number of
39
// dimensions and one or more possible shapes (this usually means that
40
// you can rotate the item). Each item has a value, and a possible list of
41
// conflicts (items you cannot put alongside this item).
42
// The objective of the problem is to fit as many items as possible in the box
43
// while maximizing the sum of values of selected items. For each item, you need
44
// to select the shape and the position of the item in the box.
45
// Each item must not overlap (in n dimensions) with any other item.
46
class
BinPacking2dParser
{
47
public
:
48
BinPacking2dParser
();
49
50
// Loads the 'instance'th instance of the bin packing problem if the given
51
// file. The instance are 1 based (first is 1).
52
// Only one call to a Load*() function is supported. All the subsequent
53
// calls will do nothing and return false.
54
bool
Load2BPFile
(absl::string_view file_name,
int
instance);
55
MultipleDimensionsBinPackingProblem
problem
()
const
{
return
problem_; }
56
57
private
:
58
enum
LoadStatus { NOT_STARTED = 0, INSTANCE_FOUND = 1, PARSING_FINISHED = 2 };
59
60
void
ProcessNew2BpLine(
const
std::string& line,
int
instance);
61
62
MultipleDimensionsBinPackingProblem problem_;
63
int
num_dimensions_;
64
65
// Temporary.
66
LoadStatus load_status_;
67
int
num_items_;
68
int
instances_seen_;
69
};
70
71
}
// namespace packing
72
}
// namespace operations_research
73
74
#endif
// OR_TOOLS_PACKING_BINPACKING_2D_PARSER_H_
operations_research::packing::BinPacking2dParser::problem
MultipleDimensionsBinPackingProblem problem() const
Definition
binpacking_2d_parser.h:55
operations_research::packing::BinPacking2dParser::Load2BPFile
bool Load2BPFile(absl::string_view file_name, int instance)
Definition
binpacking_2d_parser.cc:34
operations_research::packing::BinPacking2dParser::BinPacking2dParser
BinPacking2dParser()
Definition
binpacking_2d_parser.cc:28
operations_research::packing::MultipleDimensionsBinPackingProblem
Definition
multiple_dimensions_bin_packing.pb.h:498
multiple_dimensions_bin_packing.pb.h
operations_research::packing
Definition
arc_flow_builder.cc:32
operations_research
In SWIG mode, we don't want anything besides these top-level includes.
Definition
binary_indexed_tree.h:21
types.h
ortools
packing
binpacking_2d_parser.h
Generated by
1.14.0