Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in show(..., ::JuMP.Model) #1092

Closed
baggepinnen opened this issue Aug 9, 2017 · 7 comments
Closed

Bug in show(..., ::JuMP.Model) #1092

baggepinnen opened this issue Aug 9, 2017 · 7 comments
Labels
Category: Printing Related to printing

Comments

@baggepinnen
Copy link
Contributor

I get errors displaying some models in the terminal. Here are some related stack traces. Unfortunately, I find it hard to compose a MWE, but if the traces below don't help you figure out the issue I can continue trying.

ERROR: BoundsError: attempt to access 1-element Array{SubString{String},1} at index [2]
Stacktrace:
 [1] show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::JuMP.Model) at /home/fredrikb/.julia/v0.6/JuMP/src/print.jl:167
 [2] showall at ./show.jl:1724 [inlined]
 [3] repr(::JuMP.Model) at ./strings/io.jl:146
ERROR: BoundsError: attempt to access 1-element Array{SubString{String},1} at index [2]
Stacktrace:
 [1] show(::IOContext{Base.Terminals.TTYTerminal}, ::JuMP.Model) at /home/fredrikb/.julia/v0.6/JuMP/src/print.jl:167
 [2] show_delim_array(::IOContext{Base.Terminals.TTYTerminal}, ::Tuple{Base.AbstractIOBuffer{Array{UInt8,1}},JuMP.Model}, ::Char, ::Char, ::Char, ::Bool, ::Int64, ::Int64) at ./show.jl:381
 [3] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Tuple{Base.AbstractIOBuffer{Array{UInt8,1}},JuMP.Model}) at ./REPL.jl:122
 [4] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Tuple{Base.AbstractIOBuffer{Array{UInt8,1}},JuMP.Model}) at ./REPL.jl:125
 [5] display(::Tuple{Base.AbstractIOBuffer{Array{UInt8,1}},JuMP.Model}) at ./multimedia.jl:194
 [6] eval(::Module, ::Any) at ./boot.jl:235
 [7] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [8] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [9] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646

See also conversation in cstjean/TraceCalls.jl#35

@blegat
Copy link
Member

blegat commented Aug 9, 2017

Could you give what is the value of string(m.solver) where m is the JuMP model you are trying to print ?

@baggepinnen
Copy link
Contributor Author

It seems the problem was with the solver (from FirstOrderSolvers.jl), which did not return a string on the format expected. Is this format standardized, and in that case where can I find the specifications? Thanks

@blegat
Copy link
Member

blegat commented Aug 9, 2017

The name is obtained with split(split(string(m.solver), "Solver")[1], ".")[2]. split(string(m.solver), "Solver")[1] is expected to contained ModuleName.SolverName but here since the module name contains Solver it is FirstOrder. When when we split with "." and look for the second argument, it fails.
I doesn't look very good with Mosek either, it prints MosekMathProg because the solver is in a submodule.
We should probably just do print(io, m.solver) here or have a name function in the MPB/MOI interface. @joehuchette @chriscoey What do you think ?

@baggepinnen
Copy link
Contributor Author

Possibly as a fallback?

try
    print(io, split(split(string(m.solver), "Solver")[1], ".")[2])
catch
    print(io, m.solver)
end

@odow
Copy link
Member

odow commented Nov 10, 2018

Ref #1180

@odow
Copy link
Member

odow commented Dec 30, 2018

Can this be closed now that the new printing is implemented?

@mlubin
Copy link
Member

mlubin commented Dec 30, 2018

It can be closed because the SolverName attribute in MOI resolves this issue.

@mlubin mlubin closed this as completed Dec 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Printing Related to printing
Development

No branches or pull requests

4 participants