## Indice from Indice

Problems with syntax of GAMS
Manu123
User Posts: 2
Joined: 1 year ago

### Indice from Indice

Hi, I have to indices
one from product p
an one productfamily f
and I want to implement a mathematical equation, where p is Indice from f and I don't declare f for the equation.
In the following picture you can see the wanted Equation. Unbenannt.PNG (6.41 KiB) Viewed 3023 times
How can I implement the f and p as indices in GAMS.

bussieck
Moderator Posts: 1018
Joined: 7 years ago

### Re: Indice from Indice

You do this via a mapping set: pf(p,f). You also need this for P_m:

Code: Select all

``````set m /m1*m3/, g /g1*g5/, p /p1*p5/, f /f1*f5/;
set pf(p,f) / #p:#f /, mp(m,p) / m1.(p1,p2,p3), m2.(p2,p3,p4), m3.(p3,p4,p5) /;
variable B(m,p,g), A(m,f,g);
equation e(p,m,g);
e(p,m,g)\$mp(m,p).. B(m,p,g) =l= sum(pf(p,f), A(m,f,g));
``````
The sum(pf(p,f), ...) is not a real sum since pf is a one-to-one mapping, so it just selects the f for the active p.

-Michael
Manu123
User Posts: 2
Joined: 1 year ago

### Re: Indice from Indice

Thank you very much for this fast answer.
This helps me alot.
pseudocleft
User Posts: 4
Joined: 1 year ago

### Re: Indice from Indice Ekran görüntüsü 2022-08-04 151824.png (3.99 KiB) Viewed 2764 times
bussieck wrote: 1 year ago You do this via a mapping set: pf(p,f). You also need this for P_m:

Code: Select all

``````set m /m1*m3/, g /g1*g5/, p /p1*p5/, f /f1*f5/;
set pf(p,f) / #p:#f /, mp(m,p) / m1.(p1,p2,p3), m2.(p2,p3,p4), m3.(p3,p4,p5) /;
variable B(m,p,g), A(m,f,g);
equation e(p,m,g);
e(p,m,g)\$mp(m,p).. B(m,p,g) =l= sum(pf(p,f), A(m,f,g));
``````
The sum(pf(p,f), ...) is not a real sum since pf is a one-to-one mapping, so it just selects the f for the active p.

-Michael

Hi Michael,

if we have the condition that is in photo how can we write the k in sum symbol. İs sum(k\$M(j,k), x(i,j,k))=e=1; true. M is set of machines, k is indices of machines and j is indices of jobs.