Hello Michael,

I am a new GAMS user and I have quick question about very similar problem. I want to obtain a kronecker product of one of my variable.

Is it possible to use Matching Operator to do that or is there any way to write it without using a loop? According to your post I wrote the following :

Set i / 1*3/;*

Alias(i,j);

Set k / 19/;

Variables

w(i)

krow(k) kronecker product of w(i);Equations

obj objective function

kron kronecker product of s;

kron… krow(k) =e= sum(kij(k,i,j), w(i)*w(j));

obj… omega =e= (sum(i, w(i)*sum(j,q(i,k)*krow(k))));

But it doesn’t work. Any help will be appreciated.

Thank you very much in advance,

Umit

On Wednesday, April 3, 2013 4:34:14 PM UTC-4, Michael Bussieck wrote:

This is a perfect example for the not so well known GAMS Matching operator (see e.g. Release Notes for 22.7 at http://www.gams.com/docs/release/release.htm#22.7):

Set i /1*3/;*

Alias (i, j);

Set k /19/;

- GAMS Matching Operator introduced in GAMS 22.7 (May 2008)

set kij(k,i,j) /#k:(#i.#j)/;

display kij;

Table A(i,j)

1 2 3

1 0.5 1.2 3.9

2 2.2 0.8 5.2

3 2.3 5.0 7.3;

Parameter B(k);

B(k) = sum(kij(k,i,j), A(i,j));

display A, B;

Michael Bussieck - GAMSWorld Coordinator

On Wednesday, April 3, 2013 3:41:29 PM UTC-4, Renger van Nieuwkoop wrote:

Hi Helene

Here my solution after two glasses of fine Italian Barolo:

Parameter

B(k),

counter,

sumloop;

counter =0;

loop(i,

loop(j,

sumloop= ord(i) + counter*2+ (ord(j) -1);

loop(k$(ord(k) = sumloop),

b(k) = a(i,j);

);

);

counter = counter + 1);

display b;

There might be a more straight forward solution. Perhaps somebody else feels obliged.

Renger

\

Modelworks

Gewerbestrasse 16

3600 Thun â€“ Switzerland

+41 79 818 53 73

Info@modelworks.ch

From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Helene Eriksson

Sent: Wednesday, April 3, 2013 7:33 PM

To: gams...@googlegroups.com

Subject: Assign One Dimensional Parameter to Two Dimensional Parameter

Hello!

I have a question regarding the way to assign a two dimensional parameter to an one dimensional parameter. For instance,

Set i /1*3/;

Alias (i, j);

Set k /1*9/;

Table A(i, j)

1 2 3

1 0.5 1.2 3.9

2 2.2 0.8 5.2

3 2.3 5.0 7.3 ;

Parameter B(k);

Now I want B(1)=A(1,1); B(2)=A(1,2); … B(9)=B(3,3);

I tried some methods like loop assignment but seemed not work, do you have any idea to achieve this? Thank you.

Regards,

Helene

–

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?hl=en.

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

On Wednesday, April 3, 2013 3:41:29 PM UTC-4, Renger van Nieuwkoop wrote:

Hi Helene

Here my solution after two glasses of fine Italian Barolo:

Parameter

B(k),

counter,

sumloop;

counter =0;

loop(i,

loop(j,

sumloop= ord(i) + counter*2+ (ord(j) -1);

loop(k$(ord(k) = sumloop),

b(k) = a(i,j);

);

);

counter = counter + 1);

display b;

There might be a more straight forward solution. Perhaps somebody else feels obliged.

Renger

\

Modelworks

Gewerbestrasse 16

3600 Thun â€“ Switzerland

+41 79 818 53 73

Info@modelworks.ch

From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Helene Eriksson

Sent: Wednesday, April 3, 2013 7:33 PM

To: gams...@googlegroups.com

Subject: Assign One Dimensional Parameter to Two Dimensional Parameter

Hello!

I have a question regarding the way to assign a two dimensional parameter to an one dimensional parameter. For instance,

Set i /1*3/;

Alias (i, j);

Set k /1*9/;

Table A(i, j)

1 2 3

1 0.5 1.2 3.9

2 2.2 0.8 5.2

3 2.3 5.0 7.3 ;

Parameter B(k);

Now I want B(1)=A(1,1); B(2)=A(1,2); … B(9)=B(3,3);

I tried some methods like loop assignment but seemed not work, do you have any idea to achieve this? Thank you.

Regards,

Helene

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?hl=en.

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

\