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

Contingencies defined independently for some periods and scenarios #45

Closed
StefanoUnipd opened this issue May 15, 2024 · 2 comments · Fixed by #46
Closed

Contingencies defined independently for some periods and scenarios #45

StefanoUnipd opened this issue May 15, 2024 · 2 comments · Fixed by #46
Assignees
Labels

Comments

@StefanoUnipd
Copy link

In chapter 5.1.5 of the manual, it says that a set of contingencies can be applied to all periods and scenarios via loadmd. Alternatively, to apply contingencies only to some periods and scenarios, I think it should be used mdi.cont(t,j).contab.
I tried to apply this second method to the example most_ex4_dcopf_ss.m, in particular, the part of code relating to Secure Stochastic DC OPF (w/wind,cont,res,ramp).
I tried to apply some contingencies only to the second scenario (in total there are 3 scenarios and only one period per scenario):

contab_matrix = [
    1   0.06    CT_TGEN     2   GEN_STATUS  CT_REP  0;      %% gen 2 at bus 1
    2   0.04    CT_TBRCH    2   BR_STATUS   CT_REP  0;      %% line 1-3
];
mdi = loadmd(mpc, transmat, xgd, [], [], profiles);
mdi.cont(1,2).contab = contab_matrix;
mdo = most(mdi, mpopt);

But nothing happens, as if the contingencies weren't there.

Instead, if I use mdi.cont(t,j).contab to apply these contingencies to all scenarios, as if I used loadmd, the program works correctly:

contab_matrix = [
    1   0.06    CT_TGEN     2   GEN_STATUS  CT_REP  0;      %% gen 2 at bus 1
    2   0.04    CT_TBRCH    2   BR_STATUS   CT_REP  0;      %% line 1-3
];
mdi = loadmd(mpc, transmat, xgd, [], [], profiles);
mdi.cont(1,1).contab = contab_matrix;
mdi.cont(1,2).contab = contab_matrix;
mdi.cont(1,3).contab = contab_matrix;
mdo = most(mdi, mpopt);

I can't understand where I'm wrong, and above all I don't know if I understood the theory correctly.

@rdzman
Copy link
Member

rdzman commented May 21, 2024

I think I know what's going on. If the most.security_constraints option is set to the default –1, then most() decides whether to include contingencies by checking if contingencies are specified in the input. The issue is that it makes a faulty assumption and only checks to see whether mdi.cont(1,1).contab is present and not empty. If it doesn't find a contab there, it incorrectly assumes the problem is not security constrained and skips over any contingency handling.

I consider this a bug and plan to fix it to ensure that it doesn't disable contingency handling unless there are no contingencies specified in any period or scenario.

I was hoping you could set the most.security_constraints option to 1 and it would just work, but I just tried it and got the following error:

Error using most (line 170)
most: MDI.cont(t,j).contab cannot be empty when MPOPT.most.security_constraints = 1

And commenting out that check doesn't work either. So, it looks like this is yet another example of the wise adage ... "if you didn't test it, it doesn't work." 😞

@StefanoUnipd
Copy link
Author

Thank you very much for helping! I agree with the adage, and if the discovery of a bug could lead to being "remembered" in Appendix B of the manual, even better 😄

@rdzman rdzman closed this as completed in 7f616a4 Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants