function [Probability,Probability_Sum] = Calculate_Probability(Probability,Ant_k,Routes,Multi_Days_Route,Trip_Time,Last_Node_in_Routes,Eta,Tau,Probability_Sum); global Node_Size global Distance global Visiting_Time global End_Node global Start_Node global T_max global Alpha global Beta global Group_Size global Social_Relationship global Gamma Accessible_Nodes = cell(Group_Size,1); for user =1 : Group_Size for node = 1: Node_Size if Visited(Ant_k,node,Routes,Multi_Days_Route,user) if node ~= End_Node if Is_Avilable(Trip_Time(user),Last_Node_in_Routes(user),node,user) Candidate_Node_Time = Distance(Last_Node_in_Routes(user),node) + Visiting_Time(node) + Distance(node,End_Node) + Trip_Time(user); if Candidate_Node_Time > T_max continue; end Accessible_Nodes{user,1} = [Accessible_Nodes{user,1},node]; else continue; end end else continue; end end end Probability.Node = cell(1,Group_Size); Probability.Users = cell(1,Group_Size); Probability.Percentage = cell(1,Group_Size); for user =1 : Group_Size index =1; for node = 1: Node_Size if find([Accessible_Nodes{user,1}] == node) % Add the Node Probability.Node{index,user} = node; % Add the users with the same node ( here only the main % user Probability.Users{index,user} = user; % Add the percentage Probability.Percentage{index,user} = power(Eta(Last_Node_in_Routes(user),node,user), Alpha) * power(Tau(Last_Node_in_Routes(user),node,user), Beta) * power(1,Gamma); Probability_Sum(user) = Probability_Sum(user) + Probability.Percentage{index,user}; %Add to the index 1 index = index + 1; %List of users can visit the same node Users_Sharing_Same_Node = []; %Find if other user can visit the same node together for u = 1: Group_Size if u == user continue; end if find([Accessible_Nodes{u,1}] == node) Users_Sharing_Same_Node = [Users_Sharing_Same_Node,u]; end end %------------------------------------------------------------------------------------------------------------------------------------- %------------------------------------------------------------------------------------------------------------------------------------- %------------------------------------------------------------------------------------------------------------------------------------- %------------------------------------------------------------------------------------------------------------------------------------- %Loop to find all possiablity of conbine different group %member for depth = length(Users_Sharing_Same_Node) : -1:1 List_of_Combined_Users = nchoosek(Users_Sharing_Same_Node,depth); for combined = 1: length(List_of_Combined_Users(:,1)) % Add the Node Probability.Node{index,user} = node; % Add the users with the same node ( here only the main % user Probability.Users{index,user} = [user,List_of_Combined_Users(combined,:)]; Social_Relationship_Value = 0; %To find Social Value between the group of member for i = 1: length(Probability.Users{index,user}) Social_Relationship_Value = Social_Relationship_Value + Social_Relationship(user,Probability.Users{index,user}(1,i)); end % Add the percentage Probability.Percentage{index,user} = power(Eta(Last_Node_in_Routes(user),node,user), Alpha) * power(Tau(Last_Node_in_Routes(user),node,user), Beta) * power(Social_Relationship_Value,Gamma); Probability_Sum(user,1) = Probability_Sum(user,1) + Probability.Percentage{index,user}; %Add to the index 1 index = index + 1; end end end end end end