rm(list=ls(all=TRUE)) library(statmod) #ARA mu=1 lam=0.5 #c1=imperfect_cost/ER_cost #c3=PR_cost//PR_cost Cost=function(n,M,tu,ro,c1,c3){ F=function(x,h) pinvgauss(x, mu*h, lam*h^2) F=Vectorize(F) f=function(x,h) dinvgauss(x, mu*h, lam*h^2) f=Vectorize(f) K=c() V=c() K=1-F(M,(1-ro)*tu) if(n>2){ for(i in 2:(n-1)){ I=F(M,(1-ro)*(i-1)*tu)-integrate(function(y) f(y,(1-ro)*(i-1)*tu)*F((M-y),(1-ro)*tu),0,M)$value K=c(K,I) } } V=c(K,1-sum(K)) Ks=K/sum(K) ET=tu*sum(sapply(1:n,function(j) j*V[j])) EC=c1*sum(c(1:(n-1))*Ks)+sum(K)+c3*V[n] return(EC/ET) } Cost=Vectorize(Cost) Cost(3,2,1,0.2,1,0.5) #(n,M,tu,ro,c1,c2) Cost1=function(n) Cost(n,2,.5,0.1,0.1,0.6) Cost1=Vectorize(Cost1) aa=Cost1(2:15) ns=which.min(aa)+1 ns aa[which.min(aa)]
An Error occurred while handling another error: yii\web\HeadersAlreadySentException: Headers already sent in on line 0. in /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php:366 Stack trace: #0 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders() #1 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send() #2 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/ErrorHandler.php(135): yii\web\ErrorHandler->renderException() #3 [internal function]: yii\base\ErrorHandler->handleException() #4 {main} Previous exception: yii\web\HeadersAlreadySentException: Headers already sent in on line 0. in /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php:366 Stack trace: #0 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders() #1 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Application.php(656): yii\web\Response->send() #2 /var/www/html/prof-homepages/vendor/faravaghi/yii2-filemanager/models/Files.php(696): yii\base\Application->end() #3 /var/www/html/prof-homepages/vendor/faravaghi/yii2-filemanager/controllers/FilesController.php(484): faravaghi\filemanager\models\Files->getFile() #4 [internal function]: faravaghi\filemanager\controllers\FilesController->actionGetFile() #5 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array() #6 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams() #7 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction() #8 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction() #9 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest() #10 /var/www/html/prof-homepages/frontend/web/index.php(18): yii\base\Application->run() #11 {main}