lanl-ansi / Juniper.jl

A JuMP-based Nonlinear Integer Program Solver
https://lanl-ansi.github.io/Juniper.jl/stable/
MIT License
180 stars 22 forks source link

Documentation: "registered_functions" not working #187

Closed AndiMD closed 4 years ago

AndiMD commented 4 years ago

The following documentation example fails for Juniper master and stable. is there another way to use self-defined functions? Thanks.

using JuMP, Ipopt, Juniper

function myfunction(x1, x2, x3, x4)
    xx = [x1, x2, x3, x4]
    return sum(xx[i] for i = 1:4)
end

model = Model(
    optimizer_with_attributes(
        Juniper.Optimizer,
            "nl_solver" => optimizer_with_attributes(Ipopt.Optimizer, "print_level" => 0),
            "registered_functions" = [
                Juniper.register(:myfunction,  4, myfunction; autodiff = true)
            ]
    )
)

ERROR: syntax: invalid keyword argument name ""registered_functions""

from https://lanl-ansi.github.io/Juniper.jl/latest/options/#registered_functions::Union{Nothing,Vector{RegisteredFunction}}-[nothing]-1

Wikunia commented 4 years ago

It should be registered_functions => not just an equal sign. Does that work? I'm currently not at my laptop.

AndiMD commented 4 years ago

Thanks, works. I tried to create a pull request with this marvellous fix: https://github.com/lanl-ansi/Juniper.jl/pull/188