%%This is the main program which runs the analysis
%%Clintin Davis-Stober
%%University of Illinois at Urbana-Champaign
function [pvalue,MLE,LR,weightvector] = ConstrainedLRTWOP(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, A)
obspoint = [x1/n1; x2/n2; x3/n3; x4/n4; x5/n5; x6/n6; x7/n7; x8/n8; x9/n9; x10/n10; x11/n11; x12/n12; x13/n13; x14/n14; x15/n15; x16/n16; x17/n17; x18/n18; x19/n19; x20/n20];
[MLE,localA, fval1] = MLEsolverWOP(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, A);
p = MLE';
n = [n1; n2; n3; n4; n5; n6; n7; n8; n9; n10; n11; n12; n13; n14; n15; n16; n17; n18; n19; n20];
A = localA(:,1:20);
A = -1*rref(A);
A1 = zeros(rank(A), 20);
A1 = A1 + A(1:rank(A),:);
A = A1;
rawV = [x1; x2; x3; x4; x5; x6; x7; x8; x9; x10; x11; x12; x13; x14; x15; x16; x17; x18; x19; x20];
mleV = p;
%n1 = 30;
[LR] = LiklihoodRatioWOP(rawV, mleV, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20);
fval1;
[weightvector, W, PCineq] = chibarsquareWOP(p,n1,A);
weightvector = weightvector*.0001;
[pval] = ConstChiBarWOP(weightvector, LR);
pvalue = 1-pval;