AMPL to GAMS conversion

Dear gamsworld members,

I have just started to use GAMS. Even though I tried to model my problem several times, I couldn’t figure it out. Finally I found an AMPL example that is similar to my problem. But I don’t know how to implement it in GAMS.

Could you please help me conversion of AMPL code below to GAMS code?

Thank you.

param N := 201;
param time := 4.8;
param length := 6.0;
param ns := 3;
param z{1…ns-1};
param s{1…ns};
param h := time/N;
param uamax := 10.0;
param ubmax := 2.0;
param aa:= 0.3;
param bb := 0.14;
param cc := 0.16;
param eps := 0.05;
param pi := 4atan(1);
var x{0…N};
var v{i in 0…N-1} = (x[i+1]-x_)/h;
var v_avg{i in 1…N-1}
= (v+v[i-1])/2;
var a{i in 1…N-1} = (v-v[i-1])/h;
var ua{1…N-1} >=0.0, =0.0, train_x;
printf {i in 1…N-1}: “%10f %10f \n”,
i
h, u > train_a;
printf {i in 0…N-1}: “%10f %10f \n”,
i*h, v > train_v;
\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout._

Dear Sir!

At GAMS official site You can find place where all AMPL model from internal library were translated into GAMS.

You answer here WWW.GAMS.COM

Try and You will find

I know this because I made this many years ago

all the best!


20.06.2015, 15:07, “Patel” :

Dear gamsworld members,

I have just started to use GAMS. Even though I tried to model my problem several times, I couldn’t figure it out. Finally I found an AMPL example that is similar to my problem. But I don’t know how to implement it in GAMS.

Could you please help me conversion of AMPL code below to GAMS code?

Thank you.

param N := 201;
param time := 4.8;
param length := 6.0;
param ns := 3;
param z{1…ns-1};
param s{1…ns};
param h := time/N;
param uamax := 10.0;
param ubmax := 2.0;
param aa:= 0.3;
param bb := 0.14;
param cc := 0.16;
param eps := 0.05;
param pi := 4atan(1);
var x{0…N};
var v{i in 0…N-1} = (x[i+1]-x_)/h;
var v_avg{i in 1…N-1}
= (v+v[i-1])/2;
var a{i in 1…N-1} = (v-v[i-1])/h;
var ua{1…N-1} >=0.0, var ub{1…N-1} >=0.0, var u {i in 1…N-1} = ua-ub;
minimize energy:
sum {i in 1…N-1} ua
v_avgh;
s.t. newton {i in 1…N-1}:
h
a =
h*
(

  • sum {j in 1…ns-1}
    (s[j+1]-s[j])*
    atan((x-z[j])/eps)/pi
  • aa - bbv_avg - ccv_avg[i]ˆ2
  • u[i]
    );
    s.t. x_init: x[0] = 0;
    s.t. x_finl: x[N] = length;
    s.t. v_init: v[0] = 0;
    s.t. v_finl: v[N-1] = 0;
    data;
    param z := 1 2.0 2 4.0;
    param s := 1 2.0 2 0.0 3 -2.0;
    solve;
    printf {i in 0…N}: “%10f %10f \n”,
    ih, x[i] > train_x;
    printf {i in 1…N-1}: “%10f %10f \n”,
    i
    h, u[i] > train_a;
    printf {i in 0…N-1}: “%10f %10f \n”,
    i*h, v[i] > train_v;


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.\



With kindly regards!
Andre Savitsky
E-mail:andresavit@yandex.ru
andre_savit@yahoo.com



To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout._

Reply-to: gamsworld@googlegroups.com

Dear Savitsky,

Thanks for your response. Could you please more specific where I should look for “all AMPL model from internal library were translated into GAMS”.

Since I searched gams.com and also checked all libraries out under “model libraries” menu on GAMS IDE and unfortunately I could not find anything related to AMPL.

Regards,

Kemal



22 Haziran 2015 Pazartesi 09:04:12 UTC+3 tarihinde Savitsky Andre yazdı:


Dear Sir!

At GAMS official site You can find place where all AMPL model from internal library were translated into GAMS.

You answer here WWW.GAMS.COM

Try and You will find

I know this because I made this many years ago

all the best!


20.06.2015, 15:07, “Patel” :

Dear gamsworld members,

I have just started to use GAMS. Even though I tried to model my problem several times, I couldn't figure it out. Finally I found an AMPL example that is similar to my problem. But I don't know how to implement it in GAMS.

Could you please help me conversion of AMPL code below to GAMS code?

Thank you.

