# JuMP print sub-expressions

Hello,

I have created an optimisation problem in JuMP with a set constraints that is created from affine and non-linear expressions. When i print() the model, the constraints show up as below. Is there any way to print the full expanded constraint, or potentially even the sub-expressions that make up the constraint? I would like to check whether the formulation is being created properly. Grateful for any assistance. Many thanks,

(0_vr[1] ^ 2.0 + 0_vi[1] ^ 2.0) * (0_cr[(1, 1, 3)] ^ 2.0 + 0_ci[(1, 1, 3)] ^ 2.0) - 90.0 ^ 2.0 <= 0
(0_vr[3] ^ 2.0 + 0_vi[3] ^ 2.0) * (0_cr[(1, 3, 1)] ^ 2.0 + 0_ci[(1, 3, 1)] ^ 2.0) - 90.0 ^ 2.0 <= 0
subexpression[20] - subexpression[22] == 0
subexpression[21] - subexpression[23] == 0
subexpression[34] - subexpression[36] == 0
subexpression[35] - subexpression[37] == 0
subexpression[48] - subexpression[50] == 0
subexpression[49] - subexpression[51] == 0

You can do this if you name the constraint (upon creation or after), or if you use `all_constraints` with the right constraint type.

``````julia> m = Model();

julia> @variable(m, x[1:3]);

julia> @constraint(m, c, x[1]^2 + 3x[2]^2 + 2x[3]^2 >= 0)
c : x[1]² + 3 x[2]² + 2 x[3]² ≥ 0.0

# method 1 (use the name)
julia> c
c : x[1]² + 3 x[2]² + 2 x[3]² ≥ 0.0

julia> m[:c]
c : x[1]² + 3 x[2]² + 2 x[3]² ≥ 0.0

# method 2

c : x[1]² + 3 x[2]² + 2 x[3]² ≥ 0.0

# method 3

julia> c = @constraint(m, x[1]^2 + 3x[2]^2 + 2x[3]^2 >= 0)
x[1]² + 3 x[2]² + 2 x[3]² ≥ 0.0

julia> set_name(c, "My name")

julia> constraint_by_name(m, "My name")
My name : x[1]² + 3 x[2]² + 2 x[3]² ≥ 0.0
``````

You can find out which constraint types are in your model with `list_of_constraint_types`

Many thanks! This is most appreciated.

For nonlinear expressions, subexpression printing isn’t implemented. There is an open issue: https://github.com/jump-dev/JuMP.jl/issues/1983