rm(list = ls()) library(statmod) #ARD 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(j in 2:(n-1)){ I=integrate(function(y) f(y,(j-1)*tu)*(1-F(M/(1-ro)-y,tu)),0,M/(1-ro))$value K=c(K,I) } } V=c(K,1-sum(K)) Ks=K/sum(K) #round(K,5) #round(V,5) ET=tu*sum(sapply(1:n,function(j) j*V[j])) EC=c1*sum(sapply(1:(n-1),function(j) j*Ks[j]))+sum(K)+c3*V[n] return(EC/ET) } Cost=Vectorize(Cost) Cost(3,2,1,0.2,0.1,0.5) #(n,M,tu,ro,mu,lam) Cost1=function(n) Cost(n,2,1,0.5,0.01,0.8) Cost1=Vectorize(Cost1) #optimize(Cost1,c(1,7)) Cost1(2:8)
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}