GAMS ERROR 781

Problems with modeling
Post Reply
cosmisena
User
User
Posts: 5
Joined: 1 year ago

GAMS ERROR 781

Post by cosmisena »

Code: Select all

Sets
i "products" /i1, i2, i3/
j "processing units" /j1, j2,  j3/
s "sites" /s1, s2, s3/;

Parameters
FC  Fixed production cost for product i on unit j at site s 
v Variable production cost for product i on unit j at site s
cp  Cost of raw material i at site s
t Transportation cost of product i from site s to customer c
h Inventory holding cost for product đť‘– at site s
ss Safety stock violation penalty cost for product i at site s
MRL Minimum production run length for product i on unit j at site s
R Production rate of product i on unit j at site s
PC Production capacity on unit j at site s
IL Safety stock for product i at site s
BC Backorder unit cost of product i at site s
inventory
d /i1 1000, i2 2000, i3 3000/
m /i1 100, i2 250, i3 230/
; 

Table FC
        s1   s2   s3
i1.j1   5    0    0 
i2.j1   7    0    0
i3.j1   9    0    0
i1.j2   0    8    0
i2.j2   0    6    0
i3.j2   0    9    0
i1.j3   0    0    10
i2.j3   0    0    7
i3.j3   0    0    8;

Table v
        s1     s2     s3
i1.j1   2.5    0.0    0.0 
i2.j1   2.3    0.0    0.0
i3.j1   1.9    0.0    0.0
i1.j2   0.0    2.4    0.0
i2.j2   0.0    1.5    0.0
i3.j2   0.0    2.2    0.0
i1.j3   0.0    0.0    2.9
i2.j3   0.0    0.0    3.8
i3.j3   0.0    0.0    2.2;

Table cp

    s1  s2  s3
i1  10  12  11
i2  9   7   6
i3  13  8   7;

Table inventory

    s1  s2  s3
i1  0   0   0
i2  0   0   0
i3  0   0   0;

Table h

    s1    s2   s3
i1  1.8  1.7  1.6
i2  1.8  1.7  1.6
i3  1.8  1.7  1.6;

Table MRL
        s1   s2   s3
i1.j1   70   0    0 
i2.j1   70   0    0
i3.j1   70   0    0
i1.j2   0    80   0
i2.j2   0    80   0
i3.j2   0    80   0
i1.j3   0    0    90
i2.j3   0    0    90
i3.j3   0    0    90;


Table R
        s1   s2   s3
i1.j1   0.5  0    0 
i2.j1   0.5  0    0
i3.j1   0.5  0    0
i1.j2   0    0.6  0
i2.j2   0    0.6  0
i3.j2   0    0.6  0
i1.j3   0    0    0.8
i2.j3   0    0    0.8
i3.j3   0    0    0.8;

Table PC

    s1  s2  s3
j1  7   0   0
j2  0   9   0
j3  0   0   12;

Table ss

    s1  s2  s3
i1  10  15  25
i2  10  15  25
i3  10  15  25;

Table BC

    s1  s2  s3
i1  4   7   10
i2  4   7   10
i3  4   7   10;

Positive Variables
A(i,s) Amount of product i available for supply at site s
P(i,j,s) Production amount of product i on unit j at site s
RL(i,j,s) Production run length of product i on unit j at site s
CO(i,s) Raw material consumption of product i at site s
B(i,s) Backorder units recorded by product i of site s
Supply(i,s) Supply of product i from site s  to customer c 
ID(i,s) Safety stock deviation of product i at site s
IS(i) Shortage of product i at customer c;

Binary Variable
Y(i,j,s) Binary variable indicating whether product i is manufactured on unit j at site s;

Variable
Z objective;

Equations
obj the objective function of first stage
eq1 Equation 1 shows the production amount of a particular product obtained from production rate of product and the run length of product
eq2 Equation 2 models the capacity constraints
eq3 Equation 3 sets lower bound for the product run length
eq4 The amount available for supply in the logistics phase following the manufacturing stage is defined by Equation 4
eq5 Equation 5 presents the inventory level which is determined by the amount available for supply and the actual supply
eq6
eq7
eq8
eq9
eq10
;

obj.. Z =e= sum((i,j,s),FC(i,j,s)*Y(i,j,s)) + sum((i,j,s),v(i,j,s)*P(i,j,s)) + sum((i,s),cp(i,s)*CO(i,s)) + sum((i,s), B(i,s)*BC(i,s))
+ sum((i,s),t(i,s)*Supply(i,s))+ sum((i,s),h(i,s)*inventory(i,s)) + sum((i,s),ss(i,s)*ID(i,s)) + sum((i),m(i)*IS(i))+sum((i,s),BC(i,s)*B(i,s));
eq1(i,j,s).. P(i,j,s) =e= R(i,j,s)*RL(i,j,s);
eq2(j,s).. sum(i,RL(i,j,s)) =l= PC(j,s);
eq3(i,j,s).. MRL(i,j,s)*Y(i,j,s) =l= RL(i,j,s);
eq4(i,s).. A(i,s) =e= inventory(i,s) - B(i,s) + sum(j,P(i,j,s));
eq5(i,s).. inventory(i,s) =e= A(i,s) - Supply(i,s);
eq6(i).. sum(s,Supply(i,s)) =l= d(i);
eq7(i).. d(i) - sum(s,Supply(i,s)) =l= IS(i);
eq8(i).. IS(i) =l= d(i);
eq9(i,s).. IL(i,s) - inventory(i,s) =l= ID(i,s);
eq10(i,s).. ID(i,s) =l= IL(i,s);

Model project / all /;

File emp / '%emp.info%' /;
put emp '* problem %gams.i%'/;
$onput
randvar d('i1') normal 70  15
randvar d('i2') normal 50  10
randvar d('i3') normal 110 25
stage 2 S(i,s) I(i,s) ID(i,s) IS(i) m
stage 2 d demand
stage 2 eq5 eq6 eq7 eq8 eq9 eq10
$offput
putclose emp;


Set
scen scenarios / sc1*sc3 /;
Parameter
     s_m(scen, i) Lost revenue per scenario
     s_d(scen, i) Demand by scenario
     s_rep(scen, *) "scenario probability"   / #scen.prob 0/;
 
Set dict / scen .scenario.''
           d    .randvar .s_d
           m    .level   .s_m
           ''   .opt     .s_rep /;
 
solve project max z use EMP scenario dict;
display s_d, s_m, s_rep;


Hello! I'm trying to solve two-stage supply chain problem using stochastic optimization on GAMS. I have uncertainty demand... I get Error 781 in last part, solve part.
How can I fix this error?
Fred
Posts: 372
Joined: 7 years ago

Re: GAMS ERROR 781

Post by Fred »

Hi,

The error you get is

Code: Select all

*** The following EMP errors were detected in model project:
    781 Symbol m in dimension one not of type variable or equation in scenario dictionary
Your symbol m is a parameter. In your dict set

Code: Select all

Set dict / scen .scenario.''
           d    .randvar .s_d
           m    .level   .s_m
           ''   .opt     .s_rep /;
you are trying to save the `level` of m. But a parameter does not have a level attribute. Only variables and equations have a level attribute.

This just seems to be the first of many problems. Fixing it there are several other error messages. I suggest to study them carefully in order to debug step by step.

Good Luck!

Fred
Post Reply