From ba79f48ea6213d91e1461219413edfc9616a64a2 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 26 May 2023 05:49:39 +1200 Subject: [PATCH] Fix for Julia v1.9 by adding check_belongs_to_model (#316) * Fix for Julia v1.9 by adding check_belongs_to_model * Change location and scope * Use InfiniteVariableRef instead of DispatchVariableRef --------- Co-authored-by: pulsipher --- src/infinite_variables.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/infinite_variables.jl b/src/infinite_variables.jl index 6f3b45c8c..0e9792ea9 100644 --- a/src/infinite_variables.jl +++ b/src/infinite_variables.jl @@ -100,6 +100,21 @@ function _set_core_variable_object( return end +################################################################################ +# MODEL CHECKING +################################################################################ +# TODO(odow): this is a work-around for a bug in Julia v1.9. I've no idea why it +# is necessary. +function JuMP.check_belongs_to_model( + x::InfiniteVariableRef, + model::InfiniteModel + ) + if JuMP.owner_model(x) !== model + throw(JuMP.VariableNotOwned(x)) + end + return +end + ################################################################################ # DEFINTION HELPER METHODS ################################################################################