[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] how to make matrix multiply with mathprog
From: |
hhb83 |
Subject: |
Re: [Help-glpk] how to make matrix multiply with mathprog |
Date: |
Tue, 24 Feb 2009 18:16:20 -0800 (PST) |
It seems that I didn't make myself understood. Here, U is variable, so I
think U and X should be 'var'. but the problem is that I could not give a
value to X, even if I write this:
s.t. position{i in I, j in J, m in K}: X[i,j,m] = 2;
the X[i,j,m] are 0, but the position[i,j,m] are all 2. I don't know how to
deal with this formulation.
Thank you!
Haibin
xypron wrote:
>
> Hello!
>
> hhb83 wrote:
>>
>> I still could not work it out. Here, the Up,i is var, so should I take
>> the Xp,i as param or var? If param, it always said "expression following
>> := has invalid type". And if I define it as var, and take the formulation
>> as constraint like this:
>> s.t. position{i in I, j in J, m in K}: X[i,j,m] = if i==1 then X0[j,m]
>> else sum{k in K} A[m,k]*X[i-1,j,k] + B[m,k]*U[i-1,j,k];
>>
>>
>
> you can find a working example below.
>
> Best regards
>
> Xypron
>
>
> # hhb83: how to make matrix multiply with mathprog
> set I := {1..9};
> set J := {1..3};
> set K := {1..3};
> set M := {1..3};
> param A{j in J, k in K};
> param B{j in J, k in K};
> param X0{j in J, k in K};
> param U{i in I, j in J, k in K};
> param X{i in I, j in J, m in M} :=
> if i==1 then X0[j,m] else sum{k in K} ( A[m,k]*X[i-1,j,k] +
> B[m,k]*U[i-1,j,k] );
> display X;
> data;
> param A: 1 2 3 :=
> 1 1 2 3
> 2 4 5 6
> 3 7 8 9;
> param B: 1 2 3 :=
> 1 1 2 3
> 2 4 5 6
> 3 7 8 9;
> param X0: 1 2 3 :=
> 1 1 2 3
> 2 4 5 6
> 3 7 8 9;
> param U:=
> [1,*,*]: 1 2 3 :=
> 1 1 2 3
> 2 4 5 6
> 3 7 8 9
>
>
>
--
View this message in context:
http://www.nabble.com/how-to-make-matrix-multiply-with-mathprog-tp22077225p22194853.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.