|
10 | 10 | #include <cuopt/mathematical_optimization/cpu_optimization_problem.hpp> |
11 | 11 | #include <cuopt/mathematical_optimization/csr_matrix_utils.hpp> |
12 | 12 | #include <cuopt/mathematical_optimization/io/mps_data_model.hpp> |
13 | | -#include <cuopt/mathematical_optimization/optimization_problem.hpp> |
14 | 13 | #include <cuopt/mathematical_optimization/optimization_problem_utils.hpp> |
15 | 14 | #include <cuopt/mathematical_optimization/solve_remote.hpp> |
16 | 15 |
|
@@ -634,100 +633,6 @@ std::vector<var_t> cpu_optimization_problem_t<i_t, f_t>::get_variable_types_host |
634 | 633 | return variable_types_; |
635 | 634 | } |
636 | 635 |
|
637 | | -// ============================================================================== |
638 | | -// Conversion to optimization_problem_t |
639 | | -// ============================================================================== |
640 | | - |
641 | | -template <typename i_t, typename f_t> |
642 | | -std::unique_ptr<optimization_problem_t<i_t, f_t>> |
643 | | -cpu_optimization_problem_t<i_t, f_t>::to_optimization_problem(raft::handle_t const* handle_ptr) |
644 | | -{ |
645 | | - if (handle_ptr == nullptr) { |
646 | | - throw std::runtime_error( |
647 | | - "cpu_optimization_problem_t::to_optimization_problem(): " |
648 | | - "handle_ptr is null. A RAFT handle with CUDA resources is required to convert " |
649 | | - "a CPU-backed problem to a GPU-backed optimization_problem_t."); |
650 | | - } |
651 | | - |
652 | | - auto gpu_problem = std::make_unique<optimization_problem_t<i_t, f_t>>(handle_ptr); |
653 | | - |
654 | | - // Set scalar values |
655 | | - gpu_problem->set_maximize(maximize_); |
656 | | - gpu_problem->set_objective_scaling_factor(objective_scaling_factor_); |
657 | | - gpu_problem->set_objective_offset(objective_offset_); |
658 | | - gpu_problem->set_problem_category(problem_category_); |
659 | | - |
660 | | - // Set string values |
661 | | - if (!objective_name_.empty()) gpu_problem->set_objective_name(objective_name_); |
662 | | - if (!problem_name_.empty()) gpu_problem->set_problem_name(problem_name_); |
663 | | - if (!var_names_.empty()) gpu_problem->set_variable_names(var_names_); |
664 | | - if (!row_names_.empty()) gpu_problem->set_row_names(row_names_); |
665 | | - |
666 | | - // Set CSR constraint matrix (data will be copied to GPU by optimization_problem_t setters) |
667 | | - // Use A_offsets_ presence as the guard: a valid CSR can have zero non-zeros but still |
668 | | - // needs row offsets to define the number of constraints. |
669 | | - if (!A_offsets_.empty()) { |
670 | | - gpu_problem->set_csr_constraint_matrix(A_.data(), |
671 | | - A_.size(), |
672 | | - A_indices_.data(), |
673 | | - A_indices_.size(), |
674 | | - A_offsets_.data(), |
675 | | - A_offsets_.size()); |
676 | | - } |
677 | | - |
678 | | - // Set constraint bounds |
679 | | - if (!b_.empty()) { gpu_problem->set_constraint_bounds(b_.data(), b_.size()); } |
680 | | - |
681 | | - // Set objective coefficients |
682 | | - if (!c_.empty()) { gpu_problem->set_objective_coefficients(c_.data(), c_.size()); } |
683 | | - |
684 | | - // Set quadratic objective if present (GPU setter symmetrizes once: H = Q + Q^T) |
685 | | - if (!Q_values_.empty()) { |
686 | | - gpu_problem->set_quadratic_objective_matrix(Q_values_.data(), |
687 | | - Q_values_.size(), |
688 | | - Q_indices_.data(), |
689 | | - Q_indices_.size(), |
690 | | - Q_offsets_.data(), |
691 | | - Q_offsets_.size()); |
692 | | - } |
693 | | - |
694 | | - if (!quadratic_constraints_.empty()) { |
695 | | - gpu_problem->set_quadratic_constraints( |
696 | | - std::vector<typename optimization_problem_interface_t<i_t, f_t>::quadratic_constraint_t>( |
697 | | - quadratic_constraints_)); |
698 | | - } |
699 | | - |
700 | | - // Set variable bounds |
701 | | - if (!variable_lower_bounds_.empty()) { |
702 | | - gpu_problem->set_variable_lower_bounds(variable_lower_bounds_.data(), |
703 | | - variable_lower_bounds_.size()); |
704 | | - } |
705 | | - if (!variable_upper_bounds_.empty()) { |
706 | | - gpu_problem->set_variable_upper_bounds(variable_upper_bounds_.data(), |
707 | | - variable_upper_bounds_.size()); |
708 | | - } |
709 | | - |
710 | | - // Set variable types |
711 | | - if (!variable_types_.empty()) { |
712 | | - gpu_problem->set_variable_types(variable_types_.data(), variable_types_.size()); |
713 | | - } |
714 | | - |
715 | | - // Set constraint bounds |
716 | | - if (!constraint_lower_bounds_.empty()) { |
717 | | - gpu_problem->set_constraint_lower_bounds(constraint_lower_bounds_.data(), |
718 | | - constraint_lower_bounds_.size()); |
719 | | - } |
720 | | - if (!constraint_upper_bounds_.empty()) { |
721 | | - gpu_problem->set_constraint_upper_bounds(constraint_upper_bounds_.data(), |
722 | | - constraint_upper_bounds_.size()); |
723 | | - } |
724 | | - |
725 | | - // Set row types |
726 | | - if (!row_types_.empty()) { gpu_problem->set_row_types(row_types_.data(), row_types_.size()); } |
727 | | - |
728 | | - return gpu_problem; |
729 | | -} |
730 | | - |
731 | 636 | // ============================================================================== |
732 | 637 | // File I/O |
733 | 638 | // ============================================================================== |
|
0 commit comments