Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Conversion of variable names when writing lp files, C API

    Posted 02/15/19 08:25 AM

    Originally posted by: ops1234


    Hi,

    I am writing my whole model into a lp-file with the function CPXXwriteprob(env,lp,"myprob.lp",nullptr). In this file cplex appended #number to each variable with an increasing number for each new variable. Same thing happens with constraints. Can I somehow turn this off? I have given all my variables unique names already.

     

    Best regards,

    ops


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Conversion of variable names when writing lp files, C API

    Posted 02/15/19 10:55 AM

    This happens if some of your variable or constraint names are not valid for LP file format and have thus to be replaced for output. Consequently, this behavior cannot be turned off since otherwise the LP file would be incorrect.

    You can find the rules for names in LP files here: https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/FileFormats/topics/LP_VariableNames.html

    Make sure all your names conform to this then no change in names should happen.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Conversion of variable names when writing lp files, C API

    Posted 02/15/19 12:41 PM

    Originally posted by: ops1234


    Hi,

    thanks for your answer. I am not sure if I understand the rule concerning the letter e. Is something like 'vel3' or 'EXC3' allowed? Another question: If all my variables conform to the rules and have unique names, but several constraints 'of the same class' have the same name, e.g. several constraints were given the name "LINK_CONSTR", does cplex give only each constraint a #number or do the variables also get numbers?

     

    Best regards,

    ops


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Conversion of variable names when writing lp files, C API

    Posted 02/15/19 12:48 PM

    "vel3" is fine, "EXC3" is not (the rule says that names must not start with 'e' or 'E').

    I don't think CPLEX checks for duplicate constraint names. So if you have multiple constraints with the same name then the LP file will just have multiple constraints with the same name. Same for variables.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Conversion of variable names when writing lp files, C API

    Posted 02/15/19 01:01 PM

    Originally posted by: ops1234


    Thank you for your quick response. I could see that cplex doesn't care about same constraint names, but same variable names could become a problem? Unless cplex saves and works with its own variable identifiers and the user defined names are only for output. Well I guess I will see when I change the names. Nonetheless, thank you very much, this helped a lot. 


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Conversion of variable names when writing lp files, C API

    Posted 02/15/19 02:13 PM

    Yes, duplicate variable names can easily become a problem. CPLEX will happily write these variables to the LP file -- with the same name! Any reader can then of course not distinguish the two variables and will thus merge them into one. This will result in a different model. Thus duplicate variable names must be avoided.


    #CPLEXOptimizers
    #DecisionOptimization