21
21
#include < cuopt/linear_programming/solve.hpp>
22
22
#include < cuopt/linear_programming/solver_settings.hpp>
23
23
#include < cuopt/logger.hpp>
24
+ #include < cuopt/utilities/timestamp_utils.hpp>
24
25
25
26
#include < mps_parser/parser.hpp>
26
27
@@ -76,29 +77,6 @@ cuopt_int_t cuOptGetVersion(cuopt_int_t* version_major,
76
77
return CUOPT_SUCCESS;
77
78
}
78
79
79
- bool extraTimestamps () {
80
- const char * envValue = std::getenv (" CUOPT_EXTRA_TIMESTAMPS" );
81
- if (envValue == nullptr ) {
82
- return false ;
83
- }
84
-
85
- std::string value (envValue);
86
- return (value == " True" || value == " true" || value == " 1" );
87
- }
88
-
89
-
90
- double getCurrentTimestamp () {
91
- auto now = std::chrono::system_clock::now ();
92
- return std::chrono::duration<double >(now.time_since_epoch ()).count ();
93
- }
94
-
95
- void printTimestamp (const std::string& label) {
96
- if (extraTimestamps ()) {
97
- std::cout << std::fixed << std::setprecision (6 );
98
- std::cout << std::endl << label << " : " << getCurrentTimestamp () << std::endl;
99
- }
100
- }
101
-
102
80
cuopt_int_t cuOptReadProblem (const char * filename, cuOptOptimizationProblem* problem_ptr)
103
81
{
104
82
problem_and_stream_view_t * problem_and_stream = new problem_and_stream_view_t ();
@@ -141,7 +119,7 @@ cuopt_int_t cuOptCreateProblem(cuopt_int_t num_constraints,
141
119
cuOptOptimizationProblem* problem_ptr)
142
120
{
143
121
144
- printTimestamp (" CUOPT_CREATE_PROBLEM" );
122
+ cuopt::utilities:: printTimestamp (" CUOPT_CREATE_PROBLEM" );
145
123
146
124
if (problem_ptr == nullptr || objective_coefficients == nullptr ||
147
125
constraint_matrix_row_offsets == nullptr || constraint_matrix_column_indices == nullptr ||
@@ -199,7 +177,7 @@ cuopt_int_t cuOptCreateRangedProblem(cuopt_int_t num_constraints,
199
177
cuOptOptimizationProblem* problem_ptr)
200
178
{
201
179
202
- printTimestamp (" CUOPT_CREATE_PROBLEM" );
180
+ cuopt::utilities:: printTimestamp (" CUOPT_CREATE_PROBLEM" );
203
181
204
182
if (problem_ptr == nullptr || objective_coefficients == nullptr ||
205
183
constraint_matrix_row_offsets == nullptr || constraint_matrix_column_indices == nullptr ||
@@ -627,7 +605,7 @@ cuopt_int_t cuOptSolve(cuOptOptimizationProblem problem,
627
605
cuOptSolverSettings settings,
628
606
cuOptSolution* solution_ptr)
629
607
{
630
- printTimestamp (" CUOPT_SOLVE_START" );
608
+ cuopt::utilities:: printTimestamp (" CUOPT_SOLVE_START" );
631
609
632
610
if (problem == nullptr ) { return CUOPT_INVALID_ARGUMENT; }
633
611
if (settings == nullptr ) { return CUOPT_INVALID_ARGUMENT; }
@@ -648,7 +626,7 @@ cuopt_int_t cuOptSolve(cuOptOptimizationProblem problem,
648
626
solve_mip<cuopt_int_t , cuopt_float_t >(*op_problem, mip_settings));
649
627
*solution_ptr = static_cast <cuOptSolution>(solution_and_stream_view);
650
628
651
- printTimestamp (" CUOPT_SOLVE_RETURN" );
629
+ cuopt::utilities:: printTimestamp (" CUOPT_SOLVE_RETURN" );
652
630
653
631
return static_cast <cuopt_int_t >(
654
632
solution_and_stream_view->mip_solution_ptr ->get_error_status ().get_error_type ());
@@ -666,7 +644,7 @@ cuopt_int_t cuOptSolve(cuOptOptimizationProblem problem,
666
644
solve_lp<cuopt_int_t , cuopt_float_t >(*op_problem, pdlp_settings));
667
645
*solution_ptr = static_cast <cuOptSolution>(solution_and_stream_view);
668
646
669
- printTimestamp (" CUOPT_SOLVE_RETURN" );
647
+ cuopt::utilities:: printTimestamp (" CUOPT_SOLVE_RETURN" );
670
648
671
649
return static_cast <cuopt_int_t >(
672
650
solution_and_stream_view->lp_solution_ptr ->get_error_status ().get_error_type ());
0 commit comments