Commit 16cea4d0 authored by Larkin Heintzman's avatar Larkin Heintzman

Upload New File

parent 5fe17651
Pipeline #34 canceled with stages
function [plcs_sel, gdyInteractionTimes] = selectSamples(sample_sets_const, plcs)
% select samples given a set of viable samples, a heatmap, and both types
% of bounding sets
load_params; % reload all known parameters
% booleans
gdySolutions = true;
parOpt = false;
env.Z = Z;
env.x_area = x_area;
env.y_area = y_area;
env.gmObj = gmObj;
supergraphs = generateSupergraphs(plcs,rho,false);
if gdySolutions
useBdd = 1; % perform constrained greedy first
[greedy_sol_const, score_const] = generateGreedySolutionFast(plcs, supergraphs, env, N, useBdd,...
sig, environment_size, sample_sets_const, parOpt);
useBdd = 0; % now perform unconstrained greedy
[greedy_sol_unconst, score_unconst] = generateGreedySolutionFast(plcs, supergraphs, env, N, useBdd, ...
sig, environment_size, sample_sets_const, parOpt);
for k=1:Tk
% check both solutions for validity
if length(greedy_sol_const{k}) < N || length(greedy_sol_unconst{k}) < N
error('we failed to effectively select greedy samples, insufficient samples probably');
end
end
end
%---------------------------------------------%
fprintf('--------------------------------\n')
% assume we can get the optimal solution, somehow. Now to compare trade
% offs:
[~, gdyInteractionTimes] = sort(score_unconst - score_const);
gdyInteractionTimes = gdyInteractionTimes(1:K);
% so now return which samples go where
plcs_sel = cell(N,1);
for i=1:N
plcs_sel{i} = zeros(Tk,2);
end
for k=1:Tk
if ismember(k,gdyInteractionTimes)
[agent_idx, traj_idx] = covertIdxForm(greedy_sol_const{k}, Pj);
else
[agent_idx, traj_idx] = covertIdxForm(greedy_sol_unconst{k}, Pj);
end
for i=1:N
plcs_sel{i}(k,:) = plcs{k,traj_idx(i)}(agent_idx(i),:);
end
end
% gdyInteractionTimesNaive = [1 Tk]; % the case of interacting at the begining and at the end
%
% gdyScore = 0;
% gdyScoreNaive = 0;
% for k=1:Tk
% if gdySolutions
% if ismember(k,gdyInteractionTimes)
% gdyScore = gdyScore + score_const(k);
% else
% gdyScore = gdyScore + score_unconst(k);
% end
%
% if ismember(k,gdyInteractionTimesNaive)
% gdyScoreNaive = gdyScoreNaive + score_const(k);
% else
% gdyScoreNaive = gdyScoreNaive + score_unconst(k);
% end
% end
% end
%
% recorder(innerCounter,outterCounter) = gdyScore;
% recorderNaive(innerCounter,outterCounter) = gdyScoreNaive;
%
% plcFin = cell(Tk,1);
% plcFinNaive = cell(Tk,1);
% for k=1:Tk
% if ismember(k,gdyInteractionTimes)
% plcFin{k} = greedy_sol_const{k};
% else
% plcFin{k} = greedy_sol_unconst{k};
% end
%
% if ismember(k,gdyInteractionTimesNaive)
% plcFinNaive{k} = greedy_sol_const{k};
% else
% plcFinNaive{k} = greedy_sol_unconst{k};
% end
% end
% counterM = counterM + 1; % go to next test
% innerCounter = innerCounter + 1;
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment