// Pierre L. Douillet // www.douillet.info // version 26 // module waits pastaflag=%f; // change cumulA_one et cumulA ident='WAITS.26'; if MSDOS .. then cd("c:/gs/dossier") ; else cd("~/docs/Cherche/queuing/scilab/"); end//if deff("dire=lsd(rep)", "dire=gsort(ls(rep));"); baserep=pwd(); myfig=baserep+"/figures/"; printf('\n'); printf('\n--waits26.sce-------------------------------%s\n\n',baserep) global arv srv qui arvo // functions global maxqui0 marv1 varv1 msrv1 vsrv1 // pour un serveur global repertoire ident marv varv msrv vsrv maxqui robin lezar global nxtarv ageNda charge nbsej numcli N nb_bat nb_eve bouche_trou global tdurees // liste... global serveur sojourns attentes autres resids services // client global maxlon durees // vecteur global drawflag //caveat : les fichiers dat_* sont binary, les fichiers res_* sont non-binary couleurs=tlist(['couleur','rand','robn','size','load','fast','qqqq','jsiz','jran','rtwo'],.. 23, 1, 2, 5, 14, 4, 32, 3, 17); drawflag=%t; marv1 = 3*66.71 ; varv1 = marv1^2/0.8 ; msrv1 = 2.42*77.17 ; vsrv1 = 2.42*77.17^2 ; //********************************************************* //* menus //********************************************************* function aide printf("\n") printf("repertoire == nom d''un bloc de simulations\n\n") printf("maxqui == nombre de serveurs\n") printf("marv varv msrv vsrv == moyenne, variance arrivees et services\n\n") printf("arv srv qui == lois arrivees, services, attribution\n") printf("policies == message decrivant les politiques d''attribution\n\n") printf("nxtarv == date de la prochaine arrivee\n") printf("ageNda == [[duree_restante; numero_serveur], ... ]\n\n") printf("charge nbsej == charges et effectifs par serveur (1..maxqui)\n") printf("numcli N == numero client et Nombre total d''evenements\n\n") printf("tdurees, durees == vus par le serveur. Liste puis table \n") printf("serveur sojourns attentes autres resids services\n") printf(" == vus par le client (fichiers)\n") endfunction function policies printf("rand : choix random de la file\n") printf("robn : tourniquet\n") printf("size : file de plus courte taille\n") printf("load : file de plus courte charge\n") printf("fast : un seul serveur rapide\n") printf("bouche_trou : si %%t alors migration lorsqu''un depart cree une file vide\n") printf("qqqq : choix random et migration lors d''un depart \n") printf("jsiz : choix plus courte taille et migration lors d''un depart \n") printf("jran : choix vide ou random et migration lors d''un depart\n") printf(" : \n") endfunction function menu cd(baserep) while %t do drawflag=%t les_choix=['aide', 'petit essai', 'uniforme, moy constantes', .. 'bank story', 'systeme M/M/1', .. 'systeme M/Ga/1', 'systeme M/Ga/3', 'systeme M/Ga/5', 'systeme M/Ga/58', .. 'systeme Ga/Ga/1', 'systeme Ga/Ga/3', 'systeme Ga/Ga/5', 'systeme Ga/Ga/7',.. 'ASO_groupe', 'ASO_type', .. '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 given(); case 5 then drawflag=%f; menu_MM1(); case 6 then drawflag=%f; menu_MGa1(); case 7 then drawflag=%f; menu_MGa3(); case 8 then drawflag=%f; menu_MGa5(); case 9 then drawflag=%f; menu_MGa58(); case 10 then drawflag=%f; menu_GaGa1(); case 11 then drawflag=%f; menu_GaGa3(); case 12 then drawflag=%f; menu_GaGa5(); case 13 then drawflag=%f; menu_GaGa7(); case 14 then sig=x_mdialog('groupe',['A3s A5s B3s B5s C5s'],['A3s']); if sig ~= [] then cumulA(sig(1)); cumulS(sig(1)); cumulO(sig(1)); end; case 15 then sig=x_mdialog(' type', couleurs(1)(2:$),['rand']); /// s ??? if sig ~= [] then cumulAA(sig(1)); cumulSS(sig(1)); cumulOO(sig(1)); end; case 16 then print_all(); case 17 then printf('%s\n',' -'); case 18 then xdel(winsid()); return end//select end//while endfunction //---------------------------------------------- // allocation policies //---------------------------------------------- function qui=deff_qui_jran global nbsej maxqui 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"]); endfunction function qui=deff_qui_rtwo global nbsej maxqui deff('myphi=qui', [ sprintf(" myphi = grand(1, ''uin'', 1, %d)", maxqui); sprintf(" myphi2 = grand(1, ''uin'', 1, %d)", maxqui - 1); " if myphi2 >= myphi then myphi2 = myphi2 + 1; end"; " if nbsej(myphi2) < nbsej(myphi) then myphi = myphi2; end" ]); endfunction //---------------------------------------------- // a small run to draw chronograms //---------------------------------------------- function petitessai (initseed) global repertoire N maxqui qui arv srv if ~isdef('initseed') then initseed=12345; end//if N=11; repertoire="case-one"; maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur memo=grand('getsd') grand('setsd',initseed) [aa,bb,cc,dd]=(12,18,15,25); deff('s=arv',sprintf('s=grand(1, ''uin'', %f, %f)',aa, bb)) //arv deff('s=srv',sprintf('s=grand(1, ''uin'', %f, %f)',cc, dd)) //srv mprintf("======= arv in %d..%d, srv in %d..%d ==\n",aa,bb,cc,dd); mprintf("======= starting with seed =%d\n\n", initseed); raz_files() for i=1:N do nbcli=size(ageNda,'c'); mprintf("nxtarv=%2d charge=%2d %2d %2d %2d %2d %2d\n", nxtarv,charge,[ageNda(1,:),zeros(1,5-nbcli)]) mprintf("numcli=%2d nbsej=%2d %2d %2d %2d %2d %2d\n", numcli,nbsej, [ageNda(2,:),zeros(1,5-nbcli)]) 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 memo=grand('getsd') 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)); grand('setsd',memo) endfunction function menu_MM1 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv bouche_trou memo=grand('getsd'); ident='M1s-fast' bouche_trou=%f maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur marv=marv1; varv=marv^2; deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) msrv=msrv1; vsrv=msrv^2; deff('s=srv', sprintf("s=grand(1,''exp'',%12.10f)",msrv)) sig=x_mdialog('M/M/1',['nb_eve', 'nb_bat', 'seed'],['50000','400','12345']); if sig==[] then return ; end//if policy="" ; nb_eve=eval(sig(1)); nb_bat=eval(sig(2)); seed=eval(sig(3)); grand('setsd', seed) all_in_one(); cumulA_one(ident) grand('setsd',memo) endfunction//menu_MM1 function menu_MGa1 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv bouche_trou ident='A1s-fast' bouche_trou=%f maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur marv=marv1/maxqui; varv=marv^2 deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) msrv=msrv1; vsrv=vsrv1; aa=msrv^2/vsrv; cc=vsrv/msrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) sig=x_mdialog('M/Ga/1',['nb_eve', 'nb_bat'],['50000','400']); if sig==[] then return ; end//if nb_eve=eval(sig(1)); nb_bat=eval(sig(2)); all_in_one(); cumulA_one(ident) endfunction//menu_MGa1 function menu_MGa1_old global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv bouche_trou memo=grand('getsd') ident='A1s' maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur marv=marv1; varv= marv^2; //deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) aa=msrv0^2/vsrv0; cc=vsrv0/msrv0; msrv=aa*cc; //revue article sig=x_mdialog('File d''attente M/Ga/1',['marv','msrv','a','nb_eve', '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)); nb_eve=eval(sig(4)); nb_bat=1; bouche_trou=%f; varv=marv^2; cc=msrv/aa; 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,1/cc)) grand('setsd', seed) all_in_one(); drawgam(); // un seul batch, mais dans un sous-repertoire, comme une série 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=marv1/maxqui; varv=marv^2 deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) msrv=msrv1; vsrv=vsrv1; aa=msrv^2/vsrv; cc=vsrv/msrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) sig=x_mdialog('A3s. Policy : 1=rand, 2=robn, 3=size, 4=load, 5=fast, 6=qqqq, 7=jsiz, 8=jran',['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='A3s-rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident='A3s-robn'; 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-load'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='A3s-fast'; deff('myphi=qui', 'myphi=1'); cc=cc/maxqui; msrv=aa*cc; vsrv=aa*cc^2; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) case 6 then ident='A3s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=%t case 7 then ident='A3s-jsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 8 then ident='A3s-jran'; qui=deff_qui_jran(); bouche_trou=%t else return 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=marv1/maxqui; varv=marv^2 deff('a=arv', sprintf("a=grand(1,''exp'',%12.10f)",marv)) msrv=msrv1; vsrv=vsrv1; aa=msrv^2/vsrv; cc=vsrv/msrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) sig=x_mdialog('A5s. Policy : 1=rand, 2=robn, 3=size, 4=load, 5=fast, 6=qqqq, 7=jsiz, 8=jran, 9=rtwo, 10=sjnp',['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='A5s-rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident='A5s-robn'; 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-load'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='A5s-fast'; deff('myphi=qui', 'myphi=1'); cc=cc/maxqui; msrv=aa*cc; vsrv=aa*cc^2; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) case 6 then ident='A5s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=%t case 7 then ident='A5s-jsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 8 then ident='A5s-jran'; qui=deff_qui_jran(); bouche_trou=%t case 9 then ident='A5s-rtwo'; qui=deff_qui_rtwo(); case 10 then ident='A5s-sjnp'; else return end//select select ident case 'A5s-sjnp' then all_sjnp(); else all_in_one(); end//select 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 bouche_trou=%f aa=msrv0^2/vsrv0; cc=vsrv0/msrv0; msrv=aa*cc; vsrv=aa*cc^2; 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,1/cc)) sig=x_mdialog('C5s rho=0.8 : 1=rand, 2=robn, 3=size, 4=load, 5=fast, 6=qqqq, 7=jsiz',['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-robn'; 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-load'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='C5s-fast'; deff('myphi=qui', 'myphi=1'); cc=cc/maxqui; msrv=aa*cc; vsrv=aa*cc^2; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) case 6 then ident='C5s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=%t else return end//select all_in_one(); cumulA_one(ident) endfunction//menu_MGa5 function menu_GaGa1 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv bouche_trou ident='B1s-fast' bouche_trou=%f maxqui=1 ; deff('myphi=qui', 'myphi=1'); //un seul serveur AA=0.8; marv=marv1/maxqui; CC=marv/AA; varv=AA*CC^2; deff('s=arv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",AA,1/CC)) msrv=msrv1; vsrv=vsrv1; aa=msrv^2/vsrv; cc=vsrv/msrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) sig=x_mdialog('Ga/Ga/1',['nb_eve', 'nb_bat'],['50000','400']); if sig==[] then return ; end//if nb_eve=eval(sig(1)); nb_bat=eval(sig(2)); all_in_one(); cumulA_one(ident) endfunction//menu_GaGa1 function menu_GaGa3 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv maxqui=3 bouche_trou=%f AA=0.8; marv=marv1/maxqui; CC=marv/AA; varv=AA*CC^2; deff('s=arv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",AA,1/CC)) msrv=msrv1; vsrv=vsrv1; aa=msrv^2/vsrv; cc=vsrv/msrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) sig=x_mdialog('B3s. Policy : 1=rand, 2=robn, 3=size, 4=load, 5=fast, 6=qqqq, 7=jsiz, 8=jran, 9=rtwo',['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-robn'; 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-load'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='B3s-fast'; deff('myphi=qui', 'myphi=1'); cc=cc/maxqui; msrv=aa*cc; vsrv=aa*cc^2; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) case 6 then ident='B3s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=%t case 7 then ident='B3s-jsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 8 then ident='B3s-jran'; qui=deff_qui_jran(); bouche_trou=%t case 9 then ident='B3s-rtwo'; qui=deff_qui_rtwo(); else return end//select all_in_one(); cumulA_one(ident) endfunction//menu_GaGa3 function menu_GaGa5 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv maxqui=5 bouche_trou=%f AA=0.8; marv=marv1/maxqui; CC=marv/AA; varv=AA*CC^2; deff('s=arv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",AA,1/CC)) msrv=msrv1; vsrv=vsrv1; aa=msrv^2/vsrv; cc=vsrv/msrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) sig=x_mdialog('B5s. Policy : 1=rand, 2=robn, 3=size, 4=load, 5=fast, 6=qqqq, 7=jsiz, 8=jran, 9=rtwo',['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-robn'; 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-load'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='B5s-fast'; deff('myphi=qui', 'myphi=1'); cc=cc/maxqui; msrv=aa*cc; vsrv=aa*cc^2; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) case 6 then ident='B5s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=%t case 7 then ident='B5s-jsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 8 then ident='B5s-jran'; qui=deff_qui_jran(); bouche_trou=%t case 9 then ident='B5s-rtwo'; qui=deff_qui_rtwo(); else return end//select select ident case 'B5s-sjnp' then all_sjnp(); else all_in_one(); end//select cumulA_one(ident); cumulS_one(ident); cumulO_one(ident); endfunction//menu_GaGa5 function menu_GaGa7_old /// B7s global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv maxqui=7 bouche_trou=%f AA=0.8; marv=marv1/maxqui; CC=marv/AA; varv=AA*CC^2; deff('s=arv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",AA,1/CC)) msrv=msrv1; vsrv=vsrv1; aa=msrv^2/vsrv; cc=vsrv/msrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) nb_eve=50000; nb_bat=400; for policy=7:9 do select policy case 1 then ident='B7s-rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident='B7s-robn'; deff('myphi=qui', ['global(''robin'')'; 'robin=1+pmodulo(robin, maxqui)'; 'myphi= robin']) case 3 then ident='B7s-size'; deff('myphi=qui', '[toto,myphi] = min(nbsej)') case 4 then ident='B7s-load'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident='B7s-fast'; deff('myphi=qui', 'myphi=1'); cc=cc/maxqui; msrv=aa*cc; vsrv=aa*cc^2; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) //case 6 then ident='B7s-qqqq'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)); bouche_trou=%t case 7 then ident='B7s-jsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 8 then ident='B7s-jran'; qui=deff_qui_jran(); bouche_trou=%t case 9 then ident='B7s-rtwo'; qui=deff_qui_rtwo(); bouche_trou=%f else continue end//select all_in_one(); cumulA_one(ident); cumulS_one(ident); cumulO_one(ident); end//for endfunction//menu_GaGa7 function a=arv_old global lezar a=min(lezar) lezar=lezar-a lezar(min(find(lezar==0)))=arvo() endfunction function menu_GaGa7 global repertoire ident nb_bat nb_eve N maxqui qui marv varv msrv vsrv arv srv arvo lezar maxqui=3; ident0='B'+string(maxqui)+'t-'; bouche_trou=%f AA=marv1^2/varv1; CC=varv1/marv1; deff('s=arvo', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",AA,1/CC)) lezar=[]; for j=1:maxqui do lezar=[lezar,arvo()]; end//do deff('a=arv()', ['global(''lezar'')'; 'a = min(lezar)'; 'lezar = lezar - a'; 'lezar(min(find(lezar == 0))) = arvo()']) msrv=msrv1; vsrv=vsrv1; aa=msrv^2/vsrv; cc=vsrv/msrv; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) nb_eve=50000; nb_bat=400; for policy=1:8 do select policy case 1 then ident=ident0+'rand'; deff('myphi=qui', sprintf('myphi= grand(1, ''uin'',1,%d)', maxqui)) case 2 then ident=ident0+'robn'; deff('myphi=qui', ['global(''robin'')'; 'robin=1+pmodulo(robin, maxqui)'; 'myphi= robin']) case 3 then ident=ident0+'size'; deff('myphi=qui', '[toto,myphi] = min(nbsej)') case 4 then ident=ident0+'load'; deff('myphi=qui', '[toto,myphi] = min(charge)') case 5 then ident=ident0+'jsiz'; deff('myphi=qui', '[toto,myphi] = min(nbsej)'); bouche_trou=%t case 6 then ident=ident0+'jran'; qui=deff_qui_jran(); bouche_trou=%t case 7 then ident=ident0+'rtwo'; qui=deff_qui_rtwo(); bouche_trou=%f case 8 then ident=ident0+'fast'; deff('myphi=qui', 'myphi=1'); cc=cc/maxqui; msrv=aa*cc; vsrv=aa*cc^2; maxqui=1; deff('s=srv', sprintf("s=grand(1,''gam'',%12.10f,%12.10f)",aa,1/cc)) else continue end//select all_in_one(); cumulA_one(ident); cumulS_one(ident); cumulO_one(ident); end//for endfunction//menu_GaGa7 //********************************************************* //* gestion du systeme avec attentes -- only for unif... //********************************************************* 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 numero du serveur concerne function raz_files() global nxtarv ageNda charge nbsej numcli robin global tdurees durees sojourns attentes services autres resids serveur toto=[durees, sojourns,attentes,services,autres,resids,serveur]; tmp=dsearch(toto, file(), 'd'); toto=find(tmp>0); for j=toto do mclose(j); end//for nxtarv=0; ageNda=[]; charge=zeros(1,maxqui); nbsej=zeros(1,maxqui); numcli=0; robin=1; tdurees=list(); durees=mopen('dat_durees.txt','wb'); sojourns=mopen('dat_sojourns.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 evenement 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', sojourns); // 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 for j=[durees, sojourns,attentes,services,autres,resids,serveur] do mclose(j); end//for 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() 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) //nb= numbars // syntax : drawq(rep="..") 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 ', 'ecart_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('duree totale=%f, duree à  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 %%nan", 'durees', meanf([0:xx-1],durees), sqrt(variancef([0:xx-1],durees)))] if drawflag then h=scf(1); clf() h.figure_name="1-Durees des etats 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 drawflag 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) //eventuel 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)))] if drawflag then h=scf(2); clf() h.figure_name="2-Etat lors de l''arrivee" 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 drawflag 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)))] if drawflag then 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 drawflag 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)] if drawflag then h=scf(2); clf() h.figure_name="2-Etat lors de l''arrivee" 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 drawflag end//if [hndl,err]=mopen('dat_sojourns.txt', 'rb'); if err==0 then sojourns=mget(many,'f', hndl); mclose(hndl); numcli=size(sojourns,'c') dx=round(max(sojourns)/nb) if dx==0 then dx=cut2(max(sojourns)/nb); end//if lesx=0:dx:nb*dx [varcov, moy]=corr(sojourns,2) mv=[mv; sprintf("%10s %12.7f %12.7f %11.8f", 'sojourns', moy, sqrt(varcov(1)), varcov(2)/varcov(1))] if drawflag then h=scf(3); clf() h.figure_name="3-Temps de sejour" histplot(lesx, sojourns, 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 drawflag 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))] if drawflag then 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 drawflag end//if [hndl,err]=mopen('dat_arrivals.txt', 'rb'); if err==0 then arrivals=mget(many,'f', hndl); mclose(hndl); numcli=size(arrivals,'c') mx=max(arrivals); dx=round(mx/nb) if dx==0 then dx=cut2(mx/nb); end//if lesx=0:dx:mx+dx [varcov, moy]=corr(arrivals,2) mv=[mv; sprintf("%10s %12.7f %12.7f %11.8f", 'arrivals', moy, sqrt(varcov(1)), varcov(2)/varcov(1))] if drawflag then h=scf(10); h.figure_name="10-Inter-arrivées" histplot(lesx, arrivals, 2) curax=gca() curax.x_ticks=tlist(curax.x_ticks(1), lesx', string(lesx')) curax.sub_ticks=[0 0] end//if drawflag 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))] if drawflag then h=scf(5); clf() h.figure_name="5-Services Residuels : "+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 drawflag end//if // presents >3 end//if endfunction//drawq function drawexp //1-Durees des etats vues par le serveur" //2-Etat lors de l''arrivee" //3-Temps de sejour" //4-Temps de service" //5-Services Residuels : "+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 Residuels : "+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=fv(x)', sprintf("y=(1-cdfgam(''PQ'',x,%18.16f,%18.16f))*%18.16f", aa,cc,1/msrv)) lesy=feval(lesx, fv) ; plot2d(lesx,lesy,5) endfunction //********************************************************* //* les donnees "banque" //********************************************************* function given global maxqui0 arv srv msrv0 vsrv0 marv0 varv0 maxqui0=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]; marv0=meanf(xi,ni) varv0=variancef(xi,ni) deff('a=arv','a=grand(1,''exp'','+string(marv0)+')') deff('c=Arv(t)','c=1-exp(-t*'+string(1/marv0)+')') 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, marv0=%10.6f, sarv=%10.6f, chi2= %4.2f, nu= %d, chi2red=%6.4f", 1/marv0, marv0, sqrt(varv0), 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] msrv0=meanf(xi,ni); vsrv0=variancef(xi,ni); aa=msrv0^2/vsrv0; bb= msrv0/vsrv0; 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, msrv0=%10.6f, ssrv=%10.6f, chi2= %4.2f, nu= %d, chi2red=%6.4f", 1/msrv0, msrv0, sqrt(aa)/bb, chichi, nu, chired); printf("\n ''mu''=%8.6f, ''ms''=%10.6f, aa=%f, bb=%f", maxqui0/msrv0,msrv0/maxqui0,aa,bb); printf("\n rho=%f\n", msrv0/maxqui0/marv0); 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 tmp=batbat(source) fack=2; if part(source,2:3) == "1s" then source=part(source, 1:4)+"fast" ; end//if [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=[""]; //----------------------- quoi=grep(datas,"moyenne"); if size(quoi,'*')==1 then tmp=datas; return ; end//if //----------------------- 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 : hyp=%11.6f, obs=%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 : hyp=%11.6f, obs=%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 : hyp=%11.6f, obs=%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 : hyp=%11.6f, obs=%11.6f, z=%9.6f \n\n", '',sqrt(cible2), sqrt(moy), -(cible2-moy)/sdd)]; //----------------------- grepkey='sojourns'; quoi=grep(datas,grepkey); grepkey2='sejours'; quoi2=grep(datas,grepkey2); quoi=[quoi, quoi2]; nn=size(quoi,'*'); quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); if source=="M1s-fast" then cible=1/(1/msrv-1/marv); cible2=cible^2; batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%10s mu : hyp=%11.6f, obs=%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 : hyp=%11.6f, obs=%11.6f, z=%9.6f \n\n", '',sqrt(cible2), sqrt(moy), -(cible2-moy)/sdd)]; end//if batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%11s m : %11.6f +/- %9.6f \n", grepkey, moy,fack*sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%11s s : %11.6f +/- %9.6f \n\n", '', sqrt(moy), -sqrt(moy)+sqrt(moy+fack*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("%11s m : %11.6f +/- %9.6f \n", "nbcli_cust", moy, fack*sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%11s s : %11.6f +/- %9.6f \n\n", '', sqrt(moy), -sqrt(moy)+sqrt(moy+fack*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("%11s m : %11.6f +/- %9.6f \n", "nbcli_time", moy, fack*sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%11s s : %11.6f +/- %9.6f \n\n", '', sqrt(moy), -sqrt(moy)+sqrt(moy+fack*sdd))]; //----------------------- grepkey='occups' quoi=grep(datas,grepkey); nn=size(quoi,'*'); if nn>1 then quoi=datas(quoi); quoi=msscanf(-1, quoi, "%s%f%f"); batmea=quoi(:,2); moy=mean(batmea); sdd=sqrt(variance(batmea)/nn) tmp=[tmp;sprintf("%11s m : %11.6f +/- %9.6f \n", grepkey, moy, fack*sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%11s s : %11.6f +/- %9.6f \n\n", '', sqrt(moy), -sqrt(moy)+sqrt(moy+fack*sdd))]; end//if //----------------------- grepkey='arrivals' quoi=grep(datas,grepkey); nn=size(quoi,'*'); if nn>1 then cible=marv; cible2=varv 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 mu : hyp=%11.6f, obs=%11.6f, z=%9.6f \n", grepkey, cible, moy, -(cible-moy)/sdd)]; //tmp=[tmp;sprintf("%11s m : %11.6f +/- %9.6f \n", grepkey, moy, fack*sdd)]; batvar=quoi(:,3)^2; moy=mean(batvar); sdd=sqrt(variance(batvar)/nn) tmp=[tmp;sprintf("%10s sd : hyp=%11.6f, obs=%11.6f, z=%9.6f \n\n", '', sqrt(cible2), sqrt(moy), -(cible2-moy)/sdd)]; //tmp=[tmp;sprintf("%11s s : %11.6f +/- %9.6f \n\n", '', sqrt(moy), -sqrt(moy)+sqrt(moy+fack*sdd))]; end//if //----------------------- endfunction //batbat //********************************************************* //* les graphes A : durees [+ autres si pastaflag] //********************************************************* function thicker_legend() curfig=gcf(); taille=size(curfig.children(1).children.children, '*') for j=2:2:taille do curfig.children(1).children.children(j).thickness=5; end//do endfunction//thicker_legend 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 //cumulA_dist(sour1, sour2, how) function cumulA_one(source) fignum=6; if source=="M1s" then couleur=14 else couleur=couleurs(part(source,5:8)) end//if source 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=lsd(source+"*"); valK= size(lesrep,'*'); tous=[] hndl=mopen(sprintf('%s/dat_autres_new.txt', lesrep(1))) //pour le dernier 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(fignum); //clf() durees=cumsum(durees); autres=cumsum(autres); h.figure_name=string(fignum)+"-Number of customers in the system" nnnx=min(nnnx,70) plot2d(0:nnnx-1, [durees(1:nnnx)/sumdurees]', style=[couleur]) p=get("hdl") //get handle on current entity (here the polyline entity) p.children.thickness=3; if pastaflag then plot2d(0:nnnx-1, [autres(1:nnnx)/sumautres]', style=[couleur]) end//fi 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]; cd(baserep) endfunction//cumul Autres+Durees function cumulA(lot) fignum=6; scf(fignum); clf(); lesqui=['rand' 'robn' 'size' 'load' 'fast' 'qqqq' 'jsiz' 'jran']; recouleurs=couleurs; recouleurs('jsiz')=-6; recouleurs('jran')=-7; lesqui=['fast' 'load' 'size' 'rtwo' 'robn' 'rand']; databoun=30; //lesqui=['load' 'jsiz' 'jran']; databoun=40; lescoul=[]; plot2d([0,databoun],[1,1]); for qui=lesqui do lescoul=[lescoul, recouleurs(qui)] try cumulA_one(lot+'-'+qui); if recouleurs(qui) <0 then curax=gca(); curax.children(1).children.line_mode='off'; curax.children(1).children.mark_style=-recouleurs(qui); if pastaflag then curax.children(2).children.line_mode='off'; curax.children(2).children.mark_style=-recouleurs(qui); end//if pastaflag end//if recouleurs end//try end//for errclear() curfig=gcf(); if ident<>"M1s" then legends(lesqui,[lescoul;ones(lescoul)], with_box=%f, opt='ul', font_size=2) thicker_legend(); end//if curax=gca(); curax.data_bounds(2)=databoun; set_posfig_dim(curfig.figure_size(1),curfig.figure_size(2)) xs2eps(fignum, myfig+"_cumulA"+lot); endfunction //cumulA(lot) function cumulAA(policy) fignum=6; scf(fignum); clf(); recouleurs=couleurs recouleurs(1)=['couleur','A3s' 'B3s' 'A5s' 'B5s' 'C5s']; databoun=40; if policy == "fast" then recouleurs(1)=['couleur', 'C5s' 'A1s' 'A3s' 'A5s' 'B3s' 'B5s' 'M1s'] ; databoun=40; recouleurs('A5s')=-6; recouleurs('B5s')=-7; end//if lescoul=[]; for qui=recouleurs(1)(2:$) do lescoul=[lescoul, recouleurs(qui)] try cumulA_one(qui+'-'+policy); curax=gca(); if recouleurs(qui) <0 then curax.children(1).children.line_mode='off'; curax.children(1).children.mark_style=-recouleurs(qui); else curax.children(1).children.foreground=recouleurs(qui); end//if recouleurs end//try end//for curfig=gcf(); legends(recouleurs(1)(2:$),[lescoul;ones(lescoul)], with_box=%f, opt='lr', font_size=2) thicker_legend(); curax.title.text; curax.title.text=policy+" "+part(ans,4:length(ans)); curax.data_bounds(2)=databoun; set_posfig_dim(curfig.figure_size(1),curfig.figure_size(2)) xs2eps(fignum, myfig+"_cumulAA"+policy); endfunction//cumulAA //********************************************************* //* les graphes S : sojourns //********************************************************* function cumulS_one(source) fignum=7; if source=="M1s" then couleur=14 else couleur=couleurs(part(source,5:8)) end//if source cd(source) myfile1=sprintf('cum_%s_sojourns',source); [hndl, errco]=mopen(myfile1,'rb'); if errco==0 then toptop=mget(1,'f',hndl); nnnx=mget(1,'d',hndl); sumsojourns=mget(1,'d',hndl); valN=mget(1,'d',hndl); valK=mget(1,'d',hndl); sojourns=mget(nnnx,'d',hndl); mclose(hndl) else many=100000 lesrep=lsd(source+"*"); valK= size(lesrep,'*'); nnnx=700; // le nombre de tiroirs pour le tri sojourns=zeros(1,nnnx) toptop=0 for rrr=lesrep(1:9)' do //pour avoir les derniers hndl=mopen(sprintf('%s/dat_sojourns.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_sojourns.txt', rrr)) ligne=ceil(mget(many,'f', hndl)/toptop); mclose(hndl); tmp=max(ligne); if tmp>nnnx then sojourns=[sojourns,zeros(1, tmp-nnnx)]; nnnx=tmp; end//if for j=ligne do sojourns(j)=sojourns(j)+1; end//for end//for sumsojourns=sum(sojourns); valN=sumsojourns/valK; hndl=mopen(myfile1,'wb'); mput(toptop,'f',hndl); mput(nnnx,'d',hndl); mput(sumsojourns,'d',hndl); mput(valN,'d',hndl); mput(valK,'d',hndl); mput(sojourns,'d',hndl); mclose(hndl) end//if cumul_sejour h=scf(fignum); //clf() h.figure_name=string(fignum)+"-Temps de sejour : distributions cumulees" //nnnx=round(nnnx*0.75) if %f then lesy=[sojourns(1:nnnx)/sumsojourns/toptop]' else lesy=[cumsum(sojourns(1:nnnx))/sumsojourns]' end//if cumul or not cumul plot2d([0.5:nnnx-0.5]*toptop, lesy, style=[couleur]) p=get("hdl") //get handle on current entity (here the polyline entity) p.children.thickness=3; curax=gca() xtitle(sprintf('%s N= %d K= %d T= %d',part(source,1:3), valN, valK, sumsojourns)) curax.title.font_size=4; curax.sub_ticks=[0,0]; cd(baserep) endfunction //cumulS_one(source) function cumulS(lot) fignum=7; scf(fignum); clf(); lesqui=['rand' 'robn' 'size' 'load' 'fast' 'qqqq' 'jsiz' 'jran']; recouleurs=couleurs; // ultra-moche recouleurs('jsiz')=-6; recouleurs('jran')=-7; lesqui=['rand' 'robn' 'rtwo' 'size' 'load' 'fast']; databoun=5000; lesqui=['fast' 'load' 'size' 'rtwo' 'robn' 'rand']; databoun=4000; //lesqui=['jsiz' 'jran' 'load']; ; databoun=3000; lescoul=[]; for qui=lesqui do lescoul=[lescoul, recouleurs(qui)] try cumulS_one(lot+'-'+qui); if recouleurs(qui) <0 then curax=gca(); curax.children(1).children.line_mode='off'; curax.children(1).children.mark_style=-recouleurs(qui); end//if recouleurs catch: end//try end//for errclear() curfig=gcf(); if ident<>"M1s" then legends(lesqui,[lescoul;ones(lescoul)], with_box=%f, opt='lr', font_size=2) thicker_legend(); end//if curax=gca(); curax.data_bounds(2)=databoun; set_posfig_dim(curfig.figure_size(1),curfig.figure_size(2)) xs2eps(fignum, myfig+"_cumulS"+lot); endfunction function cumulSS_old(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') thicker_legend(); end//if curax.title.text; curax.title.text=policy+" "+part(ans,4:length(ans)); endfunction function cumulSS(policy) fignum=7; scf(fignum); clf(); recouleurs=couleurs recouleurs(1)=['couleur' 'C5s' 'A5s' 'B5s' 'A3s' 'B3s']; databoun=4000; if policy == "fast" then recouleurs(1)=['couleur', 'C5s' 'A5s' 'B5s' 'A3s' 'B3s' 'A1s' 'M1s'] ; databoun=3500; //recouleurs('A5s')=-6; recouleurs('B5s')=-7; end//if lescoul=[]; for qui=recouleurs(1)(2:$) do lescoul=[lescoul, recouleurs(qui)] try cumulS_one(qui+'-'+policy); curax=gca(); if recouleurs(qui) <0 then curax.children(1).children.line_mode='off'; curax.children(1).children.mark_style=-recouleurs(qui); else curax.children(1).children.foreground=recouleurs(qui); end//if recouleurs end//try end//for curfig=gcf(); legends(recouleurs(1)(2:$),[lescoul;ones(lescoul)], with_box=%f, opt='lr', font_size=2) thicker_legend(); curax.title.text; curax.title.text=policy+" "+part(ans,4:length(ans)); curax.data_bounds(2)=databoun; set_posfig_dim(curfig.figure_size(1),curfig.figure_size(2)) xs2eps(fignum, myfig+"_cumulSS"+policy); endfunction//cumulSS function getmax(lot, cuth) // cuth the NUMBER of rare events if ~isdef('cuth') then cuth=10; end//if for qui=['fast' 'load' 'jsiz' 'size' 'jran' 'rtwo' 'robn' 'rand'] do // for qui=['fast'] do source=lot+'-'+qui ; myfile1=sprintf('%s/cum_%s_sejour',source,source); [hndl, errco]=mopen(myfile1,'rb'); if errco==0 then toptop=mget(1,'f',hndl); nnnx=mget(1,'d',hndl); sumsojourns=mget(1,'d',hndl); valN=mget(1,'d',hndl); valK=mget(1,'d',hndl); sojourns=mget(nnnx,'d',hndl); remoy=(sojourns*[1:nnnx]'/sumsojourns-1)*toptop; qq=cumsum(sojourns($:-1:1)); ouca=max(find(qq<=cuth)); // mprintf("%s %f, %f %f, %d, %d, %d, %d \n", source, (nnnx-1)*toptop, (nnnx-ouca)*toptop, toptop, nnnx, sumsojourns, valN, valK); mprintf("%s %8.2f %8.2f %5.0f %4.1f\n", source, toptop*nnnx, (nnnx-ouca+1)*toptop, remoy , (nnnx-ouca+1)*toptop/remoy); mclose(hndl) end//if end//for endfunction //********************************************************* //* les graphes O : occupancy //********************************************************* function occups=cumulO_one(source) global maxqui couleur=couleurs(part(source,5:8)); cd(baserep+"/"+source) //lesrep=unix_g(sprintf('ls -d %s*', source)) lesrep=lsd(source+"*"); tous=[] hndl=mopen(sprintf('%s/dat_occups.txt', lesrep(1))) //pour avoir le dernier 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; if part(source,5:8)=="fast" then maxqui=eval(part(source,2:2)); nnnx=maxqui+1; occups=[occups(1), zeros(1, maxqui-1), occups($)]; end//if fast mmmm=occups*[0:maxqui]'; printf('%s %s mean=%5.3f, ratio=%5.3f\n', source, sprintf("%7.5f ", occups'), mmmm, mmmm*marv/msrv); h=scf(8); //clf() h.figure_name="8-Number of busy servers" plot2d2(-0.5:nnnx-0.5, [occups,0], style=[couleur]) p=get("hdl") //get handle on current entity (here the polyline entity) p.children.thickness=3; plot2d3(-0.5:nnnx-1.5, [occups ], style=[couleur]) p=get("hdl") //get handle on current entity (here the polyline entity) p.children.thickness=3; 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 cumulO_one(source) function cumulO(lot) fignum=8; scf(fignum); clf(); lesqui=['rand' 'robn' 'size' 'load' 'fast' 'qqqq' 'jsiz' 'jran']; recouleurs=couleurs; recouleurs('jsiz')=-6; recouleurs('jran')=-7; lesqui=['jsiz' 'jran' 'rand' 'robn' 'size' 'load']; lesqui=['fast' 'load' 'size' 'rtwo' 'robn' 'rand']; // lesqui=['fast' 'load' 'jsiz' 'jran']; lescoul=[]; for qui=lesqui do lescoul=[lescoul, recouleurs(qui)] try cumulO_one(lot+'-'+qui); if recouleurs(qui) <0 then curax=gca(); curax.children(1).children.line_mode='off'; curax.children(1).children.polyline_style=2; curax.children(2).children.line_mode='off'; curax.children(2).children.mark_style=-recouleurs(qui); end//if recouleurs catch: printf('%s-%s missing \n', lot,qui); end//try end//for errclear() curfig=gcf(); if ident<>"M1s" then legends(lesqui,[lescoul;ones(lescoul)], with_box=%f, opt='ul',font_size=2) thicker_legend(); end//if curax=gca(); curax.data_bounds(1:2)=[-0.6, maxqui+0.6]; set_posfig_dim(curfig.figure_size(1),curfig.figure_size(2)) xs2eps(fignum, myfig+"_cumulO"+lot); endfunction //cumulO(lot) function cumulOO(policy) fignum=8; scf(fignum); clf(); recouleurs=couleurs recouleurs(1)=['couleur','A3s' 'B3s' 'A5s' 'B5s' 'C5s'] if policy == "fast" then recouleurs(1)=['couleur', 'C5s' 'A1s' 'A3s' 'A5s' 'B3s' 'B5s' 'M1s'] ; recouleurs('A3s')=-6; recouleurs('A5s')=-7; end//if lescoul=[]; for qui=recouleurs(1)(2:$) do lescoul=[lescoul, recouleurs(qui)] try cumulO_one(qui+'-'+policy); curax=gca(); if recouleurs(qui) <0 then curax.children(1).children.line_mode='off'; curax.children(1).children.polyline_style=2; curax.children(2).children.line_mode='off'; curax.children(2).children.mark_style=-recouleurs(qui); else curax.children(1).children.foreground=recouleurs(qui); curax.children(2).children.foreground=recouleurs(qui); end//if recouleurs end//try end//for legends(recouleurs(1)(2:$),[lescoul;ones(lescoul)], with_box=%f, opt='ul', font_size=2) thicker_legend(); curax.title.text; curax.title.text=policy+" "+part(ans,4:length(ans)); endfunction//cumulOO function print_all (lequel) cd (baserep) resu=mopen('resultats.txt', 'w'); lescou=['fast' 'load' 'jsiz' 'size' 'jran' 'rtwo' 'robn' 'rand'] lespol=['B7s' 'B5s' 'B3s' 'B1s' 'B7t' 'B5t' 'B3t' 'B1s' 'D5s'] select lequel case 2 mfprintf(resu," &"); for cou=lescou do mfprintf(resu," %s&",cou); end; mfprintf(resu,"\\\\\n"); for pol=lespol do mfprintf(resu," %s&", pol) for cou=lescou do toto=batbat (pol+"-"+cou); mfprintf(resu, "%s&", part(toto(8),16:23 )) ; end ; //on coupe un chiffre mfprintf(resu,"\\\\\n"); end//for case 1 toto=batbat("B5s-fast"); rat1=eval(part(toto(8),17:17+6)); rat2=eval(part(toto(9),17:17+6)); mfprintf(resu,"\n\n & mean & & ratio &sd& & ratio \\\\\n"); for quoi=lescou do toto=batbat("B5s-"+quoi); mfprintf(resu, "%s & %s & %s & %4.2f & ", quoi, part(toto(8),17:17+6), part(toto(8),33:33+4), eval(part(toto(8),17:17+6))/rat1); mfprintf(resu, "%s & %s & %4.2f \\\\\n", part(toto(9),17:17+6), part(toto(9),33:33+4), eval(part(toto(9),17:17+6))/rat2); end//for end//case mclose(resu) endfunction //********************************************************* //* les graphes V : arrivals //********************************************************* function [obsmea,obsvar,obscov]=cumulV_one(source) fignum=11; if source=="M1s" then couleur=14 else couleur=couleurs(part(source,5:8)) end//if source cd(source) myfile1=sprintf('cum_%s_arrivals',source); [hndl, errco]=mopen(myfile1,'rb'); if errco==0 then toptop=mget(1,'f',hndl); nnnx=mget(1,'d',hndl); sumarrivals=mget(1,'d',hndl); valN=mget(1,'d',hndl); valK=mget(1,'d',hndl); arrivals=mget(nnnx,'d',hndl); obsmea=mget(1,'f',hndl); obsvar=mget(1,'f',hndl); obscov=mget(1,'f',hndl); mclose(hndl) else many=100000 lesrep=lsd(source+"*"); valK= size(lesrep,'*'); nnnx=700; // le nombre de tiroirs pour le tri arrivals=zeros(1,nnnx) toptop=0 for rrr=lesrep(1:9)' do //pour avoir les derniers hndl=mopen(sprintf('%s/dat_arrivals.txt', rrr),'rb') ligne=maxi(mget(many,'f', hndl)); mclose(hndl); toptop=maxi(toptop,ligne) end//for toptop=toptop/nnnx; obsmea=0; obsvar=0; obscov=0; for rrr=lesrep' do hndl=mopen(sprintf('%s/dat_arrivals.txt', rrr)) data=mget(many,'f', hndl); mclose(hndl); obsmea=obsmea+sum(data); obsvar=obsvar+sum(data .^ 2); obscov=obscov+[data(2:$),data(1)]*data'; ligne=ceil(data/toptop); tmp=max(ligne); if tmp>nnnx then arrivals=[arrivals,zeros(1, tmp-nnnx)]; nnnx=tmp; end//if for j=ligne do arrivals(j)=arrivals(j)+1; end//for end//for sumarrivals=sum(arrivals); valN=sumarrivals/valK; obsmea=obsmea/sumarrivals; obsvar=obsvar/sumarrivals - obsmea^2; obscov=obscov/sumarrivals - obsmea^2; hndl=mopen(myfile1,'wb'); mput(toptop,'f',hndl); mput(nnnx,'d',hndl); mput(sumarrivals,'d',hndl); mput(valN,'d',hndl); mput(valK,'d',hndl); mput(arrivals,'d',hndl); mput(obsmea,'f',hndl); mput(obsvar,'f',hndl); mput(obscov,'f',hndl); mclose(hndl) end//if cumul_arrivals h=scf(fignum); //clf() h.figure_name=string(fignum)+"-Inter-arrivées" //nnnx=round(nnnx*0.75) if %t then lesy=[arrivals(1:nnnx)/sumarrivals/toptop]' else lesy=[cumsum(arrivals(1:nnnx))/sumarrivals]' end//if cumul or not cumul plot2d([0.5:nnnx-0.5]*toptop, lesy, style=[couleur]) p=get("hdl") //get handle on current entity (here the polyline entity) p.children.thickness=3; curax=gca() xtitle(sprintf('%s N= %d K= %d T= %d',part(source,1:3), valN, valK, sumarrivals)) curax.title.font_size=4; curax.sub_ticks=[0,0]; cd(baserep) endfunction //cumulS_one(source) //********************************************************* //* all_sjnp //********************************************************* function all_sjnp global 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 //la taille des vecteurs tdurees et tautres nxtarv=0; numcli=0; ageNda=[]; nnn=size(ageNda, 'c'); nns=min(nnn,maxqui) 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); sojourns= mopen('dat_sojourns.txt', 'wb'); services=mopen('dat_services.txt','wb'); resids= mopen('dat_resids.txt', 'wb'); for iii=1:nb_eve do // begin evol_queue if (nnc ~=0) & (encours(1) if nnn>0 then ageNda=[ageNda(1,:)-delai;ageNda(typ,:)]; end//if //sinon: [[]-0;[]] == 0 if ~isarv then nxtarv=nxtarv-delai enregistrer le sejour du partant supprimer le parti ; appeler le prochain à servir recaller les nombres nna et nnc end//if // recaler les charges en fonction du temps ecoule //// 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 isarv then arv0= arv() ; srv0= srv() ; myphi=qui(); //on recupere le service residuel 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 apres "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(sojourns); 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_sjnp //********************************************************* //* all_in_one //********************************************************* function all_in_one // capture of arrivals--- // can be commented out at lines 38 (open), 100 (put), 110 (close) global tdurees ident nb_bat nb_eve N laps_tot // grand('setsd',12345); laps_tot=0 mkdir(ident) if MSDOS | nb_bat==1 then j0=0 else deja=unix_g('ls '+ident); j0=size(deja,'*'); /// pas le bon nombre ///*** to be fixed ///*** end//if mclose('all') cd (ident) hnd=mopen('seed.txt','w'); mfprintf(hnd, "%d\n", grand('getsd')); mclose(hnd); repertA=pwd() if j0==0 then batch=mopen('res_'+ident+'.txt', 'w'); else batch=mopen('res_'+ident+'.txt', 'a'); end//if 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 if j==nb_bat+j0-1 then drawflag=%t ; end//if 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); arrivals= mopen('dat_arrivals.txt', 'wb'); sojourns= mopen('dat_sojourns.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 ecoule //// 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 trouves 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 %t 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 %t mettre les decales end// boucle de decalage end//if bouche position end//if position vide if isarv then arv0= arv() ; srv0= srv() ; myphi=qui(); //on recupere le service residuel 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 apres "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 isarv end//for iii //end evol_queue mclose(sojourns); mclose(arrivals); 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("%s - elapsed time = %f - N= %d\n", repertoire, 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