Hello! How can I retrieve the variable values from the NEOS server? Currently I only receive the objective function value in my e-mail.
For example, to this code:
using JuMP, NamedArrays, Cbc, NEOSServer
threath = Model() do
NEOSServer.Optimizer(email="my@email.com", solver="CPLEX")
end
regions = [:A, :B, :C, :D, :E]
animals = [:α, :β]
targets = NamedArray([64, 87], animals)
costs = NamedArray([97, 73, 22, 11, 25], regions)
areas = NamedArray([24 83
36 16
00 19
15 00
40 18], (regions, animals))
@variable(threath, x[r in regions], Bin)
for animal in animals
@constraint(threath, sum(x[r]*areas[r,animal] for r in regions) >= targets[animal])
end
@objective(threath, Min, sum(x[r]*costs[r] for r in regions))
optimize!(threath)
I only receive this:
CPLEX 20.1.0.0: optimal integer solution; objective 122
0 MIP simplex iterations
0 branch-and-bound nodes
No basis.
Options
3
1
1
0
2
0
5
5
1
0
0
0
1
objno 0 2
odow
July 7, 2021, 7:09pm
2
The results are automatically loaded back into julia like any other solver. You don’t need to check the email.
(The primal solution is hidden in that file, it’s just not obvious)
Awesome! I didn’t realize, because when I type solution_summary(threath)
it gives me an error:
ERROR: ArgumentError: ModelLike of type AmplNLWriter.Optimizer does not support accessing the attribute MathOptInterface.SolveTime()
But, indeed, if I write in the REPL value(x[:A])
, it gives back the value. Great!
Nevertheless, I would like to know: why can’t I get the solution summary? Is there a workaround to do so?
Thanks!
1 Like
odow
July 7, 2021, 9:55pm
4
This is an oversight in the JuMP code:
dual_status(model),
raw_status(model),
result_count(model),
has_values(model),
has_duals(model),
objective_value(model),
_try_get(objective_bound, model),
_try_get(dual_objective_value, model),
verbose ? _get_solution_dict(model) : missing,
verbose ? _get_constraint_dict(model) : missing,
solve_time(model),
_try_get(simplex_iterations, model),
_try_get(barrier_iterations, model),
_try_get(node_count, model),
)
end
"""
Base.show([io::IO], summary::SolutionSummary; verbose::Bool = false)
Write a summary of the solution results to `io` (or to `stdout` if `io` is not
But it’s also a problem with AmplNLWriter. I should implement the SolveTime attribute.
As a work-around, you could add this to your script after you have using JuMP
:
using JuMP, NEOSServer
# Fake `SolveTime` for AmplNLWriter as a work-around so JuMP doesn't crash on
# `solution_summary(model)`.
#
# WARNING: This is type-piracy! It should be removed as soon as possible.
using AmplNLWriter
MOI.get(model::AmplNLWriter.Optimizer, ::MOI.SolveTime) = NaN
1 Like
odow
July 7, 2021, 10:40pm
5
I’ve opened a PR: Implement MOI.SolveTime by odow · Pull Request #144 · jump-dev/AmplNLWriter.jl · GitHub , so I will try to get this merged and a new released tagged today.
Edit: merged. Update your packages, restart Julia, and try again.
3 Likes
Wow, awesome! Thanks! I’ll try it today.
And thanks for maintaining the package, by the way, it’s greatto be able to use NEOS with Julia!
1 Like