@@ -76,6 +76,13 @@ static void parse_arguments(argparse::ArgumentParser& program)
7676 .choices (" None" , " Papilo" , " PSLP" , " Default" );
7777
7878 program.add_argument (" --solution-path" ).help (" Path where solution file will be generated" );
79+
80+ program.add_argument (" --pdlp-precision" )
81+ .help (
82+ " PDLP precision mode. default: native type, single: FP32 internally, "
83+ " double: FP64 explicitly, mixed: mixed-precision SpMV (FP32 matrix, FP64 vectors)." )
84+ .default_value (std::string (" default" ))
85+ .choices (" default" , " single" , " double" , " mixed" );
7986}
8087
8188static cuopt::linear_programming::presolver_t string_to_presolver (const std::string& presolver)
@@ -87,6 +94,15 @@ static cuopt::linear_programming::presolver_t string_to_presolver(const std::str
8794 return cuopt::linear_programming::presolver_t ::Default;
8895}
8996
97+ static cuopt::linear_programming::pdlp_precision_t string_to_pdlp_precision (
98+ const std::string& precision)
99+ {
100+ if (precision == " single" ) return cuopt::linear_programming::pdlp_precision_t ::SinglePrecision;
101+ if (precision == " double" ) return cuopt::linear_programming::pdlp_precision_t ::DoublePrecision;
102+ if (precision == " mixed" ) return cuopt::linear_programming::pdlp_precision_t ::MixedPrecision;
103+ return cuopt::linear_programming::pdlp_precision_t ::DefaultPrecision;
104+ }
105+
90106static cuopt::linear_programming::pdlp_solver_mode_t string_to_pdlp_solver_mode (
91107 const std::string& mode)
92108{
@@ -105,38 +121,24 @@ static cuopt::linear_programming::pdlp_solver_mode_t string_to_pdlp_solver_mode(
105121static cuopt::linear_programming::pdlp_solver_settings_t <int , double > create_solver_settings (
106122 const argparse::ArgumentParser& program)
107123{
108- cuopt::linear_programming::pdlp_solver_settings_t <int , double > settings =
109- cuopt::linear_programming::pdlp_solver_settings_t <int , double >{};
124+ cuopt::linear_programming::pdlp_solver_settings_t <int , double > settings{};
110125
111126 settings.time_limit = program.get <double >(" --time-limit" );
112127 settings.iteration_limit = program.get <int >(" --iteration-limit" );
113128 settings.set_optimality_tolerance (program.get <double >(" --optimality-tolerance" ));
114129 settings.pdlp_solver_mode =
115130 string_to_pdlp_solver_mode (program.get <std::string>(" --pdlp-solver-mode" ));
116131 settings.method = static_cast <cuopt::linear_programming::method_t >(program.get <int >(" --method" ));
117- settings.crossover = program.get <int >(" --crossover" );
118- settings.presolver = string_to_presolver (program.get <std::string>(" --presolver" ));
132+ settings.crossover = program.get <int >(" --crossover" );
133+ settings.presolver = string_to_presolver (program.get <std::string>(" --presolver" ));
134+ settings.pdlp_precision = string_to_pdlp_precision (program.get <std::string>(" --pdlp-precision" ));
119135
120136 return settings;
121137}
122138
123- int main ( int argc, char * argv[] )
139+ static int run_solver ( const argparse::ArgumentParser& program, const raft:: handle_t & handle_ )
124140{
125- // Parse binary arguments
126- argparse::ArgumentParser program (" solve_LP" );
127- parse_arguments (program);
128-
129- try {
130- program.parse_args (argc, argv);
131- } catch (const std::runtime_error& err) {
132- std::cerr << err.what () << std::endl;
133- std::cerr << program;
134- return 1 ;
135- }
136-
137- // Initialize solver settings from binary arguments
138- cuopt::linear_programming::pdlp_solver_settings_t <int , double > settings =
139- create_solver_settings (program);
141+ auto settings = create_solver_settings (program);
140142
141143 bool use_pdlp_solver_mode = true ;
142144 if (program.is_used (" --pdlp-hyper-params-path" )) {
@@ -145,13 +147,6 @@ int main(int argc, char* argv[])
145147 use_pdlp_solver_mode = false ;
146148 }
147149
148- // Setup up RMM memory pool
149- auto memory_resource = make_pool ();
150- rmm::mr::set_current_device_resource (memory_resource.get ());
151-
152- // Initialize raft handle and running stream
153- const raft::handle_t handle_{};
154-
155150 // Parse MPS file
156151 cuopt::mps_parser::mps_data_model_t <int , double > op_problem =
157152 cuopt::mps_parser::parse_mps<int , double >(program.get <std::string>(" --path" ));
@@ -168,3 +163,27 @@ int main(int argc, char* argv[])
168163
169164 return 0 ;
170165}
166+
167+ int main (int argc, char * argv[])
168+ {
169+ // Parse binary arguments
170+ argparse::ArgumentParser program (" solve_LP" );
171+ parse_arguments (program);
172+
173+ try {
174+ program.parse_args (argc, argv);
175+ } catch (const std::runtime_error& err) {
176+ std::cerr << err.what () << std::endl;
177+ std::cerr << program;
178+ return 1 ;
179+ }
180+
181+ // Setup up RMM memory pool
182+ auto memory_resource = make_pool ();
183+ rmm::mr::set_current_device_resource (memory_resource.get ());
184+
185+ // Initialize raft handle and running stream
186+ const raft::handle_t handle_{};
187+
188+ return run_solver (program, handle_);
189+ }
0 commit comments