@@ -584,6 +584,7 @@ node_status_t branch_and_bound_t<i_t, f_t>::solve_node(search_tree_t<i_t, f_t>&
584584 lp_settings.set_log (false );
585585 lp_settings.cut_off = upper_bound + settings_.dual_tol ;
586586 lp_settings.inside_mip = 2 ;
587+ lp_settings.time_limit = settings_.time_limit - toc (stats_.start_time );
587588
588589 // in B&B we only have equality constraints, leave it empty for default
589590 std::vector<char > row_sense;
@@ -739,7 +740,7 @@ void branch_and_bound_t<i_t, f_t>::exploration_ramp_up(search_tree_t<i_t, f_t>*
739740 }
740741 }
741742
742- if (toc (stats_. start_time ) > settings_.time_limit ) {
743+ if (now > settings_.time_limit ) {
743744 status_ = mip_exploration_status_t ::TIME_LIMIT;
744745 return ;
745746 }
@@ -836,17 +837,17 @@ void branch_and_bound_t<i_t, f_t>::explore_subtree(i_t id,
836837 }
837838 }
838839
839- if (toc (stats_. start_time ) > settings_.time_limit ) {
840+ if (now > settings_.time_limit ) {
840841 status_ = mip_exploration_status_t ::TIME_LIMIT;
841- break ;
842+ return ;
842843 }
843844
844845 node_status_t node_status =
845846 solve_node (search_tree, node_ptr, leaf_problem, Arow, upper_bound, settings_.log , ' B' );
846847
847848 if (node_status == node_status_t ::TIME_LIMIT) {
848849 status_ = mip_exploration_status_t ::TIME_LIMIT;
849- break ;
850+ return ;
850851
851852 } else if (node_status == node_status_t ::HAS_CHILDREN) {
852853 // The stack should only contain the children of the current parent.
@@ -972,11 +973,13 @@ void branch_and_bound_t<i_t, f_t>::diving_thread(lp_problem_t<i_t, f_t>& leaf_pr
972973 continue ;
973974 }
974975
976+ if (toc (stats_.start_time ) > settings_.time_limit ) { return ; }
977+
975978 node_status_t node_status =
976979 solve_node (subtree, node_ptr, leaf_problem, Arow, upper_bound, log, ' D' );
977980
978981 if (node_status == node_status_t ::TIME_LIMIT) {
979- break ;
982+ return ;
980983
981984 } else if (node_status == node_status_t ::HAS_CHILDREN) {
982985 auto [first, second] = child_selection (node_ptr);
0 commit comments