# 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 ^ 2.0 + 0_vi ^ 2.0) * (0_cr[(1, 1, 3)] ^ 2.0 + 0_ci[(1, 1, 3)] ^ 2.0) - 90.0 ^ 2.0 <= 0
(0_vr ^ 2.0 + 0_vi ^ 2.0) * (0_cr[(1, 3, 1)] ^ 2.0 + 0_ci[(1, 3, 1)] ^ 2.0) - 90.0 ^ 2.0 <= 0
subexpression - subexpression == 0
subexpression - subexpression == 0
subexpression - subexpression == 0
subexpression - subexpression == 0
subexpression - subexpression == 0
subexpression - subexpression == 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^2 + 3x^2 + 2x^2 >= 0)
c : x² + 3 x² + 2 x² ≥ 0.0

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

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

# method 2

c : x² + 3 x² + 2 x² ≥ 0.0

# method 3

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

julia> set_name(c, "My name")

julia> constraint_by_name(m, "My name")
My name : x² + 3 x² + 2 x² ≥ 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