I need a different set of naming conventions when using Julia to write mathematical models than what is generally recommended for general purpose code. For example, it is often important to be able to distinguish at a glance between model variables (which change during the course of a single model run) and model parameters (which don’t, although they may vary from one run to another). Both of these would be represented by ordinary variables in Julia.
So far I’ve been using the same conventions for my Julia models that I originally came up with for models written in GAMS or AMPL. I use
CamelCase with an initial capital for model variables and
lower_case_with_underscore for parameters. This works fine for me, but since I intend to start open-sourcing my models I’m becoming uncomfortable with the fact that my scheme conflicts with standard Julia naming conventions (which reserves
CamelCase for modules and types).
The distinction between variables and parameters is important because you often need to be aware of where your nonlinearities are. For example, using my convention I can immediately tell that both these equations are nonlinear, and would require a nonlinear solver:
BioNPP = base_NPP * (1 + fertilization*log(Concentration[:CO2]/preindustrial_CO2)) dt_BioReservoir = BioNPP*biobox_weight - BioReservoir*bio_Q10_factor^(TempLand/10)./biobox_time
… while these are linear and are therefore much easier to solve:
BioNPP = base_NPP * (1 + fertilization*log(concentration[:CO2]/preindustrial_CO2)) dt_BioReservoir = BioNPP*biobox_weight - BioReservoir*bio_Q10_factor^(temp_land/10)./biobox_time
I use another convention here as well: variables prefixed with
dt_ indicate a time derivative. Other models may have other requirements. For example, in a mixed-integer programming model written in JuMP you may want to use different naming schemes for integer and continuous variables.
So I’m curious what other modelers have come up with. Do you sacrifice mathematical clarity to follow standard Julian conventions, or do you break conventions when there is a good reason to do so? Is there an alternative convention I can use that works better for mathematical models in Julia? I know someone who prefixes all parameters with
p_ and all variables with
v_, but that just looks too ugly to me.