function [vazao] = AlgoritmoAleatorio(M, K, N, Pm, Pn, gama_m, gama_n, Gnb, Gmb, Gnn, Gmn, sigma2_m, sigma2_n, Wm)

gama_celula = cell(1,M);
vazao = zeros(1,M);




for m=1:M
    
    while 1
        aux1 = randi(N);
        aux2 = randi(K);
        if aux1 >= aux2
            gama_celula(1,m) = {randperm(aux1,aux2)};
            break
        end
    end
    
    soma1 = zeros(1,length(cell2mat(gama_celula(1,m))));
    soma2 = zeros(1,length(cell2mat(gama_celula(1,m))));
    if ~isempty(gama_celula(1,m))
        gama_celula_aux = cell2mat(gama_celula(1,m));
        for n=1:length(cell2mat(gama_celula(1,m)))
            soma1(1,n) = Pn(1,gama_celula_aux(n))*Gnb(1,gama_celula_aux(n));
            soma2(1,n) = Pn(1,gama_celula_aux(n))*Gnn(gama_celula_aux(n),gama_celula_aux(n));
        end
        vazao_n = zeros (1,length(cell2mat(gama_celula(1,m))));
        for n=1:length(cell2mat(gama_celula(1,m)))
            vazao_n(1,n) = Wm(1,m)*log2(1 + (Pn(1,gama_celula_aux(n))*Gnn(gama_celula_aux(n),gama_celula_aux(n)))/(sigma2_n(1,gama_celula_aux(n)) + Pm(1,m)*Gmn(m,gama_celula_aux(n)) + sum(soma2)));
        end
    end
    vazao(1,m) = Wm(1,m)*log2(1 + (Pm(1,m)*Gmb(1,m))/(sigma2_m(1,m) + sum(soma1))) + sum(vazao_n);
end

% vazão em mbits/s
vazao = vazao./10^6;
