-
Notifications
You must be signed in to change notification settings - Fork 0
/
maxsumscore_PEM.m
33 lines (32 loc) · 995 Bytes
/
maxsumscore_PEM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%Author: Zsolt T. Kosztyán Ph.D, University of Pannonia
%----------------
%Calculate maximal sum of score values of possible project scenarios
%----------------
%Output:
%score: the maximal score value of the project scenario
%Inputs:
%PEM: N by N upper triangular adjacency matrix of logic network
%P: N by N score matrix of task/dependency inclusion
%Q: N by N score matrix of task/dependency exclusion
%----------------
%Usage:
%maxsumscore_PEM(PEM,P,Q)
%----------------
%Example:
%
% % |0.8, 0.4, 0.8|
% %PEM=|0.0, 0.7, 0.7| P=PEM Q=1-P
% % |0.0, 0.0, 0.4|
%
%PEM=[[0.8,0.4,0.8];[0.0,0.7,0.7];[0.0,0.0,0.4]];P=PEM;Q=ones(3,3)-P;
%maxsumscore_PEM(PEM,P,Q)
function score=maxsumscore_PEM(PEM,P,Q)
score=1;
p=diag(P);
q=diag(Q);
pem=diag(PEM);
N=numel(pem);
pqmax=max([p,q],[],2);
if N>0 %The score of the project scenario is the sum of maximum task scores
score=sum([p(pem==1);q(pem==0);pqmax(pem>0&pem<1)]);
end