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

InexactError: Float64 when problem gets big #1973

Closed
jluoaz opened this issue May 23, 2019 · 4 comments · Fixed by #1978
Closed

InexactError: Float64 when problem gets big #1973

jluoaz opened this issue May 23, 2019 · 4 comments · Fixed by #1978
Labels
Type: Error Messages Can be fixed with better error message

Comments

@jluoaz
Copy link

jluoaz commented May 23, 2019

I'm running an optimization problem on some simulated data:

using LinearAlgebra, JuMP, Ipopt

d = 10
n = 1000
A = I + 0.5*(rand(d,d)-0.5*ones(d,d))
A = Symmetric(A)
J = sqrt(A)
eps = randn(d,n)
z = J*eps

m = Model(with_optimizer(Ipopt.Optimizer))
@variable(m, theta >= 0, start = 1.0)
@variable(m, beta[1:d-1], start = 0.0)
@NLobjective(m, Min, theta/n*sum( (z[1,j] + sum(beta[i-1] * z[i,j] for i=2:d))^2 for j=1:n) - log(theta))

optimize!(m)

This code runs great when d=10, but change to d=100, and I get the following:

InexactError: Float64(0.3362800773416026 + 0.03631914074869952im)

Stacktrace:
 [1] Type at .\complex.jl:37 [inlined]
 [2] convert at .\number.jl:7 [inlined]
 [3] push!(::Array{Float64,1}, ::Complex{Float64}) at .\array.jl:853
 [4] _parse_NL_expr_runtime(::Model, ::Complex{Float64}, ::Array{JuMP._Derivatives.NodeData,1}, ::Int64, ::Array{Float64,1}) at C:\Users\<Username>\.julia\packages\JuMP\tyMag\src\parse_nlp.jl:171
 [5] top-level scope at C:\Users\<Username>\.julia\packages\JuMP\tyMag\src\parse_expr.jl:358

Not sure what is going on here.

@odow odow added the Type: Error Messages Can be fixed with better error message label May 23, 2019
@odow
Copy link
Member

odow commented May 23, 2019

J can become a Array{Complex{Float64}, 2}, and JuMP cannot handle complex numbers.

This needs a better error message.

@jluoaz
Copy link
Author

jluoaz commented May 23, 2019

Ah, I see, I should have checked that first. Thank you!

@jluoaz jluoaz closed this as completed May 23, 2019
@odow
Copy link
Member

odow commented May 23, 2019

I'm going to re-open until this has a nicer error message.

@odow odow reopened this May 23, 2019
@jluoaz
Copy link
Author

jluoaz commented May 23, 2019

Yeah, actually, I had originally thought that log(theta) had become complex. If I knew z was complex, I would have figured it out easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Error Messages Can be fixed with better error message
Development

Successfully merging a pull request may close this issue.

2 participants