# Result and summary files not generated with BARON.jl

**URL:** <https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722>\
**Category:** Optimization (Mathematical)\
**Tags:** question, package, jump\
**Created:** [November 3, 2022, 4:03pm UTC](https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722 "2022-11-03T16:03:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [November 3, 2022, 4:03pm UTC](https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722/1 "2022-11-03T16:03:01Z")

</div>

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):

```julia
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!

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [November 3, 2022, 6:58pm UTC](https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722/2 "2022-11-03T18:58:11Z")

</div>

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`?

> <https://github.com/jump-dev/BARON.jl/blob/d052dc01551198d27ab201221e8ace0b452f2096/src/BARON.jl#L97-L98>

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [November 3, 2022, 7:08pm UTC](https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722/3 "2022-11-03T19:08:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [November 3, 2022, 7:15pm UTC](https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722/4 "2022-11-03T19:15:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [November 3, 2022, 7:57pm UTC](https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722/5 "2022-11-03T19:57:03Z")

</div>

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.

```julia
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

```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [November 3, 2022, 7:59pm UTC](https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722/6 "2022-11-03T19:59:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [November 3, 2022, 8:16pm UTC](https://discourse.julialang.org/t/result-and-summary-files-not-generated-with-baron-jl/89722/7 "2022-11-03T20:16:12Z")

</div>

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. 🙂
