# a bad probem with my gams program

 0 sets t trains/t1*t2/ s stations/s1*s3/ ts train.station/t1.s1,t1.s2,t1.s3,t2.s1,t2.s2,t2.s3/ tts H/t1.t2.s1,t1.t2.s2,t1.t2.s3/; parameters table p(t,s) *ideal departure time of t from s* s1 s2 s3 t1 5.5 2 4 t2 3 3 5; parameters table o(t,s) *ideal travel time of t from s* s1 s2 s3 t1 3 4 5 t2 2 1 4; parameters m /5000/; parameters e(s) *headway for consecutive trains in each station* /s1 2 s2 1 s3 2/; variables min"minimize sum of all delays,advances"; positive variables d(t,s) a(t,s) v(t,s) y(t,s) z(t,s) f(t,s); binary variables x(t,t,s); equations obj "define objective function" ; *travel *arrival *stop *first *second *third *forth obj .. min =e= sum ((t,s),y(t,s)+z(t,s)+f(t,s)); model SADAF/all/; loop((t,s), p(t,s)=d(t,s)-y(t,s)+z(t,s); o(t,s)=f(t,s)+v(t,s); a(t,s+1)=d(t,s)+v(t,s); d(t,s)>= a(t,s); d(t,s)=d(t,s)-m*x(t,t,s)-e(s); d(t,s)=d(t,s)+m*(1-x(t,t,s))-e(s); a(t,s+1)=a(t,s+1)-m*x(t,t,s)+e(s); a(t,s+1)=a(t,s+1)+m*(1-x(t,t,s))-e(s+1); ); solve SADAF USING MIP MINIMIZING min;  and the solution : GAMS 24.2.2 r44857 Released Mar 4, 2014 WIN-VS8 x86/MS Windows 07/09/14 14:15:35 Page 1 G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m C o m p i l a t i o n 1 sets 2 t trains/t1*t2/ 3 s stations/s1*s3/ 4 ts train.station/t1.s1,t1.s2,t1.s3,t2.s1,t2.s2,t2.s3/ 5 tts H/t1.t2.s1,t1.t2.s2,t1.t2.s3/; 6 parameters 7 table 8 p(t,s) 9 *ideal departure time of t from s* 10 11 12 s1 s2 s3 13 t1 5.5 2 4 14 t2 3 3 5; 15 16 parameters 17 table 18 o(t,s) 19 *ideal travel time of t from s* 20 21 s1 s2 s3 22 t1 3 4 5 23 t2 2 1 4; 24 parameters 25 m /5000/; 26 27 parameters 28 29 e(s) 30 *headway for consecutive trains in each station* 31 /s1 2 32 s2 1 33 s3 2/; 34 35 36 37 38 variables 39 min"minimize sum of all delays,advances"; 40 positive variables 41 d(t,s) 42 a(t,s) 43 v(t,s) 44 y(t,s) 45 z(t,s) 46 f(t,s); 47 binary variables 48 x(t,t,s); 49 50 51 52 equations 53 54 obj "define objective function" ; 55 56 * travel 57 * arrival 58 *stop 59 * first 60 * second 61 *third 62 *forth 63 64 obj .. min =e= sum ((t,s),y(t,s)+z(t,s)+f(t,s)); 65 66 67 68 69 model SADAF/all/; 70 loop((t,s), 71 p(t,s)=d(t,s)-y(t,s)+z(t,s); **** $143,141,143,141,143,141 72 o(t,s)=f(t,s)+v(t,s); ****$143,141,143,141 73 a(t,s+1)=d(t,s)+v(t,s); **** $143$143 $143 74 d(t,s)>= a(t,s); ****$143 $36 75 d(t,s)=d(t,s)-m*x(t,t,s)-e(s); ****$143 $143$143,141 76 d(t,s)=d(t,s)+m*(1-x(t,t,s))-e(s); **** $143$143 $143 77 a(t,s+1)=a(t,s+1)-m*x(t,t,s)+e(s); ****$143 $143$143 78 a(t,s+1)=a(t,s+1)+m*(1-x(t,t,s))-e(s+1); **** $143$143 $143 79 ); 80 81 82 83 solve SADAF USING MIP MINIMIZING min; ****$257 84 85 86 87 88 89 90 91 GAMS 24.2.2 r44857 Released Mar 4, 2014 WIN-VS8 x86/MS Windows 07/09/14 14:15:35 Page 2 G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m Error Messages 36 '=' or '..' or ':=' or '\$=' operator expected rest of statement ignored 141 Symbol neither initialized nor assigned A wild shot: You may have spurious commas in the explanatory text of a declaration. Check symbol reference list. 143 A suffix is missing 257 Solve statement not checked because of previous errors **** 29 ERROR(S) 0 WARNING(S) COMPILATION TIME = 0.047 SECONDS 3 MB 24.2.2 r44857 WIN-VS8 USER: GAMS Development Corporation, Washington, DC G871201/0000CA-ANY Free Demo, 202-342-0180, sales@gams.com, www.gams.com DC0000 **** FILE SUMMARY Input C:\Users\Sadeghzade\Desktop\sadaf.gms Output C:\Users\Sadeghzade\Documents\gamsdir\projdir\sadaf.lst **** USER ERROR(S) ENCOUNTERED  please help me with these errors!141,143 and when i wrote the statements in the loop in the equation part i get the message 149?why?what should i do for tha?please help me This question is marked "community wiki". asked 09 Jul '14, 07:22 sadaf 11●2●4 accept rate: 0% fbahr ♦ 4.6k●7●16

 3 In GAMS, you cannot define constraints within a loop. You should first declare their names using Equations instructions and then define them separately (similar to what you have already written for the objective function). Your code should look something like below. Equations Const1 Verbal Description of Const1 Const2 Verbal Description of Const2 ...; * Now defining constraints; Const1(t,s).. p(t,s)=d(t,s)-y(t,s)+z(t,s); Const2(t,s).. o(t,s)=f(t,s)+v(t,s); ...  You should also make sure to put the model definition line (i.e., model SADAF/all/;) after the equations instructions. answered 09 Jul '14, 09:31 Ehsan ♦ 4.8k●3●11●22 accept rate: 16% thank you very much for your help ehsan,i live in tehran too,and i am studying industrial engineering at amirkabir university... (09 Jul '14, 12:10) sadaf You're welcome. Good luck with your studies. (09 Jul '14, 13:01) Ehsan ♦
 0 My original model is: The data: total number of trains: T total number of stations: S ideal departure time of t from s: Pts ideal travel time of t from s: Ots minimum separation time between consecutive : es departures and arrivals in s the variables: dts departure time of t from s vts travel time of t from s ats arrival time of t from s yts delay on the departure time of t from s zts advance on the departure time of t from s fts delay on the travel time of t from s xt1t2s priority order between the departures from s 1=xt1t2s if t1 leaves s before t2, otherwise =0; I dont know how should I define "xt1t2s" in my program and how can I write its conditional statement? and also i should use some d(t1,s) and d(t2,s) in my equations because in fact the last two equations should be in this form (with paying attention to the definition of variable x(t1,t2,s)): a(t1,s+1)=a(t2,s+1)+m*(1-x(t1,t2,s))-e(s+1);  how should i define x? and how can i write the equations in this form? please help me. thank you link This answer is marked "community wiki". answered 10 Jul '14, 05:49 sadaf 11●2●4 accept rate: 0% fbahr ♦ 4.6k●7●16
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×51