Skip to content

Commit

Permalink
Merge pull request #17 from fontanf/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
fontanf authored Apr 20, 2024
2 parents a7f09f0 + edfa661 commit 11054e2
Show file tree
Hide file tree
Showing 30 changed files with 351 additions and 67 deletions.
2 changes: 2 additions & 0 deletions data/onedimensional/users/2023-08-01_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
51 changes: 51 additions & 0 deletions data/onedimensional/users/2023-08-01_solution.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
TYPE,ID,COPIES,BIN,X,LX
BIN,2,120,0,0,10000
ITEM,2,120,0,0,4624
ITEM,2,120,0,4624,4624
BIN,2,299,1,0,10000
ITEM,3,299,1,0,3589
ITEM,7,299,1,3589,732
ITEM,3,299,1,4321,3589
ITEM,9,299,1,7910,2056
BIN,2,236,2,0,10000
ITEM,0,236,2,0,9809
BIN,1,64,3,0,7000
ITEM,6,64,3,0,3470
ITEM,6,64,3,3470,3470
BIN,2,47,4,0,10000
ITEM,4,47,4,0,8369
BIN,2,174,5,0,10000
ITEM,6,174,5,0,3470
ITEM,5,174,5,3470,3236
ITEM,5,174,5,6706,3236
BIN,2,1,6,0,10000
ITEM,3,1,6,0,3589
ITEM,8,1,6,3589,365
ITEM,1,1,6,3954,739
ITEM,1,1,6,4693,739
ITEM,1,1,6,5432,739
ITEM,3,1,6,6171,3589
BIN,2,87,7,0,10000
ITEM,8,87,7,0,365
ITEM,8,87,7,365,365
ITEM,8,87,7,730,365
ITEM,8,87,7,1095,365
ITEM,8,87,7,1460,365
ITEM,8,87,7,1825,365
ITEM,3,87,7,2190,3589
ITEM,3,87,7,5779,3589
ITEM,8,87,7,9368,365
BIN,2,54,8,0,10000
ITEM,3,54,8,0,3589
ITEM,3,54,8,3589,3589
BIN,2,1,9,0,10000
ITEM,8,1,9,0,365
ITEM,4,1,9,365,8369
BIN,2,1,10,0,10000
ITEM,3,1,10,0,3589
ITEM,2,1,10,3589,4624
ITEM,8,1,10,8213,365
ITEM,8,1,10,8578,365
ITEM,1,1,10,8943,739
BIN,1,1,11,0,7000
ITEM,3,1,11,0,3589
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-06_t0_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
11 changes: 11 additions & 0 deletions data/onedimensional/users/2024-04-06_t0_solution.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TYPE,ID,COPIES,BIN,X,LX
BIN,0,1,0,0,3000
ITEM,1,1,0,0,1496
ITEM,1,1,0,1501,1496
BIN,1,1,1,0,7000
ITEM,3,1,1,0,3351
ITEM,3,1,1,3356,3351
BIN,1,1,2,0,7000
ITEM,2,1,2,0,2751
ITEM,2,1,2,2756,2751
ITEM,0,1,2,5512,290
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-06_t1_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
15 changes: 15 additions & 0 deletions data/onedimensional/users/2024-04-06_t1_solution.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TYPE,ID,COPIES,BIN,X,LX
BIN,3,2,0,0,4500
ITEM,1,2,0,0,1764
ITEM,1,2,0,1768,1764
ITEM,2,2,0,3536,964
BIN,3,1,1,0,4500
ITEM,0,1,1,0,1768
ITEM,0,1,1,1772,1768
ITEM,3,1,1,3544,864
BIN,3,1,2,0,4500
ITEM,1,1,2,0,1764
ITEM,4,1,2,1768,1774
ITEM,5,1,2,3546,764
BIN,6,1,3,0,1900
ITEM,0,1,3,0,1768
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-06_t2_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
5 changes: 5 additions & 0 deletions data/onedimensional/users/2024-04-06_t2_solution.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TYPE,ID,COPIES,BIN,X,LX
BIN,6,1,0,0,1400
ITEM,1,1,0,0,1164
BIN,2,1,1,0,2400
ITEM,0,1,1,0,2379
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-06_t3_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
36 changes: 36 additions & 0 deletions data/onedimensional/users/2024-04-06_t3_solution.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
TYPE,ID,COPIES,BIN,X,LX
BIN,0,1,0,0,4000
ITEM,0,1,0,0,1022
ITEM,1,1,0,1026,1022
ITEM,12,1,0,2052,925
ITEM,2,1,0,2981,922
BIN,0,1,1,0,4000
ITEM,2,1,1,0,922
ITEM,2,1,1,926,922
ITEM,4,1,1,1852,920
ITEM,4,1,1,2776,920
ITEM,10,1,1,3700,265
BIN,0,1,2,0,4000
ITEM,4,1,2,0,920
ITEM,4,1,2,924,920
ITEM,4,1,2,1848,920
ITEM,13,1,2,2772,515
ITEM,3,1,2,3291,512
BIN,0,1,3,0,4000
ITEM,3,1,3,0,512
ITEM,3,1,3,516,512
ITEM,5,1,3,1032,510
ITEM,5,1,3,1546,510
ITEM,5,1,3,2060,510
ITEM,5,1,3,2574,510
ITEM,5,1,3,3088,510
ITEM,8,1,3,3602,315
BIN,0,1,4,0,4000
ITEM,6,1,4,0,415
ITEM,7,1,4,419,415
ITEM,8,1,4,838,315
ITEM,9,1,4,1157,315
ITEM,9,1,4,1476,315
ITEM,11,1,4,1795,265
ITEM,14,1,4,2064,215
ITEM,15,1,4,2283,215
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-07_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
11 changes: 11 additions & 0 deletions data/onedimensional/users/2024-04-07_solution.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TYPE,ID,COPIES,BIN,X,LX
BIN,0,1,0,0,3000
ITEM,1,1,0,0,1496
ITEM,1,1,0,1501,1496
BIN,1,1,1,0,7000
ITEM,3,1,1,0,3351
ITEM,3,1,1,3356,3351
BIN,1,1,2,0,7000
ITEM,2,1,2,0,2751
ITEM,2,1,2,2756,2751
ITEM,0,1,2,5512,290
2 changes: 2 additions & 0 deletions data/onedimensional/users/2024-04-09_parameters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
7 changes: 7 additions & 0 deletions data/onedimensional/users/2024-04-09_solution.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TYPE,ID,COPIES,BIN,X,LX
BIN,1,2,0,0,7000
ITEM,0,2,0,0,2408
ITEM,0,2,0,2412,2408
BIN,0,2,1,0,6950
ITEM,0,2,1,0,2408
ITEM,0,2,1,2412,2408
2 changes: 1 addition & 1 deletion packingsolver/algorithms/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ std::istream& packingsolver::operator>>(
}