param N := 201;
param time := 4.8;
param length := 6.0;
param ns := 3;
param z{1..ns-1};
param s{1..ns};
param h := time/N;
param uamax := 10.0;
param ubmax := 2.0;
param aa:= 0.3;
param bb := 0.14;
param cc := 0.16;
param eps := 0.05;
param pi := 4*atan(1);
var x{0..N};
var v{i in 0..N-1} = (x[i+1]-x_)/h;
var v_avg{i in 1..N-1}
= (v+v[i-1])/2;
var a{i in 1..N-1} = (v-v[i-1])/h;
var ua{1..N-1} >=0.0,      var ub{1..N-1} >=0.0,      var u {i in 1..N-1} = ua-ub;
minimize energy:
sum {i in 1..N-1} ua*v_avg*h;
s.t. newton {i in 1..N-1}:
h*a =
h*
(
- sum {j in 1..ns-1}
(s[j+1]-s[j])*
atan((x-z[j])/eps)/pi
- aa - bb*v_avg - cc*v_avg[i]ˆ2
+ u[i]
);
s.t. x_init: x[0] = 0;
s.t. x_finl: x[N] = length;
s.t. v_init: v[0] = 0;
s.t. v_finl: v[N-1] = 0;
data;
param z := 1 2.0 2 4.0;
param s := 1 2.0 2 0.0 3 -2.0;
solve;
printf {i in 0..N}: "%10f %10f \n",
i*h, x[i] > train_x;
printf {i in 1..N-1}: "%10f %10f \n",
i*h, u[i] > train_a;
printf {i in 0..N-1}: "%10f %10f \n",
i*h, v[i] > train_v;


--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.\


\

With kindly regards!
Andre Savitsky
E-mail:a...@yandex.ru
andre...@yahoo.com

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout._

Reply-to: gamsworld@googlegroups.com

Thank you!

23 Haziran 2015 Salı 01:29:32 UTC+3 tarihinde Savitsky Andre yazdı:

Look here

Sorry! this is not gams.com

http://www.gamsworld.org/performance/princetonlib/princetonlib.htm



\

Dear Savitsky,

Thanks for your response. Could you please more specific where I should look for “all AMPL model from internal library were translated into GAMS”.

Since I searched gams.com and also checked all libraries out under “model libraries” menu on GAMS IDE and unfortunately I could not find anything related to AMPL.

Regards,

Kemal

22 Haziran 2015 Pazartesi 09:04:12 UTC+3 tarihinde Savitsky Andre yazdı:

Dear Sir!

At GAMS official site You can find place where all AMPL model from internal library were translated into GAMS.

You answer here WWW.GAMS.COM

Try and You will find

I know this because I made this many years ago

all the best!

20.06.2015, 15:07, “Patel” :

Dear gamsworld members,

I have just started to use GAMS. Even though I tried to model my problem several times, I couldn’t figure it out. Finally I found an AMPL example that is similar to my problem. But I don’t know how to implement it in GAMS.

Could you please help me conversion of AMPL code below to GAMS code?

Thank you.

param N := 201;
param time := 4.8;
param length := 6.0;
param ns := 3;
param z{1…ns-1};
param s{1…ns};
param h := time/N;
param uamax := 10.0;
param ubmax := 2.0;
param aa:= 0.3;
param bb := 0.14;
param cc := 0.16;
param eps := 0.05;
param pi := 4atan(1);
var x{0…N};
var v{i in 0…N-1} = (x[i+1]-x_)/h;
var v_avg{i in 1…N-1}
= (v+v[i-1])/2;
var a{i in 1…N-1} = (v-v[i-1])/h;
var ua{1…N-1} >=0.0, >> var ub{1…N-1} >=0.0, >> var u {i in 1…N-1} = ua-ub;
minimize energy:
sum {i in 1…N-1} ua
v_avgh;
s.t. newton {i in 1…N-1}:
h
a =
h*
(

  • sum {j in 1…ns-1}
    (s[j+1]-s[j])*
    atan((x-z[j])/eps)/pi
  • aa - bbv_avg - ccv_avg[i]ˆ2
  • u[i]
    );
    s.t. x_init: x[0] = 0;
    s.t. x_finl: x[N] = length;
    s.t. v_init: v[0] = 0;
    s.t. v_finl: v[N-1] = 0;
    data;
    param z := 1 2.0 2 4.0;
    param s := 1 2.0 2 0.0 3 -2.0;
    solve;
    printf {i in 0…N}: “%10f %10f \n”,
    ih, x[i] > train_x;
    printf {i in 1…N-1}: “%10f %10f \n”,
    i
    h, u[i] > train_a;
    printf {i in 0…N-1}: “%10f %10f \n”,
    i*h, v[i] > train_v;


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


With kindly regards!
Andre Savitsky
E-mail:a...@yandex.ru
andre...@yahoo.com

With kindly regards!
Andre Savitsky
E-mail:a...@yandex.ru
andre...@yahoo.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout._