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
6// http://www.apache.org/licenses/LICENSE-2.0
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.
14// Vector Bin Packing Problem.
16// The problem description is as follows:
19// - a fixed number of resources,
20// - a set of equivalent multidimentional bins with max capacity on each
22// - a set of items, with fixed usage for all resources, and a number of
23// copies for each item.
26// - optimization: minimizing a weighted sum of the number of bins used, plus a
27// weighted sum of skipped items; or
28// - feasibility: checking if all required items can be packed using at most a
29// given number of bins.
31// In both cases we must ensure that for each bin and each resource, the sum of
32// sizes of each assigned item is less than the capacity of the resource of the
35// An optional integer imposes an upper bound on how many copies of the same
36// item are allowed in a single bin, regardless of resource utilization.
40option java_package = "com.google.ortools.packing.vbp";
41option java_multiple_files = true;
42option csharp_namespace = "Google.OrTools.Packing.Vbp";
44package operations_research.packing.vbp;
47 // Optional name. This is only used for display/debugging purposes.
50 // Resource usages for this item. All usages must be non-negative.
51 // Should be the same size as resource_capacity in the
52 // VectorBinPackingProblem.
53 repeated int64 resource_usage = 2;
55 // Number of identical copies of this item that must be packed into some bin.
58 // The number of extra copies which may be skipped for a penalty.
59 // Currently only supported by the ArcFlow solver (arc_flow_solver.h), other
60 // solvers ignore this field.
61 int32 num_optional_copies = 5;
63 // An optional upper bound on how many copies of the same item are allowed in
64 // a single bin, regardless of resource utilization. A value of 0 is
65 // interpreted as no limit.
66 int32 max_number_of_copies_per_bin = 4;
68 // Minimize the total cost of bins plus this penalty for each optional copy
69 // not placed in any bin.
70 // Currently only supported by the ArcFlow solver (arc_flow_solver.h), other
71 // solvers ignore this field.
72 double penalty_per_missing_copy = 6;
75message VectorBinPackingProblem {
79 // Max capacity of each resource.
80 // All bins have the same resource capacities.
81 repeated int64 resource_capacity = 2;
83 // Resources names. This can either be left empty or
84 // must be of the same size as resource_capacity.
85 repeated string resource_name = 3;
87 // The list of items which are to be assigned to bins.
88 repeated Item item = 4;
90 // The maximum number of bins available. A value of 0 is interpreted as no
91 // limit. Nonzero values may be used to encode feasibility problems.
94 // If specified, tries to maximize the value of packed items minus the cost
95 // per bin used. A missing value is treated as 1.
96 // Currently only supported by the ArcFlow solver
97 // (ortools/packing/arc_flow_solver.h), other solvers
99 optional double cost_per_bin = 6;
102// Describe one filled bin in the solution.
103message VectorBinPackingOneBinInSolution {
104 // Which items are in this bin. They are supposed to be unique.
105 repeated int32 item_indices = 1;
106 // How many of each items are in this bins.
107 repeated int32 item_copies = 2;
111enum VectorBinPackingSolveStatus {
113 VECTOR_BIN_PACKING_SOLVE_STATUS_UNSPECIFIED = 0;
115 // The optimal solution was found and proven.
118 // A feasible solution has been found.
121 // The problem is infeasible.
125message VectorBinPackingSolution {
126 // Optional info from the solver.
127 string solver_info = 1;
130 repeated VectorBinPackingOneBinInSolution bins = 2;
133 VectorBinPackingSolveStatus status = 3;
136 // The total cost of bins used plus the penalty for any skipped items.
137 double objective_value = 4;
139 // Solve time in seconds.
140 double solve_time_in_seconds = 5;
142 // Time to create the Arc-Flow graph.
143 double arc_flow_time_in_seconds = 6;
145 // TODO(user): Do we add copies of bins?