jump-dev / Ipopt.jl

A Julia interface to the Ipopt nonlinear solver
https://github.com/coin-or/ipopt
Other
149 stars 58 forks source link

Add a test for the linear solver SPRAL #380

Closed amontoison closed 11 months ago

amontoison commented 11 months ago

@odow Do you know how we can implement the following code without JuMP?

model = Model(Ipopt.Optimizer)
@variable(model, x)
@objective(model, Min, (x - 2)^2)

# Use the linear solver SPRAL
set_attribute(model, "linear_solver", "spral")
optimize!(model)
@test value(x) == 2.0
codecov[bot] commented 11 months ago

Codecov Report

Patch and project coverage have no change.

Comparison is base (037c159) 94.02% compared to head (25ea437) 94.02%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #380 +/- ## ======================================= Coverage 94.02% 94.02% ======================================= Files 4 4 Lines 921 921 ======================================= Hits 866 866 Misses 55 55 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

chriscoey commented 11 months ago

@amontoison try this (no need for JuMP dependency):

    model = Ipopt.Optimizer()
    MOI.set(model, MOI.RawOptimizerAttribute("linear_solver"), "spral")    
    MOI.set(model, MOI.Silent(), true)
    x = MOI.add_variable(model)
    MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
    f = (1.0 * x - 2.0) ^ 2
    MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
    MOI.optimize!(model)
    @test MOI.get(model, MOI.VariablePrimal(), x) ≈ 2.0
odow commented 11 months ago

Looks like this worked.

Last commit on master ran

image

this PR ran

image