Indice from Indice

Problems with syntax of GAMS
Post Reply
Manu123
User
User
Posts: 2
Joined: 2 months ago

Indice from Indice

Post by Manu123 » 2 months ago

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
Unbenannt.PNG (6.41 KiB) Viewed 407 times
How can I implement the f and p as indices in GAMS.

Thank you in advance.

User avatar
bussieck
Moderator
Moderator
Posts: 808
Joined: 5 years ago

Re: Indice from Indice

Post by bussieck » 2 months 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

Manu123
User
User
Posts: 2
Joined: 2 months ago

Re: Indice from Indice

Post by Manu123 » 2 months ago

Thank you very much for this fast answer.
This helps me alot.

pseudocleft
User
User
Posts: 4
Joined: 1 month ago

Re: Indice from Indice

Post by pseudocleft » 1 week ago

Ekran görüntüsü 2022-08-04 151824.png
Ekran görüntüsü 2022-08-04 151824.png (3.99 KiB) Viewed 148 times
bussieck wrote:
2 months 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.

Post Reply