@@ -63,6 +63,7 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
6363 0.0 ; // true objVal = sig * c'x - offset, sig = 1 (min) or -1 (max)
6464 double sense_origin = 1 ; // 1 (min) or -1 (max)
6565 int * constraint_new_idx = NULL ;
66+ int *constraint_type = NULL ;
6667
6768 void * model = NULL ;
6869 void * presolvedmodel = NULL ;
@@ -99,16 +100,18 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
99100 getUserParamsFromOptions (options, ifChangeIntParam, intParam,
100101 ifChangeFloatParam, floatParam);
101102
102- std::vector<int > constraint_type (lp.num_row_ );
103+ // std::vector<int> constraint_type(lp.num_row_);
103104
104105 formulateLP_highs (lp, &cost, &nCols, &nRows, &nnz, &nEqs, &csc_beg, &csc_idx,
105106 &csc_val, &rhs, &lower, &upper, &offset, &sense_origin,
106- &nCols_origin, &constraint_new_idx, constraint_type. data () );
107+ &nCols_origin, &constraint_new_idx, & constraint_type);
107108
108109 const cupdlp_int local_log_level = getCupdlpLogLevel (options);
109110 if (local_log_level) cupdlp_printf (" Solving with cuPDLP-C\n " );
110111
111- H_Init_Scaling (local_log_level, scaling, nCols, nRows, cost, rhs);
112+ // H_Init_Scaling(local_log_level, scaling, nCols, nRows, cost, rhs);
113+ Init_Scaling (scaling, nCols, nRows, cost, rhs);
114+
112115 cupdlp_int ifScaling = 1 ;
113116
114117 CUPDLPwork* w = cupdlp_NULL;
@@ -150,8 +153,12 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
150153 memcpy (csc_cpu->colMatElem , csc_val, nnz * sizeof (double ));
151154
152155 cupdlp_float scaling_time = getTimeStamp ();
153- PDHG_Scale_Data (local_log_level, csc_cpu, ifScaling, scaling, cost,
154- lower, upper, rhs);
156+
157+ // PDHG_Scale_Data(local_log_level, csc_cpu, ifScaling, scaling, cost,
158+ // lower, upper, rhs);
159+
160+ PDHG_Scale_Data (csc_cpu, ifScaling, scaling, cost, lower, upper, rhs);
161+
155162 scaling_time = getTimeStamp () - scaling_time;
156163
157164 cupdlp_float alloc_matrix_time = 0.0 ;
@@ -200,8 +207,9 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
200207 nCols_origin, highs_solution.col_value .data (),
201208 highs_solution.col_dual .data (), highs_solution.row_value .data (),
202209 highs_solution.row_dual .data (), &value_valid, &dual_valid, ifSaveSol,
203- fp_sol, constraint_new_idx, constraint_type. data () , &pdlp_model_status,
210+ fp_sol, constraint_new_idx, constraint_type, &pdlp_model_status,
204211 &pdlp_num_iter);
212+
205213 highs_info.pdlp_iteration_count = pdlp_num_iter;
206214
207215 model_status = HighsModelStatus::kUnknown ;
@@ -301,7 +309,9 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
301309 csc_clear_host (csc_cpu);
302310 problem_clear (prob);
303311 #if !(CUPDLP_CPU)
304- CHECK_CUDA (cudaDeviceReset ())
312+ if (check_cuda_call (cudaDeviceReset (), __FILE__, __LINE__) != cudaSuccess)
313+ return HighsStatus::kError ;
314+ // CHECK_CUDA(cudaDeviceReset())
305315 #endif
306316
307317 return HighsStatus::kOk ;
@@ -312,7 +322,7 @@ int formulateLP_highs(const HighsLp& lp, double** cost, int* nCols, int* nRows,
312322 double ** csc_val, double ** rhs, double ** lower,
313323 double ** upper, double * offset, double * sense_origin,
314324 int * nCols_origin, int ** constraint_new_idx,
315- int * constraint_type) {
325+ int ** constraint_type) {
316326 int retcode = 0 ;
317327
318328 // problem size for malloc
@@ -338,6 +348,7 @@ int formulateLP_highs(const HighsLp& lp, double** cost, int* nCols, int* nRows,
338348 const double * A_csc_val = lp.a_matrix_ .value_ .data ();
339349 int has_lower, has_upper;
340350
351+ cupdlp_init_int (*constraint_type, *nRows);
341352 cupdlp_init_int (*constraint_new_idx, *nRows);
342353
343354 // recalculate nRows and nnz for Ax - z = 0
@@ -347,14 +358,14 @@ int formulateLP_highs(const HighsLp& lp, double** cost, int* nCols, int* nRows,
347358
348359 // count number of equations and rows
349360 if (has_lower && has_upper && lhs_clp[i] == rhs_clp[i]) {
350- constraint_type[i] = EQ;
361+ * constraint_type[i] = EQ;
351362 (*nEqs)++;
352363 } else if (has_lower && !has_upper) {
353- constraint_type[i] = GEQ;
364+ * constraint_type[i] = GEQ;
354365 } else if (!has_lower && has_upper) {
355- constraint_type[i] = LEQ;
366+ * constraint_type[i] = LEQ;
356367 } else if (has_lower && has_upper) {
357- constraint_type[i] = BOUND;
368+ * constraint_type[i] = BOUND;
358369 (*nCols)++;
359370 (*nnz)++;
360371 (*nEqs)++;
@@ -365,7 +376,7 @@ int formulateLP_highs(const HighsLp& lp, double** cost, int* nCols, int* nRows,
365376
366377 // what if regard free as bounded
367378 printf (" Warning: constraint %d has no lower and upper bound\n " , i);
368- constraint_type[i] = BOUND;
379+ * constraint_type[i] = BOUND;
369380 (*nCols)++;
370381 (*nnz)++;
371382 (*nEqs)++;
@@ -394,7 +405,7 @@ int formulateLP_highs(const HighsLp& lp, double** cost, int* nCols, int* nRows,
394405 }
395406 // slack bounds
396407 for (int i = 0 , j = nCols_clp; i < *nRows; i++) {
397- if (constraint_type[i] == BOUND) {
408+ if (* constraint_type[i] == BOUND) {
398409 (*lower)[j] = lhs_clp[i];
399410 (*upper)[j] = rhs_clp[i];
400411 j++;
@@ -409,23 +420,23 @@ int formulateLP_highs(const HighsLp& lp, double** cost, int* nCols, int* nRows,
409420 // permute LP rhs
410421 // EQ or BOUND first
411422 for (int i = 0 , j = 0 ; i < *nRows; i++) {
412- if (constraint_type[i] == EQ) {
423+ if (* constraint_type[i] == EQ) {
413424 (*rhs)[j] = lhs_clp[i];
414425 (*constraint_new_idx)[i] = j;
415426 j++;
416- } else if (constraint_type[i] == BOUND) {
427+ } else if (* constraint_type[i] == BOUND) {
417428 (*rhs)[j] = 0.0 ;
418429 (*constraint_new_idx)[i] = j;
419430 j++;
420431 }
421432 }
422433 // then LEQ or GEQ
423434 for (int i = 0 , j = *nEqs; i < *nRows; i++) {
424- if (constraint_type[i] == LEQ) {
435+ if (* constraint_type[i] == LEQ) {
425436 (*rhs)[j] = -rhs_clp[i]; // multiply -1
426437 (*constraint_new_idx)[i] = j;
427438 j++;
428- } else if (constraint_type[i] == GEQ) {
439+ } else if (* constraint_type[i] == GEQ) {
429440 (*rhs)[j] = lhs_clp[i];
430441 (*constraint_new_idx)[i] = j;
431442 j++;
@@ -443,20 +454,20 @@ int formulateLP_highs(const HighsLp& lp, double** cost, int* nCols, int* nRows,
443454 // same order as in rhs
444455 // EQ or BOUND first
445456 for (int j = (*csc_beg)[i]; j < (*csc_beg)[i + 1 ]; j++) {
446- if (constraint_type[A_csc_idx[j]] == EQ ||
447- constraint_type[A_csc_idx[j]] == BOUND) {
457+ if (* constraint_type[A_csc_idx[j]] == EQ ||
458+ * constraint_type[A_csc_idx[j]] == BOUND) {
448459 (*csc_idx)[k] = (*constraint_new_idx)[A_csc_idx[j]];
449460 (*csc_val)[k] = A_csc_val[j];
450461 k++;
451462 }
452463 }
453464 // then LEQ or GEQ
454465 for (int j = (*csc_beg)[i]; j < (*csc_beg)[i + 1 ]; j++) {
455- if (constraint_type[A_csc_idx[j]] == LEQ) {
466+ if (* constraint_type[A_csc_idx[j]] == LEQ) {
456467 (*csc_idx)[k] = (*constraint_new_idx)[A_csc_idx[j]];
457468 (*csc_val)[k] = -A_csc_val[j]; // multiply -1
458469 k++;
459- } else if (constraint_type[A_csc_idx[j]] == GEQ) {
470+ } else if (* constraint_type[A_csc_idx[j]] == GEQ) {
460471 (*csc_idx)[k] = (*constraint_new_idx)[A_csc_idx[j]];
461472 (*csc_val)[k] = A_csc_val[j];
462473 k++;
@@ -466,7 +477,7 @@ int formulateLP_highs(const HighsLp& lp, double** cost, int* nCols, int* nRows,
466477
467478 // slacks for BOUND
468479 for (int i = 0 , j = nCols_clp; i < *nRows; i++) {
469- if (constraint_type[i] == BOUND) {
480+ if (* constraint_type[i] == BOUND) {
470481 (*csc_idx)[(*csc_beg)[j]] = (*constraint_new_idx)[i];
471482 (*csc_val)[(*csc_beg)[j]] = -1.0 ;
472483 j++;
0 commit comments