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

2009-10-24 Thread Thilo Bohr
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@gnu.org
http://lists.gnu.org/mailman/listinfo/help-glpk


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

2009-10-24 Thread Thilo Bohr
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@gnu.org
http://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] KPI simple function

2009-10-24 Thread Simone Atzeni

Hi Xypron,

I'm sorry for disturbing you again.

Following your suggestion, I created this model:

var Z1;
var Z2;
var U;

maximize obj : 0.18 * Z1 + 0.82 * Z2;
#maximize obj : 0.5 * Z1 + 0.5 * Z2;

s.t. c1 : 20 * Z1 + 110 * U <= 83; # (0.3,0.7)-(0.85,0.6)
s.t. c2 : 28 * Z1 - 8 * U <= 19; # (0.85,0.6)-(0.75,0.25)
s.t. c3 : 4 * Z1 + 40 * U >= 13; # (0.75,0.25)-(0.25,0.3)
s.t. c4 : 80 * Z1 - 10 * U >= 17; # (0.25,0.3)-(0.3,0.7)

s.t. c5 : 40 * Z2 - 5 * U >= 9; # (0.25,0.2)-(0.3,0.6)
s.t. c6 : 30 * Z2 - 110 * U >= - 57; # (0.3,0.6)-(0.85,0.75)
s.t. c7 : 80 * Z2 - 20 * U <= 53; # (0.85,0.75)-(0.75,0.35)
s.t. c8 : 12 * Z2 - 40 * U <= -5; # (0.75,0.35)-(0.25,0.2)

solve;
printf "U =%6.3f, Z1 = %6.3f, Z2 = %6.3f\n", U, Z1, Z2;
end;

When I try to solve this problem I get the same solution whatever is  
the objective function,
but I need that when I change the objective function the result is  
different.

The real problem is this:

U is an action and Z1 and Z2 are two KPIs that depend on U. I'm  
looking for just a model to represent this in a simple way to finish  
my project. Sadly, I don't have the real KPI.


Thanks
Simone


On 23/ott/09, at 19:31, xypron wrote:



Hello Simone,

There was a typo
s.t. c4 : y >=0; # (3,0)-(0,0)

Best regards

Xypron


xypron wrote:


Hello Simone,

if the solution of a linear program is unique, it will always be in a
vertex of the
convex polyeder described by the constraints.

The objective function gives the optimization direction and hence  
decides

which
vertex of the polygon is the solution.

For a two dimensional problem lets think of an polygon given by the
following vertices:
(0,0) (1,1) (2,1) (3,0)
This corresponds to the following inequalities:
s.t. c1 : x - y >= 0; # (0,0)-(1,1)
s.t. c2 : y <= 1; # (1,1)-(2,1)
s.t. c3 : x + y <= 3; # (2,1)-(3,0)
s.t. c4 : x >=0; # (3,0)-(0,0)

If our optimization direction is (1,1) the objective is
maximize obj : x + y;
The solution is vertex (2,1)

If our optimization direction is (-1,1) the objective is
maximize obj: -x + y;
The solution is vertex (1,1);

The complete model is:

var x;
var y;

# uncomment the appropriate objective
#maximize obj :  x + y; # direction (1,1);
maximize obj : -x + y; # direction (-1,1);

s.t. c1 : x - y >= 0; # (0,0)-(1,1)
s.t. c2 : y <= 1; # (1,1)-(2,1)
s.t. c3 : x + y <= 3; # (2,1)-(3,0)
s.t. c4 : x >=0; # (3,0)-(0,0)
solve;
printf "x = %6.3f, y = %6.3f\n", x, y;
end;

Best regards

Xypron


Simone Atzeni wrote:


Hi all,

I'm looking for two functions that could represent simple KPIs.

In other world, I would like two MILP, in this way:

MILP 1:

MAX J = 0.5 * Z1 + 0.5 * Z2

Z1 = -AX + C
Z2 = BX + D

and

MILP 2:

MAX J = 0.32 * Z1 + 0.68 * Z2

Z1 = -AX + C
Z2 = BX + D

Z1 and Z2 are the values of the KPI and they depend on X. The
constraints should be equal but the results (the values of Z1 and  
Z2)

should be different changing the coefficients fo the objective
function, in this case (0.5 - 0.5) for the MILP1 and (0.32 - 0.68)  
for

the MILP 2.

I can't find a good function. I need just functions where Z1 and Z2
depend on X but changing the coefficients in the objective functions
change the values of Z1, Z2 and X.

MILPs I'm using are the follow:

MAX J = 0.5 Z.1 + 0.5 Z.2

Z.1 = 5X (0.196116135138184 Z.1 - 0.98058067569092 U.1 <= 0) (the
equations have been normalized)
Z.2 = -3X + 4 (0.196116135138184 Z.2 + 0.115384615384615 U.1 <=
0.153846153846154)

and

MAX J = 0.32 Z.1 + 0.68 Z.2

Z.1 = 5X
Z.2 = -3X + 4

This is the picture of the two functions:



Both MILPs have the same solution.

Z.1 = 1
Z.2 = 0.666795
X = 0.2

In this case the weights, (0.5 - 0.5) for the MILP1 and (0.32 -  
0.68)

for the MILP 2, don't influence the results of the MILP. I want
something in a way that the weights influence the results, so that  
the

two MILPs have different result but they should being equal.

Can someone help me?

Thanks
Simone


___
Help-glpk mailing list
Help-glpk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-glpk







--
View this message in context: 
http://www.nabble.com/KPI-simple-function-tp26025826p26030427.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




___
Help-glpk mailing list
Help-glpk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-glpk