# Semi-continuous variable
#
# Allows an activity to be switched off entirely or run at no less than a
# minimum viable level. Two linking constraints against the same binary give
# the disconnected domain {0} ∪ [L, U] exactly.
#
# Technique: x = 0 or L ≤ x ≤ U, written as L·y ≤ x ≤ U·y with y binary.
#
# On this instance the optimum is 28 (maximisation), confirmed
# independently by exhaustive enumeration before publication.
#
# Reference: Beale, E. M. L. (1968). Mathematical Programming in Practice.
# Pitman.
model m
set I = {1, 2, 3}
const p = {6, 3, 8}, forall i in I
const l = {2, 3, 2}, forall i in I
const u = {5, 6, 3}, forall i in I
const c = 4
int 0 <= x <= 6, forall i in I
bin y, forall i in I
max sum_{i in I}{p_{i} * x_{i}}
# either off (y = 0, forcing x = 0) or running at a viable level
constr x_{i} >= l_{i} * y_{i}, forall i in I
constr x_{i} <= u_{i} * y_{i}, forall i in I
constr sum_{i in I}{x_{i}} <= c
end
import elytica
Read this through MCP: read with path: "formulations/semi-continuous", or resource hlpl://formulations/semi-continuous.