Hi Tri

Perhaps this is helpful:

Set i equipment /1*5/;

Alias(i,j);

Parameter

Connections(i,j) Available connections between equipment,

Width(i) Witdh of instrument,

Length(i) Length of instrument;

Connections(i,j) = 0;

Connections(â€œ1â€,â€2â€) = 1;

Connections(â€œ2â€,â€3â€) = 1;

Connections(â€œ1â€,â€3â€) = 1;

Connections(â€œ1â€,â€2â€) = 1;

Connections(â€œ2â€,â€4â€) = 1;

Connections(â€œ4â€,â€5â€) = 1;

Variable F(i,j) Flow from i to j;

Equations

balance(i,j) outgoing flow is equal to 90% of ingoing flow;

Balance(i)…

0.9 * Sum(j$connections(j,i), Flow(j,i)) =E= sum(k$connections(i,k), Flow(i,k));

Hope this helps

Cheers

## Renger

From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Tri Nguyen

Sent: Mittwoch, 6. April 2016 15:12

To: gamsworld

Subject: Re: Define a variable using different sets

Hi Renger.

Thank you for your prompt reply. Basically, I’m learning gams and I’m trying to replicate this system as shown. I have included set i and j to show the flow from one equipment to another. In addition, under parameters, I’ve included the length and width parameters as: length(i) and width(i). however, these parameters applies for j as well as they represent the same equipment. I’m unsure of how I could phrase the problem such that I’m not double counting the equipment.

Hope that this is clearer for you.

On Wednesday, April 6, 2016 at 8:23:20 PM UTC+8, Tri Nguyen wrote:Hi everyone,

I need your help in solving this problem I have. Suppose I have 2 sets, i and j (both holds values from 1 to 5). How to define a variable V such that it can be used as both V(i) and V(j) in an equation. For example, I want to set an equation (constraint) that says V(i) + V(k) =e= 1, but I can’t assign both i and k to the same variable V. I have tried creating another variable Vv(k) but then this produces wrong results.

Thank you.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.

To post to this group, send email to gamsworld@googlegroups.com.

Visit this group at https://groups.google.com/group/gamsworld.

For more options, visit https://groups.google.com/d/optout.

–

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.

To post to this group, send email to gamsworld@googlegroups.com.

Visit this group at https://groups.google.com/group/gamsworld.

For more options, visit https://groups.google.com/d/optout.