# Result and summary files not generated with BARON.jl

I solved the following tutorial problem on JuMP’s documentation page, but the result and summary file are not generated (I do set the `result` and `summary` parameters to 1):

``````using JuMP, BARON

rocket = Model(BARON.Optimizer)
set_optimizer_attribute(rocket, "MaxTime", 500)
set_optimizer_attribute(rocket, "NumLoc", 1)
set_optimizer_attribute(rocket, "results", 1)
set_optimizer_attribute(rocket, "summary", 1)

h_0 = 1    # Initial height
v_0 = 0    # Initial velocity
m_0 = 1    # Initial mass
g_0 = 1    # Gravity at the surface

T_c = 3.5  # Used for thrust
h_c = 500  # Used for drag
v_c = 620  # Used for drag
m_c = 0.6  # Fraction of initial mass left at end

c = 0.5 * sqrt(g_0 * h_0)  # Thrust-to-fuel mass
m_f = m_c * m_0              # Final mass
D_c = 0.5 * v_c * m_0 / g_0  # Drag scaling
T_max = T_c * g_0 * m_0        # Maximum thrust

n = 800    # Time steps

@variables(rocket, begin
Δt ≥ 0, (start = 1 / n) # Time step
# State variables
v[1:n] ≥ 0            # Velocity
h[1:n] ≥ h_0          # Height
m_f ≤ m[1:n] ≤ m_0    # Mass
# Control variables
0 ≤ T[1:n] ≤ T_max    # Thrust
end);

@objective(rocket, Max, h[n])

fix(v[1], v_0; force = true)
fix(h[1], h_0; force = true)
fix(m[1], m_0; force = true)
fix(m[n], m_f; force = true)

@NLexpressions(
rocket,
begin
# Drag(h,v) = Dc v^2 exp( -hc * (h - h0) / h0 )
drag[j = 1:n], D_c * (v[j]^2) * exp(-h_c * (h[j] - h_0) / h_0)
# Grav(h)   = go * (h0 / h)^2
grav[j = 1:n], g_0 * (h_0 / h[j])^2
# Time of flight
t_f, Δt * n
end
);

for j in 2:n
# h' = v
# Rectangular integration
# @NLconstraint(rocket, h[j] == h[j - 1] + Δt * v[j - 1])
# Trapezoidal integration
@NLconstraint(rocket, h[j] == h[j-1] + 0.5 * Δt * (v[j] + v[j-1]))
# v' = (T-D(h,v))/m - g(h)
# Rectangular integration
# @NLconstraint(
#     rocket,
#     v[j] == v[j - 1] + Δt *((T[j - 1] - drag[j - 1]) / m[j - 1] - grav[j - 1])
# )
# Trapezoidal integration
@NLconstraint(
rocket,
v[j] ==
v[j-1] +
0.5 *
Δt *
(
(T[j] - drag[j] - m[j] * grav[j]) / m[j] +
(T[j-1] - drag[j-1] - m[j-1] * grav[j-1]) / m[j-1]
)
)
# m' = -T/c
# Rectangular integration
# @NLconstraint(rocket, m[j] == m[j - 1] - Δt * T[j - 1] / c)
# Trapezoidal integration
@NLconstraint(rocket, m[j] == m[j-1] - 0.5 * Δt * (T[j] + T[j-1]) / c)
end

optimize!(rocket)
``````

I am using Julia 1.8.2, BARON v0.8.0, and JuMP v1.4.0.

Any help or pointers on what exactly is going wrong here would be appreciated. Thanks!

I don’t have BARON so I can’t test. But what is the problem, exactly? Does it not solve? Or is the problem just that the results and summary files are not generated?

I don’t know what the `results` and `summary` options are. But it looks like they should be `SumName` and `ResName`?

BARON does find a feasible solution (via local search) in the time limit I provide; however, the summary and result files are not generated in the end.

`result` and `summary` option indicates whether a result and a summary file should be generated, respectively. `ResName` and `SumName` are simply the result and summary file names to be generated.

Does `BARON.jl` just do not have this option to set these particular `RawOptimizerAttribute` or am I missing something here?

Does it generate the files on other examples? Does it respect the other parameters?

If it works for other models, or BARON respects the other parameters, then this seems like a bug in BARON. I don’t think it’s a bug in JuMP or BARON.jl.

No, it never generates these files. I tried BARON with pyomo and it did generate the summary file.

If possible can you try it through a small example I provide below. Is it possible for you use some trial version of BARON.

``````function example()
model = Model(BARON.Optimizer)
set_optimizer_attribute(model, "MaxTime", 100)
set_optimizer_attribute(model, "summary", 1)
set_optimizer_attribute(model, "results", 1)
@variable(model, x >= 0)
@variable(model, y >= 0)
@NLconstraint(model, x+y+x*y <= 10)
@objective(model, Max, x+2*y)
optimize!(model)
println("x: ", value(x))
println("y: ", value(y))
end
``````

How do you know the files dont get created? Did you also try setting the file names? It looks like they get written to a temporary directory. Did you check inside there?

1 Like

OK. It works now. Setting the file names explicitly did the trick. They do have default file name (as mentioned in the BARON manual) so I assumed it should automatically generate file by that name. But apparently that’s not the case. Anyway, thanks for all the help and pointing me in the right direction.

1 Like