Skip to content
Merged

Dev 2 #312

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
4 changes: 2 additions & 2 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ set(OPTIMIZATIONTOOLS_BUILD_TEST OFF)
FetchContent_Declare(
optimizationtools
GIT_REPOSITORY https://github.com/fontanf/optimizationtools.git
GIT_TAG e8c379203792fcad764cce239986b325619475fd
GIT_TAG 7ec13db980ffdcb84dc43d5552c880661eda129b
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../optimizationtools/"
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(optimizationtools)
Expand All @@ -38,7 +38,7 @@ set(SHAPE_BUILD_TEST OFF)
FetchContent_Declare(
shape
GIT_REPOSITORY https://github.com/fontanf/shape.git
GIT_TAG 28d83c8d97066805896591b7a40ee13c0078ffec
GIT_TAG 039a433f9f1275b2e69f727fdc0c5cf99ebeac27
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../shape/"
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(shape)
Expand Down
4 changes: 4 additions & 0 deletions include/packingsolver/irregular/algorithm_formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class AlgorithmFormatter
void update_bin_packing_bound(
BinPos number_of_bins);

/** Update the variable-sized bin packing bound. */
void update_variable_sized_bin_packing_bound(
Profit cost);

/** Method to call at the end of the algorithm. */
void end();

Expand Down
18 changes: 18 additions & 0 deletions src/irregular/algorithm_formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,24 @@ void AlgorithmFormatter::update_bin_packing_bound(
mutex_.unlock();
}

void AlgorithmFormatter::update_variable_sized_bin_packing_bound(
Profit cost)
{
mutex_.lock();
if (cost > output_.variable_sized_bin_packing_bound) {
output_.variable_sized_bin_packing_bound = cost;
output_.json["IntermediaryOutputs"].push_back(output_.to_json());
parameters_.new_solution_callback(output_);

// Check optimality.
if (output_.solution_pool.best().full()
&& output_.variable_sized_bin_packing_bound == output_.solution_pool.best().number_of_bins()) {
end_ = true;
}
}
mutex_.unlock();
}

void AlgorithmFormatter::end()
{
output_.time = parameters_.timer.elapsed_time();
Expand Down
8 changes: 4 additions & 4 deletions src/irregular/optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ void optimize_onedimensional_bound(
algorithm_formatter.update_knapsack_bound(
onedim_output.knapsack_bound);
break;
//} case Objective::VariableSizedBinPacking: {
// algorithm_formatter.update_variable_sized_bin_packing_bound(
// onedim_output.variable_sized_bin_packing_bound);
// break;
} case Objective::VariableSizedBinPacking: {
algorithm_formatter.update_variable_sized_bin_packing_bound(
onedim_output.variable_sized_bin_packing_bound);
break;
} default: {
std::stringstream ss;
ss << FUNC_SIGNATURE << ": "
Expand Down
Loading