Skip to content

Commit

Permalink
Optimize iterative beam search 2
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanf committed May 18, 2024
1 parent e2e7f2a commit f571531
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions include/treesearchsolver/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ Depth depth(
node,
std::integral_constant<
bool,
HasDepthMethod<BranchingScheme,
Depth(const std::shared_ptr<typename BranchingScheme::Node>&)>::value>());
HasDepthMethod<
BranchingScheme,
Depth(const std::shared_ptr<typename BranchingScheme::Node>&)>::value>());
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
24 changes: 12 additions & 12 deletions include/treesearchsolver/iterative_beam_search_2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,25 @@ inline const IterativeBeamSearch2Output<BranchingScheme> iterative_beam_search_2
continue;
}

// Check time.
if (parameters.timer.needs_to_end())
goto ibsend;

// Check best known bound.
if (parameters.goal != nullptr
&& !branching_scheme.better(
parameters.goal,
output.solution_pool.best()))
goto ibsend;

// Get next child.
auto children = branching_scheme.children(current_node);
output.number_of_nodes_expanded++;

for (auto child: children) {
for (const auto& child: children) {

output.number_of_nodes_generated++;

// Check time.
if (parameters.timer.needs_to_end())
goto ibsend;

// Check best known bound.
if (parameters.goal != nullptr
&& !branching_scheme.better(
parameters.goal,
output.solution_pool.best()))
goto ibsend;

// Get child depth.
Depth child_depth = depth(branching_scheme, child);
if (child_depth == -1)
Expand Down

0 comments on commit f571531

Please sign in to comment.