parfor ii = 1:Workspace.Number_of_Compartments
Comp(ii).Vehicles = zeros(length(Compartment(ii).Vehicles),2)
for jj = 1:length(Compartment(ii).Vehicles)
Veh_ID = Compartment(ii).Vehicles(jj);
for zz = 1:length(Agent(Veh_ID).Structure.Following_Compartment)
if (Agent(Veh_ID).Structure.Following_Compartment(zz) == ...
Agent(Veh_ID).Structure.Current_Compartment)
Agent(Veh_ID).Structure.Local_Task = [Agent(Veh_ID).Structure.Local_Task,...
Agent(Veh_ID).Structure.Global_Task_Zones(zz)];
else
cur_comp = Agent(Veh_ID).Structure.Current_Compartment;
fol_comp = Agent(Veh_ID).Structure.Following_Compartment(zz);
Find1 = find(Compartment(cur_comp).Following_Compartment == fol_comp);
Find2 = Compartment(cur_comp).Exite_Nodes(Find1,:);
Find2_1 = find(Find2 ~= 0);
Find3 = find(Compartment(cur_comp).Exite_Nodes_State(Find1,:) == 0);
Find4 = intersect(Find2_1,Find3);
Find4 = Find4(randi(length(Find4)));
Agent(Veh_ID).Structure.Local_Task = [Agent(Veh_ID).Structure.Local_Task,...
Find2(Find4)];
end
end
end
0 Comments
Sign in to comment.