Short Variable Names
(also applies to objective and constraint names)
Models that contain a large number of variables will most likely allocate a significant amount of RAM, even though the actual solution process was not even started. A huge proportion of the allocated memory is made up by the variable/objective/constraint names that are stored as strings. This is especially true for very long names, e.g. names that consist of a concatenation of several indices. The OPTANO.Modeling Library provides a methodology to reduce the amount of memory that is allocated by variable (and constraint) names.
When the NameHandlingStyle is set to NameHandlingStyle.UniqueShortNames, the names will not be generated by the UniqueNameGenerator that is provided to the VariableCollection, but instead consist of a running counter that is converted to a string, similar to base64. An example for a short name is:
Note: Names of objectives and constraints will be overwritten, if one of the UniqueName-Generators is used.
variable.VariableName = "AAb"
(If I am not mistaken this should be the index of the 215,751st created variable: 52^2 * 27 + 52 * 27 + 2)
Note that the chars used are limited to A-Z and a-z in order to comply with all solvers (base64 uses a larger char set). The underlying counter is a 64bit Integer, thus, at most 12 digits (= Math.Ceiling(11.052)
) will be required for the name representation.
- Since it is quite unlikely, that anybody will ever create
2^63
variables, the maximum index-length of 12 chars will probably never be reached. - For a model with 10,000,000 variables, the maximum index length will be
Math.Ceiling(4.080)
=5
characters.- This upper bound will hold up to approximately 380,000,000 (~52^5 - 1) variables :)
To use an variable/constraint/objective name in the code, always refer to it as (do not use the name initially given!)
variable.Name
constraint.Name
objective.Name