I construct a model for a nonlinear optimization problem in the Julia JuMP code below, using either the non-legacy (use_legacy_model = false) or legacy (use_legacy_model = true) model interface and save the model to a .nl file using write_to_file. The .nl file created from the legacy model interface is much smaller (e.g. 229KB) than the .nl created from the non-legacy model interface (e.g. 4.5MB). What is the reason for the significantly different file sizes?

-rw-rw-r-- 1 stuart stuart 229K Jun 6 13:43 model_legacy.nl

-rw-rw-r-- 1 stuart stuart 4.5M Jun 6 13:44 model_non_legacy.nl

```
using JuMP
use_legacy_model = false # Whether to use legacy JuMP nonlinear constraints, expressions, and objectives.
N1 = 64
N = 64
zpad = 2
M = zpad*N
s = rand(M,1)
Br = rand(M, N1)
Bi = rand(M, N1)
Mt = trunc(Int,floor(M/2))+1
Br = Br[1:Mt,:]
Bi = Bi[1:Mt,:]
s = s[1:Mt]
Me = Mt
# Construct the JuMP model.
model_construction_time = @elapsed begin # Start elapsed.
model = Model()
@variable(model, y[1:N1], Bin)
if(~use_legacy_model)
print("Constructing non-legacy model.\n")
@expression(model, yh, y.-.5)
#@expression(model, yh[n=1:N1], y[n]-.5)
@expression(model, spec_r, Br*yh)
@expression(model, spec_i, Bi*yh)
#@expression(model, spec_sq_mag, spec_r.^2 .+ spec_i.^2) # Slow
@expression(model, spec_sq_mag[m=1:Me], spec_r[m]^2 + spec_i[m]^2) # Fast
#@expression(model, gamma, sum((spec_sq_mag.-s).^2)) # Slow
@expression(model, gamma, sum((spec_sq_mag[m]-s[m])^2 for m in 1:Me)) # Fast
@objective(model, Min, gamma)
else
print("Constructing legacy model.\n")
@expression(model, yh[n=1:N1], y[n]-.5)
@expression(model, spec_r, Br*yh)
@expression(model, spec_i, Bi*yh)
@NLexpression(model, spec_sq_mag[m=1:Me], spec_r[m]^2 + spec_i[m]^2)
@variable(model, gamma >= 0)
@NLconstraint(model, gamma >= sum((spec_sq_mag[m]-s[m])^2 for m in 1:Me))
@objective(model, Min, gamma)
end
end # End elapsed.
println("\nJuMP model construction time: $(model_construction_time) [s].")
# Write the JuMP model to a .nl file.
model_write_time = @elapsed begin # Start elapsed.
write_to_file(model,"model.nl")
end # End elapsed.
println("\nJuMP model write time: $(model_write_time) [s].")
```