|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Switching Indexes within an expression (Inline)Hi,
given 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 {b in B, c in C, a in A} : 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 {b in f, c in i, a in m} : (x[b, a, c] + y[b, a, c])[a, b, c]; Kind regards, Thilo _______________________________________________ Help-glpk mailing list Help-glpk@... http://lists.gnu.org/mailman/listinfo/help-glpk |
|
|
Re: Switching Indexes within an expression (Inline)Thilo Bohr schrieb:
> Hi, > > given 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 {b in B, c in C, a in A} : 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 {b in f, c in i, a in m} : > (x[b, a, c] + y[b, a, c])[a, b, c]; Sorry, that actually should read: param result {b in B, c in C, a in A} : (x[b, a, c] + y[b, a, c])[a, b, c]; > > > > > Kind regards, > Thilo _______________________________________________ Help-glpk mailing list Help-glpk@... http://lists.gnu.org/mailman/listinfo/help-glpk |
|
|
Re: Switching Indexes within an expression (Inline)Thilo Bohr schrieb:
> Thilo Bohr schrieb: Forget my former postings, my example was quite confusing because there where some badly mixed up indexes in there. So I begin again. 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]; Kind regards, Thilo _______________________________________________ Help-glpk mailing list Help-glpk@... http://lists.gnu.org/mailman/listinfo/help-glpk |
|
|
Re: Switching Indexes within an expression (Inline)Hello Thilo,
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; |
|
|
Re: Switching Indexes within an expression (Inline)xypron schrieb:
> 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. [...] Thank you for your detailed answer, Xypron. The solution does not yet exactly meet my requirements. I will try to describe these more precisely. What I am aiming for is a way to reassign the indexes of an expression that is part of a given parameter definition that I can not modify as whole but just the expression within the definition. For example, if the following parameter definition is given: param result {a1 in A, a2 in A} : v[a1, a2] * (x[a2, a1] + y[a2, a1]); I only am able to replace the expression (x[a2, a1] + y[a1, a2]) with something (that could look like "(x[a2, a1] + y[a1, a2])[a1,a2]"). Particularly it is not possible to add another parameter definition (which could be referenced instead of the expression) before this parameter definition. (The reason for this constraint is the process that generates the parameter definitions of my model.) So this replacement I am looking for could by called an amalgam of an inline parameter definition and a parameter reference. Do you - does anybody - see a solution to this requirement? Kind regards, Thilo _______________________________________________ Help-glpk mailing list Help-glpk@... http://lists.gnu.org/mailman/listinfo/help-glpk |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |