function [Cost_VEC, Time_VEC, Total_Cost_VEC] = VEC_comp(B_n,D_n, V_n_size, t_max,alpha, beta, t_V2I_stay, R_V2I_final,rsu_capacity,V_n_location, V_i_location, fV_i,Available_resources, RT_VEC)
%Cost_VEC=0
%Time_VEC=0
%t_VEC_exe=0;
%t_VEC_up=0;
P_VEC=10 %The price for VEC computation is 10 Units/s
C_VEC= 1 % The cost of transmission for source to RSU
%RT_VEC=randi([5 10],1,5) % so far just created latter this is a queue which is kept increasing as the no. of vehicles grow. 
RT_VEC_Comp=RT_VEC;
Total_Cost_VEC= zeros(1, V_n_size);
    for(i=1:V_n_size)
        if (t_V2I_stay(i)>=0)
            rsu=abs(ceil(V_n_location(i)/400))
            gamma(i)=D_n(i)-(alpha(i)+beta(i))
            if (gamma(i)>0)
                t_VEC_up(i)=D_n(i)/ R_V2I_final(i)    %Transmission time from source to RSU/VEC server in its range
                %t_VEC_exe(i)=B_n(i)/rsu_capacity(rsu)             %execution time of VEC server 
                t_VEC_exe(i)=B_n(i)/(8*10^8);                  % the upper statement gives error sometimes. so to get rid off we use this.
                Time_VEC(i)= gamma(i)*t_VEC_up(i) + RT_VEC_Comp(rsu)+ gamma(i)*t_VEC_exe(i) 
                Cost_VEC(i)= (C_VEC*gamma(i)*t_VEC_up(i))+ (P_VEC*((RT_VEC_Comp(rsu)+ (gamma(i)* t_VEC_exe(i))))) % Cost of indivisual vehicle at VEC server
                RT_VEC_Comp(rsu)= RT_VEC_Comp(rsu)-1;
                if (RT_VEC_Comp(rsu)==-1)
                    RT_VEC_Comp(rsu)=0;
                end
            else
                Cost_VEC(i)=0;
            end
        end
        
    end
    Total_Cost_VEC= Cost_VEC          %For taking the Total cost of all VEC server for all vehicles 
    for i=2:length(Cost_VEC);
        Total_Cost_VEC(i)=Total_Cost_VEC(i-1)+Cost_VEC(i);
    end
end

