help-glpk
[Top][All Lists]

## [Help-glpk] Re: Switching Indexes within an expression (Inline)

 From: Thilo Bohr Subject: [Help-glpk] Re: Switching Indexes within an expression (Inline) Date: Sun, 25 Oct 2009 02:49:24 +0400

```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.

[...]

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

```