I am trying to define a decision variable L \in \mathbb{R}^{n\times n} in JuMP, which is lower triangular. As of now, I am defining this matrix as follows.

@variable(my_model, L_mat[1:n, 1:n])
# upper off-diagonal terms of L_mat are zero
for i in 1:n
for j in 1:n
if i < j
fix(L_mat[i,j], 0; force = true)
end
end
end

While this works for my purpose, I was wondering if there is a more efficient way to define this matrix in JuMP? The number n can be quite large for the example that I am trying to solve.

Yes, I tried that @odow , but for some reason, I got a â€śtoo few degrees of freedomâ€ť error using IPOPT for my problem when doing this (make a symmetric matrix and then form the lower triangle). Okay, for now, let me just stick to how I am defining it, I do not think this is a major issue for my problem. I was just curious to know if there is a direct way.

Too few degrees of freedom is usually when the problem is over determined. Do you have duplicate sets of constraints? Itâ€™s not a problem from the triangular matrix directly.