@@ -561,7 +561,6 @@ optimization_problem_solution_t<i_t, f_t> solve_lp_with_method(
561561template <typename i_t , typename f_t >
562562optimization_problem_solution_t <i_t , f_t > solve_lp (detail::problem_t <i_t , f_t >& problem,
563563 pdlp_solver_settings_t <i_t , f_t > const & settings,
564- bool problem_checking,
565564 bool use_pdlp_solver_mode,
566565 bool inside_mip)
567566{
@@ -575,18 +574,10 @@ optimization_problem_solution_t<i_t, f_t> solve_lp(detail::problem_t<i_t, f_t>&
575574
576575 raft::common::nvtx::range fun_scope (" Running solver" );
577576
578- if (problem_checking) {
579- raft::common::nvtx::range fun_scope (" Check problem representation" );
580- // This is required as user might forget to set some fields
581- if (!inside_mip) {
582- problem_checking_t <i_t , f_t >::check_problem_representation (*problem.original_problem_ptr );
583- problem_checking_t <i_t , f_t >::check_initial_solution_representation (
584- *problem.original_problem_ptr , settings);
585- } else {
586- problem.check_problem_representation (true , true );
587- problem_checking_t <i_t , f_t >::check_initial_solution_representation (problem, settings);
588- }
589- }
577+ cuopt_func_call (problem.check_problem_representation (true , inside_mip));
578+ using problem_checking_t = problem_checking_t <i_t , f_t >; // Can't use "," inside a macro
579+ cuopt_func_call (problem_checking_t::check_initial_solution_representation (problem, settings));
580+
590581 CUOPT_LOG_INFO (
591582 " Solving a problem with %d constraints %d variables (%d integers) and %d nonzeros" ,
592583 problem.n_constraints ,
@@ -632,8 +623,24 @@ optimization_problem_solution_t<i_t, f_t> solve_lp(optimization_problem_t<i_t, f
632623 bool problem_checking,
633624 bool use_pdlp_solver_mode)
634625{
635- detail::problem_t <i_t , f_t > problem (op_problem);
636- return solve_lp (problem, settings, problem_checking, use_pdlp_solver_mode);
626+ try {
627+ if (problem_checking) {
628+ raft::common::nvtx::range fun_scope (" Check problem representation" );
629+ problem_checking_t <i_t , f_t >::check_problem_representation (op_problem);
630+ problem_checking_t <i_t , f_t >::check_initial_solution_representation (op_problem, settings);
631+ }
632+ detail::problem_t <i_t , f_t > problem (op_problem);
633+ const bool inside_mip = false ;
634+ return solve_lp (problem, settings, use_pdlp_solver_mode, inside_mip);
635+ } catch (const cuopt::logic_error& e) {
636+ CUOPT_LOG_ERROR (" Error in solve_lp: %s" , e.what ());
637+ return optimization_problem_solution_t <i_t , f_t >{e, op_problem.get_handle_ptr ()->get_stream ()};
638+ } catch (const std::bad_alloc& e) {
639+ CUOPT_LOG_ERROR (" Error in solve_lp: %s" , e.what ());
640+ return optimization_problem_solution_t <i_t , f_t >{
641+ cuopt::logic_error (" Memory allocation failed" , cuopt::error_type_t ::RuntimeError),
642+ op_problem.get_handle_ptr ()->get_stream ()};
643+ }
637644}
638645
639646template <typename i_t , typename f_t >
@@ -727,7 +734,6 @@ optimization_problem_solution_t<i_t, f_t> solve_lp(
727734 template optimization_problem_solution_t <int , F_TYPE> solve_lp ( \
728735 detail::problem_t <int , F_TYPE>& problem, \
729736 pdlp_solver_settings_t <int , F_TYPE> const & settings, \
730- bool problem_checking, \
731737 bool use_pdlp_solver_mode, \
732738 bool inside_mip); \
733739 template optimization_problem_solution_t <int , F_TYPE> solve_lp ( \
0 commit comments