41void ParseAndSolve(
const std::string& filename, absl::string_view solver,
42 const std::string& params) {
43 std::string problem_name = filename;
44 const size_t found = problem_name.find_last_of(
"/\\");
45 if (found != std::string::npos) {
46 problem_name = problem_name.substr(found + 1);
48 if (absl::EndsWith(problem_name,
".vbp")) {
50 problem_name.resize(problem_name.size() - 4);
53 packing::vbp::VectorBinPackingProblem data;
57 LOG(FATAL) <<
"Cannot read " << filename;
60 data.set_name(problem_name);
62 if (data.max_bins() != 0) {
64 <<
"Ignoring max_bins value. The feasibility problem is not supported.";
67 LOG(INFO) <<
"Solving vector packing problem '" << data.name() <<
"' with "
68 << data.item_size() <<
" item types, and "
69 << data.resource_capacity_size() <<
" dimensions.";
70 if (absl::GetFlag(FLAGS_display_proto)) {
77 packing::vbp::VectorBinPackingSolution
solution =
79 data, solver_type, params, absl::GetFlag(FLAGS_time_limit),
80 absl::GetFlag(FLAGS_threads), absl::GetFlag(FLAGS_max_bins));
83 LOG(INFO) <<
"Bin " <<
b;
84 const packing::vbp::VectorBinPackingOneBinInSolution& bin =
86 for (
int i = 0; i < bin.item_indices_size(); ++i) {
87 LOG(INFO) <<
" - item: " << bin.item_indices(i)
88 <<
", copies: " << bin.item_copies(i);
96int main(
int argc,
char** argv) {
97 absl::SetFlag(&FLAGS_stderrthreshold, 0);
99 if (absl::GetFlag(FLAGS_input).empty()) {
100 LOG(FATAL) <<
"Please supply a data file with --input=";
104 absl::GetFlag(FLAGS_solver),
105 absl::GetFlag(FLAGS_params));
vbp::VectorBinPackingSolution SolveVectorBinPackingWithArcFlow(const vbp::VectorBinPackingProblem &problem, MPSolver::OptimizationProblemType solver_type, const std::string &mip_params, double time_limit, int num_threads, int max_bins)
ABSL_FLAG(std::string, input, "", "Vector Bin Packing (.vpb) data file name.")
int main(int argc, char **argv)