@@ -271,6 +271,7 @@ SCIP_RETCODE SCIPreaderWrite(
271
271
SCIP_READER * reader , /**< reader */
272
272
SCIP_PROB * prob , /**< problem data */
273
273
SCIP_SET * set , /**< global SCIP settings */
274
+ SCIP_MESSAGEHDLR * msghdlr , /**< message handler */
274
275
FILE * file , /**< output file (or NULL for standard output) */
275
276
const char * extension , /**< file format */
276
277
SCIP_Bool genericnames , /**< using generic variable and constraint names? */
@@ -302,12 +303,52 @@ SCIP_RETCODE SCIPreaderWrite(
302
303
int nconss ;
303
304
int nvars ;
304
305
int i ;
306
+ int nduplicates ;
305
307
306
308
vars = SCIPprobGetVars (prob );
307
309
nvars = SCIPprobGetNVars (prob );
308
310
fixedvars = SCIPprobGetFixedVars (prob );
309
311
nfixedvars = SCIPprobGetNFixedVars (prob );
310
312
313
+ /* check if multiple variables have the same name */
314
+ if ( !genericnames )
315
+ {
316
+ nduplicates = 0 ;
317
+
318
+ for ( i = 0 ; i < nvars ; ++ i )
319
+ {
320
+ if ( vars [i ] != (SCIP_VAR * ) SCIPprobFindVar (prob , (void * ) SCIPvarGetName (vars [i ])) )
321
+ {
322
+ if ( nduplicates < 3 )
323
+ {
324
+ SCIPmessageFPrintWarning (msghdlr , "The same variable name <%s> has been used for at least two different variables.\n" , SCIPvarGetName (vars [i ]));
325
+ }
326
+ ++ nduplicates ;
327
+ }
328
+ }
329
+
330
+ for ( i = 0 ; i < nfixedvars ; ++ i )
331
+ {
332
+ if ( fixedvars [i ] != (SCIP_VAR * ) SCIPprobFindVar (prob , (void * ) SCIPvarGetName (fixedvars [i ])) )
333
+ {
334
+ if ( nduplicates < 3 )
335
+ {
336
+ SCIPmessageFPrintWarning (msghdlr , "The same variable name <%s> has been used for at least two different variables.\n" , SCIPvarGetName (fixedvars [i ]));
337
+ }
338
+ ++ nduplicates ;
339
+ }
340
+ }
341
+
342
+ if ( nduplicates > 0 )
343
+ {
344
+ if ( nduplicates > 3 )
345
+ {
346
+ SCIPmessageFPrintWarning (msghdlr , "In total %d duplicate variable names.\n" , nduplicates );
347
+ }
348
+ SCIPmessageFPrintWarning (msghdlr , "This will likely result in wrong output files. Please use unique variable names.\n" );
349
+ }
350
+ }
351
+
311
352
/* case of the transformed problem, we want to write currently valid problem */
312
353
if ( SCIPprobIsTransformed (prob ) )
313
354
{
@@ -369,6 +410,33 @@ SCIP_RETCODE SCIPreaderWrite(
369
410
nconss = SCIPprobGetNConss (prob );
370
411
}
371
412
413
+ /* check if multiple constraints have the same name */
414
+ if ( !genericnames )
415
+ {
416
+ nduplicates = 0 ;
417
+
418
+ for ( i = 0 ; i < SCIPprobGetNConss (prob ); ++ i )
419
+ {
420
+ if ( conss [i ] != (SCIP_CONS * ) SCIPprobFindCons (prob , (void * ) SCIPconsGetName (conss [i ])) )
421
+ {
422
+ if ( nduplicates < 3 )
423
+ {
424
+ SCIPmessageFPrintWarning (msghdlr , "The same constraint name <%s> has been used for at least two different constraints.\n" , SCIPconsGetName (conss [i ]));
425
+ }
426
+ ++ nduplicates ;
427
+ }
428
+ }
429
+
430
+ if ( nduplicates > 0 )
431
+ {
432
+ if ( nduplicates > 3 )
433
+ {
434
+ SCIPmessageFPrintWarning (msghdlr , "In total %d duplicate constraint names.\n" , nduplicates );
435
+ }
436
+ SCIPmessageFPrintWarning (msghdlr , "This can result in wrong output files, especially with indicator constraints.\n" );
437
+ }
438
+ }
439
+
372
440
if ( genericnames )
373
441
{
374
442
SCIP_VAR * var ;
0 commit comments