@@ -279,6 +279,7 @@ SCIP_RETCODE SCIPreaderWrite(
279
279
SCIP_READER * reader , /**< reader */
280
280
SCIP_PROB * prob , /**< problem data */
281
281
SCIP_SET * set , /**< global SCIP settings */
282
+ SCIP_MESSAGEHDLR * msghdlr , /**< message handler */
282
283
FILE * file , /**< output file (or NULL for standard output) */
283
284
const char * extension , /**< file format */
284
285
SCIP_Bool genericnames , /**< using generic variable and constraint names? */
@@ -310,6 +311,7 @@ SCIP_RETCODE SCIPreaderWrite(
310
311
int nconss ;
311
312
int nvars ;
312
313
int i ;
314
+ int nduplicates ;
313
315
314
316
/* only readers marked as exact can read and write in exact solving mode */
315
317
if ( set -> exact_enable && !reader -> exact )
@@ -323,6 +325,45 @@ SCIP_RETCODE SCIPreaderWrite(
323
325
fixedvars = SCIPprobGetFixedVars (prob );
324
326
nfixedvars = SCIPprobGetNFixedVars (prob );
325
327
328
+ /* check if multiple variables have the same name */
329
+ if ( !genericnames )
330
+ {
331
+ nduplicates = 0 ;
332
+
333
+ for ( i = 0 ; i < nvars ; ++ i )
334
+ {
335
+ if ( vars [i ] != (SCIP_VAR * ) SCIPprobFindVar (prob , (void * ) SCIPvarGetName (vars [i ])) )
336
+ {
337
+ if ( nduplicates < 3 )
338
+ {
339
+ SCIPmessageFPrintWarning (msghdlr , "The same variable name <%s> has been used for at least two different variables.\n" , SCIPvarGetName (vars [i ]));
340
+ }
341
+ ++ nduplicates ;
342
+ }
343
+ }
344
+
345
+ for ( i = 0 ; i < nfixedvars ; ++ i )
346
+ {
347
+ if ( fixedvars [i ] != (SCIP_VAR * ) SCIPprobFindVar (prob , (void * ) SCIPvarGetName (fixedvars [i ])) )
348
+ {
349
+ if ( nduplicates < 3 )
350
+ {
351
+ SCIPmessageFPrintWarning (msghdlr , "The same variable name <%s> has been used for at least two different variables.\n" , SCIPvarGetName (fixedvars [i ]));
352
+ }
353
+ ++ nduplicates ;
354
+ }
355
+ }
356
+
357
+ if ( nduplicates > 0 )
358
+ {
359
+ if ( nduplicates > 3 )
360
+ {
361
+ SCIPmessageFPrintWarning (msghdlr , "In total %d duplicate variable names.\n" , nduplicates );
362
+ }
363
+ SCIPmessageFPrintWarning (msghdlr , "This will likely result in wrong output files. Please use unique variable names.\n" );
364
+ }
365
+ }
366
+
326
367
/* case of the transformed problem, we want to write currently valid problem */
327
368
if ( SCIPprobIsTransformed (prob ) )
328
369
{
@@ -384,6 +425,33 @@ SCIP_RETCODE SCIPreaderWrite(
384
425
nconss = SCIPprobGetNConss (prob );
385
426
}
386
427
428
+ /* check if multiple constraints have the same name */
429
+ if ( !genericnames )
430
+ {
431
+ nduplicates = 0 ;
432
+
433
+ for ( i = 0 ; i < SCIPprobGetNConss (prob ); ++ i )
434
+ {
435
+ if ( conss [i ] != (SCIP_CONS * ) SCIPprobFindCons (prob , (void * ) SCIPconsGetName (conss [i ])) )
436
+ {
437
+ if ( nduplicates < 3 )
438
+ {
439
+ SCIPmessageFPrintWarning (msghdlr , "The same constraint name <%s> has been used for at least two different constraints.\n" , SCIPconsGetName (conss [i ]));
440
+ }
441
+ ++ nduplicates ;
442
+ }
443
+ }
444
+
445
+ if ( nduplicates > 0 )
446
+ {
447
+ if ( nduplicates > 3 )
448
+ {
449
+ SCIPmessageFPrintWarning (msghdlr , "In total %d duplicate constraint names.\n" , nduplicates );
450
+ }
451
+ SCIPmessageFPrintWarning (msghdlr , "This can result in wrong output files, especially with indicator constraints.\n" );
452
+ }
453
+ }
454
+
387
455
if ( genericnames )
388
456
{
389
457
SCIP_VAR * var ;
0 commit comments