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

Error sum{} function #596

Closed
Vgrunert opened this issue Oct 5, 2015 · 0 comments
Closed

Error sum{} function #596

Vgrunert opened this issue Oct 5, 2015 · 0 comments

Comments

@Vgrunert
Copy link

Vgrunert commented Oct 5, 2015

Hi,

I get the following error when using sum{...} in @setObjective():

ERROR: LoadError: MethodError: colon has no method matching colon(::Int32, ::JuMP.Model)

when trying to reproduce the mle.jl example. Here is the code:

function gauss( )
m = 100
data = rand( Normal( -3, 7 ), m )
m = Model( solver = NLoptSolver( algorithm = :LD_MMA ) )
@defvar(m, μ, start = 0.0)
@defvar(m, σ >= 0.0, start = 1.0)
@setNLObjective(m, Max, (m/2)_log(1/(2π_σ^2))-sum{(data[i]-μ)^2, i=1:m}/(2σ^2))
solve(m)
println("μ = ", getValue(μ))
println("mean(data) = ", mean(data))
println("σ^2 = ", getValue(σ)^2)
println("var(data) = ", var(data))
println("MLE objective: ", getObjectiveValue(m))
end

And I get the same error when running this:

function test( )
m = 100
data = rand( Normal( -3, 7 ), m )
m = Model( solver = SCSSolver( ) )
@defvar(m, μ, start = 0.0)
@setObjective(m, Min, sum{(data[i]-μ)^2, i=1:m})
solve(m)
println("μ = ", getValue(μ))
end

So I can rule out the solver/non linearity as the source of the error. I don't get an error when using this:

@setObjective(m, Min, 2μ)

in the test() function.

Here are the julia infos:
Julia Version 0.4.0-rc1

  • JuMP 0.10.2
  • NLopt 0.2.3
  • SCS 0.0.9

And the full error message:
ERROR: LoadError: MethodError: colon has no method matching colon(::Int32, ::JuMP.Model)
Closest candidates are:
colon{T<:Real}(::T<:Real, ::Any, ::T<:Real)
colon{A<:Real,C<:Real}(::A<:Real, ::Any, ::C<:Real)
colon{T}(::T, ::Any, ::T)
...
[inlined code] from /home/...julia/v0.4/JuMP/src/v0.4/parseExpr_staged.jl:325
in testc at /home/.../Dropbox/Programming/Languages/julia/mathProgramming/cP/estimtion.jl:99
in main at /home/.../Dropbox/Programming/Languages/julia/mathProgramming/cP/estimtion.jl:113
in include at ./boot.jl:260
in include_from_node1 at ./loading.jl:271
while loading /home/.../Dropbox/Programming/Languages/julia/mathProgramming/cP/estimtion.jl, in expression starting on line 117

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

No branches or pull requests

1 participant