Read MPS file using MathOptInterface and extract each variable from MOI

Please read the below code. It can read MPS file. How can I get each variable from m? Please share the code.

using JuMP
using GLPK
using MathOptInterface

const MOI = MathOptInterface
mathoptformat_model = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_MPS)
MOI.read_from_file(mathoptformat_model, FILE_NAME)
m = Model(GLPK.Optimizer)
MOI.copy_to(m, mathoptformat_model)

Did you try JuMP.all_variables?


1 Like