Skip to content

Enable Constraint Restriction and Set Tags #241

@pulsipher

Description

@pulsipher

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions