Cbc icon indicating copy to clipboard operation
Cbc copied to clipboard

Q: Is there a maximum length or other restrictions on variable names in the LP file?

Open hvoerman opened this issue 3 years ago • 2 comments

Is there a maximum length or other restrictions on variable names in the LP file?

hvoerman avatar Aug 18 '22 20:08 hvoerman

I've ran into a similar question after receiving errors on my chosen names so I looked at the source code myself and found the following points of reference:

At this point in time, the restrictions on variable (, constraint, and objective function) names in LP files seem to be:

  • the name length must be <= 100 characters (or <= 96 characters for ranged constraints since _low is appended to the name of the lower bound constraint)
  • the name can only contain any of these characters: 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"!#$%&(),.;?@_'{}~ and the backtick character which does not play nicely in this markdown
  • the name cannot be empty
  • the name cannot start with a number i.e. not with any of these characters: 1234567890
  • the name cannot be a keyword as defined here i.e. not any of these names with any capitalization: bound, bounds, integer, integers, general, generals, binary, binaries, semi-continuous, semi, semis, sos, end
  • the name cannot be any other reserved keyword as defined here i.e. not any of these names with any capitalization: free, inf

Hope this helps 🤓

Greetings

chriswasser avatar Sep 28 '22 13:09 chriswasser

Hopefully the above can be confirmed by one of the CBC developers.

@chriswasser: thanks very much for this investigation!

hvoerman avatar Sep 29 '22 21:09 hvoerman