Note that there are some explanatory texts on larger screens.

plurals
  1. POoptimization in R across multiple 'areas'
    primarykey
    data
    text
    <p>I am building a bioeconomic model of a fishery with multiple areas and fleets. I need to add a cost function to the objective function. The cost function derivative is: </p> <pre><code>dvcost&lt;-(maxeff/(maxeff-(total f))*k*(f/total f)-ln(1-((total f)/maxeff))*k*maxeff/(total f)*(1-(f/total f)) </code></pre> <p>where: for each fleet, f is effort in a specific area where the objective function is being minimized, total f is the sum of effort across areas for a particular fleet. k and maxeff are parameters.</p> <p>My question is: how do I apply this cost function to my problem? I already have total f (which is 'f' in the code), but I need to find the f for the area that the objective function is working over.</p> <p>Any suggestions are much appreciated. Thanks!</p> <p>The full code is below: <strong><em>CODE</em></strong></p> <pre><code>nfleets&lt;-2 nareas&lt;-2 M&lt;-1 M&lt;-array(M,dim=c(nfleets,nareas)) N&lt;-1000 cost&lt;-c(30,30) cost&lt;-array(cost,dim=c(nfleets,nareas)) Price&lt;-2 Price&lt;-array(Price,dim=c(nfleets,nareas)) q&lt;-array(0.1,dim=c(nfleets,nareas)) f&lt;-1 f&lt;-array(f,dim=c(nfleets,nareas)) init.eff&lt;-array(3,dim=c(nfleets,nareas)) OF&lt;-array(c(q*f), dim=c(nfleets, nareas)) Catch&lt;-array(0,dim=c(nfleets, nareas)) obj&lt;-function(f){ f &lt;- array(f, dim=c(nfleets, nareas)) F &lt;- q*f Z &lt;- M+sum(F) S &lt;- exp(-Z) Catch&lt;- N*F/Z*(1-S) Tot.Catch &lt;- sum(Catch) NR&lt;-array(0,dim=c(nfleets,nareas)) NR&lt;-Price*Catch - f*cost d.NR&lt;-array(0,dim=c(nfleets,nareas)) f &lt;- apply(f, 1, sum) d.NR&lt;- N*q/Z*(1-S-F/Z+F/Z*S+F*S)*Price - cost return(sum(d.NR*d.NR)) } zero.bnd &lt;- rep.int(0, length(f)) opt.eff &lt;- optim( init.eff, obj, method="Nelder-Mead" ) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload