Decision Optimization

 View Only
Expand all | Collapse all

Dubt when using Tuples

  • 1.  Dubt when using Tuples

    Posted Thu November 11, 2021 09:16 AM
    Dear Comrades,

    I'm trying to solve an optimization problem in CPLEX. The code runs without any conflict and does need any relaxation. However, it does not give the expected results because in constraints 5 and 6 (balance in each i bus for both active and reactive power) the system does not get all the lines connected to that i bus. The problem is somehow similar to the power flow network. The left-hand lines connected to bus i are called "parents" (sum of j) and the right-hand connected lines are called "children". At the moment, if there's only one parent and children, the algorithm works well, but two or more children or parents are considered, it only gets one of them.
    As an example, if we consider bus 7, there's one parent (5) and two children (buses 8 and 10). With the current code, all power flow is transmitted from (5,7) to (7,8), and it should go to (7,8) and (7,10). how can I amend this? anyone can help me? I think I should add j variable somewhere in the loop but don't know where...

    I attach the model and the .dat.

    Thank you very much in advance.

    Alex

    / / / / / /  MODEL / / / / / / 

    // parameters

    int n=...; // number of buses
    int y=...; // large number
    int z=...; // cost of LS
    int t=...; // Rated voltage
    float Vmax=...; //V MAX
    float Vmin=...; //V Min

    range buses = 1..n;// length set of buses

    int beta[buses] = ...;// 1 if power is SUB or DISPATCH. DG at bus i, 0 otherwise
    float PDGmax[buses] = ...;//Max Active Power of dispatchable DG
    float QDGmax[buses] = ...;//Max Reactive Power of dispatchable DG
    float PDGmin[buses] = ...;//Min Active Power of dispatchable DG
    float QDGmin[buses] = ...;//Min Reactive Power of dispatchable DG
    float PLoad[buses] = ...;//Active Power OF EACH BUS
    float QLoad[buses] = ...;//Reactive Power OF EACH BUS

    // Create a record to hold information about each line
    tuple line {
    key int fromnode;
    key int tonode;
    float ub;
    float lb;
    int alpha;
    float resistance;
    float reactance;
    }
    // Get the set of lines

    {line} Lines = ...;

    // variables
    dvar float+ Pl[a in Lines];//Active power flow across lines
    dvar float+ Ql[a in Lines];//Reactive power flow across lines
    dvar float+ PDG[buses];//Active power injected by DG
    dvar float+ QDG[buses];//Reactive power injected by DG
    dvar float+ Pls[buses];//Active powerload shedding flow across line
    dvar float+ Qls[buses];//Reactive power load shedding flow across line
    dvar float+ V[buses];//Voltage buses
    dvar float+ DELTAV[a in Lines];//Voltage drop across lines

    // model

    minimize sum(i in buses) (Pls[i]+Qls[i])*z;

    // constraints

    subject to
    {

    forall (i in buses)
    0<=Pls[i]<=PLoad[i]; //Limit for active power load shedding

    forall (i in buses)
    0<=Qls[i]<=QLoad[i]; //Limit for reactive power load shedding

    forall (i in buses)
    beta[i]*PDGmin[i]<=PDG[i]<=beta[i]*PDGmax[i];//Limit for Active power DG

    forall (i in buses)
    beta[i]*QDGmin[i]<=QDG[i]<=beta[i]*QDGmax[i]; //Limit for reactive power DG

    forall (i in buses)
    sum (<i,j,ub,lb,alpha,r,x> in Lines) Pl[<i,j,ub,lb,alpha,r,x>]-sum (<j,i,ub,lb,alpha,r,x> in Lines) Pl[<j,i,ub,lb,alpha,r,x>] == PLoad[i]-(beta[i]*PDG[i])-Pls[i];// ACTIVE power balance at each bus

    forall (i in buses)
    sum (<i,j,ub,lb,alpha,r,x> in Lines) Ql[<i,j,ub,lb,alpha,r,x>]-sum (<j,i,ub,lb,alpha,r,x> in Lines) Ql[<j,i,ub,lb,alpha,r,x>] == QLoad[i]-(beta[i]*QDG[i])-Qls[i];// REACTIVE power balance at each bus

    forall (<i,j,ub,lb,alpha,r,x> in Lines)
    DELTAV[<i,j,ub,lb,alpha,r,x>]*alpha == (Pl[<i,j,ub,lb,alpha,r,x>]*r+Ql[<i,j,ub,lb,alpha,r,x>]*x)/t;// Voltage drop across lines

    forall (<i,j,ub,lb,alpha,r,x> in Lines)
    (1-alpha)*-y<= (V[j]-V[i])-DELTAV[<i,j,ub,lb,alpha,r,x>]<= (1-alpha)*y;// Voltage cross constraint

    forall (<i,j,ub,lb,alpha,r,x> in Lines)

    ub*alpha<=Pl[<i,j,ub,lb,alpha,r,x>]<=lb*alpha;//active power limits

    forall (<i,j,ub,lb,alpha,r,x> in Lines)

    ub*alpha<=Ql[<i,j,ub,lb,alpha,r,x>]<=lb*alpha;//reactive power limits

    forall (i in buses)
    Vmin<=V[i]<=Vmax; //Voltage buses limits
    V[9]==1; //Imposing islanding root DG voltage

    }

    / / / / / /  DATA/ / / / / / 
    n = 12;
    y = 1000;
    z = 350;
    t = 1;
    Vmax=1.05;
    Vmin=0.95;

    PLoad= [0,0,0,0,0,0,0.333,0.333,0,0.333,0,0];
    QLoad = [0,0,0,0,0,0,0,0,0,0,0,0];
    beta= [0,0,0,0,0,0,0,0,1,0,0,0];
    PDGmax =[0,0,0,0,0,0,0,0,0.999,0,0,0];
    QDGmax =[0,0,0,0,0,0,0,0,0.2,0,0,0];
    PDGmin =[0,0,0,0,0,0,0,0,0,0,0,0];
    QDGmin =[0,0,0,0,0,0,0,0,0,0,0,0];

    Lines= {
    // from, to, lb,ub,alpha,r,x
    < 1, 2, -2, 2, 1,0.0024,0.0034 >,
    < 2, 3, -2, 2, 0,0.0024,0.0034 >,
    < 3, 4, -2, 2, 1,0.00096,0.00136 >,
    < 3, 5, -2, 2, 1,0.0024,0.0034 >,
    < 5, 6, -2, 2, 1,0.00096,0.00136 >,
    < 5, 7, -2, 2, 1,0.0024,0.0034 >,
    < 7, 8, -2, 2, 1,0.0024,0.0034 >,
    < 7, 10, -2, 2, 1,0.0024,0.0034 >,
    < 8, 9, -2, 2, 1,0.0024,0.0034 >,
    < 10, 11, -2, 2, 1,0.00096,0.00136 >,
    < 11, 12, -2, 2, 1,0.0024,0.0034 >
    };

    ------------------------------
    Alejandro Serrano Fontova
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Dubt when using Tuples

    Community Leadership
    Posted Mon November 15, 2021 02:53 PM
    As I don't know anything about power flow network, I can't really give you a specific advice.  All I can suggest is the following...
    • If you have an issue with bus 7 and its children, you may want to remove from your data everything but these three buses and the two corresponding lines.  This allows to focus on the issue at hand, and make sure that other variables and constraints can't make the issue more complex than it needs to be.
    • when you say that "it should go to (7,8) and (7,10)", you should translate this to "variable xxx should be equal to mmm and variable yyy should be equal to nnnn" or a constraint such as "the sum of xxx and yyy should be such and such".  This should give you insight as to which constraints your model is missing.
    • If you think that you expressed all the constraints already, then the issue is that what you expressed doesn't have the correct effect.  In other words, the OPL statements don't really capture what you have in mind. If this is the case, you may want to export the model as an LP and check that the constraints in that LP really correspond to what you mean.

    I hope this helps.

    ------------------------------
    Xavier
    ------------------------------