SHARE
TWEET

Untitled

a guest Jun 18th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. T = 100; p = 1.; δ = 0.05127; ρ = 1./(1. + δ); c = 50.; R0 = 1.;
  2. obj[qlist_ /; VectorQ[qlist, NumericQ]] :=
  3.  Module[{Rlist, obj},
  4.   Rlist = FoldList[(#1 - #2) &, R0, qlist];
  5.  
  6. If[Min[Rlist] < 0, Return[-1000]]; (* Constraint to keep R>=0 *)
  7.  
  8. (* This is the objective function *)
  9. Sum[ρ^t*(p*qlist[[t + 1]] -
  10.       0.5 c ((qlist[[t + 1]])^2)/Rlist[[t + 1]]), {t, 0, T - 1}]
  11.   ]
  12.  
  13. choicevar = Table[Unique[q], {i, 0, T - 1}];
  14. sol = NMaximize[Prepend[Thread[0 <= choicevar], obj[choicevar]],
  15.    choicevar];
  16. sol[[1]]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top