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

Cannot use value on Parameter Functions #254

Closed
pulsipher opened this issue Mar 10, 2022 · 1 comment
Closed

Cannot use value on Parameter Functions #254

pulsipher opened this issue Mar 10, 2022 · 1 comment
Labels
bug Something isn't working transformations Something to do with model transformations

Comments

@pulsipher
Copy link
Collaborator

JuMP.value is not implemented correctly for parameter functions, currently it errors.

using InfiniteOpt, Ipopt

model = InfiniteModel(Ipopt.Optimizer)
@infinite_parameter(model, s in [0, 1], num_supports = 4)
@variable(model, y, Infinite(s))
my_func(s) = 42
@parameter_function(model, pfunc == my_func(s))
@objective(model, Min, integral((y - pfunc)^2, s))
optimize!(model)
value(pfunc)
ERROR: MethodError: no method matching value(::Float64; result=1)
Closest candidates are:
  value(::Number) at C:\Users\Joshua\.julia\packages\JuMP\zn6NT\src\variables.jl:1298 got unsupported keyword argument "result"
  value(::Any, ::Function) at C:\Users\Joshua\.julia\packages\JuMP\zn6NT\src\deprecate.jl:17 got unsupported keyword argument "result"
  value(::AbstractArray{<:AbstractJuMPScalar}) at C:\Users\Joshua\.julia\packages\JuMP\zn6NT\src\variables.jl:1290 got unsupported keyword argument "result"
  ...
Stacktrace:
  [1] (::InfiniteOpt.var"#480#481"{Int64})(v::Float64)
    @ InfiniteOpt C:\Users\Joshua\Documents\InfiniteOpt.jl\src\results.jl:65
  [2] iterate
    @ .\generator.jl:47 [inlined]
  [3] _collect
    @ .\array.jl:744 [inlined]
  [4] collect_similar(cont::Vector{Float64}, itr::Base.Generator{Vector{Float64}, InfiniteOpt.var"#480#481"{Int64}})
    @ Base .\array.jl:653
  [5] map(f::Function, A::Vector{Float64})
    @ Base .\abstractarray.jl:2849
  [6] map_value(vref::GeneralVariableRef, key::Val{:TransData}, result::Int64; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ InfiniteOpt C:\Users\Joshua\Documents\InfiniteOpt.jl\src\results.jl:65
  [7] map_value(vref::GeneralVariableRef, key::Val{:TransData}, result::Int64)
    @ InfiniteOpt C:\Users\Joshua\Documents\InfiniteOpt.jl\src\results.jl:63
  [8] _get_value(vref::GeneralVariableRef, index_type::Type, result::Int64; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ InfiniteOpt C:\Users\Joshua\Documents\InfiniteOpt.jl\src\results.jl:101
  [9] _get_value(vref::GeneralVariableRef, index_type::Type, result::Int64)
    @ InfiniteOpt C:\Users\Joshua\Documents\InfiniteOpt.jl\src\results.jl:101
 [10] value(vref::GeneralVariableRef; result::Int64, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ InfiniteOpt C:\Users\Joshua\Documents\InfiniteOpt.jl\src\results.jl:143
 [11] value(vref::GeneralVariableRef)
    @ InfiniteOpt C:\Users\Joshua\Documents\InfiniteOpt.jl\src\results.jl:143
 [12] top-level scope
    @ REPL[12]:1

However, transcription_variable works:

julia> transcription_variable(pfunc)
4-element Vector{Float64}:
 42.0
 42.0
 42.0
 42.0
@pulsipher pulsipher added bug Something isn't working transformations Something to do with model transformations labels Mar 10, 2022
@pulsipher
Copy link
Collaborator Author

This is resolved by ecc1ee2. I forgot to make a pull request :)

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

No branches or pull requests

1 participant