Hello Thilo,
Thilo Bohr wrote: > > Given are the following Parameter: > > param x {b in B, a in A, c in C}; > param y {b in B, a in A, c in C}; > param z {b in B, a in A, c in C} : > (x[b, a, c] + y[b, a, c]); > param result {a in A, b in B, c in C} : z[a, b, c]; > > As you can see, the result has the Indexes a and b switched. > > Is there a construct that allows me define the result Parameter without > the need of the z Parameter? > > I.e. is it possible to switch the indexes a und b "inline" (i.e. within > the expression)? > > The following does not work: > > param result {a in A, b in B, c in C} : > (x[b, a, c] + y[b, a, c])[a, b, c]; > Your statements concerning z are only valid, if A = B. For the correct syntax without z see r2 in example below. For a correct transposition look at r3. Best regards Xypron set A; set C; param x {b in A, a in A, c in C} := Uniform(0,1); param y {b in A, a in A, c in C} := Uniform(0,1); param z {b in A, a in A, c in C} := x[b, a, c] + y[b, a, c]; # the fowllowing does not cause as transposition param r1 {a in A, b in A, c in C} := z[a, b, c]; param r2 {a in A, b in A, c in C} := x[a, b, c] + y[a, b, c]; # now lets do a proper transposition param r3 {a in A, b in A, c in C} := x[b, a, c] + y[b, a, c]; printf "Please, check the following:\n"; printf "[%2s,%2s,%2s]: %6s + %6s = %6s = %6s ?= %6s\n", "", "", "", "x", "y", "r1", "r2", "r3"; for {a in A, b in A, c in C} printf "[%2s,%2s,%2s]: %6.4f + %6.4f = %6.4f = %6.4f ?= %6.4f\n", a, b, c, x[a,b,c], y[a,b,c], r1[a,b,c], r2[a,b,c], r3[a,b,c]; data; set A := a1 a2; set C := c1 c2; end; -- View this message in context: http://www.nabble.com/Switching-Indexes-within-an-expression-%28Inline%29-tp26023272p26030086.html Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com. _______________________________________________ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk