Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instability when considering investment in Markov Chain model #578

Closed
AngeBlanchard opened this issue Mar 30, 2023 · 2 comments
Closed

Instability when considering investment in Markov Chain model #578

AngeBlanchard opened this issue Mar 30, 2023 · 2 comments

Comments

@AngeBlanchard
Copy link

AngeBlanchard commented Mar 30, 2023

Hi Oscar,

I'm trying to model an hourly electric dispatch. I consider a full year of 365 nodes, one node per day with 24 hours within. Renewable production being uncertain, I model their production through stochastic variables that take their values at the beginning of each day. Moreover, I model disruption that can occur on gas import routes via a Markov chain, i.e. either we can import gas to burn it into the turbines, either we cannot.

With this being said, I try to find the optimal gas storage capacity to invest in, in order to hedge against the risk of gas supply disruption. The idea being that a storage asset can help to handle a crisis situation when gas imports are no longer available.

This is how I tried to handle this problem (I only write the code section of interest) :

# The first node is deterministic and here to decide the investment level in UHS
        if t == 1
            @constraint(sp, CAPA_STORAGE.out >= CAPA_STORAGE.in) # we allow the investment in gas storage
            for i in 1:24
                JuMP.fix(ξ_wind[i], Ω[1][1][(t-1)*24 + i]; force = true)
                JuMP.fix(ξ_pv[i], Ω[1][2][(t-1)*24 + i]; force = true)
                JuMP.fix(ξ_load[i], Ω[1][3][(t-1)*24 + i]; force = true)
            end # here the electric generation from renewables is forced deterministically for the 24 hours of the first node
            @stageobjective(sp, 
            sum( all generating costs at hour i, for i in 1:24) # pseudo code to keep it short
            + CAPA_STORAGE.out * INV_COST_STOCK_H2 # investment cost
            ) 
    # Otherwise, the investment is prohibited
        else
            @constraint(sp, CAPA_STORAGE.out == CAPA_STORAGE.in) # storage capacity can't change anymore
            SDDP.parameterize(sp, Ω) do ω 
                for i in 1:24
                    JuMP.fix(ξ_wind[i], ω[1][(t-1)*24 + i]; force = true)
                    JuMP.fix(ξ_pv[i], ω[2][(t-1)*24 + i]; force = true)
                    JuMP.fix(ξ_load[i], ω[3][(t-1)*24 + i]; force = true)
                end
                @stageobjective(sp, 
                sum( all generating costs at hour i, for i in 1:24)
                ) 
            end 

My problem is: even though I eventually get policies of rather good quality (2% discrepancy with the lower bound after 100 iterations), the level of investment is not stable at all and when I train the model with a low investment cost in gas storage (sensitivity analysis) I sometimes get policies that invest less than in cases whereby costs are higher ! Which is nonsense obviously.

Do you have any idea of what's happening ? Is it just that I need more iterations ? Or is there a better alternative to model investment in this case ?

Thanks a lot,
Ange

PS: how do you manage to get the code in markdown with all the colors ? Even with ``` it does not seem to work for me ?

@odow
Copy link
Owner

odow commented Mar 30, 2023

Do you have any idea of what's happening ? Is it just that I need more iterations ?

Yes. This is a pretty common issue in the literature that is often overlooked: just because the costs are converging, does not mean that the primal policy has converged 😄.

See https://odow.github.io/SDDP.jl/stable/explanation/theory_intro/#Termination-criteria

With 365 nodes, I'd guess you'd need thousands of cuts before the policy is "nice." Certainly many, many, more than 100.

See also: #178

how do you manage to get the code in markdown with all the colors ? Even with ``` it does not seem to work for me ?

You need ```julia. I've edited your post, so take a look.

@AngeBlanchard
Copy link
Author

Well, then I guess I'll have to start the training phase and go to chill outside for hours haha.
Thanks for your help and the provided links ! I close.
Ange

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants