File size: 1,919 Bytes
43c68a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.

function _add_startup_cost_eqs!(
    model::JuMP.Model,
    g::ThermalUnit,
    formulation::MorLatRam2013.StartupCosts,
)::Nothing
    eq_startup_choose = _init(model, :eq_startup_choose)
    eq_startup_restrict = _init(model, :eq_startup_restrict)
    S = length(g.startup_categories)
    startup = model[:startup]
    for t in 1:model[:instance].time
        # If unit is switching on, we must choose a startup category
        eq_startup_choose[g.name, t] = @constraint(
            model,
            model[:switch_on][g.name, t] ==
            sum(startup[g.name, t, s] for s in 1:S)
        )

        for s in 1:S
            # If unit has not switched off in the last `delay` time periods, startup category is forbidden.
            # The last startup category is always allowed.
            if s < S
                range_start = t - g.startup_categories[s+1].delay + 1
                range_end = t - g.startup_categories[s].delay
                range = (range_start:range_end)
                initial_sum = (
                    g.initial_status < 0 && (g.initial_status + 1 in range) ? 1.0 : 0.0
                )
                eq_startup_restrict[g.name, t, s] = @constraint(
                    model,
                    startup[g.name, t, s] <=
                    initial_sum + sum(
                        model[:switch_off][g.name, i] for i in range if i >= 1
                    )
                )
            end

            # Objective function terms for start-up costs
            add_to_expression!(
                model[:obj],
                startup[g.name, t, s],
                g.startup_categories[s].cost,
            )
        end
    end
    return
end