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

How to use Measurements in Optim #73

Closed
hzgzh opened this issue Jun 21, 2020 · 4 comments
Closed

How to use Measurements in Optim #73

hzgzh opened this issue Jun 21, 2020 · 4 comments

Comments

@hzgzh
Copy link

hzgzh commented Jun 21, 2020

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
Copy link
Member

Maybe @pkofod has some ideas 🙂

@hzgzh
Copy link
Author

hzgzh commented Jun 21, 2020

fine I will @pkofod

@hzgzh hzgzh closed this as completed Jun 21, 2020
@giordano
Copy link
Member

For reference, an issue has been opened in Optim.jl: JuliaNLSolvers/Optim.jl#823

@pkofod
Copy link

pkofod commented Aug 17, 2020

sorry I did not see this issue. Will think about the feedback Mosè gave on the other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants