@@ -229,10 +229,10 @@ cupdlp_retcode cupdlp_pc_scaling(CUPDLPcsc *csc, cupdlp_float *cost,
229229 return retcode ;
230230}
231231
232- cupdlp_retcode PDHG_Scale_Data (CUPDLPcsc * csc , cupdlp_int ifScaling ,
233- CUPDLPscaling * scaling , cupdlp_float * cost ,
234- cupdlp_float * lower , cupdlp_float * upper ,
235- cupdlp_float * rhs ) {
232+ cupdlp_retcode PDHG_Scale_Data (cupdlp_int log_level , CUPDLPcsc * csc ,
233+ cupdlp_int ifScaling , CUPDLPscaling * scaling ,
234+ cupdlp_float * cost , cupdlp_float * lower ,
235+ cupdlp_float * upper , cupdlp_float * rhs ) {
236236 cupdlp_retcode retcode = RETCODE_OK ;
237237 // scaling->dObjScale = 1.0;
238238
@@ -255,11 +255,13 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
255255 }
256256 dAvgElem /= csc -> colMatBeg [nCols ];
257257
258- cupdlp_printf ("Problem before rescaling:\n" );
259- cupdlp_printf (
260- "Absolute value of nonzero constraint matrix elements: largest=%f, "
261- "smallest=%f, avg=%f\n" ,
262- dMaxElem , dMinElem , dAvgElem );
258+ if (log_level ) {
259+ cupdlp_printf ("Problem before rescaling:\n" );
260+ cupdlp_printf (
261+ "Absolute value of nonzero constraint matrix elements: largest=%f, "
262+ "smallest=%f, avg=%f\n" ,
263+ dMaxElem , dMinElem , dAvgElem );
264+ }
263265
264266 // calculate the three statistics of objective vector
265267 dMinElem = OUR_DBL_MAX ;
@@ -274,6 +276,8 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
274276 dAvgElem += dAbsElem ;
275277 }
276278 dAvgElem /= nCols ;
279+
280+ // if (log_level) {}
277281 cupdlp_printf (
278282 "Absolute value of objective vector elements: largest=%f, smallest=%f, "
279283 "avg=%f\n" ,
@@ -299,26 +303,26 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
299303#endif
300304
301305 if (ifScaling ) {
302- cupdlp_printf ("--------------------------------------------------\n" );
303- cupdlp_printf ("running scaling\n" );
306+ if ( log_level ) cupdlp_printf ("--------------------------------------------------\n" );
307+ if ( log_level ) cupdlp_printf ("running scaling\n" );
304308
305309 if (scaling -> ifRuizScaling ) {
306- cupdlp_printf ("- use Ruiz scaling\n" );
310+ if ( log_level ) cupdlp_printf ("- use Ruiz scaling\n" );
307311 CUPDLP_CALL (cupdlp_ruiz_scaling (csc , cost , lower , upper , rhs , scaling ))
308312 scaling -> ifScaled = 1 ;
309313 }
310314 if (scaling -> ifL2Scaling ) {
311- cupdlp_printf ("- use L2 scaling\n" );
315+ if ( log_level ) cupdlp_printf ("- use L2 scaling\n" );
312316 CUPDLP_CALL (cupdlp_l2norm_scaling (csc , cost , lower , upper , rhs , scaling ))
313317 scaling -> ifScaled = 1 ;
314318 }
315319 if (scaling -> ifPcScaling ) {
316- cupdlp_printf ("- use PC scaling\n" );
320+ if ( log_level ) cupdlp_printf ("- use PC scaling\n" );
317321 CUPDLP_CALL (cupdlp_pc_scaling (csc , cost , lower , upper , rhs , scaling ))
318322 scaling -> ifScaled = 1 ;
319323 }
320324
321- cupdlp_printf ("--------------------------------------------------\n" );
325+ if ( log_level ) cupdlp_printf ("--------------------------------------------------\n" );
322326 }
323327
324328 /* make sure the csr matrix is also scaled*/
@@ -339,8 +343,8 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
339343 }
340344 dAvgElem /= csc -> colMatBeg [nCols ];
341345
342- cupdlp_printf ("Problem after rescaling:\n" );
343- cupdlp_printf (
346+ if ( log_level ) cupdlp_printf ("Problem after rescaling:\n" );
347+ if ( log_level ) cupdlp_printf (
344348 "Absolute value of nonzero constraint matrix elements: largest=%f, "
345349 "smallest=%f, avg=%f\n" ,
346350 dMaxElem , dMinElem , dAvgElem );
@@ -358,7 +362,7 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
358362 dAvgElem += dAbsElem ;
359363 }
360364 dAvgElem /= nCols ;
361- cupdlp_printf (
365+ if ( log_level ) cupdlp_printf (
362366 "Absolute value of objective vector elements: largest=%f, smallest=%f, "
363367 "avg=%f\n" ,
364368 dMaxElem , dMinElem , dAvgElem );
@@ -375,7 +379,7 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
375379 dAvgElem += dAbsElem ;
376380 }
377381 dAvgElem /= nRows ;
378- cupdlp_printf (
382+ if ( log_level ) cupdlp_printf (
379383 "Absolute value of rhs vector elements: largest=%f, smallest=%f, "
380384 "avg=%f\n" ,
381385 dMaxElem , dMinElem , dAvgElem );
@@ -387,9 +391,9 @@ cupdlp_retcode PDHG_Scale_Data(CUPDLPcsc *csc, cupdlp_int ifScaling,
387391 return retcode ;
388392}
389393
390- cupdlp_retcode Init_Scaling (CUPDLPscaling * scaling , cupdlp_int ncols ,
391- cupdlp_int nrows , cupdlp_float * cost ,
392- cupdlp_float * rhs ) {
394+ cupdlp_retcode Init_Scaling (cupdlp_int log_level , CUPDLPscaling * scaling ,
395+ cupdlp_int ncols , cupdlp_int nrows ,
396+ cupdlp_float * cost , cupdlp_float * rhs ) {
393397 cupdlp_retcode retcode = RETCODE_OK ;
394398
395399 scaling -> rowScale = NULL ;
0 commit comments