function [ap,Sp] = BR_driver
% BR_driver - demonstrate how fsolve and fmincon compare to ground truth
% On input:
%     N/A
% On output:
%     ap (nx3 vector): atom probabilities
%       column 1: actual
%       column 2: fsolve
%       column 3: fmincon
%     Sp (mx3 vector): sentence probabilities
%       column 1: actual
%       column 2: fsolve
%       column 3: fmincon
% Call:
%     [ap4,Sp4] = BR_driver;
% Author:
%     T. Henderson
%     UU
%     Fall 2017
%

ap = zeros(5,3);

[KB2,cc_probs2] = BR_gen_test_KB(5,10,4);
num_sentences = length(KB2);
Sp = zeros(num_sentences,3);
% Make sure it says 'success'

ap(:,1) = BR_cc_probs2ap(cc_probs2);

BR_KB2F(KB2,'IJ');
% Create an equation function (.m file)

ap(:,2) = fsolve(@IJ,0.5*ones(5,1));

ap(:,3) = fmincon(@IJs,0.5*ones(5,1),[],[],[],[],0,1);

Sp(:,1) = [KB2(:).prob]';
Sp(:,2) = BR_KB_ap2Sp(KB2,ap(:,2)');
Sp(:,3) = BR_KB_ap2Sp(KB2,ap(:,3)');

