help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] comparing variable binary vector to each row of static m


From: malekro
Subject: Re: [Help-glpk] comparing variable binary vector to each row of static matrix
Date: Mon, 6 Jun 2011 23:55:06 -0700 (PDT)

hello xypron,

thanks for your answer, unfortunately im stuggling with matching the
individual cells. i adapted my attempt to your description, but i still have
problems matching the individual cells. P are the columns, T are the rows.
unfortunately using variables in if-constraints is not allowed  (st
matchcells), resulting in an error. the other way i could think of is using
multiplication but it results in non linearity.


set P := 1..4;
set T := 1..9;

param matrix{t in T, p in P}, integer, >= -1, <= 1;

var vector{p in P}, binary;
var cellmatch{t in T, p in P}, binary;
var rowmatch{t in T}, binary;

subject to matchcells{t in T, p in P}: cellmatch[t,p] = (if matrix[t,p] ==
-1 || matrix[t,p] == vector[p] then 1 else 0);
subject to matchrows{t in T}: rowmatch[t] = ((sum{p in P} cellmatch[t,p]) /
card(P));

maximize z: sum{t in T} (rowmatch[t]);


i guess i did not understand what you ment by "real variables for each row".
i would be glad if you could give me further advice.

thanks,
manuel


xypron wrote:
> 
> Hello Manual,
> 
> use binary variables for each column and real variables (>=0, <=1) for
> each row, describing if the row is matched. Add constraints. Maximize the
> number of row matches.
> 
> Best regards
> 
> Xypron
> 

-- 
View this message in context: 
http://old.nabble.com/comparing-variable-binary-vector-to-each-row-of-static-matrix-tp31787965p31789483.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]