# Soft constraints by goal programming
#
# Hits production targets as closely as possible when hitting them exactly
# may be infeasible. Each target becomes an equality with a pair of
# non-negative deviations; penalising them keeps the model feasible and
# makes the trade-off explicit rather than hidden in constraint ordering.
#
# Technique: Add under/over deviation variables to a target and penalise
# them in the objective instead of enforcing the target
# strictly.
#
# On this instance the optimum is 2 (minimisation), confirmed
# independently by exhaustive enumeration before publication.
#
# Reference: Charnes, A. and Cooper, W. W. (1961). Management Models and
# Industrial Applications of Linear Programming. Wiley. doi:10.2307/1909344
model m
set I = {1, 2, 3, 4}
const g = {6, 3, 6, 3}, forall i in I
const pu = {3, 2, 1, 1}, forall i in I
const po = {3, 3, 3, 2}, forall i in I
const c = 16
int 0 <= x <= 8, forall i in I
int 0 <= u <= 8, forall i in I
int 0 <= o <= 8, forall i in I
min sum_{i in I}{pu_{i} * u_{i}} + sum_{i in I}{po_{i} * o_{i}}
# the target is met exactly, up to a shortfall or an excess
constr x_{i} + u_{i} - o_{i} = g_{i}, forall i in I
constr sum_{i in I}{x_{i}} <= c
end
import elytica
Read this through MCP: read with path: "formulations/goal-programming", or resource hlpl://formulations/goal-programming.