We can use string(variable) to convert integer variable to string. Can we convert VariableRef to string? VariableRef we are getting from math model.
I tried with parse(AbstractString,VariableRef) or string(VariableRef) but it is not working. Please check the code mentioned below:
using JuMP
using GLPK
using MathOptInterface
const MOI = MathOptInterface
mathoptformat_model = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_MPS)
FILE_NAME=“E:\file1.mps”
MOI.read_from_file(mathoptformat_model, FILE_NAME)
m = Model(GLPK.Optimizer)
MOI.copy_to(m, mathoptformat_model)
optimize!(m)
println(“Optimal Solution:”,objective_value(m))
for var in all_variables(m)
var_name = parse(AbstractString, var) # or string(var)
if var_name[1] == “C”
println(var_name)
end
end
Please suggest.