Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ID,X,Y,Z,COST,COPIES,MAXIMUM_WEIGHT
0,6,5,5,7,2,100
1,12,5,5,10,1,100
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID,X,Y,Z,ROTATION_XYZ,ROTATION_YXZ,ROTATION_ZYX,ROTATION_YZX,ROTATION_XZY,ROTATION_ZXY,WEIGHT,COPIES
0,6,5,5,1,1,1,1,1,1,1,2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TYPE,ID,COPIES,BIN,X,Y,Z,LX,LY,LZ,ROTATION
BIN,1,1,0,0,0,0,12,5,5,
ITEM,0,1,0,0,0,0,6,5,5,XYZ
ITEM,0,1,0,6,0,0,6,5,5,XYZ
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ID,X,Y,Z,COST,COPIES,MAXIMUM_WEIGHT
0,6,5,5,7,2,100
1,12,5,5,10,1,100
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID,X,Y,Z,ROTATION_XYZ,ROTATION_YXZ,ROTATION_ZYX,ROTATION_YZX,ROTATION_XZY,ROTATION_ZXY,WEIGHT,COPIES,GROUP_ID,STACKABILITY_ID,NESTING_HEIGHT,MAXIMUM_STACKABILITY,MAXIMUM_WEIGHT_ABOVE
0,6,5,5,1,1,1,1,1,1,1,2,0,0,0,1,100
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME,VALUE
objective,variable-sized-bin-packing
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TYPE,ID,COPIES,BIN,STACK,X,Y,Z,LX,LY,LZ,GROUP_ID,ROTATION
BIN,1,1,0,-1,0,0,0,12,5,5,,
STACK,0,1,0,0,0,0,0,6,5,5,,
ITEM,0,1,0,0,0,0,0,6,5,5,0,XYZ
STACK,1,1,0,1,6,0,0,6,5,5,,
ITEM,0,1,0,1,6,0,0,6,5,5,0,XYZ
2 changes: 2 additions & 0 deletions src/box/solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ bool Solution::operator<(const Solution& solution) const
return strictly_greater_profit(solution.profit(), profit());
} case Objective::Feasibility: {
return strictly_greater_profit(solution.profit(), profit());
} case Objective::VariableSizedBinPacking: {
return strictly_lesser_cost(solution.cost(), cost());
} default: {
std::stringstream ss;
ss << FUNC_SIGNATURE << ": "
Expand Down
2 changes: 2 additions & 0 deletions src/boxstacks/solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ bool Solution::operator<(const Solution& solution) const
return strictly_greater_profit(solution.profit(), profit());
} case Objective::Feasibility: {
return strictly_greater_profit(solution.profit(), profit());
} case Objective::VariableSizedBinPacking: {
return strictly_lesser_cost(solution.cost(), cost());
} default: {
std::stringstream ss;
ss << FUNC_SIGNATURE << ": "
Expand Down
121 changes: 61 additions & 60 deletions test/box/box_test.cpp
Original file line number Diff line number Diff line change
@@ -1,60 +1,61 @@
//#include "packingsolver/box/instance_builder.hpp"
//#include "packingsolver/box/optimize.hpp"

//#include <gtest/gtest.h>
//#include <boost/filesystem.hpp>

//using namespace packingsolver::box;
//namespace fs = boost::filesystem;

//struct BoxOptimizeTestParams
//{
// fs::path items_path;
// fs::path bins_path;
// fs::path defects_path;
// fs::path parameters_path;
// fs::path certificate_path;
//};

//inline std::ostream& operator<<(std::ostream& os, const BoxOptimizeTestParams& test_params)
//{
// os << test_params.items_path;
// return os;
//}

//class BoxOptimizeTest: public testing::TestWithParam<BoxOptimizeTestParams> { };

//TEST_P(BoxOptimizeTest, BoxOptimize)
//{
// BoxOptimizeTestParams test_params = GetParam();
// InstanceBuilder instance_builder;
// instance_builder.read_item_types(test_params.items_path.string());
// instance_builder.read_bin_types(test_params.bins_path.string());
// instance_builder.read_parameters(test_params.parameters_path.string());
// Instance instance = instance_builder.build();

// OptimizeParameters optimize_parameters;
// optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytimeSequential;
// Output output = optimize(instance, optimize_parameters);

// Solution solution(instance, test_params.certificate_path.string());
// std::cout << std::endl
// << "Reference solution" << std::endl
// << "------------------" << std::endl;
// solution.format(std::cout);

// EXPECT_EQ(!(output.solution_pool.best() < solution), true);
// EXPECT_EQ(!(solution < output.solution_pool.best()), true);
//}

//INSTANTIATE_TEST_SUITE_P(
// Box,
// BoxOptimizeTest,
// testing::ValuesIn(std::vector<BoxOptimizeTestParams>{
// {
// fs::path("data") / "box" / "users" / "2024-11-24" / "items.csv",
// fs::path("data") / "box" / "users" / "2024-11-24" / "bins.csv",
// fs::path(""),
// fs::path("data") / "box" / "users" / "2024-11-24" / "parameters.csv",
// fs::path("data") / "box" / "users" / "2024-11-24" / "solution.csv",
// }}));
#include "packingsolver/box/instance_builder.hpp"
#include "packingsolver/box/optimize.hpp"
#include "box/solution_builder.hpp"

#include <gtest/gtest.h>
#include <boost/filesystem.hpp>

using namespace packingsolver::box;
namespace fs = boost::filesystem;

struct BoxOptimizeTestParams
{
fs::path items_path;
fs::path bins_path;
fs::path parameters_path;
fs::path certificate_path;
};

inline std::ostream& operator<<(std::ostream& os, const BoxOptimizeTestParams& test_params)
{
os << test_params.items_path;
return os;
}

class BoxOptimizeTest: public testing::TestWithParam<BoxOptimizeTestParams> { };

TEST_P(BoxOptimizeTest, BoxOptimize)
{
BoxOptimizeTestParams test_params = GetParam();
InstanceBuilder instance_builder;
instance_builder.read_item_types(test_params.items_path.string());
instance_builder.read_bin_types(test_params.bins_path.string());
instance_builder.read_parameters(test_params.parameters_path.string());
Instance instance = instance_builder.build();

OptimizeParameters optimize_parameters;
optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytimeSequential;
Output output = optimize(instance, optimize_parameters);

SolutionBuilder solution_builder(instance);
solution_builder.read(test_params.certificate_path.string());
Solution solution = solution_builder.build();
std::cout << std::endl
<< "Reference solution" << std::endl
<< "------------------" << std::endl;
solution.format(std::cout);

EXPECT_EQ(!(output.solution_pool.best() < solution), true);
EXPECT_EQ(!(solution < output.solution_pool.best()), true);
}

INSTANTIATE_TEST_SUITE_P(
Box,
BoxOptimizeTest,
testing::ValuesIn(std::vector<BoxOptimizeTestParams>{
{
fs::path("data") / "box" / "tests" / "variable_sized_bin_packing_two_bin_types" / "items.csv",
fs::path("data") / "box" / "tests" / "variable_sized_bin_packing_two_bin_types" / "bins.csv",
fs::path("data") / "box" / "tests" / "variable_sized_bin_packing_two_bin_types" / "parameters.csv",
fs::path("data") / "box" / "tests" / "variable_sized_bin_packing_two_bin_types" / "solution.csv",
}}));
3 changes: 2 additions & 1 deletion test/boxstacks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
add_executable(PackingSolver_boxstacks_test)
target_sources(PackingSolver_boxstacks_test PRIVATE
boxstacks_test.cpp
sequential_onedimensional_rectangle_test.cpp)
sequential_onedimensional_rectangle_test.cpp
optimize_test.cpp)
target_include_directories(PackingSolver_boxstacks_test PRIVATE
${PROJECT_SOURCE_DIR}/src)
target_link_libraries(PackingSolver_boxstacks_test
Expand Down
61 changes: 61 additions & 0 deletions test/boxstacks/optimize_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "packingsolver/boxstacks/instance_builder.hpp"
#include "packingsolver/boxstacks/optimize.hpp"
#include "boxstacks/solution_builder.hpp"

#include <gtest/gtest.h>
#include <boost/filesystem.hpp>

using namespace packingsolver::boxstacks;
namespace fs = boost::filesystem;

struct BoxStacksOptimizeTestParams
{
fs::path items_path;
fs::path bins_path;
fs::path parameters_path;
fs::path certificate_path;
};

inline std::ostream& operator<<(std::ostream& os, const BoxStacksOptimizeTestParams& test_params)
{
os << test_params.items_path;
return os;
}

class BoxStacksOptimizeTest: public testing::TestWithParam<BoxStacksOptimizeTestParams> { };

TEST_P(BoxStacksOptimizeTest, BoxStacksOptimize)
{
BoxStacksOptimizeTestParams test_params = GetParam();
InstanceBuilder instance_builder;
instance_builder.read_item_types(test_params.items_path.string());
instance_builder.read_bin_types(test_params.bins_path.string());
instance_builder.read_parameters(test_params.parameters_path.string());
Instance instance = instance_builder.build();

OptimizeParameters optimize_parameters;
optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytimeSequential;
Output output = optimize(instance, optimize_parameters);

SolutionBuilder solution_builder(instance);
solution_builder.read(test_params.certificate_path.string());
Solution solution = solution_builder.build();
std::cout << std::endl
<< "Reference solution" << std::endl
<< "------------------" << std::endl;
solution.format(std::cout);

EXPECT_EQ(!(output.solution_pool.best() < solution), true);
EXPECT_EQ(!(solution < output.solution_pool.best()), true);
}

INSTANTIATE_TEST_SUITE_P(
BoxStacks,
BoxStacksOptimizeTest,
testing::ValuesIn(std::vector<BoxStacksOptimizeTestParams>{
{
fs::path("data") / "boxstacks" / "tests" / "variable_sized_bin_packing_two_bin_types" / "items.csv",
fs::path("data") / "boxstacks" / "tests" / "variable_sized_bin_packing_two_bin_types" / "bins.csv",
fs::path("data") / "boxstacks" / "tests" / "variable_sized_bin_packing_two_bin_types" / "parameters.csv",
fs::path("data") / "boxstacks" / "tests" / "variable_sized_bin_packing_two_bin_types" / "solution.csv",
}}));
Loading