# 组合拍卖-matlab



function
[allocation,utility,Percentage,Userper] = Demo

%Definition of Cloud pool

c=[3000,20000,10000];%ci instance the amount of resource

t=length(c); %the
cloud pool has t types of source

r=[2,3.75,410;8,15,1680;5,1.7,350;20,7,1680;6.5,17.1,420;35,60.5,2048];

[Sc,m]=size(VM);

allocation=zeros(1,Sc);%the allocation where 1 means the bid have been
allocated;Sc

[bc,maxbid]=size(B);

%initialize the dual

y=zeros(1,bc);%bc

z=1./c;

U=zeros(1,bc);

utility=0;%the
whole price of the bids which have been allocated

R=GetR(VM,r);

A=GetA(c,R);

%iteration

while
(GetSumcz(c,z)<t*exp(A-1))&&(~all(U(:)))

S=GetmaxS(B,U,Price);%Si means the
maximum price bid of i's bids

u=Getmaxi(U,S,Price,r,VM,z);%select the
best bid Su with the maximum unit resource

allocation(S(u))=1;

y(u)=Price(S(u));

U(u)=1;

utility=utility+Price(S(u));

for k=1:t

z(k)=z(k)*exp(A-1)^(GetSumnr(VM,S,u,r,k)/(c(k)-R(k)));

end

end

%compute the percentage of CPU

Percentage =(allocation*VM*r)./c;

%compute the percentage of user

Userper = sum(U,2)/bc;




function A =GetA(c,R)

temp=c./R;

A=min(temp);




function u =Getmaxi(U,S,Price,r,VM,z)

temp=zeros(1,length(U));

total=VM*r*z';

for
i=1:length(U)

if U(i)==0

temp(i)=Price(S(i))/total(i);

end

end

[maxu,rows]=max(temp);

u=rows;




function S =GetmaxS(B,U,Price)

[a,b]=size(B);

p=zeros(1,b);

S=zeros(1,a);

for
i=1:length(U)

if U(i)==0

for j=1:b

temp=B(i,j);

p(j)=Price(temp);

end

[my_max,rows]=max(p);

S(i)=B(i,rows);

end

end




function R =GetR(VM,r)

[a,b]=size(r);

temp=VM*r;

[R,I]=max(temp);

function sumcz =GetSumcz(c,z)

sumcz=c*z';

end

function nrk =GetSumnr(VM,S,u,r,k)

nr=VM(S(u),:)*r;

nrk=nr(k);



©️2019 CSDN 皮肤主题: 数字20 设计师: CSDN官方博客