%%writefile cap_ef.mod
# Declare index sets
set STAGES ordered;
set RESOURCES ordered;
# Decision variables
var cap_exp {STAGES, RESOURCES} >= 0; # Variable cost associated with increase in capacity
var cap_dec {STAGES, RESOURCES} integer; # Fixed cost associated with decision to involve a new resource
# Parameters
param var_cost {STAGES, RESOURCES} > 0;
param fix_cost {STAGES, RESOURCES} > 0;
param cap_ub {STAGES, RESOURCES} > 0;
param demand {STAGES};
# Objective function
minimize total_cost:
sum{t in STAGES, i in RESOURCES} (var_cost[t,i]*cap_exp[t,i] + fix_cost[t,i]*cap_dec[t,i]);
# Constraints
subject to cap_acqu_bound {t in STAGES, i in RESOURCES}:
cap_exp[t,i] <= cap_ub[t,i]*cap_dec[t,i]; # Upper bounds on total capacity
subject to statisfy_demand {T in STAGES}:
sum {t in STAGES, i in RESOURCES: ord(t) <= ord(T)} cap_exp[t,i] >= demand[T]; # Demand needs to be satisfied at all times
subject to one_resource:
sum {t in STAGES} cap_dec[t,first(RESOURCES)] <= 1;