Cbc
Cbc copied to clipboard
Q: Is there a maximum length or other restrictions on variable names in the LP file?
Is there a maximum length or other restrictions on variable names in the LP file?
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:
- the
is_invalid_nameimplementation in CoinUtils - the notes section in the associated header
- the documentation for
is_invalid_name
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
_lowis 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
Hopefully the above can be confirmed by one of the CBC developers.
@chriswasser: thanks very much for this investigation!