// Pierre L. Douillet // www.douillet.info // version 18 // module decis ident='WAITS.18'; if MSDOS .. then cd("c:/MapleV6/Users/Douillet/waits") ; else cd("~/docs/Ensait/waits/scilab") ; end//if baserep=pwd(); printf('\n'); printf('\n---------------------------------%s\n\n',baserep) global arv srv qui // functions global repertoire ident marv varv msrv vsrv maxqui robin global nxtarv ageNda charge nbsej numcli N nb_bat nb_eve bouche_trou global tdurees // liste... global serveur sejours attentes autres resids services // client global maxlon durees // vecteur //caveat : les fichiers dat_* sont binary, les fichiers res_* sont non-binary couleurs=tlist(['couleur','fast','size','tour','rand','qqqq','qran','qsiz','best'],.. 14, 2, 1, 23, 4, 3, 32, 5); couleurs=tlist(['couleur','fast','rand','tour','qqqq','size','qran','qsiz','best'],.. 14, 23, 1, 4, 2, 3, 32, 5); //********************************************************* //* menus //********************************************************* function aide printf("\n") printf("repertoire == nom d''un bloc de simulations\n\n") printf("maxqui == nombres de serveurs\n") printf("marv varv msrv vsrv == moyenne, variance arrivées et services\n\n") printf("arv srv qui == lois arrivées, services, attribution\n\n") printf("nxtarv == date de la prochaine arrivée\n") printf("ageNda == [[durée_restante; numéro_serveur], ... ]\n\n") printf("charge nbsej == charges et effectifs par serveur (1..maxqui)\n") printf("numcli N == numéro client et Nombre total d''événements\n\n") printf("tdurees, durees == vus par le serveur. Liste puis table \n") printf("serveur sejours attentes autres resids services\n") printf(" == vus par le client (fichiers)\n") endfunction function menu cd(baserep) while %t do les_choix=['aide', 'petit essai', 'uniforme, moy constantes', 'système M/M/1', 'système M/Ga/1', .. 'système M/Ga/3', 'système M/Ga/5', 'système Ga/Ga/3', 'système Ga/Ga/5', 'système M/Ga/58', .. 'bank story', 'cumulA', 'cumulS', 'cumulO', 'print_all', 'new_line', 'fermer tout']; n=x_choose(les_choix, [ident+':'; sprintf('choisir un item (1:%d)', size(les_choix,'*'))]) select n case 0 then disp('cancelled'); return; case 1 then aide(); case 2 then petitessai(); case 3 then menu_unif(); case 4 then menu_MM(); case 5 then menu_MGa1(); case 6 then menu_MGa3(); case 7 then menu_MGa5(); case 8 then menu_GaGa3(); case 9 then menu_GaGa5(); case 10 then menu_MGa58(); case 11 then given(); case 12 then sig=x_mdialog('cumulA',['durees+autres'],['B5s']); if sig ~= [] then cumulA(sig(1)); end; case 13 then sig=x_mdialog('cumulS',['sejours'] ,['B5s']); if sig ~= [] then cumulS(sig(1)); end; case 14 then sig=x_mdialog('cumulO',['occups'] ,['B5s']); if sig ~= [] then cumulO(sig(1)); end; case 15 then print_all(); case 16 then printf('%s\n',' -'); case 17 then for j=9:-1:0 do xdel(j); end//for return end//select end//while endfunction function petitessai global repertoire N maxqui qui arv srv N=10; repertoire="case-one"; maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur memo=grand('getsd') grand('setsd',12345) deff('s=arv',sprintf('s=grand(1, ''uin'', %f, %f)',12, 18)) deff('s=srv',sprintf('s=grand(1, ''uin'', %f, %f)',15, 25)) mprintf("======= arv in 15..25, srv in 12..18 ==\n\n"); raz_files(N) for i=1:N do mprintf("nxtarv=%2d charge=%2d %2d %2d %2d %2d %2d\n", nxtarv,charge,[ageNda(1,:),zeros(1,5)]) mprintf("numcli=%2d nbsej=%2d %2d %2d %2d %2d %2d\n", numcli,nbsej, [ageNda(2,:),zeros(1,5)]) mprintf("\n") evol_queue(); end//for clean_files(); grand('setsd',memo) endfunction function menu_unif global repertoire N maxqui qui marv varv msrv vsrv arv srv maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur N=5000 marv=20; msrv=15; n=x_choose(['sdA=02, sdS=01', 'sdA=04, sdS=02', 'sdA=10, sdS=05', 'sdA=15, sdS=10', 'sdA=19, sdS=14'],[sprintf('Uniforme mA=%d, mS=%d',marv,msrv); 'choisir un item']) select n case 0 then return case 1 then repertoire="unif01" ; sdA=02; sdS=01 case 2 then repertoire="unif02" ; sdA=04; sdS=02 case 3 then repertoire="unif05" ; sdA=10; sdS=05 case 4 then repertoire="unif10" ; sdA=15; sdS=10 case 5 then repertoire="unif14" ; sdA=19; sdS=14 end//select deff('s=arv',sprintf('s=grand(1, ''unf'', %f, %f)',marv-sdA, marv+sdA)) deff('s=srv',sprintf('s=grand(1, ''unf'', %f, %f)',msrv-sdS, msrv+sdS)) printf("\narv: [%2d-%2d], srv: [%2d-%2d] ",marv-sdA,marv+sdA, msrv-sdS,msrv+sdS) grand('setsd',12345') doser(); disp(drawq(nb=20)); endfunction function menu_MM global repertoire N maxqui qui marv varv msrv vsrv arv srv maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur repertoire="1s-exp" aa=2.42; bb=1/77.17; msrv=aa/bb; marv=66.71*3 //revue article sig=x_mdialog('File d''attente M/M/1',['marv','msrv','N'],[string(marv), string(msrv),'50000']); if sig==[] then return ; end//if marv=eval(sig(1)); msrv=eval(sig(2)); N=eval(sig(3)); vsrv=msrv^2; varv=marv^2; deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) deff('s=srv', sprintf("s=grand(1,''exp'',%12.10f)",msrv)) doser(); disp(drawq(nb=30)); drawexp(); endfunction function menu_MGa1 global repertoire N maxqui qui marv varv msrv vsrv arv srv memo=grand('getsd') maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur // repertoire="1s-gam" ; aa=2.42; cc=1/77.17; msrv=aa/cc; marv=66.71*3 //revue article repertoire="1s-gam3" ; aa=2.42; cc=1/77.17*3; msrv=aa/cc; marv=66.71 //revue article sig=x_mdialog('File d''attente M/Ga/1',['marv','msrv','a','N', 'seed'],[string(marv), string(msrv),string(aa),'50000','12345']); if sig==[] then return ; end//if marv=eval(sig(1)); msrv=eval(sig(2)); aa=eval(sig(3)); N=eval(sig(4)); seed= eval(sig(5)); varv=marv^2; cc=aa/msrv; vsrv=aa/cc^2; deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,cc)) grand('setsd', seed) doser(); disp(drawq(nb=30)); drawgam(); grand('setsd',memo) endfunction function menu_MGa3 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv bouche_trou bouche_trou=%f maxqui=3 marv=66.71; varv=marv^2 deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) aa=2.42; bb=1/77.17; msrv=aa/bb; vsrv=aa/bb/bb; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) sig=x_mdialog('Policy : 1=rand, 2=tour, 3=size, 4=best, 5=fast, 6=qsiz',['Policy','nb_eve', 'nb_bat'],['6', '50000','400']); if sig==[] then return ; end//if policy=eval(sig(1)); nb_eve=eval(sig(2)); nb_bat=eval(sig(3)); select policy case 1 then ident='A3s-rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident='A3s-tour'; deff('myphi=qui', ['global(''robin'')'; 'robin=1+pmodulo(robin, maxqui)'; 'myphi= robin']) case 3 then ident='A3s-size'; deff('myphi=qui', '[toto,myphi] = min(nbsej)') case 4 then ident='A3s-best'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='A3s-fast'; deff('myphi=qui', 'myphi=1'); bb=maxqui*bb; msrv=aa/bb; vsrv=aa/bb/bb; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) case 6 then ident='A3s-qsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t end//select all_in_one(); cumulA_one(ident) endfunction//menu_MGa3 function menu_MGa5 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv bouche_trou=%f maxqui=5 marv=66.71*3/maxqui; varv=marv^2 deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) aa=2.42; bb=1/77.17; msrv=aa/bb; vsrv=aa/bb/bb; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) sig=x_mdialog('Policy : 1=rand, 2=tour, 3=size, 4=best, 5=fast, 6=qsiz, 7=qqqq',['Policy','nb_eve', 'nb_bat'],['1', '5000','4']); if sig==[] then return ; end//if policy=eval(sig(1)); nb_eve=eval(sig(2)); nb_bat=eval(sig(3)); select policy case 1 then ident='A5s-rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident='A5s-tour'; deff('myphi=qui', ['global(''robin'')'; 'robin=1+pmodulo(robin, maxqui)'; 'myphi= robin']) case 3 then ident='A5s-size'; deff('myphi=qui', '[toto,myphi] = min(nbsej)') case 4 then ident='A5s-best'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='A5s-fast'; deff('myphi=qui', 'myphi=1'); bb=maxqui*bb; msrv=aa/bb; vsrv=aa/bb/bb; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) case 6 then ident='A5s-qsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 7 then ident='A5s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=%t end//select all_in_one(); cumulA_one(ident) endfunction//menu_MGa5 function menu_MGa58 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv maxqui=5 aa=2.42; bb=1/77.17; msrv=aa/bb; vsrv=aa/bb/bb; marv=msrv/0.8/maxqui; varv=marv^2 deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) sig=x_mdialog('C5s (rho=0.8) : 1=rand, 2=tour, 3=size, 4=best, 5=fast, 6=qsiz, 7=qqqq',['Policy','nb_eve', 'nb_bat'],['1', '50000','400']); if sig==[] then return ; end//if policy=eval(sig(1)); nb_eve=eval(sig(2)); nb_bat=eval(sig(3)); select policy case 1 then ident='C5s-rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident='C5s-tour'; deff('myphi=qui', ['global(''robin'')'; 'robin=1+pmodulo(robin, maxqui)'; 'myphi= robin']) case 3 then ident='C5s-size'; deff('myphi=qui', '[toto,myphi] = min(nbsej)') case 4 then ident='C5s-best'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='C5s-fast'; deff('myphi=qui', 'myphi=1'); bb=maxqui*bb; msrv=aa/bb; vsrv=aa/bb/bb; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) end//select all_in_one(); cumulA_one(ident) endfunction//menu_MGa5 function menu_GaGa3 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv maxqui=3 AA=0.8; marv=66.71; BB=AA/marv; varv=AA/BB/BB deff('s=arv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",AA,BB)) aa=2.42; bb=1/77.17; msrv=aa/bb; vsrv=aa/bb/bb; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) sig=x_mdialog('Policy : 1=rand, 2=tour, 3=size, 4=best, 5=fast, 6=qsiz, 7=qqqq',['Policy','nb_eve', 'nb_bat'],['1', '50000','400']); if sig==[] then return ; end//if policy=eval(sig(1)); nb_eve=eval(sig(2)); nb_bat=eval(sig(3)); select policy case 1 then ident='B3s-rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident='B3s-tour'; deff('myphi=qui', ['global(''robin'')'; 'robin=1+pmodulo(robin, maxqui)'; 'myphi= robin']) case 3 then ident='B3s-size'; deff('myphi=qui', '[toto,myphi] = min(nbsej)') case 4 then ident='B3s-best'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='B3s-fast'; deff('myphi=qui', 'myphi=1'); bb=maxqui*bb; msrv=aa/bb; vsrv=aa/bb/bb; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) case 6 then ident='B3s-qsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 7 then ident='B3s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=%t end//select all_in_one(); cumulA_one(ident) endfunction//menu_MGa3 function menu_GaGa5 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv maxqui=5 AA=0.8; marv=66.71*3/maxqui; BB=AA/marv; varv=AA/BB/BB deff('s=arv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",AA,BB)) aa=2.42; bb=1/77.17; msrv=aa/bb; vsrv=aa/bb/bb; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) sig=x_mdialog('Policy : 1=rand, 2=tour, 3=size, 4=best, 5=fast, 6=qsiz, 7=qqqq, 8=qran',['Policy','nb_eve', 'nb_bat'],['1', '50000','400']); if sig==[] then return ; end//if policy=eval(sig(1)); nb_eve=eval(sig(2)); nb_bat=eval(sig(3)); select policy case 1 then ident='B5s-rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident='B5s-tour'; deff('myphi=qui', ['global(''robin'')'; 'robin=1+pmodulo(robin, maxqui)'; 'myphi= robin']) case 3 then ident='B5s-size'; deff('myphi=qui', '[toto,myphi] = min(nbsej)') case 4 then ident='B5s-best'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='B5s-fast'; deff('myphi=qui', 'myphi=1'); bb=maxqui*bb; msrv=aa/bb; vsrv=aa/bb/bb; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) case 6 then ident='B5s-qsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 7 then ident='B5s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=% case 8 then ident='B5s-qran'; bouche_trou=%t deff('myphi=qui', [" tmp = find(nbsej==0)"; sprintf("if tmp == [] then myphi = grand(1, ''uin'', 1, %d)", maxqui); " else myphi = grand(1, ''uin'', 1, size(tmp, ''*'')); myphi = tmp(myphi)"; "end"]); end//select all_in_one(); cumulA_one(ident); cumulS_one(ident); cumulO_one(ident); endfunction//menu_MGa3 //********************************************************* //* gestion du système avec attentes //********************************************************* function n=cut2(x) mu=10^(floor(log10(x))-1) n=round(x/mu)*mu endfunction dur=1; typ=2; // les deux lignes de ageNda //ageNda(typ,nn) contient le numéro du serveur concerné function raz_files(N) global nxtarv ageNda charge nbsej numcli robin global tdurees durees sejours attentes services autres resids serveur mclose('all') nxtarv=0; ageNda=[]; charge=zeros(1,maxqui); nbsej=zeros(1,maxqui); numcli=0; robin=1; tdurees=list(); durees=mopen('dat_durees.txt','wb'); sejours=mopen('dat_sejours.txt','wb'); // attentes=mopen('dat_attentes.txt','wb'); services=mopen('dat_services.txt','wb'); autres=mopen('dat_autres.txt','wb'); resids=mopen('dat_resids.txt','wb'); serveur=mopen('dat_serveur.txt','wb'); endfunction function evol_queue global nxtarv ageNda charge nbsej delai=nxtarv ; n=size(ageNda,'c') ; isarv=%T if (n ~=0) & (ageNda(dur,1)0 & ageNda(dur,i)>charge0 do i=i-1; end//while ageNda = [ageNda(:,1:i), [charge0;myphi], ageNda(:,i+1:$)] //on intercalle le nouvel événement client_observe(myphi, srv0, resi0) endfunction function serveur_observe(n, delai) global tdurees try tdurees(n+1)= tdurees(n+1)+delai catch tdurees(n+1)= delai end//try endfunction function client_observe(myphi, srv0, resi0) global numcli numcli=numcli+1 mput(myphi, 'us', serveur); mput(charge(myphi), 'f', sejours); // mput(charge-srv0, 'f', attentes); mput(sum(nbsej)-1, 'i', autres); mput(resi0, 'f', resids); mput(srv0, 'f', services); endfunction function clean_files global maxlon // global durees tdurees numcli repertoire maxlon=size(tdurees); for i=1:maxlon do mput(tdurees(i), 'f', durees) ; end//for mclose('all') mkdir (repertoire) if MSDOS .. then unix ('copy dat*.txt '+repertoire) else unix ('cp dat*.txt '+repertoire) end//if endfunction function doser global N tic(); raz_files(N) for i=1:N do evol_queue() ; end//for // while size(ageNda,'c') ~=0 do i=i+1; evol_queue(); end//while N=i printf("elapsed time = %f - N= %d\n", toc(),N) clean_files(); endfunction //********************************************************* //* dessins //********************************************************* function mv=drawq(nb,rep) //numbars global numcli mv=[] if ~isdef('nb') then nb=40; end//if //num bars if repertoire==[] then repertoire=rep ; repertA=part(rep,1:length(rep)-3) repertB=baserep+"/"+repertA+"/"+repertoire; printf("using : %s\ncd(baserep) to go back\n", repertB) cd(repertB) end//if //utilisation directe rho=msrv/marv/maxqui; many=100000 mv=[sprintf("%10s %12s %12s %11s", 'nom', 'moyenne ', 'écart_type', 'auto_corr.")] [hndl,err]=mopen('dat_durees.txt', 'rb'); if err == 0 then err=err; durees=mget(many, 'f', hndl); mclose(hndl); xx=size(durees,'c') dx=1; if xx>30 then dx=2 ; end//if printf('durées totale=%f, durées à vide=%f\n', sum(durees), durees(1)) xxx=ceil(xx/dx); fdurees=matrix([durees,zeros(1,xxx*dx-xx+dx)],dx,xxx+1) fdurees=sum(fdurees,'r')/sum(fdurees)/dx mv=[mv; sprintf("%10s %12.8f %12.8f", 'durees', meanf([0:xx-1],durees), sqrt(variancef([0:xx-1],durees)))] h=scf(1); clf() h.figure_name="1-Durées des états vues par le serveur" plot2d3(-0.5:dx:xxx*dx-0.5, [fdurees],[2]) plot2d2(-0.5:dx:xxx*dx-0.5, [fdurees],[2]) xtitle(sprintf('%s : rho=%5.3f, N=%d', repertoire, rho, N)) curax=gca() curax.x_ticks=tlist(curax.x_ticks(1), (0:2*dx:xx)', string((0:2*dx:xx)')) curax.sub_ticks=[0 0] curax.title.font_size=4 end//if [hndl,err]=mopen('dat_autres_new.txt', 'rb'); if err==0 then autres=mget(many,'i', hndl); mclose(hndl); xx=size(autres, 'c'); //numcli=size(autres,'c') dx=1; if xx>30 then dx=2 ; end//if xxx=ceil(xx/dx); fautres=matrix([autres,zeros(1,xxx*dx-xx+dx)],dx,xxx+1) //éventuel groupement par deux fautres=sum(fautres,'r')/sum(fautres)/dx mv=[mv; sprintf("%10s %12.8f %12.8f", 'autres', meanf([0:xx-1],autres), sqrt(variancef([0:xx-1],autres)))] h=scf(2); clf() h.figure_name="2-Etat lors de l''arrivée" plot2d3(-0.5:dx:xxx*dx-0.5, [fautres],[2]) plot2d2(-0.5:dx:xxx*dx-0.5, [fautres],[2]) curax=gca() curax.x_ticks=tlist(curax.x_ticks(1), (0:2*dx:xx)', string((0:2*dx:xx)')) curax.sub_ticks=[0 0] end//if [hndl,err]=mopen('dat_occups.txt', 'rb'); if err==0 then occups=mget(many,'i', hndl); mclose(hndl); xx=size(occups, 'c')-1; foccups=[occups/sum(occups),0] mv=[mv; sprintf("%10s %12.8f %12.8f", 'occups', meanf([0:xx],occups), sqrt(variancef([0:xx],occups)))] h=scf(9); clf() h.figure_name="9-Occupation des serveurs" plot2d3(-0.5:xx+0.5, [foccups],[2]) plot2d2(-0.5:xx+0.5, [foccups],[2]) curax=gca() curax.x_ticks=tlist(curax.x_ticks(1), (0:xx)', string((0:xx)')) curax.sub_ticks=[0 0] end//if [hndl,err]=mopen('dat_autres.txt', 'rb'); if err==0 then autres=mget(many,'i', hndl); mclose(hndl); numcli=size(autres,'c') xx=max(autres); dx=1; if xx>30 then dx=2 ; end//if [varcov, moy]=corr(autres,2) if varcov(1)==0 then toto=0; else toto= varcov(2)/varcov(1); end//if mv=[mv; sprintf("%10s %12.8f %12.8f %11.8f", 'autres', moy, sqrt(varcov(1)), toto)] h=scf(2); clf() h.figure_name="2-Etat lors de l''arrivée" histplot(-0.5:dx:xx+0.5, autres, [2]) curax=gca() curax.x_ticks=tlist(curax.x_ticks(1), (0:2*dx:xx)', string((0:2*dx:xx)')) curax.sub_ticks=[0 0] end//if [hndl,err]=mopen('dat_sejours.txt', 'rb'); if err==0 then sejours=mget(many,'f', hndl); mclose(hndl); numcli=size(sejours,'c') dx=round(max(sejours)/nb) if dx==0 then dx=cut2(max(sejours)/nb); end//if lesx=0:dx:nb*dx [varcov, moy]=corr(sejours,2) mv=[mv; sprintf("%10s %12.7f %12.7f %11.8f", 'sejours', moy, sqrt(varcov(1)), varcov(2)/varcov(1))] h=scf(3); clf() h.figure_name="3-Temps de séjour" histplot(lesx, sejours, 2) curax=gca() curax.x_ticks=tlist(curax.x_ticks(1), (0:3*dx:nb*dx)', string((0:3*dx:nb*dx)')) curax.sub_ticks=[0 0] end//if [hndl,err]=mopen('dat_services.txt', 'rb'); if err==0 then services=mget(many,'f', hndl); mclose(hndl); numcli=size(services,'c') mx=max(services); dx=round(mx/nb) if dx==0 then dx=cut2(mx/nb); end//if lesx=0:dx:mx+dx [varcov, moy]=corr(services,2) mv=[mv; sprintf("%10s %12.7f %12.7f %11.8f", 'services', moy, sqrt(varcov(1)), varcov(2)/varcov(1))] h=scf(4); clf() h.figure_name="4-Temps de service" histplot(lesx, services, 2) curax=gca() curax.x_ticks=tlist(curax.x_ticks(1), lesx', string(lesx')) curax.sub_ticks=[0 0] end//if [hndl,err]=mopen('dat_resids.txt', 'rb'); if err==0 then resids=mget(many,'f', hndl); mclose(hndl); numcli=size(resids,'c') resids=resids(find(resids>%eps)); presents=size(resids,'c'); if presents > 3 then mx=max(resids); dx=round(mx/nb) if dx==0 then dx=cut2(mx/nb); end//if lesx=[10^(-10) dx:dx:mx+dx] [varcov, moy]=corr(resids,2) mv=[mv; sprintf("%10s %12.7f %12.7f %11.8f", 'residuels', moy, sqrt(varcov(1)), varcov(2)/varcov(1))] h=scf(5); clf() h.figure_name="5-Services Résiduels : "+string(presents) histplot(lesx, resids, 2) lesx=[0 lesx(2:$)] curax=gca() curax.x_ticks=tlist(curax.x_ticks(1), lesx', string(lesx')) curax.sub_ticks=[0 0] end//if // presents >3 end//if endfunction//drawq function drawexp //1-Durées des états vues par le serveur" //2-Etat lors de l''arrivée" //3-Temps de séjour" //4-Temps de service" //5-Services Résiduels : "+string(presents) rho=msrv/marv; scf(1); curax=gca(); lesx=[0:ceil(curax.data_bounds(2,1))]; lesy=(1-rho)*exp(lesx*log(rho)); plot2d(lesx, lesy,5) scf(2) plot2d(lesx,lesy,5) scf(3) clr=1/msrv-1/marv; lesx=0:(1/clr/4):(5/clr) ; lesy=exp(-lesx*clr)*clr ; plot2d(lesx,lesy,5) scf(4) lesx=0:(msrv/4):(5*msrv) ; lesy=exp(-lesx/msrv)/msrv ; plot2d(lesx,lesy,5) scf(5) plot2d(lesx,lesy,5) endfunction function drawgam //4-Temps de service" //5-Services Résiduels : "+string(presents) lesx=0:msrv/12:msrv*3 ; //bb est la quasi-moyenne, c'est à dire le beta Maple //cc est le b Scilab aa=msrv^2/vsrv; cc=msrv/vsrv; bb=1/cc; scf(4) deff('y=fu(x)', sprintf("y=x^(%12.10f-1)*exp(-x*%12.10f)*%12.10f",aa,cc,cc^aa/gamma(aa))) lesy=feval(lesx, fu) ; plot2d(lesx,lesy,5) scf(5) deff('y=fu(x)', sprintf("y=(1-cdfgam(''PQ'',x,%18.16f,%18.16f))*%18.16f", aa,cc,1/msrv)) lesy=feval(lesx, fu) ; plot2d(lesx,lesy,5) endfunction //********************************************************* //* les données "banque" //********************************************************* function given global maxqui arv srv msrv vsrv marv maxqui=3 scf(6); clf(); xi=[15 45 75 105 135 165 195 225 255 285 315] ; ni=[163 73 68 35 18 18 6 7 4 5 8]; marv=meanf(xi,ni) varv=variancef(xi,ni) deff('a=arv','a=grand(1,''exp'','+string(marv)+')') deff('c=Arv(t)','c=1-exp(-t*'+string(1/marv)+')') lesx=[0:30:300, 360]; xx=size(lesx,'c'); tmp=feval(lesx(1:$-1), Arv); tmp=(tmp(2:$)-tmp(1:$-1))*sum(ni); tmp=[tmp, (sum(ni)-sum(tmp))]; nu=size(ni,'c')-2; chichi=sum( (tmp-ni)^2 ./ tmp); chired=(chichi-nu)/sqrt(2*nu); printf("\nlambda=%8.6f, marv=%10.6f, sarv=%10.6f, chi2= %4.2f, nu= %d, chi2red=%6.4f", 1/marv, marv, sqrt(varv), chichi, nu, chired); totox=[lesx(1);lesx(1)]; totoy=[0;ni(1)]; totoz=[0;tmp(1)]; ni($)=ni($)/2; tmp($)=tmp($)/2; for j=2:xx-1 do totox=[totox; lesx(j)*ones(3,1)] ; totoy=[totoy;ni(j-1);0;ni(j)]; totoz=[totoz;tmp(j-1);0;tmp(j)]; end//for totox=[totox;lesx($);lesx($)]; totoy=[totoy;ni($);0]; totoz=[totoz;tmp($);0]; plot2d(totox,totoy,11) ; plot2d(totox,totoz) curax=gca(); curax.children(2).children.background=4; curax.children(2).children.fill_mode="on"; xtitle(sprintf('observed=filled, modelled=wireframe, chi2red=%4.2f', chired)) curax.title.font_size=4; curax.sub_ticks=[0,0]; scf(7); clf(); xi=[30:60:630] ni=[36 86 101 76 43 24 9 6 8 5 7] msrv=meanf(xi,ni); vsrv=variancef(xi,ni); aa=msrv^2/vsrv; bb= msrv/vsrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,bb)) deff('c=Srv(t)',sprintf('c=cdfgam(''PQ'',t,%18.16f,%18.16f)',aa,bb)) lesx=[0:60:600, 720]; xx=size(lesx,'c'); tmp=feval(lesx(1:$-1), Srv); tmp=(tmp(2:$)-tmp(1:$-1))*sum(ni); tmp=[tmp, (sum(ni)-sum(tmp))]; nu=size(ni,'c')-3; chichi=sum( (tmp-ni)^2 ./ tmp); chired=(chichi-nu)/sqrt(2*nu); printf("\n mu=%8.6f, msrv=%10.6f, ssrv=%10.6f, chi2= %4.2f, nu= %d, chi2red=%6.4f", 1/msrv, msrv, sqrt(aa)/bb, chichi, nu, chired); printf("\n ''mu''=%8.6f, ''ms''=%10.6f, aa=%f, bb=%f", maxqui/msrv,msrv/maxqui,aa,bb); printf("\n rho=%f\n", msrv/maxqui/marv); totox=[lesx(1);lesx(1)]; totoy=[0;ni(1)]; totoz=[0;tmp(1)]; ni($)=ni($)/2; tmp($)=tmp($)/2; for j=2:xx-1 do totox=[totox; lesx(j)*ones(3,1)] ; totoy=[totoy;ni(j-1);0;ni(j)]; totoz=[totoz;tmp(j-1);0;tmp(j)]; end//for totox=[totox;lesx($);lesx($)]; totoy=[totoy;ni($);0]; totoz=[totoz;tmp($);0]; plot2d(totox,totoy,11) ; plot2d(totox,totoz) curax=gca(); curax.children(2).children.background=4; curax.children(2).children.fill_mode="on"; xtitle(sprintf('observed=filled, modelled=wireframe, chi2red=%4.2f', chired)) curax.title.font_size=4; curax.sub_ticks=[0,0]; endfunction //********************************************************* //* les batches de traitement //********************************************************* function batbatexp source='exp-1s' hndl=mopen('res_'+source+'.txt') datas=mgetl(hndl) ; mclose(hndl); printf("\n"); //----------------------- grepkey='services' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); cible=msrv/3 batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) printf("%10s mu=%11.6f, get=%11.6f, z=%9.6f \n", grepkey, cible, moy, (cible-moy)/sdd) batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) printf("%10s sd=%11.6f, get=%11.6f, z=%9.6f \n\n", '', (msrv/3), sqrt(moy), ((msrv/3)^2-moy)/sdd) //----------------------- grepkey='residuels' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); cible=msrv/3 batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) printf("%10s mu=%11.6f, get=%11.6f, z=%9.6f \n", grepkey, cible, moy, (cible-moy)/sdd) batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) printf("%10s sd=%11.6f, get=%11.6f, z=%9.6f \n\n", '',(msrv/3), sqrt(moy), ((msrv/3)^2-moy)/sdd) //----------------------- grepkey='sejours' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); cible=1/(3/msrv-1/marv) batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) printf("%10s mu=%11.6f, get=%11.6f, z=%9.6f \n", grepkey, cible, moy, (cible-moy)/sdd) batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) printf("%10s sd=%11.6f, get=%11.6f, z=%9.6f \n\n", '', (cible), sqrt(moy), ((cible)^2-moy)/sdd) //----------------------- grepkey='autres' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); rho=msrv/3/marv; cible=rho/(1-rho) batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) printf("%10s mu=%11.6f, get=%11.6f, z=%9.6f \n", grepkey, cible, moy, (cible-moy)/sdd) batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) printf("%10s sd=%11.6f, get=%11.6f, z=%9.6f \n\n", '', sqrt(cible/(1-rho)), sqrt(moy), (cible/(1-rho)-moy)/sdd) //----------------------- endfunction function tmp=batbat(source) [hndl,err]=mopen('res_'+source+'.txt') if err~=0 then hndl=mopen(sprintf('%s/res_%s.txt', source, source)); end datas=mgetl(hndl) ; mclose(hndl); tmp=[""]; //----------------------- grepkey='services' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); cible=msrv; cible2=vsrv batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%10s mu=%11.6f, get=%11.6f, z=%9.6f \n", grepkey, cible, moy, (cible-moy)/sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%10s sd=%11.6f, get=%11.6f, z=%9.6f \n\n", '', sqrt(cible2), sqrt(moy), (cible2-moy)/sdd)]; //----------------------- grepkey='residuels' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); cible=(msrv+vsrv/msrv)/2; cible2=(msrv^2+6*vsrv+5*(vsrv/msrv)^2)/12; // b^2*(a+1)*(a+5)/12 batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%10s mu=%11.6f, get=%11.6f, z=%9.6f \n", grepkey, cible, moy, (cible-moy)/sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%10s sd=%11.6f, get=%11.6f, z=%9.6f \n\n", '',sqrt(cible2), sqrt(moy), (cible2-moy)/sdd)]; //----------------------- grepkey='sejours' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%10s [%11.6f, %11.6f] \n", grepkey, moy-sdd, moy+sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%10s [%11.6f, %11.6f] \n\n", '', sqrt(moy-sdd), sqrt(moy+sdd))]; //----------------------- grepkey='autres' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%10s [%11.6f, %11.6f] \n", grepkey, moy-sdd, moy+sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%10s [%11.6f, %11.6f] \n\n", '', sqrt(moy-sdd), sqrt(moy+sdd))]; //----------------------- grepkey='durees' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%10s [%11.6f, %11.6f] \n", grepkey, moy-sdd, moy+sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%10s [%11.6f, %11.6f] \n\n", '', sqrt(moy-sdd), sqrt(moy+sdd))]; //----------------------- grepkey='occups' quoi=grep(datas,grepkey); nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%10s [%11.6f, %11.6f] \n", grepkey, moy-sdd, moy+sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%10s [%11.6f, %11.6f] \n\n", '', sqrt(moy-sdd), sqrt(moy+sdd))]; //----------------------- endfunction function cumulO_one(source) couleur=couleurs(part(source,5:8)) cd(source) lesrep=unix_g(sprintf('ls -d %s*', source)) tous=[] hndl=mopen(sprintf('%s/dat_occups.txt', lesrep($))) ligne=mget(500,'i', hndl); mclose(hndl); nnnx=size(ligne,'c'); maxqui=nnnx-1 for rrr=lesrep' do hndl=mopen(sprintf('%s/dat_occups.txt', rrr)) ligne=mget(500,'i', hndl); mclose(hndl); tous=[tous;[ligne, zeros(1,nnnx-size(ligne,'*'))]] end//for occups=sum(tous,'r'); sumoccups=sum(occups); occups=occups/sumoccups; printf('%s %s\n', source, sprintf("%f ", occups')); h=scf(8); //clf() h.figure_name="8-Occupations cumulées" plot2d2(-0.5:nnnx-0.5, [occups,0], style=[couleur]) plot2d3(-0.5:nnnx-1.5, [occups ], style=[couleur]) curax=gca() xtitle(sprintf('%s N= %d K= %d T= %d',part(source,1:3),sumoccups/size(lesrep,'*'),size(lesrep,'*'), sumoccups)) curax.title.font_size=4; curax.sub_ticks=[0,0]; cd(baserep) endfunction//cumul Autres+Durées function [autre1, autre2]=cumulA_dist(sour1, sour2, how) myfile1=sprintf('%s/%s/cum_%s_autres',baserep, sour1, sour1); myfile2=sprintf('%s/%s/cum_%s_autres',baserep, sour2, sour2); hndl=mopen(myfile1,'rb'); nnnx1=mget(1,'d',hndl); sumautre1=mget(1,'d',hndl); valN=mget(1,'d',hndl); valK=mget(1,'d',hndl); autre1=mget(nnnx1,'d',hndl); mclose(hndl); hndl=mopen(myfile2,'rb'); nnnx2=mget(1,'d',hndl); sumautre2=mget(1,'d',hndl); valN=mget(1,'d',hndl); valK=mget(1,'d',hndl); autre2=mget(nnnx2,'d',hndl); mclose(hndl); auta=autre1(1:how); autb=autre2(1:how); autb=autb*sum(auta)/sum(autb); sum((auta-autb)^2./auta); printf('chi2(%d)= %f', how, ans); endfunction function cumulA_one(source) couleur=couleurs(part(source,5:8)) cd(source) myfile1=sprintf('cum_%s_autres',source); myfile2=sprintf('cum_%s_durees',source); [hndl, errco]=mopen(myfile1,'rb'); if errco==0 then nnnx=mget(1,'d',hndl); sumautres=mget(1,'d',hndl); valN=mget(1,'d',hndl); valK=mget(1,'d',hndl); autres=mget(nnnx,'d',hndl); mclose(hndl); hndl=mopen(myfile2,'rb'); nnnx=mget(1,'d',hndl); sumdurees=mget(1,'f',hndl); valN=mget(1,'d',hndl); valK=mget(1,'d',hndl); durees=mget(nnnx,'f',hndl); mclose(hndl) else lesrep=unix_g(sprintf('ls -d %s*', source)); valK= size(lesrep,'*'); tous=[] hndl=mopen(sprintf('%s/dat_autres_new.txt', lesrep($))) ligne=mget(500,'i', hndl); mclose(hndl); nnnx=size(ligne,'c') for rrr=lesrep' do hndl=mopen(sprintf('%s/dat_autres_new.txt', rrr)) ligne=mget(500,'i', hndl); mclose(hndl); tous=[tous;[ligne, zeros(1,nnnx-size(ligne,'*'))]] end//for autres=sum(tous,'r'); sumautres=sum(autres); valN=sumautres/valK; hndl=mopen(myfile1,'wb'); mput(nnnx,'d',hndl); mput(sumautres,'d',hndl); mput(valN,'d',hndl); mput(valK,'d',hndl); mput(autres,'d',hndl); mclose(hndl) tous=[] for rrr=lesrep' do hndl=mopen(sprintf('%s/dat_durees.txt', rrr)) ligne=mget(500,'f', hndl); mclose(hndl); tous=[tous;[ligne, zeros(1,nnnx-size(ligne,'*'))]] end//for durees=sum(tous,'r'); sumdurees=sum(durees); hndl=mopen(myfile2,'wb'); mput(nnnx,'d',hndl); mput(sumdurees,'f',hndl); mput(valN,'d',hndl); mput(valK,'d',hndl); mput(durees,'f',hndl); mclose(hndl) end//if cumul_autres h=scf(6); //clf() h.figure_name="6-Etats cumulés" nnnx=min(nnnx,70) plot2d(0:nnnx-1, [autres(1:nnnx)/sumautres; durees(1:nnnx)/sumdurees]', style=[couleur;couleur]) curax=gca() xtitle(sprintf('%s N= %d K= %d T= %d',part(source,1:3), valN, valK, sumautres)) curax.title.font_size=4; curax.sub_ticks=[0,0]; gcf(); if size(ans.children, '*') == 1 then legends(couleurs(1)(2:$),[[couleurs(2),couleurs(3),couleurs(4),couleurs(5),couleurs(6),couleurs(7),couleurs(8),couleurs(9)];ones(1,8)], with_box=%f, opt='ur') end//if cd(baserep) endfunction//cumul Autres+Durées function cumulA(lot) for qui=couleurs(1)(2:$) do cumulA_one(lot+'-'+qui); end//for endfunction function cumulS_one(source) couleur=couleurs(part(source,5:8)) cd(source) myfile=sprintf('cum_%s_sejour',source); [hndl, errco]=mopen(myfile,'rb'); if errco==0 then toptop=mget(1,'f',hndl); nnnx=mget(1,'d',hndl); sumtous=mget(1,'d',hndl); valN=mget(1,'d',hndl); valK=mget(1,'d',hndl); tous=mget(nnnx,'d',hndl); else many=100000 lesrep=unix_g(sprintf('ls -d %s*', source)); valK= size(lesrep,'*'); nnnx=700 tous=zeros(1,nnnx) toptop=0 for rrr=lesrep($-9:$)' do hndl=mopen(sprintf('%s/dat_sejours.txt', rrr),'rb') ligne=maxi(mget(many,'f', hndl)); mclose(hndl); toptop=maxi(toptop,ligne) end//for toptop=toptop/nnnx for rrr=lesrep' do hndl=mopen(sprintf('%s/dat_sejours.txt', rrr)) ligne=ceil(mget(many,'f', hndl)/toptop); mclose(hndl); tmp=max(ligne); if tmp>nnnx then tous=[tous,zeros(1, tmp-nnnx)]; nnnx=tmp; end//if for j=ligne do tous(j)=tous(j)+1; end//for end//for sumtous=sum(tous); valN=sumtous/valK; hndl=mopen(myfile,'wb'); mput(toptop,'f',hndl); mput(nnnx,'d',hndl); mput(sumtous,'d',hndl); mput(valN,'d',hndl); mput(valK,'d',hndl); mput(tous,'d',hndl); end//if mclose(hndl) printf("nnnx=%d\n", nnnx); h=scf(7); //clf() h.figure_name="7-Sejours cumulés" nnnx=round(nnnx*0.75) if %f then plot2d([0.5:nnnx-0.5]*toptop, [tous(1:nnnx)/sumtous/toptop]', style=[couleur], leg='sejours') else tmp=tous(1) for j=2:nnnx do tmp=tmp+tous(j); tous(j)=tmp; end//for plot2d([0.5:nnnx-0.5]*toptop, [tous(1:nnnx)/sumtous]', style=[couleur]) end//if curax=gca() xtitle(sprintf('%s N= %d K= %d T= %d',part(source,1:3), valN, valK, sumtous)) curax.title.font_size=4; curax.sub_ticks=[0,0]; curax.data_bounds(2,1)=4000 gcf(); if size(ans.children, '*') == 1 then legends(couleurs(1)(2:$),[[couleurs(2),couleurs(3),couleurs(4),couleurs(5),couleurs(6),couleurs(7),couleurs(8),couleurs(9)];ones(1,8)], with_box=%f, opt='lr') end//if cd(baserep) endfunction function cumulS(lot) for qui=couleurs(1)(2:$) do cumulS_one(lot+'-'+qui); end//for endfunction function cumulO(lot) //fast(1) => killed, gran(7) et qsiz(8) => star for qui=couleurs(1)(2:$) do if qui=='fast' then continue; end//if cumulO_one(lot+'-'+qui); select qui case 'qran' then curax=gca(); curax.children(1).children.line_mode='off'; curax.children(1).children.mark_style=7; curax.children(2).children.line_mode='off'; curax.children(2).children.mark_style=7; case 'qsiz' then curax=gca(); curax.children(1).children.line_mode='off'; curax.children(1).children.mark_style=6; curax.children(2).children.line_mode='off'; curax.children(2).children.mark_style=6; end//select end//for gcf(); if size(ans.children, '*') == 1 then legends(couleurs(1)(3:$),[[couleurs(3),couleurs(4),couleurs(5),couleurs(6),-7,-6,couleurs(9)];ones(1,7)], with_box=%f, opt='ul') end//if endfunction function cumulAA(policy) couleurS=couleurs couleurS(1)=['couleur','A3s','A5s','B3s','B5s'] for qui=couleurS(1)(2:$) do cumulA_one(qui+'-'+policy); curax=gca(); curax.children(1).children.foreground=couleurS(qui); end//for legends(couleurS(1)(2:$),[couleurS(2),couleurS(3),couleurS(4),couleurS(5);1,1,1,1], with_box=%f, opt='ur') curax.title.text; curax.title.text=policy+" "+part(ans,4:length(ans)); endfunction function cumulSS(policy) couleurS=couleurs couleurS(1)=['couleur','A3s','A5s','B3s','B5s','C5s'] for qui=couleurS(1)(2:$) do cumulS_one(qui+'-'+policy); curax=gca(); curax.children(1).children.foreground=couleurS(qui); end//for curax.data_bounds(2,1)=4000 gcf(); if size(ans.children, '*') == 1 then legends(couleurS(1)(2:$),[couleurS(2),couleurS(3),couleurS(4),couleurS(5),couleurS(6);1,1,1,1,1], with_box=%f, opt='lr') end//if curax.title.text; curax.title.text=policy+" "+part(ans,4:length(ans)); endfunction function print_all batch=mopen('res_3s_5s.txt', 'a'); toto=msrv; totu=vsrv; mfprintf(batch,"%s\n",'fast') msrv=toto/3; vsrv=totu/9; mfprintf(batch,"%s\n", batbat('A3s-fast')) msrv=toto/5; vsrv=totu/25;mfprintf(batch,"%s\n", batbat('A5s-fast')) msrv=toto; vsrv=totu; for qui=couleurs(1)(3:$) do mfprintf(batch,"\n\n%s\n",qui) mfprintf(batch,"%s\n", batbat('A3s-'+qui)); mfprintf(batch,"%s\n", batbat('A5s-'+qui)); end//for; mclose(batch) endfunction //********************************************************* //* all_in_one //********************************************************* function all_in_one global tdurees ident nb_bat nb_eve N laps_tot grand('setsd',12345); laps_tot=0 mkdir(ident) if MSDOS then j0=0 else deja=unix_g('ls '+ident); j0=size(deja,'*'); end//if mclose('all') cd (ident) repertA=pwd() batch=mopen('res_'+ident+'.txt', 'a'); N=nb_eve nnnx=4 nxtarv=0; ageNda=[]; charge=zeros(1,maxqui); nbsej=zeros(1,maxqui); numcli=0; robin=1; nnn=size(ageNda,'c') ; for j=j0:j0+nb_bat-1 do tic(); repertoire=sprintf("%s%03d",ident,j); repertB=repertA+"/"+repertoire; printf('%s\n', repertB) mkdir(repertA,repertoire); cd(repertB) tdurees=zeros(1,nnnx+1); tautres=zeros(1,nnnx+1); toccups=zeros(1,maxqui+1); sejours= mopen('dat_sejours.txt', 'wb'); services=mopen('dat_services.txt','wb'); resids= mopen('dat_resids.txt', 'wb'); for iii=1:nb_eve do // begin evol_queue delai=nxtarv ; isarv=%T if (nnn ~=0) & (ageNda(dur,1)0 then ageNda=[ageNda(dur,:)-delai;ageNda(typ,:)]; end//if //sinon: [[]-0;[]] == 0 // recaler les charges en fonction du temps écoulé //// for p=1:maxqui do charge(p)= max(charge(p)-delai,0) ; end//for charge=max(charge-delai,0) /// coutait 44... et maintenant 1.5 if bouche_trou & ~isarv & nbsej(myphi)==0 then toto=find(nbsej>1); if toto ~= [] then yourphi=toto(grand(1,'uin',1,size(toto,'*'))) lesbons=find(ageNda(typ,:)==yourphi); //au moins deux sont trouvés srv0=ageNda(dur,lesbons(2))-ageNda(dur,lesbons(1)); zjj=lesbons(2); while %t do if zjj>1 & ageNda(dur,zjj-1)>srv0 then ageNda(dur,zjj)=ageNda(dur,zjj-1);ageNda(typ,zjj)=ageNda(typ,zjj-1); zjj=zjj-1; else ageNda(dur,zjj)=srv0; ageNda(typ,zjj)=myphi; nbsej(myphi)=1; nbsej(yourphi)=nbsej(yourphi)-1; charge(myphi)=srv0; charge(yourphi)=charge(yourphi)-srv0; break; end//if end//while où mettre le sauteur for zkk=lesbons(3:$) do valeur=ageNda(dur,zkk)-srv0; zjj=zkk; while %t do if ageNda(dur,zjj-1)>valeur then ageNda(dur,zjj)=ageNda(dur,zjj-1);ageNda(typ,zjj)=ageNda(typ,zjj-1); zjj=zjj-1; else ageNda(dur,zjj)=valeur; ageNda(typ,zjj)=yourphi; break; end//if end//while où mettre les décalés end// boucle de décalage end//if bouche position end//if position vide if isarv then arv0= arv() ; srv0= srv() ; myphi=qui(); //on récupère le service résiduel du client en cours sur CE serveur //ci-dessous : essai non efficace : 2.5 pour 2.6 //ageNda(dur, find(ageNda(typ,:)==myphi)); if ans==[] then resi0=0; else resi0=ans(1); end//if resi0=0; for i=1:nnn do if ageNda(typ,i)==myphi then resi0=ageNda(dur,i); break; end; end//for charge0 = charge(myphi) + srv0 ; charge(myphi)=charge0 ; occup0=size(find(nbsej>0),'*')+1; nbsej(myphi)= nbsej(myphi)+1; nxtarv=arv0 // on trouve i entre 0 et nnn et on place le nouveau après "i" /// i=nnn; while i>0 & ageNda(dur,i)>charge0 do i=i-1; end//while i=max(find(ageNda(dur,:)nnnx then nnnx=nnn; tdurees=[tdurees,0]; tautres=[tautres,0]; end//if //nnnx permet d'avoir des tables variables, alors que try/catch plante end//if end//for iii //end evol_queue mclose(sejours); mclose(services); mclose(resids); //mclose(serveur); durees= mopen('dat_durees.txt', 'wb'); for t=tdurees' do mput(t, 'f', durees) ; end//for //ligne .... mclose(durees); autres= mopen('dat_autres_new.txt', 'wb'); for t=tautres' do mput(t, 'i', autres) ; end//for //ligne .... mclose(autres); occups= mopen('dat_occups.txt', 'wb'); for t=toccups' do mput(t, 'i', occups) ; end//for //ligne .... mclose(occups); laps=toc(); laps_tot=laps_tot+laps; printf("elapsed time = %f - N= %d\n", laps, nb_eve) resu=drawq(); // disp(resu); mfprintf(batch,"%s\n", resu); end//do (on nb_bat) mclose(batch) cd (sprintf('%s/%s',baserep,ident)) mprintf("%s\n", batbat(ident)); cd(baserep) printf("total elapsed time = %f - N= %d - K= %d\n", laps_tot, nb_eve, nb_bat) endfunction //all_in_one //********************************************************* //* menu //********************************************************* menu