Custom recorder on stages with different constraints

Hi Oscar,
I’ve been having issues with creating a custom recorder in SDDP.simulate. I have a capacity expansion problem where stage 1 covers the investment decision and stages 2,…T are monthly dispatch problems at hourly resolution connected by storage level state variables (and the capacity decisions from stage 1). In each dispatch stage I have an internal storage plant equation (as opposed to an external one connecting stages) of which I would like to get the dual values in a given simulation.

My problem is the following: Since these constraints do not appear in the investment stage 1, the custom recorder is throwing me an error. Is there a way to skip a node in recording dual control variables?

Thank you very much!

Felix

1 Like

The custom recorder is an arbitrary Julia function. So you could do something like:

function my_custom_recorder(sp::JuMP.Model)
    dict = JuMP.object_dictionary(sp)
    if !haskey(dict, :demand_constraint)
        return NaN
    end
    return JuMP.dual(dict[:demand_constraint])
end

# and then

    custom_recorders = Dict{Symbol,Function}(
        :price => my_custom_recorder,
    )
1 Like

Hi Oscar,
just what I was looking for! Thank you!

Best

Felix

1 Like