Search code examples
juliajulia-jump

is there distributions with variable parameters in julia?


Is there any way that static distributions are used for objective function and constraints? if so, which solvers are suitable to optimize them? thanks for your kindly help:).

sig=0.86;

@variable(ALT,k>=0);
@variable(ALT,i>=0);

@constraint(ALT,c1,400*cdf(Normal(0,1),-k)<=1);
f=(1-cdf(Normal(0,1),k-sig*sqrt(i))+cdf(Normal(0,1),-k-sig*sqrt(i)));
@objective(ALT,Min,f);
status=solve(ALT);    ```

Solution

  • Use a user-defined function: https://jump.dev/JuMP.jl/v0.21.1/nlp/#User-defined-Functions-1

    using JuMP, Distributions, Ipopt
    
    f(x) = cdf(Normal(0, 1), x)
    
    model = Model(Ipopt.Optimizer)
    JuMP.register(model, :f, 1, f; autodiff = true)
    @variable(model, k >= 0)
    @variable(model, i >= 0)
    @NLconstraint(model, f(-k) <= 1)
    @NLobjective(model, Min, 1 - f(k - sqrt(i)) + f(-k - sqrt(i)))
    optimize!(model)