Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending Hypatia #839

Closed
araujoms opened this issue Apr 11, 2024 · 3 comments
Closed

Extending Hypatia #839

araujoms opened this issue Apr 11, 2024 · 3 comments

Comments

@araujoms
Copy link
Contributor

Is it possible to extend Hypatia to add a new cone? I'd much rather do an extension than a fork, but I don't see how. The difficulty is that I would need to redefine const HypatiaCones from src/MathOptInterface/cones.jl, but it's a const.

@chriscoey
Copy link
Collaborator

chriscoey commented Apr 12, 2024

Good question. @odow do you have any recommendations here? HypatiaCones goes into SupportedCone which is used in a few places in https://github.com/jump-dev/Hypatia.jl/blob/master/src/MathOptInterface/wrapper.jl - maybe you can just add methods in your extension for e.g.

function MOI.supports_constraint(
    ::Optimizer{T},
    ::Type{<:Union{VV, VAF{T}}},
    ::Type{<:Union{MOI.Zeros, SupportedCone{T}}},
) where {T <: Real}
    return true
end

replacing ::Type{<:Union{MOI.Zeros, SupportedCone{T}}} with the type of your new cone, and similarly for MOI.modify etc. But maybe @odow will have an idea for a nicer way to do things, maybe removing the const type lists.

@odow
Copy link
Member

odow commented Apr 12, 2024

Nope. If you add support for new cones from MOI you'll need to define the appropriate methods.

I'd much rather do an extension than a fork

I don't see why not just a PR here?

@araujoms
Copy link
Contributor Author

Thanks a lot, that worked! For future reference, what one needs to redefine are the four functions in src/MathOptInterface/wrapper.jl where SupportedCone, as well as the extension of Base.copy at the end of src/MathOptInterface/cones.jl. I also had to copy most of the preamble in src/Hypatia.jl to define the relevant symbols, and finally import all the cone functions in order to extend them (update_feas, update_grad, etc.).

I don't see why not just a PR here?

This is research software. It needs to be in a repository under my control, and it's not yet ready for the prime time. When it's done I'll be happy to do a PR if you don't think it's too niche.

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

No branches or pull requests

3 participants