Don't know what else to do, i'm getting the same syntax error over and over again. Industrial Maximization Model.

32 views
Skip to first unread message

The Flying Raccoons GT

unread,
Sep 20, 2017, 2:48:09 AM9/20/17
to AMPL Modeling Language
Hi everyone,

I got the following model, but wen i run it, ampl gives me this msg:

ampl: model D:\AMPL\ampl_mswin64-7\amplide\ampl\Factory.mod;

D:\AMPL\ampl_mswin64-7\amplide\ampl\Factory.mod, line 47 (offset 720):
syntax error
context:   >>> V[p, <<< t] * A[t,p,k] * Mt[t]))-

I've tried it all in order to fix the problem, but nothing seems to work and i dont know what else to do.

Hope you guys can help me. Thanks in Advance.

i have the .dat file if you guys need it.

Here's it the model. The line 47 with the problem is in red.

#Sets
set k:= 1..5;
set t:= 1..5;  
set p:= 1..3;
set m:= 1..2;
set f:= 1..2;
set e:= 1..2;
#Parameters
param Mmin{t};
param Mmax{t};
param Cgiro := 0;
param CT{f};
param alfa{t};
param beta{f,t};
param fi{t};
param gamma{t};
param Cest{e,p};
param L{f,t};
param H{e,p};
param Hs{e,p};
param DS{p,t};
param V{p,t};
param VC{p,t};
param I{e,p};
param Disp{m};
param M{m};
param A{t,p,k};
param CK{t,k};
param C{m,t};

#Variables
var X {k,t} binary;
var Mt {t} >=0;
var Mp {m,t} >=0;
var Mpp {f,t} >=0;
var Mppp {k,t} >=0;
var DISPq {m,t} >=0;
var Iq {p,e,t} >=0;


#FO
maximize total_revenue: 
sum {i in t}
((sum {j in p}
(sum {x in k} 
V[p,t] * A[t,p,k] * Mt[t]))-
(sum {z in m} 
C[m,t]*Mp[m,t] + 
sum {h in f} 
L[f,t]*Mpp[f,t] + 
sum {x in k} 
CK[t,k]*Mppp[k,t] + 
sum {j in p}
(sum {g in e} 
H[e,p]*Iq[p,e,t]) + 
sum {j in p}
(sum {g in e} 
Hs[e,p]*I[p,e,T]))) ;



#Restrictions
#(2)
subject to inventory_balance {j in p, i in t}:
sum{g in e} I[p,e,t] = (sum{g in e} I[p,e,t-1]) + (sum{x in k} A[t,p,k] * Mt[t] - DS[p,t]) ;
#(3)
subject to small_bucket {i in t} :
sum{x in k} X[k,t] = 1 ;
#(4)
subject to compatibility :
sum{z in m} Mp[m,t] = sum{h in f} Mpp[f,t] = sum{x in k} Mppp = Mq[t] ; 
#(5)
subject to sugarcane_availability {z in m, i in t} :
DISPq[m,t] = DISPq[m,t-1] - Mp[m,t-1] >= Mp[m,t] ; 
#(6)
subject to utilization:
sum{z in m} DISPq[m,1] = sum{i in t} Mq[t] ; 
#(7)
subject to capacity_crushed{i in t}:
Mmin[t] * (fi[t]/100) * (gamma[t]/100) <= Mq[t] <= Mmax[t] * (fi[t]/100) * (gamma[t]/100) ; 
#(8)
subject to cash_flow{i in t} :
sum{j in p}(sum{x in k} VC[p,t] * A[t,p,k] * Mq[t]) + Cgiro >= ((sum{z in m} C[m,t] * Mp[m,t]) + (sum{h in f} L[f,t] * Mpp[f,t]) + (sum{x in k} CK[t,k] * Mppp[k,t]) + (sum{j in p}(sum{g in e} H[e,p] * Iq[p,e,t]))) ;

#(9)
# 1 =  Farm
# 2 =  Own
subject to sugarcane_supplied{i in t} : 
Mp[1,t] + Mp[2,t] <= alfa[t] * Mq[t] ;
#(10)
subject to capacity_transported{h in f, i in t} : 
Mpp[f,t] <= (beta[f,t]/100) * (gamma[t]/100)* CT[f] ;
#(11)
subject to inventory_capacity{j in p, g in e, i in t} : 
Iq[p,e,t] <= Cest[e,p] ;
#(12)
subject to sugarcane_processed{x in k, i in t} : 
Mppp[k,t] <= Mmax[t] ;
#(13)
subject to dominio_M : 
Mq[t] >= 0 ;
 
subject to dominio_Mp :
Mp[m,t] >= 0 ; 
subject to dominio_Mpp :
Mpp[f,t] >= 0 ;
subject to dominio_Mppp :
Mppp[k,t] >= 0 ;
subject to dominio_Disp :
DISPq[m,t] >= 0 ;
subject to dominio_I :
Iq[p,e,t] >= 0 ;

subject to dominio_X{x in k, i in t}:
X[k,t] in {0,1}

Ansuman Swain

unread,
Sep 20, 2017, 2:52:45 PM9/20/17
to AMPL Modeling Language
Hi,
 
While declaring the indexed parameter the set name is used inside the { } ,
However further reference to the parameter can be done by of bracketed ‘‘subscripts’’ The value inside [ ] is the element/member of the set. 

In the following case : V[p,t] * A[t,p,k] * Mt[t]))-

Parameter V is indexed over set p and t,
Parameter A is indexed over set t ,p and k,
Parameter Mt is indexed over set t,

In Objective function before the expression :
sum {i in t}
((sum {j in p}
(sum {x in k} 
represents, each elements of sets t,p,k are i,j,x 
 
Thus the expression should be:
V[j,i] * A[i,j,x] * Mt[i])) and so on.

The Flying Raccoons GT

unread,
Sep 24, 2017, 6:07:14 PM9/24/17
to AMPL Modeling Language
Hi Ansuman,

Thank you very much for the response!

Now i got another error.

which can be reduced from my code to:

set t:= 1..5; #Time periods
set e:= 1..2; #Intentory places
set p:= 1..3; #Products

var Iq{p,e,t} >= 0; #Inventory variable

#Moving variables:
# i for sums in t
# g for sums in e
# j for sums in p

subject to inventory_balance {j in p, i in t}:
sum{g in e} Iq[j,g,i] = sum{g in e} Iq[j,g,i-1] + sum{x in k} A[j,i,x] * Mt[i] - DS[i,j] ;

This is the inventory level, which is the sum of "g in e" of the inventory level at time i-1 plus other things. The problem is the "i-1" time period. The first iteration will be for time t=1 i.e because of the constraint it will become time t=0. I know that in that period (t=0) the amount of inventory is 0. So the thing is, how can I set the variable Iq[p,e,0] be 0 in a constraint? 

Thanks in advance!
Reply all
Reply to author
Forward
0 new messages