function modelo = CS_flip_max_sat(clause,KB,model)
%

n = max(CS_vars(KB,[]));
m = length(KB);
len_clause = length(clause);
num_sat = zeros(n,1);

for k = 1:len_clause
    literal = clause(k);
    atom = abs(literal);
    model_k = model;
    model_k(atom) = 1 - model(atom);
    count = 0;
    for c = 1:m
        if CS_sat(KB(c).clauses,model_k)
            num_sat(atom) = num_sat(atom) + 1;
        end
    end
end
index = find(num_sat==max(num_sat));
index = index(1);
modelo = model;
modelo(index) = 1 - modelo(index);
