diff --git a/src/FileFormats/NL/read.jl b/src/FileFormats/NL/read.jl index 0bc97c5d06..2ece11701a 100644 --- a/src/FileFormats/NL/read.jl +++ b/src/FileFormats/NL/read.jl @@ -17,7 +17,7 @@ mutable struct _CacheModel objective::Expr sense::MOI.OptimizationSense complements_map::Dict{Int,Int} - defined_variables::Dict{Int,Expr} + defined_variables::Dict{Int,Union{Float64,MOI.VariableIndex,Expr}} function _CacheModel() return new( @@ -33,7 +33,7 @@ mutable struct _CacheModel :(), MOI.FEASIBILITY_SENSE, Dict{Int,Int}(), - Dict{Int,Expr}(), + Dict{Int,Union{Float64,MOI.VariableIndex,Expr}}(), ) end end diff --git a/test/FileFormats/NL/test_read.jl b/test/FileFormats/NL/test_read.jl index dd2c8d7bc4..b9301e8573 100644 --- a/test/FileFormats/NL/test_read.jl +++ b/test/FileFormats/NL/test_read.jl @@ -551,6 +551,27 @@ function test_parse_V() return end +function test_parse_V_constant() + model = NL._CacheModel() + io = IOBuffer("V2 0 0\nn0\n") + seekstart(io) + NL._parse_section(io, model) + @test length(model.defined_variables) == 1 + @test model.defined_variables[2] === 0.0 + return +end + +function test_parse_V_variable() + model = NL._CacheModel() + NL._resize_variables(model, 2) + io = IOBuffer("V1 0 0\nv0\n") + seekstart(io) + NL._parse_section(io, model) + @test length(model.defined_variables) == 1 + @test model.defined_variables[1] === MOI.VariableIndex(1) + return +end + function test_parse_L() model = NL._CacheModel() io = IOBuffer()