function Is_Valid = Valid(Ant_k, Routes) global Start_Node; global End_Node; global T_max; global Group_Size Is_Valid = true; for user = 1: Group_Size if length(Routes.Path{Ant_k,1,user}) < 2 Is_Valid = false; return elseif Routes.Path{Ant_k,1,user}(1,1) ~= Start_Node || Routes.Path{Ant_k,1,user}(1,end) ~= End_Node Is_Valid = false; return end Time = 0.0; for index = 1:length(Routes.Path(Ant_k,1,user)) - 1 Time = Time + Distance(Routes.Path{Ant_k,1,user}(1,index), Routes.Path{Ant_k,1,user}(1,index+1)); end if Time > T_max Is_Valid = false; return end end end