1

I have a GAMS model where I have

 Set   i       / 1*6 /;
 Alias (i,ip,il) ;
 Variables
  x(i,ip) ;

And I want to generate equations which operates on the scalar products of all vectors in x, excluding the product of the same vector. Something like:

 scalarProduct(i)..
  sum(ip,x(i,ip)x(i,il)) =e= someConstant;

However this does not exclude the product of identical vectors. How to add this? Can I do it with a dollar statement somehow? There's probably a few bugs in that statement anyway, I didn't try it because I think the exclusion I want is missing.

user3917718
  • 85
  • 2
  • 13
  • I dont't understand what you are trying to do with `scalarProduct`. You want to multiply things like `x(i1,i2) * x(i1,i3)` and want to exclude things like `x(i1,i2)*x(i1,i2)`? – Jon Cardoso-Silva Aug 25 '15 at 15:32
  • 1
    I'd almost forgotten about this. I found out how to do it in the mean time, will post the answer now – user3917718 Aug 26 '15 at 18:37

1 Answers1

1

so what I wanted to do is this:

Sets
i        / 1*13 /
ii(i,i) diagonal elements / #i:#i /
ij(i,i) all elements / #i.#i /
ij_wo_ii(i,i);

get all combinations without the diagonal elements:

ij_wo_ii(i,j) = ij(i,j) - ii(i,j);

and then I use it in an equation like this:

equation(j,k)..
  sum(i,x(i,j)*x(i,k)$ij_wo_ii(j,k)) =l= 1;

This does something similar to orthogonality, except that the product of vectors in a matrix must be smaller than some value and not necessarily 0. don't know if there is a term for this. Hope it will be of use to someone else as well.

user3917718
  • 85
  • 2
  • 13