OR-Tools
9.2
binpacking_2d_parser.h
Go to the documentation of this file.
1
// Copyright 2010-2021 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 "
ortools/base/integral_types.h
"
21
#include "
ortools/packing/multiple_dimensions_bin_packing.pb.h
"
22
23
namespace
operations_research
{
24
namespace
packing {
25
26
// A BinPacking parser.
27
// It supports the following file format:
28
// - 2bp:
29
// see http://or.dei.unibo.it/library/two-dimensional-bin-packing-problem
30
// - Binpacking with conflicts:
31
// see http://or.dei.unibo.it/library/bin-packing-problem-conflicts
32
//
33
// The generated problems have the following characteristics:
34
//
35
// You have one box with n dimensions. The size of the box is stored in the
36
// field box_shape().
37
// You need to fit items into this box. Each item has the same number of
38
// dimensions and one or more possible shapes (this usually means that
39
// you can rotate the item). Each item has a value, and a possible list of
40
// conflicts (items you cannot put alongside this item).
41
// The objective of the problem is to fit as many items as possible in the box
42
// while maximizing the sum of values of selected items. For each item, you need
43
// to select the shape and the position of the item in the box.
44
// Each item must not overlap (in n dimensions) with any other item.
45
class
BinPacking2dParser
{
46
public
:
47
BinPacking2dParser
();
48
49
// Loads the 'instance'th instance of the bin packing problem if the given
50
// file. The instance are 1 based (first is 1).
51
// Only one call to a Load*() function is supported. All the subsequent
52
// calls will do nothing and return false.
53
bool
Load2BPFile
(
const
std::string& file_name,
int
instance);
54
MultipleDimensionsBinPackingProblem
problem
()
const
{
return
problem_; }
55
56
private
:
57
enum
LoadStatus { NOT_STARTED = 0, INSTANCE_FOUND = 1, PARSING_FINISHED = 2 };
58
59
void
ProcessNew2BpLine(
const
std::string& line,
int
instance);
60
61
MultipleDimensionsBinPackingProblem problem_;
62
int
num_dimensions_;
63
64
// Temporary.
65
LoadStatus load_status_;
66
int
num_items_;
67
int
instances_seen_;
68
};
69
70
}
// namespace packing
71
}
// namespace operations_research
72
73
#endif // OR_TOOLS_PACKING_BINPACKING_2D_PARSER_H_
operations_research::packing::BinPacking2dParser
Definition:
binpacking_2d_parser.h:45
operations_research::packing::BinPacking2dParser::problem
MultipleDimensionsBinPackingProblem problem() const
Definition:
binpacking_2d_parser.h:54
integral_types.h
operations_research::packing::MultipleDimensionsBinPackingProblem
Definition:
multiple_dimensions_bin_packing.pb.h:405
operations_research::packing::BinPacking2dParser::Load2BPFile
bool Load2BPFile(const std::string &file_name, int instance)
Definition:
binpacking_2d_parser.cc:30
multiple_dimensions_bin_packing.pb.h
operations_research::packing::BinPacking2dParser::BinPacking2dParser
BinPacking2dParser()
Definition:
binpacking_2d_parser.cc:24
operations_research
Collection of objects used to extend the Constraint Solver library.
Definition:
dense_doubly_linked_list.h:21
ortools
packing
binpacking_2d_parser.h
Generated by
1.8.15