function [Solution,Max_Sum]=PSMerge(File_path)
fid = fopen(File_path, 'r');
N_Bases = fscanf(fid,'%i', 1);
N_Variables = fscanf(fid,'%i', 1);
N_Disjoints = fscanf(fid,'%i', [N_Bases]);
Literal_Matrix= fscanf(fid,'%d', [2*N_Variables,inf]);


Solution_Set = [0];
Max_Sum = 0;
state = zeros(1,N_Variables);

for i = 1:2^N_Variables  % Interpretations
    i_Binary = dec2bin(i-1,N_Variables);
    for j=1:N_Variables
       state(j) = str2num(i_Binary(j));
    end
    Sum = 0;
    for s = 1:N_Bases    % number of sources
	ps_disjoint=zeros(1,N_Disjoints(s));
	for d=sum(N_Disjoints(1:s-1))+1:sum(N_Disjoints(1:s));
		satisfied=0;
		conjuncts=0;
		var_no_appearing=0;
		for j = 1:N_Variables
			if state(j)==0 ,satisfied=satisfied + Literal_Matrix(2*j,d); end
			if state(j)==1, satisfied=satisfied + Literal_Matrix(2*j-1,d); end
			conjuncts=conjuncts+Literal_Matrix(2*j,d)+Literal_Matrix(2*j-1,d);
			if (Literal_Matrix(2*j,d)==0 & Literal_Matrix(2*j-1,d)==0),var_no_appearing=var_no_appearing+1;end
		end
		ps_disjoint(d-sum(N_Disjoints(1:s-1)))=max([satisfied/conjuncts,(var_no_appearing)/(2*N_Variables)]);
	end
	%PS(i,s)= max(ps_disjoint);

    	%Sum(i) = Sum(i) + PS(i,s);
	Sum = Sum + max(ps_disjoint);
    end
    if (strcmp(num2str(Sum), num2str(Max_Sum)))
	Solution_Set(sum(size(Solution_Set)))=i-1;

    elseif (Sum > Max_Sum)
    	Solution_Set = [i-1];
        Max_Sum=Sum;

    end
end
L=length(Solution_Set);
for i=1:L
Solution(i,:)=dec2bin(Solution_Set(i),N_Variables);
end
return