Hello,
I am in looking for help in optimizing a power system network. I have developed model based on the much I have gotten from the AMPL book. I just started programming about three weeks ago. Below is a description of my attachments. The Thesis.mod is my model written to my best ability at the moment. I am looking for help in debugging it. The Syntax for Running Program,txt is the commands I have prepared for running my model. The Optimization Model gives the description of the work that I am doing and how I came about my equations. The Gen.xls is the Excel file that contains the data that I am analyzing. I know this requires time from you guys but I am desperately in need of help in order to make it through this work. I will be grateful and appreciative of it always if there is any one that can help me. Thanks. Ifedi (+1306-979-4988/ +1306-292-0046) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- 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 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; model Thesis.mod; table Gendata "ODBC" "Gen.xls":[TIME] IN,MCP IN,SRP IN,MF IN,beta OUT; table S IN "ODBC" "Gen.xls": SCENARIO <-[SCENARIO]; table SP IN "ODBC" "Gen.xls": SPOT <-[SPOT]; table RK IN "ODBC" "Gen.xls": RANK <-[RANK]; table RK1 IN "ODBC" "Gen.xls": RANK1 <-[RANK1]; table loads IN "ODBC" "Gen.xls": [TIME,SCENARIO],D,p; table Spot IN "ODBC" "Gen.xls": [TIME,SCENARIO],D,p; table Price IN "ODBC" "Gen.xls": [TIME,GEN,RANK],RUP,P,UR,Pmax,Pmin; table Price1 IN "ODBC" "Gen.xls": [TIME,GEN,RANK1],RDP,Q,DR,Qmax,Qmin; table Actual IN "ODBC" "Gen.xls": [TIME,GEN],R; read table S; read table SP; read table RK; read table RK1; read table loads; read table Spot; read table Price; read table Price1; read table Actual; solve; write table Gendata; |
Thanks Ali for your comment,
My main problem is how to manage the if-then-else commands I have in my model. The chain of if-then-else generate the objective function since a lot of comparison of cost and power limits are made before the objective function is formed. I tried to run the model but was getting syntax error from the first for statement in the model, I tried changing it to if and I had the same thing. My question is how to do write those chain of if-then-else and for statement in order for the code to work. Looking forward to your help if you can. I know very much you do not have time but I will appreciate the sacrifice. Thanks. On Sat, Nov 15, 2008 at 6:00 PM, Ali Baharev <[hidden email]> wrote: Could you please narrow down your problem? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
Hello, > My main problem is how to manage the if-then-else commands I have in my > model. I am interested in developing solvers, i rarely use modeling languages but i think i can (at least partly) answer your question. In case of CPLEX you can use the so-called indicators: http://www.ilog.com/products/cplex/news/whatsnew.cfm If it is not good for you then the proposal in page 14 can be an alternative method: J. N. Hooker, A principled approach to mixed integer/linear problem formulation, June, revised August, to appear in ICS Proceedings 2009. http://ba.gsia.cmu.edu/jnh/milpmodeling2.pdf http://ba.gsia.cmu.edu/jnh/papers.html Good luck, Ali --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
Free forum by Nabble | Edit this page |