infiniteopt / InfiniteOpt.jl

An intuitive modeling interface for infinite-dimensional optimization problems.
https://infiniteopt.github.io/InfiniteOpt.jl/stable
MIT License
251 stars 17 forks source link

Enable Constraint Restriction and Set Tags #241

Open pulsipher opened 2 years ago

pulsipher commented 2 years ago

JuMP enables users to define set constraints the following two ways:

julia> model = InfiniteModel();

julia> @infinite_parameter(model, t in [0, 1]);

julia> @variable(model, x[1:2], Infinite(t));

julia> y = [0.5, 0.75];

julia> @constraint(model, x >= y, MOI.Nonnegatives(2))
[x[1](t) - 0.5, x[2](t) - 0.75] ∈ MathOptInterface.Nonnegatives(2), ∀ t ∈ [0, 1]

julia> @constraint(model, x - y in MOI.Nonnegatives(2))
[x[1](t) - 0.5, x[2](t) - 0.75] ∈ MathOptInterface.Nonnegatives(2), ∀ t ∈ [0, 1]

In the latter syntax we can add DomainRestrictions, but we cannot with the first since no additional arguments can be accepted. One workaround would be to make some hybrid tag object, for example:

@constraint(model, x >= y, MultiTag(MOI.Nonnegatives(2), DomainRestrictions(t => [0, 0.5]))

However, this doesn't seem like the most elegant solution. @odow Any thoughts?

Ideally, it would be nice to add keyword arguments to @constraint, but I don't believe this is currently possible.