# GAMS Support Wiki

### Site Tools

gams:a_more_complex_parameter_to_set_-_matching_problem

# Differences

This shows you the differences between two versions of the page.

 gams:a_more_complex_parameter_to_set_-_matching_problem [2007/08/10 12:30]127.0.0.1 external edit gams:a_more_complex_parameter_to_set_-_matching_problem [2020/05/28 10:51]Michael Bussieck 2020/05/28 10:52 Michael Bussieck 2020/05/28 10:51 Michael Bussieck 2007/08/10 12:30 external edit 2020/05/28 10:52 Michael Bussieck 2020/05/28 10:51 Michael Bussieck 2007/08/10 12:30 external edit Last revision Both sides next revision Line 3: Line 3: Q: //I want to create a parameter a(k) and multiply a(k)*x(i,j) where x is a variable and k= Ord(i) - Ord(j) with the complication that x(i,j) is not full for all i and j.  I can't seem to get this to work.// Q: //I want to create a parameter a(k) and multiply a(k)*x(i,j) where x is a variable and k= Ord(i) - Ord(j) with the complication that x(i,j) is not full for all i and j.  I can't seem to get this to work.// - I would make a set ''​ijk(i,​j,​k)''​. The elements of this set are the matching tuples. The problem is that k is a set element and not a number. So your k in ''​k=Ord(i)-Ord(j)''​ also needs a function that maps it to a value, like ord. Depending on the range of ''​ord(i)-ord(j)''​ you can either work with ''​ord''​ or (as I did in my example) ​have a parameter with the proper values. Please find the complete example attached. + I would make a set ''​ijk(i,​j,​k)''​. The elements of this set are the matching tuples. The problem is that k is a set element and not a number. So your k in ''​k=Ord(i)-Ord(j)''​ also needs a function that maps it to a value, like ord. Depending on the range of ''​ord(i)-ord(j)''​ you can either work with ''​ord''​ or have a parameter with the proper values ​or (as in the example below) work with ''​k.val''​. Please find the complete example attached. <​code>​ <​code>​ set i /i1*i10/, k /0*9/; alias (i,j); set i /i1*i10/, k /0*9/; alias (i,j); - Parameter nk(k); nk(k) = ord(k)-1; set ij(i,j); ij(i,j) = ord(i)>​=ord(j) and uniform(0,​1)<​0.5;​ set ij(i,j); ij(i,j) = ord(i)>​=ord(j) and uniform(0,​1)<​0.5;​ - set ijk(i,j,k); ijk(ij(i,​j),​k) = ord(i) - ord(j) = nk(k); + set ijk(i,j,k); ijk(ij(i,​j),​k) = ord(i)-ord(j) = k.val; - option ijk:0:0:1; display ​nk, ij, ijk; + option ijk:0:0:1; display ij, ijk; binary variable x(i,j); variable z; binary variable x(i,j); variable z; 