jump-dev / ECOS.jl

A Julia interface to the ECOS conic optimization solver
https://github.com/embotech/ecos
Other
41 stars 17 forks source link

Fix TerminationStatus #114

Closed blegat closed 3 years ago

blegat commented 3 years ago

Closes https://github.com/jump-dev/ECOS.jl/issues/113

codecov[bot] commented 3 years ago

Codecov Report

Merging #114 (a8452d6) into master (addb861) will decrease coverage by 0.45%. The diff coverage is 41.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
- Coverage   86.31%   85.86%   -0.46%     
==========================================
  Files           4        4              
  Lines         475      481       +6     
==========================================
+ Hits          410      413       +3     
- Misses         65       68       +3     
Impacted Files Coverage Δ
src/MOI_wrapper.jl 76.98% <41.66%> (-0.70%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update addb861...a8452d6. Read the comment docs.

mtanneau commented 3 years ago

@blegat you were faster than me :)

If it's of interest, I was writing a test for that too: (I guess it's easier if I just post it here directly)

@testset "Iteration Limit" begin
        # Problem data
        v = [5.0, 3.0, 1.0]
        w = [2.0, 1.5, 0.3]

        MOI.empty!(bridged)

        MOI.set(bridged, MOI.RawParameter("maxit"), 1)
        MOI.set(bridged, MOI.Silent(), true)

        x = MOI.add_variables(bridged, 3)
        for xj in x
            MOI.add_constraint(bridged, MOI.SingleVariable(xj), MOI.Interval(0.0, 1.0))
        end

        # Constraint
        MOI.add_constraint(bridged, MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(w, x), 0.0), MOI.LessThan(3.0))

        # Set the objective
        MOI.set(bridged,
            MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(),
            MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(v, x), 0.0)
        )
        MOI.set(bridged, MOI.ObjectiveSense(), MOI.MAX_SENSE)

        MOI.optimize!(bridged)

        @test MOI.get(bridged, MOI.TerminationStatus()) == MOI.ITERATION_LIMIT
end