From 7dbc3cf90b629f622c63c3b1e8bb7df0bea29a91 Mon Sep 17 00:00:00 2001 From: Alinson S Xavier Date: Fri, 14 Nov 2025 10:23:26 -0600 Subject: [PATCH] model: Capacity cannot decrease over time --- docs/src/problem.md | 9 +++++++++ src/model/build.jl | 7 +++++++ test/src/model/build_test.jl | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/docs/src/problem.md b/docs/src/problem.md index 7521cd8..933a4cd 100644 --- a/docs/src/problem.md +++ b/docs/src/problem.md @@ -249,6 +249,15 @@ The goal is to minimize a linear objective function with the following terms: \end{align*} ``` +- Plant capacity cannot decrease over time (`eq_capacity_nondecreasing[p.name, t]`): + +```math +\begin{align*} +& z^\text{exp}_{pt} \geq z^\text{exp}_{p,t-1} +& \forall p \in P, t \in T +\end{align*} +``` + - Plant is initially open if initial capacity is positive: ```math diff --git a/src/model/build.jl b/src/model/build.jl index a8e1717..04a4e0a 100644 --- a/src/model/build.jl +++ b/src/model/build.jl @@ -370,6 +370,13 @@ function build_model(instance::Instance; optimizer, variable_names::Bool = false eq_keep_open[p.name, t] = @constraint(model, x[p.name, t] >= x[p.name, t-1]) end + # Plants: Capacity cannot decrease over time + eq_capacity_nondecreasing = _init(model, :eq_capacity_nondecreasing) + for p in plants, t in T + eq_capacity_nondecreasing[p.name, t] = + @constraint(model, z_exp[p.name, t] >= z_exp[p.name, t-1]) + end + # Plants: Building period eq_building_period = _init(model, :eq_building_period) for p in plants, t in T diff --git a/test/src/model/build_test.jl b/test/src/model/build_test.jl index 2dda67a..3639082 100644 --- a/test/src/model/build_test.jl +++ b/test/src/model/build_test.jl @@ -128,6 +128,12 @@ function model_build_test() "eq_keep_open[L1,4] : -x[L1,3] + x[L1,4] ≥ 0" @test repr(model[:eq_keep_open]["L1", 1]) == "eq_keep_open[L1,1] : x[L1,1] ≥ 1" + # Plants: Capacity cannot decrease over time + @test repr(model[:eq_capacity_nondecreasing]["L1", 4]) == + "eq_capacity_nondecreasing[L1,4] : -z_exp[L1,3] + z_exp[L1,4] ≥ 0" + @test repr(model[:eq_capacity_nondecreasing]["L1", 1]) == + "eq_capacity_nondecreasing[L1,1] : z_exp[L1,1] ≥ 150" + # Plants: Building period @test ("L1", 1) ∉ keys(model[:eq_building_period]) @test repr(model[:eq_building_period]["L1", 2]) ==