[AMPL 15312] AMPL: Syntax Error Message in Summation

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

[AMPL 15312] AMPL: Syntax Error Message in Summation

12S32 TEO AI HUI DELIA
Dear Sir,

I am trying to solve an optimization problem in AMPL as follows:

# PART 0 DECLARATION OF PARAMETERS
param m;
set i := 1..m;
param T;
set t := 1..T;
param f{i}; #fare for class i
param v{i}; #probability of choosing delayed purchase option
param cf; #contingent fee
param pb; #probability of exercising option
param a{i,t}; #Cancellation probability
param fr; #refunded fare (if any)

# PART 1 DECLARATION OF VARIABLES
var x{i,t} >= 0; #number of reservations and contingents accepted

# PART 2 OBJECTIVE FUNCTION
maximize revenue: sum{i in 1..m, t in 1..T} (f[i]*(1-v[i])*x[i,t]
+(cf+pb*f[i])*x[i,t] 
-a[i,t]*fr);


I keep getting an error message that tells me:
syntax error
context:  maximize revenue: sum{i  >>> in  <<< 1..m,t in 1..T} (f[i]*(1-v[i])*x[i,t]

I can't seem to find any topics on this on the google group forum. Any help would be greatly appreciated!

Cheers,
Delia

Virus-free. www.avast.com

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[AMPL 15318] Re: AMPL: Syntax Error Message in Summation

ptiwari
Why are you defining set i? Instead of defining set i and t, and using these to define other parameters, you could use 'm' and 'T'.

So, you could replace param f{i} by param f{1..m}; Similarly var x{i,t} by var x{1..m, 1..T}; and remove set i; and set t; from your model. You have been using 'i' and 't' as indices defined over 1..m and 1..T in the objective function.

Thanks,
Paras




On Thursday, December 7, 2017 at 1:15:14 PM UTC-8, 12S32 TEO AI HUI DELIA wrote:
Dear Sir,

I am trying to solve an optimization problem in AMPL as follows:

# PART 0 DECLARATION OF PARAMETERS
param m;
set i := 1..m;
param T;
set t := 1..T;
param f{i}; #fare for class i
param v{i}; #probability of choosing delayed purchase option
param cf; #contingent fee
param pb; #probability of exercising option
param a{i,t}; #Cancellation probability
param fr; #refunded fare (if any)

# PART 1 DECLARATION OF VARIABLES
var x{i,t} >= 0; #number of reservations and contingents accepted

# PART 2 OBJECTIVE FUNCTION
maximize revenue: sum{i in 1..m, t in 1..T} (f[i]*(1-v[i])*x[i,t]
+(cf+pb*f[i])*x[i,t] 
-a[i,t]*fr);


I keep getting an error message that tells me:
syntax error
context:  maximize revenue: sum{i  >>> in  <<< 1..m,t in 1..T} (f[i]*(1-v[i])*x[i,t]

I can't seem to find any topics on this on the google group forum. Any help would be greatly appreciated!

Cheers,
Delia

<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;"> Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:#4453ea" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Dwebmail\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFuftbSgu95389HmI-4V1nVL3tGJw&#39;;return true;">www.avast.com
<a href="#CAEX=4pyMxOq_3F=a5zgvMxjDfuNR6+XArSMmJtu1J0b7qVnw8w@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1" rel="nofollow" onmousedown="this.href=&#39;#CAEX\x3d4pyMxOq_3F\x3da5zgvMxjDfuNR6+XArSMmJtu1J0b7qVnw8w@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;" onclick="this.href=&#39;#CAEX\x3d4pyMxOq_3F\x3da5zgvMxjDfuNR6+XArSMmJtu1J0b7qVnw8w@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;">

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.