Skip to content

[DNMY] Add MOI wrapper for CCOpt#63

Open
frapac wants to merge 1 commit into
masterfrom
fp/moi_interface
Open

[DNMY] Add MOI wrapper for CCOpt#63
frapac wants to merge 1 commit into
masterfrom
fp/moi_interface

Conversation

@frapac

@frapac frapac commented Apr 30, 2026

Copy link
Copy Markdown
Member

With this PR, we can solve a JuMP model with complementarity constraints using CCOpt:

using JuMP
using CCOpt
using MathOptComplements
using NLPModelsJuMP

function fletcher_leyffer_ex2_model()
    model = Model()
    @variable(model, z[1:2] >= 0)
    @objective(model, Min, z[1] + z[2])
    @constraint(model, z[2]^2 >= 1)
    @constraint(model, [z[1], z[2]]  MOI.Complements(2))
    return model
end


model = fletcher_leyffer_ex2_model()
MathOptComplements.Bridges.add_all_bridges(model)
set_optimizer(model, CCOpt.Optimizer)
JuMP.optimize!(model)

The MOI wrapper is developed as a package extension. It requires MathOptComplements to reformulate automatically the mixed-complementarity constraints in MOI as strict complementarity.

cc @blegat

@frapac frapac requested a review from apozharski April 30, 2026 10:01
@frapac frapac changed the title Add MOI wrapper for CCOpt [DNMY] Add MOI wrapper for CCOpt Apr 30, 2026
@noahrhodes

Copy link
Copy Markdown

Is this branch fully working? It would be great for a current project

@apozharski apozharski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, and needs a rebase, but otherwise LGTM.

end

function MOI.get(::Optimizer, ::MOI.DualStatus)
# TODO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not actually sure what this is supposed to return, but I should be return UNKNOWN_RESULT_STATUS?

ind_x1 = getfield.(ind_cc1, :value)
ind_x2 = getfield.(ind_cc2, :value)

dest.mpcc = CCOpt.MPCCModelVarVar(nlp, ind_x1, ind_x2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this needs a rename.

contypes = MOI.get(src, MOI.ListOfConstraintTypesPresent())
cc_cons = MOI.get(src, MOI.ListOfConstraintIndices{MOI.VectorOfVariables, _CC_SETS}())
if length(cc_cons) == 0
error("The model does not have any complementarity constraints. Please switch to an appropriate solver.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advise perhaps MadNLP 😄

@apozharski

Copy link
Copy Markdown
Member

@noahrhodes Hmmm I am not an MOI/JuMP expert 😅 (and I forgot that you actually asked for review on this, sorry @frapac ) but from what I can tell it seems like it should work, but the best way to know would be for someone to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants