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

Test failure on Julia 1.9 #315

Closed
odow opened this issue May 11, 2023 · 4 comments · Fixed by #316
Closed

Test failure on Julia 1.9 #315

odow opened this issue May 11, 2023 · 4 comments · Fixed by #316
Labels
bug Something isn't working

Comments

@odow
Copy link
Contributor

odow commented May 11, 2023

Trying to debug jump-dev/JuMP.jl#3350 (comment), using my printing PR here: #314.

But I'm going crazy.

I've edited the code in point_variables.jl to print what's happening:

image

When the function is called. No error is thrown. When you eval in the REPL, an error is thrown. Ideas???

julia> using Test

julia> using InfiniteOpt

julia> m1 = InfiniteModel()
An InfiniteOpt Model
Feasibility problem with:
Finite Parameters: 0
Infinite Parameters: 0
Variables: 0
Derivatives: 0
Measures: 0
Optimizer model backend information: 
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> @infinite_parameter(m1, p in [0, 1])
p

julia> @variable(m1, x, Infinite(p))
x(p)

julia> v = build_variable(
           error, 
           VariableInfo(false, 0.0, false, 0.0, false, 0.0, false, 0.0, false, false), 
           Point(x, 0.5),
       )
PointVariable{GeneralVariableRef}(VariableInfo{Float64, Float64, Float64, Float64}(false, 0.0, false, 0.0, false, 0.0, false, 0.0, false, false), x(p), [0.5])

julia> m2 = InfiniteModel()
An InfiniteOpt Model
Feasibility problem with:
Finite Parameters: 0
Infinite Parameters: 0
Variables: 0
Derivatives: 0
Measures: 0
Optimizer model backend information: 
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> JuMP.add_variable(m2, v)
[ Info: Called here
[ Info: x(p)
#= /Users/oscar/.julia/dev/InfiniteOpt/src/point_variables.jl:436 =# InteractiveUtils.@which(JuMP.check_belongs_to_model(divref, model)) = check_belongs_to_model(v::AbstractVariableRef, model::AbstractModel) @ JuMP ~/.julia/packages/JuMP/jYny8/src/variables.jl:280
[ Info: Passed check
x(0.5)

julia> ivref = v.infinite_variable_ref
x(p)

julia> divref = dispatch_variable_ref(ivref)
x(p)

julia> @info divref
[ Info: x(p)

julia> @show InteractiveUtils.@which JuMP.check_belongs_to_model(divref, m2)
#= REPL[85]:1 =# InteractiveUtils.@which(JuMP.check_belongs_to_model(divref, m2)) = check_belongs_to_model(v::AbstractVariableRef, model::AbstractModel) @ JuMP ~/.julia/packages/JuMP/jYny8/src/variables.jl:280
check_belongs_to_model(v::AbstractVariableRef, model::AbstractModel)
     @ JuMP ~/.julia/packages/JuMP/jYny8/src/variables.jl:280

julia> JuMP.check_belongs_to_model(divref, m2)
ERROR: VariableNotOwned{InfiniteVariableRef}(x(p))
Stacktrace:
 [1] check_belongs_to_model(v::InfiniteVariableRef, model::InfiniteModel)
   @ JuMP ~/.julia/packages/JuMP/jYny8/src/variables.jl:282
 [2] top-level scope
   @ REPL[86]:1

(InfiniteOpt) pkg> st
Project InfiniteOpt v0.5.7
Status `~/.julia/dev/InfiniteOpt/Project.toml`
  [1520ce14] AbstractTrees v0.4.4
  [864edb3b] DataStructures v0.18.13
  [31c24e10] Distributions v0.25.90
  [442a2c76] FastGaussQuadrature v0.5.1
  [4076af6c] JuMP v1.11.0 `https://github.com/jump-dev/JuMP.jl.git#master`
  [1d6d02ad] LeftChildRightSiblingTrees v0.2.0
  [d8a4904e] MutableArithmetics v1.3.0
  [189a3867] Reexport v1.2.2
  [276daf66] SpecialFunctions v2.2.0
  [b77e0a4c] InteractiveUtils
  [37e2e46d] LinearAlgebra
@odow odow added the bug Something isn't working label May 11, 2023
@odow
Copy link
Contributor Author

odow commented May 11, 2023

So I added this method:

# TODO(odow): why is this needed for v1.9?
function JuMP.check_belongs_to_model(
    v::InfiniteVariableRef,
    model::InfiniteModel,
)
    if JuMP.owner_model(v) !== model
        throw(JuMP.VariableNotOwned(v))
    end
    return
end

Which is just the method it was trying to call in JuMP:

https://github.com/jump-dev/JuMP.jl/blob/dd66846cd28b9cc65b82b8d6bb8de67162c83f8b/src/variables.jl#L280-L284

So this feels like a bug in Julia. But it looks like you're testing on nightly, so I don't understand what happened.

@pulsipher
Copy link
Collaborator

I came to the same conclusion (see #314 (comment)). I also have no idea why this is happening. And I checked the last few nightly runs, they all ran without issue...

@odow
Copy link
Contributor Author

odow commented May 11, 2023

So perhaps it was a bug that was fixed and not back ported to 1.9?

@pulsipher
Copy link
Collaborator

pulsipher commented May 11, 2023

So perhaps it was a bug that was fixed and not back ported to 1.9?

This seems the most plausible.

Or maybe it's a bug in Julia that only shows with the new version of JuMP for some reason...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants