Dear Pedro,

Thank you very much! That was just what I wanted.

You just saved me a lot of hours, I really appreciate that!

Best Regards,

Henrik

Den torsdag den 5. juni 2014 13.02.23 UTC+2 skrev PowerChile:

Dear Henrik,

Attached please find a dummy example.

Cheers,

Pedro

On Thu, Jun 5, 2014 at 11:04 AM, Henrik Holm wrote:

Hello Pedro

Thanks for answer and fast response.

I tried your suggestion, but ran into this problem,

**** 50 equation objective… loop index used in equation

**** 50 equation objective… loop index used in equation

**** 50 equation objective… loop index used in equation

**** 50 equation objective… loop index used in equation

I therefore made an alias for j, hence

alias(j,k)

So now I loop over set k instead - that should be fine right?

However, as I understand the ord operator, It does this,

In the first iteration ord(k) = ‘t1’ = value of that index in the set is now 1 and next ord(k) = ‘t2’ = value 2.

This means that in my parameter b(i,j) all my values becomes 1 in the first iteration, 2 in the second iteration etc.

I dont want it to change the values. I just want to change which index in set j it uses.

The values in my parameter b(i,j) already exists, so i what to iterate over them.

Best Regards,

Henrik Holm

Den onsdag den 4. juni 2014 10.33.10 UTC+2 skrev PowerChile:

Dear Henrik,

You need to make your loop over the set j, not over the parameter b:

loop(j,

b(i,j) = ord(j);

solve model using LP min/max z;

);

Please note that if you need to store the results from each run, you need new parameters for such purpose.

Cheers,

Pedro

On Tue, Jun 3, 2014 at 10:14 PM, Henrik Holm wrote:

Hello,

I am a little stuck with my GAMS model.

To illustrate my problem here is a small model.

Set i /1*10/

Set j /t1, t2, t3/

Parameter b(i,j)

Variable x(i)

Objective … z =e= sum(i, x(i)*b(i,j)

Now I want to make a loop so can iterate over set j in the parameter b(i,j), hence

loop(b,

b = 1 = t1

Solve model z =e= sum(i, x(i)*b(i,‘t1’)

b = 2 = t2

Solve model z =e= sum(i, x(i)*b(i,‘t2’)

b = 3 = t3

Solve model z =e= sum(i, x(i)*b(i,‘t3’)

);

So I end up having 3 solutions, one for each j (t1, t2, t3)

I hope It make sense, otherwise I will try to explain it more clearly.

Thanks in advance

Best Regards,

Henrik Holm

PEDRO JAVIER RAMÃREZ TORREALBA

Ingeniero Civil ElÃ©ctrico PUC

MSc en IngenierÃa ElÃ©ctrica PUC

Londres, REINO UNIDO

Celular: +44-(0)75-8069-3119

PEDRO JAVIER RAMÃREZ TORREALBA

Ingeniero Civil ElÃ©ctrico PUC

MSc en IngenierÃa ElÃ©ctrica PUC

Londres, REINO UNIDO

Celular: +44-(0)75-8069-3119

–

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 http://groups.google.com/group/gamsworld.

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