[AMPL 2081] Help Needed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 2081] Help Needed

Ifedi Odinakaeze
Please can anybody help me out here.
Below is my model but when I try running it, I have syntax error from my first 'for command' and it points to >> s=1..<<


set GEN; # sources
set RANK; # Ranking order of the RUP
set SCENARIO; # load forecast 7-step model
set SPOT; # Spot Market Price 5-step Model
set TIME; # 24-Hour Schedule
set RANK1; # Ranking order of the RDP

param T > 0;                             # number of Hours
#param S > 0;                            # number of Load Steps
#param SP > 0;                            # number SR Price Steps
#param load {BUS,1..T} >= 0;                    # demand @ BUS[b] @ TIME[t]
param x1 >= 0;                            # Ramp-Down Power
param x2 >= 0;                            # Ramp-Down Power
param x3 >= 0;                            # Ramp-Down Power
param x4 >= 0;                            # Ramp-Up Power
param x5 >= 0;                            # Ramp-Up Power
param x6 >= 0;                            # Ramp-Up Power
param x7 >= 0;                            # SMP Power limit
param x8 >= 0;                            # Ramp-Down Power limits
param x9 >= 0;                            # Ramp-Down Power limits
param x10 >= 0;                            # Ramp-Down Power limits
param x11 >= 0;                            # Ramp-Up Power limits
param x12 >= 0;                            # Ramp-Up Power limits
param x13 >= 0;                            # Ramp-Up Power limits
param T_A >= 0;                            # Total Cost under scenario (1..3)
param T_B >= 0;                            # Total Cost under scenario (4)
param T_C >= 0;                            # Total Cost under scenario (5..7)
param T_D >= 0;                            # Total Cost under scenario (1..7)
param D {SCENARIO,1..T} >= 0;                     # Load under scenario[s] @ TIME[t]
param p {SCENARIO,1..T} > 0;                     # Load forecast scenario probability
param P {GEN,1..T,RANK} >= 0;                     # Power available @ Source[j] @ TIME[t] during Ramp Up
param Q {GEN,1..T,RANK1} >= 0;                    # Power available @ Source[j] @ TIME[t] during Ramp down
param R {GEN,1..T} >= 0;                    # Power available @ Source [j] @ Time [t] when actual is equal to forecaste
param MCP {1..T} >= 0;                         # MCP @ TIME[t]
param q {SPOT,1..T} > 0;                     # Probability of SMP MOdel under SPOT[k] @ TIME[t]
param SMP {SPOT,1..T} >= 0;                     # Spot Market price under SPOT[k] @ TIME[t]
param RUP {GEN,1..T,RANK} >= 0;                 # Ramp-Up Price of Source[j] @ TIME[t]
param RDP {GEN,1..T,RANK1} >= 0;                 # Ramp-Down Price of Source[j] @ TIME[t]
param SRP {1..T} >= 0;                         # Spinning Reserve Price @ TIME[t]
param MF {1..T} >= 0;                         # Maintenance Fee @ TIME[t]
param UR {GEN,1..T,RANK} >= 0;                     # Ramp-Up Limit of Source[j]
param DR {GEN,1..T,RANK1} >= 0;                 # Ramp-Down Limit of Source[j]
#param SMAX {1..T} >= 0;                     # Spot Market Limit @ TIME[t]
param Pmin {GEN,1..T,RANK} >= 0;                 # Minimum Power from Source[j]  
param Pmax {j in GEN,t in TIME,r in RANK} >= Pmin[j,t,r];     # Power limits from Source[j] during Ramp Up
param Qmin {GEN,1..T,RANK1} >= 0;                 # Minimum Power from Source[j]  
param Qmax {j in GEN,t in TIME,r in RANK1} >= Qmin[j,t,r];     # Power limits from Source[j] during Ramp Down


var beta {1..T} >= 0, <= 1;                     #  Spinning Reserve factor

for {t in TIME,s in SCENARIO: s=1..3}

