function [res,maxes] = CS_EX1_medium(num_trials,sat)
% CS_EX1_medium - Experiment 1 results on medium solvable KBs (50 vars)
%    ~200 clauses; KBs in datasets/Hoos/SAT
% On input:
%     num_trials (int): number of KBs to test
%     sat (Boolean): 1 SAT; 0 UNSAT
% On output:
%     res (num_trials x 1 vector): 1 if soution found; else 0
%     maxes (num_trialsx1 vector): max distance projection
% Call:
%     [res,maxes] = CS_EX1_medium(100);
% Author:
%     T. Henderson
%     UU
%     Fall 2022
%

TOL = 0.01;
if sat==1
    PNAME = 'C:\Users\tch\OneDrive\Documents\MATLAB\PSSAT\datasets\Hoos\SAT';
else
    PNAME = 'C:\Users\tch\OneDrive\Documents\MATLAB\PSSAT\datasets\Hoos\UNSAT';
end
 
n = 50;  % fixed size in KBs
max_dist = sqrt(n-2)/2 + TOL;
pc = 0.5*ones(n,1);
res = zeros(num_trials,1);  % 1 if solution found; else 0
maxes = zeros(num_trials,1);
wb = waitbar(0,'Medium Projections');
for t = 1:num_trials
    waitbar(t/num_trials);
    if sat==1
        KB = CS_SATCNF2KB([PNAME,'/uf50-0',num2str(t),'.cnf']);
    else
        KB = CS_SATCNF2KB([PNAME,'/uuf50-0',num2str(t),'.cnf']);
    end
    [p,proj] = CS_EX1_projections(KB);
    res(t) = max(p)>max_dist;
    maxes(t) = max(p);
end
close(wb);

tch = 0;
