Professional Documents
Culture Documents
Group Members:
Aditishree, 18074002
Meera Joshi, 18074010
Problem Statement:
To propose and implement a Group Decision Making (GDM) model that deals with detecting
and managing the non-cooperative / manipulative behavior of decision makers.
In this report, we describe the problem statement and the relevant terms in detail which are
required as the foundation for the project.
2. Selection Process: In the selection process, a solution is obtained from all given
preferences. For reaching a decision that can reflect the opinion of every individual in the
group, it is required to achieve a high degree of consensus. .
Then, a fuzzy preference relation PR is usually modeled by the n × n matrix PR = (prij), being
prij = μPR (xi ,xj ), (∀i,j ∈ {1,…,n})
interpreted as the preference degree of the alternative xi over xj .
In particular:
- prij = 0.5 indicates indifference between xi and xj
- prij = 1 indicates that xi is absolutely preferred to xj
- prij > 0.5 indicates that xi is preferred to xj.
Based on this interpretation, we have that prii = 0.5 ∀i ∈ {1,…,n}. In addition, since prii’s do
not matter, they are usually written as ‘-‘ instead of 0.5.
The consensus reaching process takes place in several rounds. After each round, the decision
makers send their modified decisions based on the feedback obtained from the previous round, in
order to reach a high degree of group consensus. Non-cooperative behavior means that the
decision makers are unwilling to modify their preferences in order to reach group consensus, and
might even undermine the consensus reaching.
Since the presence of non-cooperative behaviors will not only bias the consensus-reaching
process, but also hinder and prolong the consensus-reaching process, they need to be identified
and properly handled.
This project aims to propose and implement a model that can deal with non-cooperative
behaviors of decision makers.
1. Utility Value Assume that 𝑢 = { 𝑢1 , 𝑢2 ,..., 𝑢𝑛 } is the set of utility values provided by
one of the decision makers (DMs). 𝑢𝑖 ϵ [0, 1], 𝑖 = 1, 2,..., 𝑛 represents the utility values
of alternative 𝑥𝐼 . Generally, higher utility value represents a more important alternative.
2.1.1 Real-world scenario explaining why feedback mechanism based CRP fails:
● In real decision making processes, the DMs’ opinions will evolve in response to their
interactions. Thus, consensus models formally based on opinion evolution have been
introduced.
● In some situations, DMs might be dishonest, and try to engage other DMs into trust
relationships with them to assemble a clique to manipulate decision results. This type of
group malicious or simply undermining is called trust relationship manipulation behavior
and it needs to be taken seriously.
● There may also be DMs who are not intentionally manipulative for a given purpose, but
they may engage in malicious behaviors that are not conducive to the legitimate intent of
the CRP, such as dishonest, disobedient or divergent behaviors [17]. This type of
non-cooperative behavior can significantly decrease the consensus efficiency and should
be addressed in the CRP.
2.2.1 DeGroot Model: Let {𝑒1, 𝑒2, … , 𝑒𝑚} be a set of actors. A weighting matrix
𝑊 = (𝑤𝑖𝑗)𝑚×𝑚 is utilized to depict the relationship among the actors, where 𝑤𝑖𝑗 represents the
𝑚
direct influence of actor 𝑒𝑗 to 𝑒𝑖 and satisfies 𝑤𝑖𝑗≥ 0 and ∑ 𝑤𝑖𝑗 = 1 for all 𝑖, 𝑗 ∈ {1, 2, … , 𝑚}.
𝑗=1
2.2.2 Social connection strength: Assuming the decision makers to be the nodes in a directed
graph, For a directed graph 𝐺(𝑉 , 𝐿) with 𝑉 = {𝑣1, 𝑣2, … , 𝑣𝑚}, we use the membership
function 𝜇𝑅 : 𝑉 × 𝑉 ⟶ [0, 1], 𝑠𝑖𝑗 = 𝜇𝑅(𝑣𝑖 , 𝑣𝑗) to define the weighted adjacency matrix
𝑆 = (𝑠𝑖𝑗) 𝑚×𝑚 , , where 𝑠𝑖𝑗means the social connection strength from 𝑣𝑖 to 𝑣𝑗 .
2.2.3 Interaction Strength We investigate and analyze the trust relationships among DMs by
referring to their interaction frequency in the interaction network that is taken into account in the
decision process. The existence of a connection between two users usually implies that they can
communicate with each other.
The interaction strength between DMs 𝑒ℎ and 𝑒𝑙 can be measured by their interaction frequency
𝑓ℎ𝑙 . The normalized interaction strength between 𝑒ℎ and 𝑒𝑙 can be represented as:
𝑚𝑖𝑛
𝑓ℎ𝑙−𝑓ℎ
𝐼𝑆ℎ𝑙 = 𝑚𝑎𝑥 𝑚𝑖𝑛
𝑓ℎ −𝑓ℎ
2.2.3 Strength of trust: A DM is more likely to trust those DMs who have high interaction
strengths with them, therefore, a simple rule can be utilized to ascertain whether there exists trust
from 𝑒ℎ to 𝑒𝑙:
where 𝜈 is the threshold value. If the normalized interaction strength is lower than 𝜈, then the
interaction strength can be ignored, in other words, only high interaction strength is taken to
exert trust on DMs’ opinions.
Section 3: Solution
Solution steps:
1. Determining the relationship between decision makers
2. Manipulative Behavior
a. Detection of manipulative behavior
b. Management of manipulative behavior
3. Consensus Reaching Process
a. Reaching Consensus Degree
b. Feedback adjustment
4. Non-cooperative Behavior
a. Detection of non-cooperative behavior
b. Management of non-cooperative behavior
5. Complete Algorithm
We assume that we have the data of interaction of decision makers (DMs) through some
networking app like Whatsapp or Microsoft Teams. We calculate the relationship among DMs by
referring to their interaction frequency on the app that is taken into account in the decision
process. In the social network graph, the connection between two users implies that they can
communicate with each other. The interaction strength between between DMs 𝑒ℎ and 𝑒𝑙 in the
network can be measured by their interaction frequency 𝑓ℎ𝑙 . The normalized interaction strength
between 𝑒ℎ and 𝑒𝑙 can be represented by:
𝑚𝑖𝑛
𝑓ℎ𝑙 − 𝑓ℎ
𝐼𝑆ℎ𝑙 = 𝑚𝑎𝑥 𝑚𝑖𝑛
𝑓ℎ − 𝑓ℎ
𝑚𝑖𝑛 𝑚𝑎𝑥
where 𝑓ℎ and 𝑓ℎ are the minimum and maximum interaction frequency from 𝑒ℎ to other
DMs, respectively. Here, we can consider that a DM is more likely to trust those DMs who have
high interaction strengths with them, therefore, strength of trust (𝑆𝑇ℎ𝑙) can be determined as:
𝑆𝑇ℎ𝑙 = {𝐼𝑆ℎ𝑙 𝑖𝑓 𝐼𝑆ℎ𝑙 > 𝑣 𝑎𝑛𝑑 ℎ ≠ 𝑙 , 0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 }
where 𝑣 is the threshold value.
Thus, the corresponding graph will be a directed graph, which can be denoted as 𝐺(𝐸, 𝐿), where
𝐸 = {𝑒1 , 𝑒2 , …, 𝑒𝑚} represents the set of DMs, and 𝐿 the set of edges which represents whether
they trust each other. 𝑆𝑇 = (𝑆𝑇ℎ𝑙)𝑚×𝑚 is the weighted adjacency matrix corresponding to DMs’
trust network 𝐺(𝐸, 𝐿) and 𝑃𝑘 = (𝑝 𝑘𝑖𝑗)𝑛×𝑛 is the FPR provided by 𝑒𝑘 .
The subgroups can be detected by the following Algorithm:
A DM in the set {𝑒𝑘 |𝑒𝑖 → 𝑒𝑘 , for all 𝑒𝑖 ∈ 𝑉 ∕𝑒𝑘 } is called an opinion leader, otherwise he/she is
a follower.
2: Manipulative Behavior
a. Detection
In a social network, manipulative behavior has three key characteristics. We define each
characteristic mathematically and combine them to find the DMs involved in manipulative
behavior. We define one rule for each characteristic and identify the involved DMs as follows:
R1) The preferences of these DMs differ significantly from other DMs. The deviation between
DM ek’s opinion and collective opinion can be defined as:
R2) The DMs’ preferences are heavily inclined to a specific alternative. This case becomes
evident if the DM evaluates one alternative as much higher than other alternatives. We define
this higher preference as:
𝑛
𝑘
Where, 𝑙 = arg max 𝑖∈{1,2,…,𝑛} min 𝑗≠𝑖 (𝜑(𝑥 𝑖 ) 𝑘 − 𝜑(𝑥 𝑗 ) 𝑘 ) and 𝜑(𝑥𝑖 ) = ∑ 𝑝𝑖𝑗 .
𝑘 𝑗=1
𝑛
𝑐
Let 𝑁𝐶2 (𝑙) = min𝑗≠𝑙 (𝜑(𝑥𝑙 ) 𝑐 − 𝜑(𝑥𝑗 ) 𝑐 ), where 𝜑(𝑥𝑙 ) = ∑ 𝑝𝑙𝑗 and β ∈ [0, 1] be the
𝑐 𝑗=1
evaluation threshold such that β > 𝑁𝐶2(𝑙).
→ If 𝑁𝐶2k (l) ≥ β, we deduce that evaluation of 𝑒𝑘 is heavily inclined to alternative 𝑥𝑙 .
𝑙
→ Let 𝑀𝐵 be the set of DMs whose evaluations differ greatly from others and are heavily
𝑙
inclined to alternative 𝑥𝑙, then 𝑀𝐵 = {𝑒𝑘 |𝑁𝐶k1 ≥ 𝛼 ∧ 𝑁𝐶𝑘2 (𝑙) ≥ 𝛽}.
R3) The DMs involved in manipulation behaviors are often linked to several common DMs in
the interaction network.
Let all DMs be divided into 𝑠 sub-groups 𝐸1 , 𝐸2 , …, 𝐸𝑠 (1 ≤ 𝑠 ≤ 𝑚). The set of opinion leaders
and followers in 𝐸𝑘 are denoted as 𝐸k𝑙𝑒𝑎𝑑𝑒𝑟 and 𝐸k𝑓𝑜𝑙𝑙𝑜𝑤𝑒𝑟 respectively. Let 𝑚𝑘 and 𝑚𝑘∗ be the number
of DMs and opinion leaders in the sub-network 𝐸𝑘 .
Let 𝑀𝐵𝑖𝑘 represents the set of members in 𝐸𝑘 who satisfy rules R1 and R2 (for alternative 𝑥𝑖), i.e.
𝑀𝐵𝑖 𝑘 = 𝑀𝐵𝑖 ∩ 𝐸𝑘 .
→ If there is at least an opinion leader in 𝑀𝐵𝑖 𝑘 , i.e. 𝑀𝐵𝑖𝑘 ∩ 𝐸 𝑘𝑙𝑒𝑎𝑑𝑒𝑟 ≠ ∅, then we induce that DMs
in 𝑀𝐵𝑖𝑘 perform manipulation behaviors and the opinion leaders in 𝑀𝐵𝑖 𝑘 are the initiators of this
kind of behavior.
● If 𝑁𝐶ℎ 2 (𝑙) = 0, it means 𝜑(𝑥1)ℎ = 𝜑(𝑥2 )ℎ = ⋯ = 𝜑(𝑥𝑛)ℎ , which means these alternatives are
the same for DM 𝑒ℎ . We do not consider this case.
● In Algorithm 2, the penalty factor 𝜚ℎ is used to penalize the weight of manipulator 𝑒ℎ.
● Here, 𝜚ℎ ∈ [0, 1] and 𝑤′ℎ is bounded to the [0, 𝑤ℎ ].
● After removal of manipulators, the interaction network will be updated again using
Algorithm 1 and it will be divided into several sub-networks and outliers.
● For evaluating consensus degree and implementing feedback mechanism, the DMs in the
same subnetwork are included in a sub-group and all the outliers are included in a
subgroup.
● Suppose that there are 𝑠* sub-groups in the CRP, denoted as 𝐺ℎ , ℎ = 1, 2, …, 𝑠∗ , where
the sub-group 𝐺s* is the sub-group whose members are the outliers. Let 𝑀𝐵 be the set of
manipulators and #𝑀B be the number of manipulators.
● The weights of the manipulators are obtained by Algorithm 2 and other DMs’ weight are
𝑤𝑘
normalized according to the manipulators’ weights, i.e., 𝑤𝑘 = 𝑚−#𝑀𝐵
(1 − Σ𝑒 ∈𝑀𝐵𝑤𝑖).
𝑖
● Let γ be the consensus threshold. If all the sub-groups’ consensus levels are higher than
the threshold 𝛾, then the consensus has been reached.
● The best alternative will be decided by the score value
𝑛
𝑐
ϕ(𝑥𝑖) = ∑ 𝑝 𝑖𝑗
𝑗=1
● The sub-groups whose consensus degrees are lower than 𝛾 are identified as the
incompatible sub-groups, we call these a part of GLT, i.e., 𝐺𝐿𝑇 = {𝐺𝑘 |𝐴𝐶𝐷𝑘 < 𝛾}.
The process ends when the consensus degree of Gk exceeds the threshold γ.
a. Detection
Some DMs may refuse to change their opinions, or dishonestly change (for example, making
only slight changes). This is termed as non-cooperative behavior. We identify non-cooperative
behavior in the case of outliers and subgroups as follows:
● Outliers: The DMs may modify their opinion only slightly, or in a direction opposite to
what is suggested in the feedback. To identify this, we define consensus adjustment
frequency as:
𝑘,𝑡 𝑘,𝑡−1 𝑘,𝑡 𝑘,𝑡−1
𝑁𝐶3 = (𝑁𝐶1 − 𝑁𝐶1 )∕𝑁𝐶1 , 𝑡 = 1, 2, …
It can be noted that:
𝑘,𝑡
→ 𝑁𝐶3 ≤ 1
𝑘,𝑡
→ Larger 𝑁𝐶3 means better adjustment to reach consensus
𝑘,𝑡
→ 𝑁𝐶3 < 0 means adjustment is in opposite direction than feedback
We define ζ as the efficiency threshold, then the set of DMs in outliers performing non
cooperating behavior can be identified as:
𝑘,𝑡 𝑘,𝑡
𝑁𝐵 = {𝑒𝑘 |𝑁𝐶1 ≥ 1 − 𝛾 ∧ 𝑁𝐶3 ≤ 𝜁}.
● Subgroups: For subgroups, it is possible that a DM is willing to cooperate, but is not
𝑘,𝑡
persuaded enough by others, hence, a lower or negative value of 𝑁𝐶3 cannot determine
non-cooperative behavior. However, if this continues for a long period, then they are
showing non-cooperative behavior. Therefore, if the above conditions hold for T
successive rounds, we say that the DM is showing non-cooperative behavior. Formally,
𝑘,𝑡+𝑇1 𝑘,𝑡+𝑞
𝑁𝐵 = {𝑒 𝑘 |𝑁𝐶1 ≥ 1 − 𝛾 ∧ 𝑁𝐶3 ≤ 𝜁 𝑓𝑜𝑟 𝑞 = 1, 2, … , 𝑇1}.
In our project, we take 𝑇1 = 2
b. Management
There are generally two ways to manage such behavior:
● Weight Penalizing
● Discarding Preferences of such DMs
We use the following algorithm to reduce the trust and weight of these DMs, so that their
contribution to CRP decreases. The idea is to make the punishment on weight and trust large if
the relative consensus adjustment efficiency is low.
5. Complete Algorithm
The complete algorithm can be summarized as follows:
Algorithm 4
Input:
𝑙
- DMs’ initial opinions 𝑃𝑙 = (𝑝𝑖𝑗 )𝑛×𝑛, 𝑙 = 1, 2, … , 𝑚
- DMs’ interaction network on a social networking app such as Whatsapp or Teams
- the DMs’ weighting vector 𝜔 = (𝜔 1 , 𝜔 2 , … , 𝜔 𝑚 )
- the deviation threshold 𝛼
- evaluation threshold 𝛽
- consensus threshold 𝛾
- efficiency threshold 𝜁
- round number 𝑡 = 0
- DMs’ self appraisal vector z
- Moderator’s trust vector 𝜏
Output: The ranking of the alternatives and 𝑡.
Step 1: By Algorithm 1, the DMs can be classified into different sub-groups 𝐸 𝑘 (𝑘 = 1, 2, …) and
their corresponding opinion leader sets 𝐸 𝑘 𝑙𝑒𝑎𝑑𝑒𝑟 (𝑘 = 1, 2, …) can also be obtained.
Step 2: Identify whether there are manipulators by the rules R1, R2 and R3. If there are
manipulators, go to step 3, otherwise go to step 4.
Step 3: Apply the Algorithm 2 to update the weights of DMs. Remove the manipulators from the
sub-network and obtain the updated sub-groups.
𝑐 ℎ
Step 4: Calculate the collective opinion 𝑃 and consensus degree 𝐴𝐶𝐷 of each sub-group.. If all
the sub-groups’ consensus levels are higher than the threshold 𝛾, go to step 9, otherwise, go to
step 5.
Step 5:
- Identify the sub-groups whose consensus levels are lower than the threshold 𝛾, i.e.,
𝐺𝐿𝑇 = {𝐺 𝑘 |𝐴𝐶𝐷 𝑘 < 𝛾}.
- If the sub-group whose members are the outliers satisfies 𝐺 𝑠 ∗ ∈ 𝐺𝐿𝑇 , then the DM
𝑒 ℎ ∈ 𝐺 𝑠 ∗ satisfying 𝑁𝐶 1 ℎ, 𝑡 ≥ 1 − 𝛾 will be advised by the moderator to modify
their preferences in the round 𝑡 + 1 as described for outliers.
- For the sub-group whose members are within a sub-network, if 𝐺 𝑘 ∈ 𝐺𝐿𝑇 , then the
moderator will provide suggestion and ask the members to discuss. Their preferences will
evolve as described for subgroups.
- If the consensus degrees of the identified sub-groups are larger than 𝛾, then go to step 9,
otherwise, go to next step.
Step 6: Identify the sets of DMs showing non-cooperative behavior from both outliers and
subgroups, as defined in the detection process.
Step 7: If there are DMs performing non-cooperative behaviors, then go to step 8, otherwise go
back to step 5.
Step 8: By Algorithm 3, the weights and trust values of the DMs can be updated. Go back to step
4.
𝑛
𝑐
Step 9: Decide the best alternative using score value ϕ(𝑥𝑖) = ∑ 𝑝 𝑖𝑗, as described.
𝑗=1
Step 10: End.
Section 4: Code with each algorithm step
import numpy as np
'''
Defining global variables
'''
# evaluation threshold
beta = 0.2
# consensus threshold
gamma = 0.75 # changed from .75 to test
# deviation threshold
alpha = 0.20
# efficiency threshold
chi = 0.05
# m - no. of experts
m = 5
# n - no. of alternatives
n = 4
# P - 3d preference relation matrix of dimension m*n*n (FPR)
P = [
[[0.5, 0.44, 0.40, 0.36],
[0.56, 0.5, 0.79, 0.58],
[0.60, 0.21, 0.5, 0.98],
[0.94, 0.42, 0.02, 0.5]],
P = np.array(P)
selfTrust = np.random.rand(5)
selfTrust = np.round(selfTrust, 1)
moderatorTrust = np.random.rand(5)
moderatorTrust = np.round(moderatorTrust, 1)
def NC1(k,Pc,P):
temp = np.abs(P[k] - Pc) #for the case i=j, both Pij and Pcij are 0.5,
so the difference does not contribute to sum, same as in paper
nc1 = np.sum(temp)
nc1 = nc1/(n*n - n)
return nc1
def NC2(k):
phi_k = np.sum(P[k],1) # 1D array having sum of preference of each
alternative
print("phi_k: ", phi_k)
l = -1
nc2= -999
for i in range(n):
min_val = 999
for j in range(n):
if j!=i:
diff = phi_k[i]-phi_k[j]
min_val = min(min_val, diff)
if min_val>nc2:
nc2 = min_val
l = i
return nc2,l
Obtain the groups in the network as shown in Algorithm 1. The function detectSubgroups return
a list of lists, where each inner list denotes a group and contains two lists, the first having leaders
and the second having followers in that group.
# Sub-network detection method based on WeChat-like interaction network
def detectSubgroups(trustMat, k=1): #trustMat is the mxm trust matrix
m = trustMat.shape[0]
# step 1
C = np.identity(m) + trustMat
for i in range(m):
for j in range(m):
if C[i][j] > 0:
C[i][j] = 1
#print(C)
#step 2
Ebar = []
nc = []
for i in range(m):
nci = np.count_nonzero(C[:,i])
#print(trustMat[:,i])
if nci > 0:
Ebar.append((nci, i))
Ebar.sort(reverse=True)
print(Ebar)
#step 3
groups = []
while Ebar:
ejk = Ebar[0][1]
ncjk = Ebar[0][0]
EkLeader = []
for i in Ebar:
ncp = i[0]
ep = i[1]
if ncjk == ncp and C[ejk][ep]==1:
EkLeader.append(ep)
# E bar = Ebar \ EkLeader
Ebar = [i for i in Ebar if i[1] not in EkLeader]
print("Group ", k)
k+=1
print("EkLeader:", EkLeader)
#print(Ebar)
EkFollower = []
for i in Ebar:
ei = i[1]
for j in EkLeader:
if C[ei][j] == 1:
EkFollower.append(ei)
break
#print(Ebar)
# E bar = Ebar \ EkFollower
Ebar = [i for i in Ebar if i[1] not in EkFollower]
print("EkFollower:", EkFollower)
#print(Ebar)
EkLeader.sort()
EkFollower.sort()
Ek = [EkLeader, EkFollower]
groups.append(Ek)
return groups
Helper function to normalize weights of remaining DMs after the manipulator weights are
penalized.
for i in range(m):
if i not in MBexperts:
weights[i] *= nfactor
# print("in normalize: ", weights, "factor: ", nfactor)
return weights
def consensus_degree_groups(groups,Pc):
ACD = []
for group in groups:
w_sum = lambda_den(group)
cd_group = 0
for l in group: # l is for the two lists, leader and follower
for expert in l:
lambdak = weights[expert]/w_sum
cd_group += lambdak*consensus_degree_expert(expert,Pc)
ACD.append(cd_group)
return ACD
Obtain influence matrix representing how the extent by which an expert’s decision is influenced
by other’s decisions, manipulator, and their own previous decision.
# influence matrix matrix
def getInfluenceMatrix(group, trustMat = trustMat, selfTrust =
selfTrust, moderatorTrust = moderatorTrust):
mk = len(group)
TD = np.zeros((mk, mk+1))
z = []
# print(trustMat.shape)
for i in range(mk):
for j in range(mk):
TD[i][j] = trustMat[group[i]][group[j]]
TD[i][mk] = moderatorTrust[group[i]]
z.append(selfTrust[group[i]])
#normalize TD
sum_of_rows = TD.sum(axis=1)
TD = TD / sum_of_rows[:, np.newaxis]
# obtain influence matrix W for this group
q = np.eye(mk) - np.diag(z)
W = np.c_[np.diag(z), np.zeros(mk)] + np.matmul(q, TD) #equation 14
return W
Obtain the preference of an expert in the next round after feedback, based upon the influence
matrix and moderator’s suggestion that is based on the collective Pc of the previous round.
def getNextPreference(group, Pt, Pct):
# here and in getInfluenceMatrix, group is assumed to be a list of
experts, not list of list having leaders and followers
Wk = getInfluenceMatrix(group)
#evolved preferences
pNext = []
mk = len(group)
for i in range(mk): #obtain next preference of each expert as per eq
15
prefI = np.zeros((n,n))
for j in range(mk+1):
prefI += Wk[i][j]*pij[j]
pNext.append(prefI)
pNext = np.array(pNext)
# print(pNext.shape)
return np.array(pNext)
Identify Manipulators involved in Non-cooperative behavior
def identifyNB(flatG,Pc,Pc_prev,P,Pprev):
NB = []
for k in flatG:
nc1 = NC1(k,Pc,P)
nc1_prev = NC1(k,Pc_prev,Pprev)
nc3 = (nc1_prev - nc1)/nc1_prev
if nc1 >= (1-gamma) and nc3 <= chi:
NB.append(k)
return NB
for k in range(m):
nc2k, l = NC2(k)
# print(k, ":", nc2k)
collectiveNC2 = collectiveNc2(Pc,l) #generally, we choose beta >
nc2l, that has to be implemented
# print("collectiveNC2:", collectiveNC2)
if nc2k >= beta:
R2experts.append((l,k))
if k in R1experts:
if l not in MB: MB[l] = [k]
else: MB[l].append(k)
print("R2 experts: ", R2experts)
# print("experts following R1 and R2 supporting some alternative: ",
MB)
#R3
groups = detectSubgroups(trustMat)
nGrps = len(groups)
MBexperts = {} # dict having the alternative and corresponding
manipulative experts
MBorNBexists = True
#To get back to step 3, i.e keep updating weights until manipulative or
non-coopertaive behaviour exists
while MBorNBexists:
# print(weights)
# Update weights
for alternative in MBexperts:
update_MBweights(weights, collectiveNc2(Pc, alternative), Pc,
MBexperts[alternative],P)
# print(weights)
weights = normalize_weights(MBexpertsList, weights)
# print("normalized weights", weights)
# remove manipulative experts from subgroups
for group in groups:
group[0] = [i for i in group[0] if i not in MBexpertsList]
group[1] = [i for i in group[1] if i not in MBexpertsList]
# print(MBexpertsList)
# print(groups)
GLT = [groups[0]]
# print("groups: ", groups)
'''Step 5: CRP for groups with consensus degree less than gamma
'''
gamma = .95 #to test
for g in GLT:
# for subgroups with memeber in GLT (non outliers)
# print(g)
# print("flat", flatten(g))
cdg = consensus_degree_groups([g], Pc)
# print("gamma: ",gamma, "CD: ", cdg)
# if the consensus degree of this group has not reached threshold
r=0
while cdg[0] < gamma:
# print(cdg[0])
# for h in range(1):
r = r + 1
print("consensus degree after round", r,": ", cdg)
# obtain next evolution based on feedback
flatG = flatten(g)
Pnext = getNextPreference(flatG, P, Pc)
P_prev = P
# update P as per Pnext
for i in range(len(flatG)):
P[flatG[i]] = Pnext[i]
# update Pc
Pc_prev = Pc
Pc = collective_matrix(weights, P)
cdg = consensus_degree_groups([g], Pc)
# print(cdg)
update_NBweights(weights,NB,Pc,P)
# if NC behavior exists, make it true so that the loop from step
3 continues
if NB: MBorNBexists = False
Section 5: Output