{

if Power {t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
sum {j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s] <= DR[j,t,r];
then x1 = sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s];

    if (Q[j,t,1] -x1) <= Qmin[j,t,1];
    then x8 = Qmin[j,t,1];
    else x8 = (Q[j,t,r] -x1);
T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + MCP[t]*(x8 + Q[j,t,2] + Q[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
((sum {j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1]) >= 0,<= DR[j,t,2];
then x1 = DR[j,t,1];
     x2 = ((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1]);

    if (Q[j,t,2] -x2) <= Qmin[j,t,2];
    then x9 = Qmin[j,t,2];
    else x9 = (Q[j,t,2] -x2);
T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + RDP[j,t,2]*x2 + MCP[t]*(x8 + x9 + Q[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1] - DR[j,t,2]) >= 0,<= DR[j,t,3];
then x2 = DR[j,t,2];
     x3 = ((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1] - DR[j,t,2]);
else x3 = DR[j,t,3];

    if (Q[j,t,3] -x3) <= Qmin[j,t,3];
    then x10 = Qmin[j,t,3];
    else x10 = (Q[j,t,3] -x3);

T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + RDP[j,t,2]*x2 + RDP[j,t,3]*x3 + MCP[t]*(x8 + x9 + x10));

}

for {t in TIME,s in SCENARIO: s = 4}
{
T_B = p[t,s] * (MCP[t] * sum{j in GEN} R[t,j]);
}

for {t in TIME,s in SCENARIO: s = 5..7} {

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) <= UR[j,t,1];
then x4 = D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

         if (P[j,t,1] + x4) >= Pmax[j,t,1];
             then x11 = Pmax[j,t,1];
             else x11 = (P[j,t,1] + x4);

T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + MCP[t]*(x11 + P[j,t,2] + P[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - UR[j,t,1] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) >= 0, <= UR[j,t,2];
then x4 = UR[j,t,1];
     x5 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

        if (P[j,t,2] + x5) >= Pmax[j,t,2];
             then x12 = Pmax[j,t,2];
             else x12 = (P[j,t,2] + x5);    
   
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + MCP[t]*(x11 + x12 + P[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) >= 0, <= UR[j,t,3];
then x5 = UR[j,t,2];
     x6 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

        if (P[j,t,3] + x6) >= Pmax[j,t,3];
             then x13 = Pmax[j,t,3];
             else x13 = (P[j,t,3] + x6);    
   
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x11 + x12 + x13));

else x6 = UR[j,t,2];
     x7 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

if RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x4 + x5+ x6) + sum{k in SPOT} q[t,k]*SMP[t,k]*x7 >= sum{k in SPOT} q[t,k]*SMP[t,k]*(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]);
then
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + MCP[t]*(sum{t in TIME, j in GEN, r in RANK} P[j,t,r] + sum{k in SPOT} q[t,k]*SMP[t,k]*(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]);
else
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x11 + x12 + x13) + sum{k in SPOT} q[t,k]*SMP[t,k]*x7);
}

minimize T_D:
    sum {t in TIME} T_A + T_B + T_C ;


subject to SRF {t in TIME, s in SCENARIO}:
    beta[t] * D[t,s] >= 0;



I do not know how else to set it up inorder to eliminate the syntax error.
The model is written in such a way that the for and if-then-else statements generate the objective function to be minimized at the end. If I am wrong in the placement of my codes, please do correct me.

Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

[AMPL 2082] Re: Help Needed

Robert Fourer-2

Dear Ifedi,

 

Your for command deviates from the AMPL syntax -- described in section 13.2 of the book -- in many ways.  Just to begin with, you cannot write

 

   for {t in TIME,s in SCENARIO: s=1..3}

 

because s is a member of SCENARIO while 1..3 is a set; there is no way that they can be equal.

 

More fundamentally, however, I do not understand why you are writing a for statement at this point.  There is no way to specify a set, parameter, variable, objective, or constraint using a for statement; in the middle of a model, a for statement is only useful for assigning values to sets and parameters that have already been declared (by means of set and param statements). 

 

Bob Fourer

[hidden email]

 

 


From: [hidden email] [mailto:[hidden email]]

On Behalf Of Ifedi Odinakaeze
Sent: Monday, November 17, 2008 11:03 AM
To: [hidden email]
Subject: [AMPL 2081] Help Needed

 

Please can anybody help me out here.
Below is my model but when I try running it, I have syntax error from my first 'for command' and it points to >> s=1..<<


