Generates and adds short index aliases for sets in a multimod model. These aliases are used as iteration variable names in constraint indexing and array subscripts across different output formats (GMPL, Julia, Pyomo, LaTeX).
Details
Index aliases are short symbolic names used in equations:
GMPL:
{h in tech, r in region}where h, r are index aliasesJulia:
@constraint(model, [h in tech, r in region], ...)LaTeX:
\\sum_{h \\in \\mathcal{T}}
Auto-generated aliases follow these rules:
Use first letter(s) of set name
Handle plurals (e.g., "technologies" -> "t")
Avoid conflicts with existing symbols
For aliases like "commp", append suffix (e.g., "cp")
Examples
model <- new_model(
sets = list(
tech = new_set("technology"),
region = new_set("region"),
comm = new_set("commodity")
)
)
# Auto-generate aliases
model <- add_index_aliases(model)
# model$index_aliases: c(tech = "h", region = "r", comm = "c")
# Custom aliases
model <- add_index_aliases(model, index_aliases = c(tech = "t", region = "reg"))
#> Model already has index_aliases. Use overwrite=TRUE to replace them.