std::ostream& packingsolver::operator<<(
std::ostream &os,
std::ostream& os,
OptimizationMode optimization_mode)
{
switch (optimization_mode) {
Expand Down
19 changes: 14 additions & 5 deletions packingsolver/boxstacks/instance_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ void InstanceBuilder::set_item_types_infinite_copies()
/////////////////////////////// Read from files ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

void InstanceBuilder::read_parameters(std::string parameters_path)
void InstanceBuilder::read_parameters(
const std::string& parameters_path)
{
if (parameters_path.empty())
return;
Expand Down Expand Up @@ -407,7 +408,12 @@ void InstanceBuilder::read_parameters(std::string parameters_path)
}
}
//std::cout << "name " << name << std::endl;
if (name == "unloading-constraint") {
if (name == "objective") {
Objective objective;
std::stringstream ss(value);
ss >> objective;
set_objective(objective);
} if (name == "unloading-constraint") {
rectangle::UnloadingConstraint unloading_constraint;
std::stringstream ss(value);
ss >> unloading_constraint;
Expand All @@ -416,7 +422,8 @@ void InstanceBuilder::read_parameters(std::string parameters_path)
}
}

void InstanceBuilder::read_bin_types(std::string bins_path)
void InstanceBuilder::read_bin_types(
const std::string& bins_path)
{
std::ifstream f(bins_path);
if (!f.good()) {
Expand Down Expand Up @@ -499,7 +506,8 @@ void InstanceBuilder::read_bin_types(std::string bins_path)
}
}

void InstanceBuilder::read_defects(std::string defects_path)
void InstanceBuilder::read_defects(
const std::string& defects_path)
{
std::ifstream f(defects_path);
if (defects_path != "" && !f.good()) {
Expand Down Expand Up @@ -565,7 +573,8 @@ void InstanceBuilder::read_defects(std::string defects_path)

}

void InstanceBuilder::read_item_types(std::string items_path)
void InstanceBuilder::read_item_types(
const std::string& items_path)
{
std::ifstream f(items_path);
if (!f.good()) {
Expand Down
8 changes: 4 additions & 4 deletions packingsolver/boxstacks/instance_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class InstanceBuilder
*/

/** Read parameters from a file. */
void read_parameters(std::string parameters_path);
void read_parameters(const std::string& parameters_path);

/** Read bin types from a file. */
void read_bin_types(std::string bins_path);
void read_bin_types(const std::string& bins_path);

/** Read defects from a file. */
void read_defects(std::string defects_path);
void read_defects(const std::string& defects_path);

/** Read item types from a file. */
void read_item_types(std::string items_path);
void read_item_types(const std::string& items_path);

/*
* Set parameters
Expand Down
10 changes: 7 additions & 3 deletions packingsolver/boxstacks/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ int main(int argc, char *argv[])
}

InstanceBuilder instance_builder;
instance_builder.set_objective(vm["objective"].as<Objective>());

std::string items_path = vm["items"].as<std::string>();
if (!std::ifstream(items_path).good())
Expand Down Expand Up @@ -133,12 +132,17 @@ int main(int argc, char *argv[])

std::string parameters_path = (vm.count("parameters"))?
vm["parameters"].as<std::string>():
(std::ifstream(items_path + "_parameters.csv").good())?
items_path + "_parameters.csv":
(std::ifstream(vm["items"].as<std::string>() + "_parameters.csv").good())?
vm["items"].as<std::string>() + "_parameters.csv":
"";
if (!parameters_path.empty())
instance_builder.read_parameters(parameters_path);

if (vm.count("objective"))
instance_builder.set_objective(vm["objective"].as<Objective>());
if (vm.count("unloading-constraint"))
instance_builder.set_unloading_constraint(vm["unloading-constraint"].as<rectangle::UnloadingConstraint>());

Instance instance = instance_builder.build();

#if XPRESS_FOUND
Expand Down
21 changes: 12 additions & 9 deletions packingsolver/onedimensional/instance_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ void InstanceBuilder::set_item_types_infinite_copies()
/////////////////////////////// Read from files ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

void InstanceBuilder::read_parameters(std::string parameters_path)
void InstanceBuilder::read_parameters(
const std::string& parameters_path)
{
if (parameters_path.empty())
return;
Expand Down Expand Up @@ -265,16 +266,17 @@ void InstanceBuilder::read_parameters(std::string parameters_path)
}
}

//if (name == "unloading-constraint") {
// rectangle::UnloadingConstraint unloading_constraint;
// std::stringstream ss(value);
// ss >> unloading_constraint;
// set_unloading_constraint(unloading_constraint);
//}
if (name == "objective") {
Objective objective;
std::stringstream ss(value);
ss >> objective;
set_objective(objective);
}
}
}

void InstanceBuilder::read_bin_types(std::string bins_path)
void InstanceBuilder::read_bin_types(
const std::string& bins_path)
{
std::ifstream f(bins_path);
if (!f.good()) {
Expand Down Expand Up @@ -327,7 +329,8 @@ void InstanceBuilder::read_bin_types(std::string bins_path)
}
}

void InstanceBuilder::read_item_types(std::string items_path)
void InstanceBuilder::read_item_types(
const std::string& items_path)
{
std::ifstream f(items_path);
if (!f.good()) {
Expand Down
6 changes: 3 additions & 3 deletions packingsolver/onedimensional/instance_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class InstanceBuilder
*/

/** Read parameters from a file. */
void read_parameters(std::string parameters_path);
void read_parameters(const std::string& parameters_path);

/** Read bin types from a file. */
void read_bin_types(std::string bins_path);
void read_bin_types(const std::string& bins_path);

/** Read item types from a file. */
void read_item_types(std::string items_path);
void read_item_types(const std::string& items_path);

/*
* Set parameters
Expand Down
11 changes: 7 additions & 4 deletions packingsolver/onedimensional/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ int main(int argc, char *argv[])
}

InstanceBuilder instance_builder;
instance_builder.set_objective(vm["objective"].as<Objective>());

std::string items_path = vm["items"].as<std::string>();
if (!std::ifstream(items_path).good())
Expand All @@ -126,11 +125,15 @@ int main(int argc, char *argv[])

std::string parameters_path = (vm.count("parameters"))?
vm["parameters"].as<std::string>():
(std::ifstream(items_path + "_parameters.csv").good())?
items_path + "_parameters.csv":
(std::ifstream(vm["items"].as<std::string>() + "_parameters.csv").good())?
vm["items"].as<std::string>() + "_parameters.csv":
"";
if (!parameters_path.empty())
if (!parameters_path.empty()) {
instance_builder.read_parameters(parameters_path);
}

if (vm.count("objective"))
instance_builder.set_objective(vm["objective"].as<Objective>());

Instance instance = instance_builder.build();

Expand Down
Loading

0 comments on commit 11054e2

Please sign in to comment.