set GEN; # sources
set RANK; # Ranking order of the RUP
set SCENARIO; # load forecast 7-step model
set SPOT; # Spot Market Price 5-step Model
set TIME; # 24-Hour Schedule
set RANK1; # Ranking order of the RDP

param T > 0;                             # number of Hours
#param S > 0;                            # number of Load Steps
#param SP > 0;                            # number SR Price Steps
#param load {BUS,1..T} >= 0;                    # demand @ BUS[b] @ TIME[t]
param x1 >= 0;                            # Ramp-Down Power
param x2 >= 0;                            # Ramp-Down Power
param x3 >= 0;                            # Ramp-Down Power
param x4 >= 0;                            # Ramp-Up Power
param x5 >= 0;                            # Ramp-Up Power
param x6 >= 0;                            # Ramp-Up Power
param x7 >= 0;                            # SMP Power limit
param x8 >= 0;                            # Ramp-Down Power limits
param x9 >= 0;                            # Ramp-Down Power limits
param x10 >= 0;                            # Ramp-Down Power limits
param x11 >= 0;                            # Ramp-Up Power limits
param x12 >= 0;                            # Ramp-Up Power limits
param x13 >= 0;                            # Ramp-Up Power limits
param T_A >= 0;                            # Total Cost under scenario (1..3)
param T_B >= 0;                            # Total Cost under scenario (4)
param T_C >= 0;                            # Total Cost under scenario (5..7)
param T_D >= 0;                            # Total Cost under scenario (1..7)
param D {SCENARIO,1..T} >= 0;                     # Load under scenario[s] @ TIME[t]
param p {SCENARIO,1..T} > 0;                     # Load forecast scenario probability
param P {GEN,1..T,RANK} >= 0;                     # Power available @ Source[j] @ TIME[t] during Ramp Up
param Q {GEN,1..T,RANK1} >= 0;                    # Power available @ Source[j] @ TIME[t] during Ramp down
param R {GEN,1..T} >= 0;                    # Power available @ Source [j] @ Time [t] when actual is equal to forecaste
param MCP {1..T} >= 0;                         # MCP @ TIME[t]
param q {SPOT,1..T} > 0;                     # Probability of SMP MOdel under SPOT[k] @ TIME[t]
param SMP {SPOT,1..T} >= 0;                     # Spot Market price under SPOT[k] @ TIME[t]
param RUP {GEN,1..T,RANK} >= 0;                 # Ramp-Up Price of Source[j] @ TIME[t]
param RDP {GEN,1..T,RANK1} >= 0;                 # Ramp-Down Price of Source[j] @ TIME[t]
param SRP {1..T} >= 0;                         # Spinning Reserve Price @ TIME[t]
param MF {1..T} >= 0;                         # Maintenance Fee @ TIME[t]
param UR {GEN,1..T,RANK} >= 0;                     # Ramp-Up Limit of Source[j]
param DR {GEN,1..T,RANK1} >= 0;                 # Ramp-Down Limit of Source[j]
#param SMAX {1..T} >= 0;                     # Spot Market Limit @ TIME[t]
param Pmin {GEN,1..T,RANK} >= 0;                 # Minimum Power from Source[j]  
param Pmax {j in GEN,t in TIME,r in RANK} >= Pmin[j,t,r];     # Power limits from Source[j] during Ramp Up
param Qmin {GEN,1..T,RANK1} >= 0;                 # Minimum Power from Source[j]  
param Qmax {j in GEN,t in TIME,r in RANK1} >= Qmin[j,t,r];     # Power limits from Source[j] during Ramp Down


var beta {1..T} >= 0, <= 1;                     #  Spinning Reserve factor

for {t in TIME,s in SCENARIO: s=1..3}

