Hello,I have another problem with my program too.

I have two problems in writing that in gams:

  1. i don’t know how to write the" x t1t2s "(that is a binary variable,it give me an error if i write like this because i dont have any t1 or t2 in my set and they are only the elements of a set)???

  2. i don’t know how to write its conditional statement for being 0 or 1 in my gams?

Please help me my friends….

xt1t2s=1 if train1 leaves s before train2

and

xt1t2s=0 if train2 leaves s before train1

(departurture time of t2 is lowerr than t1 or d(t2)<d(t1)) but i dont know how can i separate t1 from t2 and even how should i introduce xt1t2s in variables????

what should i do?!

My gams program is like the below:

sets
t   trains/1*2/
s   stations/1*3/

tts   H/t1.t2.s1,t1.t2.s2,t1.t2.s3/;

parameters
table
p(t,s) *ideal departure time of t from s*

      1     2    3
 1  5.50 5.53 5.60
 2  5.63 5.66 5.73;

parameters
table
 o(t,s)    *ideal travel time of t from s*

    1        2       3
 1  0.03     0.07    0
 2  0.03     0.07    0;

parameters
e(s)  *headway for consecutive trains in each station*

  /1 0.13
   2 0.13
   3 0.13/
m /+inf/;

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"
 departure
 travel
 arrival
 stop
 first
 second
 third
 forth ;

obj   ..   min =e= sum ((t,s),y(t,s)+z(t,s)+f(t,s));
departure(t,s)  .. p(t,s)=e=d(t,s)-y(t,s)+z(t,s);
travel(t,s) .. o(t,s)=e=v(t,s)-f(t,s);
arrival(t,s) .. a(t,s+1)-d(t,s)-v(t,s)=e=0;
stop(t,s) .. d(t,s)-a(t,s)=g=0;
first(t,s) .. d(t,s)-d(t+1,s)+m*x(t,t+1,s)=g=e(s);
second(t,s) .. -d(t,s)+d(t+1,s)+m*(1-x(t,t+1,s))=g=e(s);
third(t,s) .. a(t,s+1)-a(t+1,s+1)+m*x(t,t+1,s)=g=e(s+1);
forth(t,s) .. -a(t,s+1)+a(t+1,s+1)+m*(1-x(t,t+1,s))=g=e(s+1);

model  SADAF/all/;

if (d(t,s)<d(t+1,s),
  x(t,t,s)=1;
 else
 x(t,t,s)=0;
);

solve SADAF USING MIP MINIMIZING min;

And the output is:

GAMS 24.2.2  r44857 Released Mar  4, 2014 WIN-VS8 x86/MS Windows 07/10/14 10:06:57 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/1*2/
   3  s   stations/1*3/
   4  *ts  train.station/1.1,1.2,1.3,2.1,2.2,2.3/
   5  tts   H/t1.t2.s1,t1.t2.s2,t1.t2.s3/;
   6   
   7   
   8  parameters
   9  table
  10  p(t,s) *ideal departure time of t from s*
  11   
  12        1     2    3
  13   1  5.50 5.53 5.60
  14   2  5.63 5.66 5.73;
  15   
  16  parameters
  17  table
  18   o(t,s)    *ideal travel time of t from s*
  19   
  20      1        2       3
  21   1  0.03     0.07    0
  22   2  0.03     0.07    0;
  23   
  24  parameters
  25  e(s)  *headway for consecutive trains in each station*
  26   
  27    /1 0.13
  28     2 0.13
  29     3 0.13/
  30  m /+inf/;
  31   
  32   
  33  variables
  34  min"minimize sum of all delays,advances" ;
  35   
  36  positive variables
  37   d(t,s)
  38   a(t,s)
  39   v(t,s)
  40   y(t,s)
  41   z(t,s)
  42   f(t,s);
  43  binary variables
  44  x(t,t,s);
  45   
  46   
  47  equations
  48   
  49   obj   "define objective function"
  50   departure
  51   travel
  52   arrival
  53   stop
  54   first
  55   second
  56   third
  57   forth ;
  58   
  59   
  60   
  61  obj   ..   min =e= sum ((t,s),y(t,s)+z(t,s)+f(t,s));
  62  departure(t,s)  .. p(t,s)=e=d(t,s)-y(t,s)+z(t,s);
  63  travel(t,s) .. o(t,s)=e=v(t,s)-f(t,s);
  64  arrival(t,s) .. a(t,s+1)-d(t,s)-v(t,s)=e=0;
  65  stop(t,s) .. d(t,s)-a(t,s)=g=0;
  66  first(t,s) .. d(t,s)-d(t+1,s)+m*x(t,t+1,s)=g=e(s);
  67  second(t,s) .. -d(t,s)+d(t+1,s)+m*(1-x(t,t+1,s))=g=e(s);
  68  third(t,s) .. a(t,s+1)-a(t+1,s+1)+m*x(t,t+1,s)=g=e(s+1);
  69  forth(t,s) .. -a(t,s+1)+a(t+1,s+1)+m*(1-x(t,t+1,s))=g=e(s+1);
  70   
  80  model  SADAF/all/;
  81   
  82   
  83  if (d(t,s)<d(t+1,s),
****      $143,141,149,149,143,149,149
  84    x(t,t,s)=1;
****    $143
  85   else
  86   x(t,t,s)=0;
****   $143
  87  );
  88   
  89    
  94  solve SADAF USING MIP MINIMIZING min;
****                                      $257
  95   
GAMS 24.2.2  r44857 Released Mar  4, 2014 WIN-VS8 x86/MS Windows 07/10/14 10:06:57 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

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
149  Uncontrolled set entered as constant
257  Solve statement not checked because of previous errors

**** 10 ERROR(S)   0 WARNING(S)

COMPILATION TIME     =        0.109 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

What should I do with all these errors?

This question is marked "community wiki".

asked 10 Jul '14, 02:22

sadaf's gravatar image

sadaf
1124
accept rate: 0%

converted to question 10 Jul '14, 04:43

fbahr's gravatar image

fbahr ♦
4.6k716

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • 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

Asked: 10 Jul '14, 02:22

Seen: 1,337 times

Last updated: 10 Jul '14, 04:43

OR-Exchange! Your site for questions, answers, and announcements about operations research.