Four functions: var_ete_pacrt , var_ete_dec_pacrt, funcre_pacrt, and mmd_pacrt_int are defined as follows: start var_ete_pacrt(numclust, clustsz, numrepperd, corrwtnperd, corrintperd, corrwtnpart) global(stddev, numperiod); churnrate=numrepperd/clustsz; corrclustperd=(clustsz*corrwtnperd*corrintperd+(1-churnrate)*(1-corrwtnperd)*corrwtnpart)/(1+(clustsz-1)*corrwtnperd); f=4*stddev**2/(numperiod*numclust*clustsz)*(1+(clustsz-1)*corrwtnperd)*(1+(numperiod-1)*corrclustperd); return (f); finish var_ete_pacrt; start var_ete_dec_pacrt(decclustsz) global(corrpar, stddev, numperiod, numrepperd, costperclust, costperpart, costperoutc, budget); corrwtnperd = corrpar[1]; corrintperd = corrpar[2]; corrwtnpart = corrpar[3]; if decclustsz>0 then churnrate = numrepperd/decclustsz; decnumclust=budget/(costperclust+costperpart*(1+(numperiod-1)*churnrate)*decclustsz+costperoutc*numperiod*decclustsz); corrclustperd=(decclustsz*corrwtnperd*corrintperd+(1-corrwtnperd)*corrwtnpart*(1-churnrate))/(1+(decclustsz-1)*corrwtnperd); f=4*stddev**2/(numperiod*decnumclust*decclustsz)*(1+(decclustsz-1)*corrwtnperd)*(1+(numperiod-1)*corrclustperd); *print corrwtnperd corrintperd corrwtnpart corrclustperd decclustsz churnrate decnumclust f; return (f); finish var_ete_dec_pacrt; start funcre_pacrt(x) global(corrpar, numclust, clustsz, minnumclust, maxnumclust, minclustsz, maxclustsz, numperiod, numrepperd, costperclust, costperpart, costperoutc, budget); corrpar=j(3, 1); corrpar[1:3] = x; * copy x -> corrpar; print numclust clustsz; corrwtnperd = x[1]; corrintperd = x[2]; corrwtnpart = x[3]; churncost=costperpart*(numperiod-1)*numrepperd; bound1=(budget/maxnumclust-costperclust-churncost)/(costperpart+costperoutc*numperiod); bound2=(budget/minnumclust-costperclust-churncost)/(costperpart+costperoutc*numperiod); print corrpar, x, bound1 bound2; con=j(3, 3, .); con[1, 1]=max(2, bound1, minclustsz); con[2, 1]=min(bound2, maxclustsz); con[3, 1]=1; con[3, 2]=1; con[3, 3]=1; par=j(10, 1, .); par[9, 1]=4; x0=10; optn=j(1, 10, .); optn[1]=0; call nlpqn(rc, decclustsz, "var_ete_dec_pacrt", x0, optn) blc=con par=par; re=999; decnumclust=budget/(costperclust+(costperpart+costperoutc*numperiod)*decclustsz+churncost); minvar=var_ete_dec_pacrt(decclustsz); temp_var=var_ete_pacrt(decnumclust, decclustsz, numrepperd, corrwtnperd, corrintperd, corrwtnpart); var=var_ete_pacrt(numclust, clustsz, numrepperd, corrwtnperd, corrintperd, corrwtnpart); if var>0 & minvar>=0 then re = minvar/var; return (re); finish funcre_pacrt; start mmd_pacrt_int(corrwtnperdmin, corrwtnperdmax, corrintperdmin, corrintperdmax, corrwtnpartmin, corrwtnpartmax) global(costperclust, costperpart, costperoutc, budget, churncost, numseq_lcrt, numperiod, numrepperd, clustszstart, minnumclust, maxnumclust, minclustsz, maxclustsz); if mod(minnumclust, numseq_lcrt)=0 then numcluststart=minnumclust; else numcluststart=(int(minnumclust/numseq_lcrt)+1)*numseq_lcrt; reminmax=0; do numclust=numcluststart to maxnumclust by numseq_lcrt; clustsz=clustszstart; actcost=numclust*(costperclust+(costperpart+costperoutc*numperiod)*clustsz+churncost); clustsztemp=(budget/numclust-costperclust-churncost)/(costperpart+costperoutc*numperiod); clustszend=min(maxclustsz, int(clustsztemp)); do while (actcost<=budget & clustsz<=clustszend); print numclust clustsz; con=j(2, 3, .); con[1, 1]=corrwtnperdmin; con[2, 1]=corrwtnperdmax; con[1, 2]=corrintperdmin; con[2, 2]=corrintperdmax; con[1, 3]=corrwtnpartmin; con[2, 3]=corrwtnpartmax; par=j(10, 1, .); par[9, 1]=4; x0=j(1, 3, .); x0[1, 1]=(corrwtnperdmin+corrwtnperdmax)/2; x0[1, 2]=(corrintperdmin+corrintperdmax)/2; x0[1, 3]=(corrwtnpartmin+corrwtnpartmax)/2; optn = {0}; call nlpqn(rc, xres, "funcre_pacrt", x0, optn) blc=con par=par; remin=funcre_pacrt(xres); print xres remin reminmax; if remin>reminmax then do; mmdcorrwtnperd=xres[1]; mmdcorrintperd=xres[2]; mmdcorrwtnpart=xres[3]; mmdnumclust=numclust; mmdclustsz=clustsz; mmdre=remin; mmdactcost=actcost; reminmax=remin; *print reflag numclust clustsz actcost remin revar retau reomega reminmax; end; clustsz=clustsz+1; actcost=numclust*(costperclust+(costperpart+costperoutc*numperiod)*clustsz+churncost); end; *enddowhile; end; *end numclust; mmdchurnrate=numrepperd/mmdclustsz; mmd=corrwtnperdmin||corrwtnperdmax||corrintperdmin||corrintperdmax||corrwtnpartmin||corrwtnpartmax||mmdcorrwtnperd||mmdcorrintperd||mmdcorrwtnpart||numseq_lcrt||numperiod||numrepperd||mmdnumclust||mmdclustsz||mmdchurnrate||mmdre||mmdactcost; return (mmd); finish mmd_pacrt_int; the main code: trteff=1; stddev=1; corrwtnperdmin=0.1; corrintperdmin=0.05; corrwtnpartmin=0.2; corrwtnperdmax=0.2; corrintperdmax=0.1; corrwtnpartmax=0.8; costperclust=1000; costperpart=300; costperoutc=40; budget=200000; numrepperd=2; numseq_lcrt=2; numperiod=6; minclustsz=2; maxclustsz=100; minnumclust=2; maxnumclust=100; clustszstart=max(minclustsz, numrepperd); churncost=costperpart*(numperiod-1)*numrepperd; mmdpacrt=j(1, 17); mmdpacrt[1, 1:17]=mmd_pacrt_int(corrwtnperdmin, corrwtnperdmax, corrintperdmin, corrintperdmax, corrwtnpartmin, corrwtnpartmax); Here is log file: ERROR: Matrix numclust has not been set to a value. statement : PRINT at line 2186 column 1 traceback : module FUNCRE_PACRT at line 2186 column 1 module MMD_PACRT_INT at line 2186 column 1 ERROR: Execution error as noted previously. (rc=1000) operation : NLPQN at line 2186 column 1 operands : *LIT1130, x0, optn, con, , par *LIT1130 1 row 1 col (character, size 12) funcre_pacrt x0 1 row 3 cols (numeric) 0.125 0.11 0.35 optn 1 row 1 col (numeric) 0 con 2 rows 3 cols (numeric) 0.05 0.02 0.2 0.2 0.2 0.5 par 10 rows 1 col (numeric) . . . . . . . . 4 . statement : CALL at line 2186 column 1 traceback : module MMD_PACRT_INT at line 2186 column 1 statement : CALL at line 2186 column 1 traceback : module MMD_PACRT_INT at line 2186 column 1 ERROR: Matrix mmdpacrt has not been set to a value. statement : PRINT at line 2186 column 1
... View more