{

if Power {t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
sum {j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s] <= DR[j,t,r];
then x1 = sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s];

    if (Q[j,t,1] -x1) <= Qmin[j,t,1];
    then x8 = Qmin[j,t,1];
    else x8 = (Q[j,t,r] -x1);
T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + MCP[t]*(x8 + Q[j,t,2] + Q[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
((sum {j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1]) >= 0,<= DR[j,t,2];
then x1 = DR[j,t,1];
     x2 = ((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1]);

    if (Q[j,t,2] -x2) <= Qmin[j,t,2];
    then x9 = Qmin[j,t,2];
    else x9 = (Q[j,t,2] -x2);
T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + RDP[j,t,2]*x2 + MCP[t]*(x8 + x9 + Q[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1] - DR[j,t,2]) >= 0,<= DR[j,t,3];
then x2 = DR[j,t,2];
     x3 = ((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1] - DR[j,t,2]);
else x3 = DR[j,t,3];

    if (Q[j,t,3] -x3) <= Qmin[j,t,3];
    then x10 = Qmin[j,t,3];
    else x10 = (Q[j,t,3] -x3);

T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + RDP[j,t,2]*x2 + RDP[j,t,3]*x3 + MCP[t]*(x8 + x9 + x10));

}

for {t in TIME,s in SCENARIO: s = 4}
{
T_B = p[t,s] * (MCP[t] * sum{j in GEN} R[t,j]);
}

for {t in TIME,s in SCENARIO: s = 5..7} {

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) <= UR[j,t,1];
then x4 = D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

         if (P[j,t,1] + x4) >= Pmax[j,t,1];
             then x11 = Pmax[j,t,1];
             else x11 = (P[j,t,1] + x4);

T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + MCP[t]*(x11 + P[j,t,2] + P[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - UR[j,t,1] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) >= 0, <= UR[j,t,2];
then x4 = UR[j,t,1];
     x5 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

        if (P[j,t,2] + x5) >= Pmax[j,t,2];
             then x12 = Pmax[j,t,2];
             else x12 = (P[j,t,2] + x5);    
   
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + MCP[t]*(x11 + x12 + P[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) >= 0, <= UR[j,t,3];
then x5 = UR[j,t,2];
     x6 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

        if (P[j,t,3] + x6) >= Pmax[j,t,3];
             then x13 = Pmax[j,t,3];
             else x13 = (P[j,t,3] + x6);    
   
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x11 + x12 + x13));

else x6 = UR[j,t,2];
     x7 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

if RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x4 + x5+ x6) + sum{k in SPOT} q[t,k]*SMP[t,k]*x7 >= sum{k in SPOT} q[t,k]*SMP[t,k]*(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]);
then
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + MCP[t]*(sum{t in TIME, j in GEN, r in RANK} P[j,t,r] + sum{k in SPOT} q[t,k]*SMP[t,k]*(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]);
else
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x11 + x12 + x13) + sum{k in SPOT} q[t,k]*SMP[t,k]*x7);
}

minimize T_D:
    sum {t in TIME} T_A + T_B + T_C ;


subject to SRF {t in TIME, s in SCENARIO}:
    beta[t] * D[t,s] >= 0;



I do not know how else to set it up inorder to eliminate the syntax error.
The model is written in such a way that the for and if-then-else statements generate the objective function to be minimized at the end. If I am wrong in the placement of my codes, please do correct me.

Thanks.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

[AMPL 2083] Re: Help Needed

Ifedi Odinakaeze
Thanks for reply.
My set SCENARIO has three major categories, s=1..3, s=4 and s=5..7;
Each of these major categories contributes to the objective function.
The question is how do I get my code to analyze for the different categories and then bring together their different costs in order to generate the objective function.

Can an if-then-else statement be used instead of the for and what is the best way to deal with this categories?
If I get past this point, I think the modle should be able to run.
Also I have this syntax comment, Power not defined- I used Power to call up the if-then-else statement as you can see from the code.



On Mon, Nov 17, 2008 at 2:42 PM, Robert Fourer <[hidden email]> wrote:

Dear Ifedi,

 

Your for command deviates from the AMPL syntax -- described in section 13.2 of the book -- in many ways.  Just to begin with, you cannot write

 

   for {t in TIME,s in SCENARIO: s=1..3}

 

because s is a member of SCENARIO while 1..3 is a set; there is no way that they can be equal.

 

More fundamentally, however, I do not understand why you are writing a for statement at this point.  There is no way to specify a set, parameter, variable, objective, or constraint using a for statement; in the middle of a model, a for statement is only useful for assigning values to sets and parameters that have already been declared (by means of set and param statements). 

 

Bob Fourer

[hidden email]

 

 


