hdavid16 / DisjunctiveProgramming.jl

A JuMP extension for Generalized Disjunctive Programming
MIT License
27 stars 3 forks source link

Handle printing empty disjuncts #108

Closed hdavid16 closed 2 months ago

hdavid16 commented 6 months ago

When a disjunct has no constraints assigned to it the following occurs:

@variable(m,x)
@variable(m,Y[1:2],Logical)
@constraint(m, x >= 0, Disjunct(Y[1]))
@disjunction(m,Y)

Error showing value of type DisjunctionRef{Model}:
ERROR: KeyError: key Y[2] not found
Stacktrace:
  [1] getindex(h::Dict{LogicalVariableRef{Model}, Vector{Union{…}}}, key::LogicalVariableRef{Model})
    @ Base ./dict.jl:498
  [2] constraint_string(mode::MIME{Symbol("text/plain")}, d::Disjunction{Model})
    @ DisjunctiveProgramming ~/Documents/DisjunctiveProgramming.jl/src/print.jl:112

We should either throw a meaningful error or handle the empty disjunct, which will be reformulated as if the variables in the disjunction were unrestricted (i.e., x is unbounded in the example above) or bounded by the variable bounds.

hdavid16 commented 4 months ago

This is a printing bug. Adding a semicolon to the end of the @disjunction call returns no error.