Hi!
I need to solve:
W’ * NACE1 * W = NACE2
where ’ means transposition and W, NACE1 and NACE2 are matrices such that:
-NACE1 and NACE2 are square and known, 60x60 and 65x65, respectively.
-W is rectangular (60x65) and partially unknown: only 152 out of the 3776 elements of W are unknown but in the range [0, 1] (the rest of the elements are predetermined zeroes or ones, that cannot be changed). The rowise sum of W must be 1, but not so the columns.
I am writing a code to solve this system of equations using CONOPT but:
-How can I make different for GAMS zeroes and blanks in my imported matrices?
-As far as W is not square, it can not be inverted.
-The problem in which I am stuck is how make the matrix product within an equation (to let the solver work over one of the matrices) in which one of the matrices is composed by parameters and variables at the same time. I have thought to use a subset, but as far as I am working with matrices I can not define a subset involving two different indexes.
I guess I should either:
-Define something that is a parameter or a variable condition to w is known or not (blank), but I do not know if that is posible and how to do it.
-Make any kind of loop that set the values of a parameter after each iteration with the results of the variables before making the next interation instead of letting the solver make the iterations by itself, but I do not know how to do it.
Any other easier way? Any ideas??? (A draft of the code below)
Thanks beforehand!
Regards,
Antonio
================
$title BridgeMatrix
Sets
i NACE1.1 codes /C01,C02,C05,C10,C11,C12,C13,C14,C15,C16,C17,C18,C19,C20,C21,C22,C23,C24,C25,C26,C27,C28,C29,C30,C31,C32,C33,C34,C35,C36,C37,C40,C41,C45,C50,C51,C52,C55,C60,C61,C62,C63,C64,C65,C66,C67,C70,C71,C72,C73,C74,C75,C80,C85,C90,C91,C92,C93,C95/
j NACE2 codes /V01,V02,V03,VB,V10_12,V13_15,V16,V17,V18,V19,V20,V21,V22,V23,V24,V25,V26,V27,V28,V29,V30,V31_32,V33,VD,V36,V37_39,VF,V45,V46,V47,V49,V50,V51,V52,V53,VI,V58,V59_60,V61,V62_63,V64,V65,V66,VL,V69_70,V71,V72,V73,V74_75,V77,V78,V79,V80_82,VO,VP,V86,V87_88,V90_92,V93,V94,V95,V96,VT,VU/
;
Alias(i,ii);
Alias(j,jj);
Table fw(i,j) fixed wheights
$ondelim
$include fw.csv
$offdelim
;
Table NACE1(i,ii)
$ondelim
$include NACE1.csv
$offdelim
;
Table NACE2(j,jj)
$ondelim
$include NACE2.csv
$offdelim
;
Variable vw(i,j) weights to be determined;
vw.l(i,j)=0;
vw.u(i,j)=1;
Variable w(i,j) weights used for matrix product;
w(i,j)=fw(i,j)+vw(i,j);
*A problem here is that all the elements of the matrix can float, but only those for which fw is blank should float. Note that vw, and consequently w, can be 0 and 1.
Equations
rowsw(i) Rowise sum of weights = 1
cell(j,jj) Each cell of the transformed matrix must match the official one
;
rowsw(i)… sum(i, vw(i,j)) =e= 1
cell(j,jj)… sum{i, [w(j,i)*sum{ii, [NACE1(i,ii)*w(ii,jj)]}]} =e= NACE2(j,jj)
;
model BridgeMatrix /all/;
Solve BridgeMatrix USING cns;
–
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/GKQZp-41bvcJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.