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

Can't construct NumberParameter #18

Closed
JonnyCBB opened this issue Mar 23, 2016 · 2 comments
Closed

Can't construct NumberParameter #18

JonnyCBB opened this issue Mar 23, 2016 · 2 comments

Comments

@JonnyCBB
Copy link

I'm trying to use your package and I'm failing at the first hurdle.

I'm trying to create a Number parameter object but it's not working:

julia> NumberParameter(0.0, 2.0, 1.0, "test")
ERROR: MethodError: `convert` has no method matching convert(::Type{StochasticSearch.NumberParameter{T<:Number}}, ::Float64, ::Float64, ::Float64, ::ASCIIString)
This may have arisen from a call to the constructor StochasticSearch.NumberParameter{T<:Number (...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, ::T)
 in call at essentials.jl:57

Can you help me out here. I assume I'm missing something really small. I'm using Julia v0.4.3

@phrb
Copy link
Owner

phrb commented Mar 23, 2016

Hi, hope you didn't give up because of this. NumberParameter is a parametrized type, so you should do:

julia> NumberParameter{Float64}(0.0, 2.0, 1.0, "test")
    [NumberParameter]
    name : test
    min  : 0.000000
    max  : 2.000000
    value: 1.000000

But in this case it is simpler to do:

julia> FloatParameter(0.0, 2.0, 1.0, "test")
    [NumberParameter]
    name : test
    min  : 0.000000
    max  : 2.000000
    value: 1.000000

Because FloatParameter is a typealias to NumberParameter{AbstractFloat}.

I updated the README with the correct format. I make sure tests are always passing, so you will learn more from the test code than the documentation at this point, although I intend to document the package fully. I would be happy to help If you find other issues.

Please, for now, check the tests for the techniques, such as simulated_annealing, to find working examples.

Would mind telling me what you intend to use the package for? I can provide more meaningful examples for your applications.

@JonnyCBB
Copy link
Author

Hi @phrb. Thanks very much for this. It worked! I'm still getting my head around Julia. I will go ahead with the simulated annealing and let you know if there are any other problems that I encounter.

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

No branches or pull requests

2 participants