From: [hidden email] [mailto:[hidden email]]

On Behalf Of Ifedi Odinakaeze
Sent: Monday, November 17, 2008 11:03 AM
To: [hidden email]
Subject: [AMPL 2081] Help Needed

 

Please can anybody help me out here.
Below is my model but when I try running it, I have syntax error from my first 'for command' and it points to >> s=1..<<


set GEN; # sources
set RANK; # Ranking order of the RUP
set SCENARIO; # load forecast 7-step model
set SPOT; # Spot Market Price 5-step Model
set TIME; # 24-Hour Schedule
set RANK1; # Ranking order of the RDP

param T > 0;                             # number of Hours
#param S > 0;                            # number of Load Steps
#param SP > 0;                            # number SR Price Steps
#param load {BUS,1..T} >= 0;                    # demand @ BUS[b] @ TIME[t]
param x1 >= 0;                            # Ramp-Down Power
param x2 >= 0;                            # Ramp-Down Power
param x3 >= 0;                            # Ramp-Down Power
param x4 >= 0;                            # Ramp-Up Power
param x5 >= 0;                            # Ramp-Up Power
param x6 >= 0;                            # Ramp-Up Power
param x7 >= 0;                            # SMP Power limit
param x8 >= 0;                            # Ramp-Down Power limits
param x9 >= 0;                            # Ramp-Down Power limits
param x10 >= 0;                            # Ramp-Down Power limits
param x11 >= 0;                            # Ramp-Up Power limits
param x12 >= 0;                            # Ramp-Up Power limits
param x13 >= 0;                            # Ramp-Up Power limits
param T_A >= 0;                            # Total Cost under scenario (1..3)
param T_B >= 0;                            # Total Cost under scenario (4)
param T_C >= 0;                            # Total Cost under scenario (5..7)
param T_D >= 0;                            # Total Cost under scenario (1..7)
param D {SCENARIO,1..T} >= 0;                     # Load under scenario[s] @ TIME[t]
param p {SCENARIO,1..T} > 0;                     # Load forecast scenario probability
param P {GEN,1..T,RANK} >= 0;                     # Power available @ Source[j] @ TIME[t] during Ramp Up
param Q {GEN,1..T,RANK1} >= 0;                    # Power available @ Source[j] @ TIME[t] during Ramp down
param R {GEN,1..T} >= 0;                    # Power available @ Source [j] @ Time [t] when actual is equal to forecaste
param MCP {1..T} >= 0;                         # MCP @ TIME[t]
param q {SPOT,1..T} > 0;                     # Probability of SMP MOdel under SPOT[k] @ TIME[t]
param SMP {SPOT,1..T} >= 0;                     # Spot Market price under SPOT[k] @ TIME[t]
param RUP {GEN,1..T,RANK} >= 0;                 # Ramp-Up Price of Source[j] @ TIME[t]
param RDP {GEN,1..T,RANK1} >= 0;                 # Ramp-Down Price of Source[j] @ TIME[t]
param SRP {1..T} >= 0;                         # Spinning Reserve Price @ TIME[t]
param MF {1..T} >= 0;                         # Maintenance Fee @ TIME[t]
param UR {GEN,1..T,RANK} >= 0;                     # Ramp-Up Limit of Source[j]
param DR {GEN,1..T,RANK1} >= 0;                 # Ramp-Down Limit of Source[j]
#param SMAX {1..T} >= 0;                     # Spot Market Limit @ TIME[t]
param Pmin {GEN,1..T,RANK} >= 0;                 # Minimum Power from Source[j]  
param Pmax {j in GEN,t in TIME,r in RANK} >= Pmin[j,t,r];     # Power limits from Source[j] during Ramp Up
param Qmin {GEN,1..T,RANK1} >= 0;                 # Minimum Power from Source[j]  
param Qmax {j in GEN,t in TIME,r in RANK1} >= Qmin[j,t,r];     # Power limits from Source[j] during Ramp Down


var beta {1..T} >= 0, <= 1;                     #  Spinning Reserve factor

for {t in TIME,s in SCENARIO: s=1..3}

