JuMP -- MethodError: no method matching _parse_section

Hello,

I receive the following error message

ERROR: MethodError: no method matching _parse_section(::Val{:header}, ::MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ObjectiveContainer{Float64}, MathOptInterface.Utilities.VariablesContainer{Float64}, MathOptInterface.FileFormats.LP.ModelFunctionConstraints{Float64}}, ::MathOptInterface.FileFormats.LP._ReadCache, ::SubString{String})
Closest candidates are:
  _parse_section(::Val{:objective}, ::MathOptInterface.Utilities.GenericModel{T, MathOptInterface.Utilities.ObjectiveContainer{T}, MathOptInterface.Utilities.VariablesContainer{T}, MathOptInterface.FileFormats.LP.ModelFunctionConstraints{T}} where T, ::MathOptInterface.FileFormats.LP._ReadCache, ::AbstractString) at C:\Users\Andrew Freiburger\.julia\packages\MathOptInterface\kCmJV\src\FileFormats\LP\LP.jl:514
  _parse_section(::Val{:constraints}, ::MathOptInterface.Utilities.GenericModel{T, MathOptInterface.Utilities.ObjectiveContainer{T}, MathOptInterface.Utilities.VariablesContainer{T}, MathOptInterface.FileFormats.LP.ModelFunctionConstraints{T}} 
where T, ::MathOptInterface.FileFormats.LP._ReadCache, ::AbstractString) at C:\Users\Andrew Freiburger\.julia\packages\MathOptInterface\kCmJV\src\FileFormats\LP\LP.jl:535
  _parse_section(::Val{:bounds}, ::MathOptInterface.Utilities.GenericModel{T, MathOptInterface.Utilities.ObjectiveContainer{T}, MathOptInterface.Utilities.VariablesContainer{T}, MathOptInterface.FileFormats.LP.ModelFunctionConstraints{T}} where T, ::MathOptInterface.FileFormats.LP._ReadCache, ::AbstractString) at C:\Users\Andrew Freiburger\.julia\packages\MathOptInterface\kCmJV\src\FileFormats\LP\LP.jl:606
  ...
Stacktrace:
  [1] read!(io::IOStream, model::MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ObjectiveContainer{Float64}, MathOptInterface.Utilities.VariablesContainer{Float64}, MathOptInterface.FileFormats.LP.ModelFunctionConstraints{Float64}})
    @ MathOptInterface.FileFormats.LP C:\Users\Andrew Freiburger\.julia\packages\MathOptInterface\kCmJV\src\FileFormats\LP\LP.jl:787
  [2] #11
    @ C:\Users\Andrew Freiburger\.julia\packages\MathOptInterface\kCmJV\src\FileFormats\FileFormats.jl:121 [inlined]      
  [3] open(::MathOptInterface.FileFormats.var"#11#12"{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ObjectiveContainer{Float64}, MathOptInterface.Utilities.VariablesContainer{Float64}, MathOptInterface.FileFormats.LP.ModelFunctionConstraints{Float64}}}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base .\io.jl:330
  [4] open(::Function, ::String, ::String)
    @ Base .\io.jl:328
  [5] compressed_open(f::Function, filename::String, mode::String, #unused#::MathOptInterface.FileFormats.NoCompression)  
    @ MathOptInterface.FileFormats C:\Users\Andrew Freiburger\.julia\packages\MathOptInterface\kCmJV\src\FileFormats\utils.jl:213
  [6] compressed_open(f::Function, filename::String, mode::String, #unused#::MathOptInterface.FileFormats.AutomaticCompression)
    @ MathOptInterface.FileFormats C:\Users\Andrew Freiburger\.julia\packages\MathOptInterface\kCmJV\src\FileFormats\utils.jl:251
  [7] read_from_file(model::MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ObjectiveContainer{Float64}, MathOptInterface.Utilities.VariablesContainer{Float64}, MathOptInterface.FileFormats.LP.ModelFunctionConstraints{Float64}}, filename::String)
    @ MathOptInterface.FileFormats C:\Users\Andrew Freiburger\.julia\packages\MathOptInterface\kCmJV\src\FileFormats\FileFormats.jl:120
  [8] read_from_file(filename::String; format::MathOptInterface.FileFormats.FileFormat, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JuMP C:\Users\Andrew Freiburger\.julia\packages\JuMP\Y4piv\src\file_formats.jl:121
  [9] read_from_file
    @ C:\Users\Andrew Freiburger\.julia\packages\JuMP\Y4piv\src\file_formats.jl:119 [inlined]
 [10] execute_cobra(model_path::String)
    @ Main c:\Users\Andrew Freiburger\Documents\Argonne\ProjectNotebooks\CommunityModeling\julia\cobra_execution.jl:5     
 [11] top-level scope
    @ c:\Users\Andrew Freiburger\Documents\Argonne\ProjectNotebooks\CommunityModeling\julia\cobra_execution.jl:10

julia> 

when I execute this Julia file with this LP file. Does the error arise from an inability to parse the LP file?

My broad intention is to execute Python (Optlang) LP models in Julia JuMP (MathOptInterface) via PyCall, which would ideally improve performance while remaining within an existing Python ecosystem. The seemingly best option is to port an intermediary LP file from Optlang to JuMP, since these files are small. One alternative is to use intermediary .mat LP files between Python COBRA and Julia COBRA, but .mat LP files can reach 1GB and Julia COBRA is outdated. The least appealing alternative is composing Julia code that constructs the same LP model as Optlang from scratch.

I welcome any suggestions.

Thank you :slight_smile:

1 Like

How did you produce the LP file? The file seems to be corrupt and missing new lines?

Edit: I’ve opened an issue to throw a nicer error, but this is a problem with whatever created that file, not with how JuMP is reading it: FileFormats.LP: throw nicer error on corrupt files · Issue #1910 · jump-dev/MathOptInterface.jl · GitHub

1 Like