function res = ABMS_SF_driver(roads,num_trials)
%

rng('default');

for k = 1:54
    res(k).stats = [];
    res(k).params = [];
end
count = 0;
for d = [1000]
    for speed = [5,10,15]
        for hd = [5,10,30]
            for flex = [0,5,30]
                count = count + 1;
                [d,speed,hd,flex]
                res(count).params = [d,speed,hd,flex];
                tdata = zeros(num_trials,5);
                for t = 1:num_trials
                    r = LEM_test_SF(roads,[1:399],[1:399],4*d,0,...
                        flex,speed,hd);
                    indexes0 = find(r.P_LBSD(:,2)<0);
                    r.P_LBSD(indexes0,2) = 0;
                    indexes2 = find(r.P_LBSD(:,2)~=Inf);
                    tdata(t,1) = mean(r.P_LBSD(indexes2,2));
                    tdata(t,2) = max(r.P_LBSD(indexes2,2));
                    tdata(t,3) = mean(r.P_LBSD(indexes2,4));
                    tdata(t,4) = max(r.P_LBSD(indexes2,4));
                    tdata(t,5) = sum(r.P_LBSD(:,5));
                    tch = 0;
                end
                res(count).stats = [mean(tdata(:,1)),max(tdata(:,2)),...
                    mean(tdata(:,3)),max(tdata(:,4)),mean(tdata(:,5)),...
                    max(tdata(:,5))];
                tch = 0;
            end
        end
    end
end