{

if Power {t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
sum {j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s] <= DR[j,t,r];
then x1 = sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s];

    if (Q[j,t,1] -x1) <= Qmin[j,t,1];
    then x8 = Qmin[j,t,1];
    else x8 = (Q[j,t,r] -x1);
T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + MCP[t]*(x8 + Q[j,t,2] + Q[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
((sum {j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1]) >= 0,<= DR[j,t,2];
then x1 = DR[j,t,1];
     x2 = ((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1]);

    if (Q[j,t,2] -x2) <= Qmin[j,t,2];
    then x9 = Qmin[j,t,2];
    else x9 = (Q[j,t,2] -x2);
T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + RDP[j,t,2]*x2 + MCP[t]*(x8 + x9 + Q[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK1, s in SCENARIO}:
((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1] - DR[j,t,2]) >= 0,<= DR[j,t,3];
then x2 = DR[j,t,2];
     x3 = ((sum{j in GEN, t in TIME, r in RANK1} Q[j,t,r] - D[t,s]) - DR[j,t,1] - DR[j,t,2]);
else x3 = DR[j,t,3];

    if (Q[j,t,3] -x3) <= Qmin[j,t,3];
    then x10 = Qmin[j,t,3];
    else x10 = (Q[j,t,3] -x3);

T_A = sum {s in SCENARIO} p[t,s]*(RDP[j,t,1]*x1 + RDP[j,t,2]*x2 + RDP[j,t,3]*x3 + MCP[t]*(x8 + x9 + x10));

}

for {t in TIME,s in SCENARIO: s = 4}
{
T_B = p[t,s] * (MCP[t] * sum{j in GEN} R[t,j]);
}

for {t in TIME,s in SCENARIO: s = 5..7} {

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) <= UR[j,t,1];
then x4 = D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

         if (P[j,t,1] + x4) >= Pmax[j,t,1];
             then x11 = Pmax[j,t,1];
             else x11 = (P[j,t,1] + x4);

T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + MCP[t]*(x11 + P[j,t,2] + P[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - UR[j,t,1] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) >= 0, <= UR[j,t,2];
then x4 = UR[j,t,1];
     x5 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

        if (P[j,t,2] + x5) >= Pmax[j,t,2];
             then x12 = Pmax[j,t,2];
             else x12 = (P[j,t,2] + x5);    
   
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + MCP[t]*(x11 + x12 + P[j,t,3]));

else

if Power{t in TIME, j in GEN, r in RANK, s in SCENARIO}:
(D[t,s]*(1 - beta[t]) - UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]) >= 0, <= UR[j,t,3];
then x5 = UR[j,t,2];
     x6 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

        if (P[j,t,3] + x6) >= Pmax[j,t,3];
             then x13 = Pmax[j,t,3];
             else x13 = (P[j,t,3] + x6);    
   
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x11 + x12 + x13));

else x6 = UR[j,t,2];
     x7 = D[t,s]*(1 - beta[t]) -UR[j,t,1] - UR[j,t,2] - sum{j in GEN, t in TIME, r in RANK} P[j,t,r];

if RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x4 + x5+ x6) + sum{k in SPOT} q[t,k]*SMP[t,k]*x7 >= sum{k in SPOT} q[t,k]*SMP[t,k]*(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]);
then
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + MCP[t]*(sum{t in TIME, j in GEN, r in RANK} P[j,t,r] + sum{k in SPOT} q[t,k]*SMP[t,k]*(D[t,s]*(1 - beta[t]) - sum{j in GEN, t in TIME, r in RANK} P[j,t,r]);
else
T_C = sum {s in SCENARIO} p[t,s]*((SRP[t] + MF[t])*(beta[t]*D[t,s]) + RUP[j,t,1]*x4 + RUP[j,t,2]*x5 + RUP[j,t,3]*x6 + MCP[t]*(x11 + x12 + x13) + sum{k in SPOT} q[t,k]*SMP[t,k]*x7);
}

minimize T_D:
    sum {t in TIME} T_A + T_B + T_C ;


subject to SRF {t in TIME, s in SCENARIO}:
    beta[t] * D[t,s] >= 0;



I do not know how else to set it up inorder to eliminate the syntax error.
The model is written in such a way that the for and if-then-else statements generate the objective function to be minimized at the end. If I am wrong in the placement of my codes, please do correct me.

Thanks.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---