Skip to content

Commit

Permalink
Fix rectangleguillotine::BranchingScheme::to_solution
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanf committed Jan 11, 2025
1 parent 252e707 commit 7e4ee61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rectangleguillotine/branching_scheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,8 +1485,9 @@ Solution BranchingScheme::to_solution(
(instance().parameters().number_of_stages == 3 && current_node->first_stage_orientation == CutOrientation::Vertical)
|| (instance().parameters().number_of_stages == 2 && current_node->first_stage_orientation == CutOrientation::Horizontal))?
CutOrientation::Vertical: CutOrientation::Horizontal;
BinTypeId bin_type_id = instance().bin_type_id(number_of_bins);
solution_builder.add_bin(
number_of_bins,
bin_type_id,
1,
cut_orientation);
number_of_bins++;
Expand Down
9 changes: 9 additions & 0 deletions src/rectangleguillotine/solution_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ void SolutionBuilder::add_bin(
BinPos copies,
CutOrientation first_cut_orientation)
{
if (bin_type_id >= solution_.instance().number_of_bin_types()) {
throw std::invalid_argument(
"rectangleguillotine::SolutionBuilder::add_bin"
"; bin_type_id: " + std::to_string(bin_type_id)
+ "; instance().number_of_bin_types(): "
+ std::to_string(solution_.instance().number_of_bin_types())
+ ".");
}

//std::cout << "add_bin bin_type_id " << bin_type_id << " copies " << copies << " first_cut_orientation " << first_cut_orientation << std::endl;
const BinType& bin_type = solution_.instance().bin_type(bin_type_id);
SolutionBin bin;
Expand Down

0 comments on commit 7e4ee61

Please sign in to comment.