I am building an optimization model where I would like to use JuMP expressions to smoothly add elements of constraints across different parts of the model. However, the sets I am working with and over which I am initializing my variables are not numeric but often lists of strings. In this case, @expresssion macro returns DenseAxisArray instead of Matrix{AffExpr}, which I cannot easily manipulate, add together and use functions such as [add_to_expression!]

Here is a simple example:

using JuMP
model = Model()
I = [1, 2, 3] #first set
J = ["A", "B", "C"] #second set
@variable(model, x[i in I, j in J] >= 0)
@expression(model, expr[i in I, j in J], x) #produces the DenseAxisArray

Can you share a larger example of what you are trying to do? In most cases, you should be able to write similar code depending on whether the data structure is a matrix or dense axis array.

See Containers · JuMP, which explains the various operations you can do with a dense axis array.