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

Not supporting normal distribution CDF function from Distributions.jl #389

Closed
jackweou opened this issue Jun 2, 2020 · 2 comments
Closed

Comments

@jackweou
Copy link

jackweou commented Jun 2, 2020

I was trying to solve a optimisation problem which need invoking the CDF function of a normal distribution. I use the following code.

`using Convex, Distributions

a = Variable(10, 1)
var = A * a
cdf.(Normal(0, sigma), var)`

But it returns the error below
`MethodError: no method matching iterate(::Convex.MultiplyAtom)
Closest candidates are:
iterate(!Matched::Core.SimpleVector) at essentials.jl:603
iterate(!Matched::Core.SimpleVector, !Matched::Any) at essentials.jl:603
iterate(!Matched::ExponentialBackOff) at error.jl:253
...

Stacktrace:
[1] copyto!(::Array{Any,1}, ::Convex.MultiplyAtom) at ./abstractarray.jl:721
[2] _collect(::UnitRange{Int64}, ::Convex.MultiplyAtom, ::Base.HasEltype, ::Base.HasLength) at ./array.jl:609
[3] collect(::Convex.MultiplyAtom) at ./array.jl:603
[4] broadcastable(::Convex.MultiplyAtom) at ./broadcast.jl:665
[5] broadcasted(::Function, ::Normal{Float64}, ::Convex.MultiplyAtom) at ./broadcast.jl:1236
[6] top-level scope at In[58]:1
`
I guess the error is due to the cdf expression not supported in Convex.jl. Is there an solution to this issue.

Thank you in advance.

@ericphanson
Copy link
Collaborator

Hello,

You’re right that this isn’t currently supported.

The CDF of the standard normal distribution is given by the error function, which is concave on positive numbers and convex on negative numbers, so it couldn’t be supported for all numbers, but maybe it could be for those with a definite sign. I’m not really sure how, though. Do you know if this is supported in CVX or CYXPY for example?

One thing to know is Convex.jl is focused on disciplined convex optimization (see http://cvxr.com/dcp/) which efficient global solutions to optimization problems but not all problems can be formulated in this framework. If you don’t need globally optimal solutions, you could try local methods like Optim.jl or the IPOPT solver with JuMP.jl.

@odow
Copy link
Member

odow commented Feb 23, 2022

Closing as won't-fix. For this sort of formulation it is better to use JuMP.

@odow odow closed this as completed Feb 23, 2022
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

3 participants