Skip to content

Strongly typed indices #1291

Closed
Closed
@mlubin

Description

@mlubin

This is more of a Julia ecosystem issue than a JuMP issue, but it would be nice to have better syntax to do the following:

item_count = 3
factory_count = 3
struct ItemIndex
    value::Int
end

struct FactoryIndex
    value::Int
end

item_set = [ItemIndex(i) for i in 1:item_count]
factory_set = [FactoryIndex(i) for i in 1:factory_count]

m = Model()
@variable(m, item_is_produced_at_factory[item_set, factory_set], Bin)
item_is_produced_at_factory[ItemIndex(1), FactoryIndex(1)] # Ok
item_is_produced_at_factory[FactoryIndex(1), ItemIndex(1)] # Error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions