function util = trajectoryUtility(verts, G, env, sig)

% Tj = size(plcs,2);
% [vertags,vertplcs] = covertIdxForm(verts,Tj);
% agentplcs = zeros(length(verts),2);
% % get each vertex position
% for a = 1:length(verts)
%     agentplcs(a,:) = plcs{k,vertplcs(a)}(vertags(a),:);
% end


coords = G.nodes(verts,1:2);
util = 0;

for i=1:length(env.x_area)
    for j=1:length(env.y_area)
        dists = sqrt((coords(:,1) - env.x_area(i)).^2 + (coords(:,2) - env.y_area(j)).^2);
        if any(dists <= sig) % if anybody is close enough to get a measurement
            util = util + env.Z(j, i);
        end
    end
end

% experiment with a horizontal additive element to the objective function
% max_Z = max(max(env.Z));
% min_Z = min(min(env.Z));
% 
% if strcmp(option, 'dists')
%     mean_dist = norm(mean(goals,1) - mean(coords,1));
%     beta = max(env.x_area);
%     h_gain = (1/beta)*abs(beta - mean_dist);
%     alpha = 10;
%     util = util + alpha*h_gain;
% elseif strcmp(option, 'goals')
%     N = size(goals,1);
%     close_dist = zeros(N,1);
%     for i=1:N
%         coords_i = coords(order == i,:);
%         close_dist(i) = norm(coords_i(end,:) - goals(i,:));
%     end
%     
%     beta = max(env.x_area);
%     h_dist = sum(close_dist);
%     normalizer = (1/(1 + N*beta));
%     h_gain = (1/(1 + h_dist))/normalizer;
%     alpha = t/3; % testing a time dependent solution
%     util = util + alpha*h_gain;
%     
% end

end