How to use Measurements in Optim
hzgzh opened this issue · 4 comments
hzgzh commented
Hi:
I want to use some Measurements variable in optim problem.
but have some error,how do I handle it,wish to get reply
using Measurements,Optim
f(x)=(1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
x=zeros(Measurement{Float64},2)
optimize(f,x)
MethodError: no method matching Float64(::Measurement{Float64})
Closest candidates are:
Float64(::Real, !Matched::RoundingMode) where T<:AbstractFloat at rounding.jl:200
Float64(::T) where T<:Number at boot.jl:715
Float64(!Matched::Int8) at float.jl:60
...
Stacktrace:
[1] convert(::Type{Float64}, ::Measurement{Float64}) at .\number.jl:7
[2] Optim.MultivariateOptimizationResults{NelderMead{Optim.AffineSimplexer,Optim.AdaptiveParameters},Float64,Array{Measurement{Float64},1},Measurement{Float64},Measurement{Float64},Array{OptimizationState{Measurement{Float64},NelderMead{Optim.AffineSimplexer,Optim.AdaptiveParameters}},1},Bool}(::NelderMead{Optim.AffineSimplexer,Optim.AdaptiveParameters}, ::Array{Measurement{Float64},1}, ::Array{Measurement{Float64},1}, ::Measurement{Float64}, ::Int64, ::Bool, ::Bool, ::Measurement{Float64}, ::Measurement{Float64}, ::Measurement{Float64}, ::Measurement{Float64}, ::Bool, ::Measurement{Float64}, ::Measurement{Float64}, ::Measurement{Float64}, ::Measurement{Float64}, ::Bool, ::Measurement{Float64}, ::Measurement{Float64}, ::Bool, ::Array{OptimizationState{Measurement{Float64},NelderMead{Optim.AffineSimplexer,Optim.AdaptiveParameters}},1}, ::Int64, ::Int64, ::Int64, ::Bool, ::Float64, ::Float64) at C:\Users\Administrator\.julia\packages\Optim\SFpsz\src\types.jl:167
[3] optimize(::NonDifferentiable{Measurement{Float64},Array{Measurement{Float64},1}}, ::Array{Measurement{Float64},1}, ::NelderMead{Optim.AffineSimplexer,Optim.AdaptiveParameters}, ::Optim.Options{Float64,Nothing}, ::Optim.NelderMeadState{Array{Measurement{Float64},1},Measurement{Float64},Array{Measurement{Float64},1}}) at C:\Users\Administrator\.julia\packages\Optim\SFpsz\src\multivariate\optimize\optimize.jl:98
[4] optimize(::NonDifferentiable{Measurement{Float64},Array{Measurement{Float64},1}}, ::Array{Measurement{Float64},1}, ::NelderMead{Optim.AffineSimplexer,Optim.AdaptiveParameters}, ::Optim.Options{Float64,Nothing}) at C:\Users\Administrator\.julia\packages\Optim\SFpsz\src\multivariate\optimize\optimize.jl:33
[5] optimize(::Function, ::Array{Measurement{Float64},1}; inplace::Bool, autodiff::Symbol, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Administrator\.julia\packages\Optim\SFpsz\src\multivariate\optimize\interface.jl:64
[6] optimize(::Function, ::Array{Measurement{Float64},1}) at C:\Users\Administrator\.julia\packages\Optim\SFpsz\src\multivariate\optimize\interface.jl:58
[7] top-level scope at In[48]:1
giordano commented
For reference, an issue has been opened in Optim.jl
: JuliaNLSolvers/Optim.jl#823
pkofod commented
sorry I did not see this issue. Will think about the feedback Mosè gave on the other issue.