Was solving a puzzle using glpk and wanted to model logical constraints.
Glpsol says : "Operand preceding = has invalid type"
Context: s.t. third : if truth[3]=1.......

Can't the if operator be used this way?
----------------------------------------


set N ;
var own {n in N}, binary;
var mentions{n in N},binary;
var truth{n in N}, binary;

maximize obj: mentions[1];

subject to first:  truth[1]=own[3];
s.t. second: truth[2]=1-own[2];
s.t. third : if truth[3]=1 then sum{n in N}truth[n]=1;
s.t. CA:( if truth[3]=1 and mentions[1] then own[1] else(1- own[1]))=1;
s.t. CB:if (truth[3]=1 and mentions[2]) then own[2]=1 else(1- own[2])=1;
s.t. CC:if (truth[3]=1 and mentions[3]) then own[3]=1 else(1- own[3])=1;


s.t. owner:sum{n in N}own[n]=1;
s.t. cmentions: sum{n in N}mentions[n]=1;


data;
set N :=1 2 3;
end;


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Help-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to