You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Registering user-defined functions appears to be a global action. This can lead to some undesirable outcomes. For example:
function foo( A::Float64 )
f(x) = exp( A * x )
f1(x) = A * exp( A * x )
f2(x) = A * A * exp( A * x )
# Function to register
JuMP.register(:f,1,f1,f2)
# Registration
####
# Optimization problem here using f
# Leads to some return statement
####
end
# Session code
use1 = foo(2.0)
# Works fine
use2 = foo(3.0)
# Gives error "Operator f has already been defined"
use3 = foo(2.0)
# Also gives the error(!)
Here I want the symbol :f to register a locally-defined JuMP function. But it appears to be global and immutable. So I'd like to request the following features:
If possible, make function registration local.
If this isn't possible, add methods to: a) check that a function is registered, and b) de-register a previously-defined function.
The example above seems like a pretty important one. For starters, it is a way to use one function (here foo) to solve similar problems with differently parameterized objective functions. In addition, the current set-up leads to an error when calling the same function twice (see use1 and use3 above) with no apparent way to check for this (aside from a try-catch block).
Hopefully this isn't too hard to add, and it seems like the payoff would be pretty large. Thanks!
Registering user-defined functions appears to be a global action. This can lead to some undesirable outcomes. For example:
Here I want the symbol
:f
to register a locally-defined JuMP function. But it appears to be global and immutable. So I'd like to request the following features:The example above seems like a pretty important one. For starters, it is a way to use one function (here
foo
) to solve similar problems with differently parameterized objective functions. In addition, the current set-up leads to an error when calling the same function twice (seeuse1
anduse3
above) with no apparent way to check for this (aside from atry-catch
block).Hopefully this isn't too hard to add, and it seems like the payoff would be pretty large. Thanks!
PS. This is based on my similar stackoverflow question here: http://stackoverflow.com/questions/38774351/how-to-check-if-a-user-defined-function-is-already-registered-in-julia-jump
The text was updated successfully, but these errors were encountered: