Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The problem I face involves three constrained optimization problems (which i will call B,R and F) which interact. The optimization problem F is solved "after" (in terms of the model behind the optimization) the other two.

F consist of four equalities (first order conditions), one inequality ("<=" in which equality is possibly fulfilled), five parameters and non-negativity restrictions on four of the parameters. Running Reduce does not provide results in reasonable time (some hours), therefore I use

solr2[Qb_,Qr_,T_]:=solr2[Qb,Qr,T]=
 FindInstance[{
  eqn1[p,r,Qf,Zf,T]<=0 && eqn1[p,r,Qf,Zf,T] Qf == 0,
  eqn2[p,r,Qf,Zf,T]<=0 && eqn2[p,r,Qf,Zf,T] Zf == 0,
  eqn3[p,r,Qb,Zb,T]<=0 && eqn3[p,r,Qb,Zb,T] Zb == 0,
  Zb+Zf<=Qr && (Zb + Zf - Qr) r == 0,
  p == 1 - Qb - Qr - Qf,
  0 <= r,
  0 <= Zf,
  0 <= Zb,
  0 <= Qf
 }, {Qf, Zf, Zb, r, p}]

where T is an exogenous parameter and Qb, Qr are the values which will be determined by the optimization problems B and R. Calculation of this solution is reasonably fast (about 0.02 seconds).

Optimization problems B and R are solved simultaneously by using

solr1[T_] :=
 FindRoot[{
   focb[Qb, Kr, T, Zb, r, p] == 0,
   focr[Qb, Kr, T, r, p] == 0
 }, {{Qb, 0.5, 0, 0.8}, {Kr, 0.1, 0, 0.5}}]

where again T is an exogenous parameter and focr, focb are first order conditions and Zb, r, p are determined by F. The link between Kr in solr1 and Qr in solr2 is the following: focb and focr more or less (I simplified since the details circumstancial) look like

focb[Qb_, Kr_, T_, Zb_, r_, p_]= 
 Integrate[p/.solr2[Qb, Qr, T] Qb - r/.solr2[Qb, Qr, T] Zb/.solr2[Qb, Qr, T], {Qr, 0, Kr}]/Kr
focr[Qb_, Kr_, T_, r_, p_]= 
 D[Integrate[(p/.solr2[Qb, Qr, T] + r/.solr2[Qb, Qr, T])Qr, {Qr, 0, Kr}]/Kr, Kr]

I simplified the above since I believe the details of the functions are unimportant. Of course I can provide the detailed functions if this helps.

Problems:

  1. Calculation of solr1 for a value of T takes between 30 and 100 seconds. Since I want to plot results for a whole interval of T (in this case [0,1]), calculations take several (5-8) hours.
  2. Apparently FindRoot does find different roots dependent on the starting values I provide, implying there are several solutions.

Questions:

  1. Is there a better way to connect/nest the optimization problems?
  2. Is there a way to speed up my code? (I believe calculations are slow because of the "nestedness" and the integration necessary for focb and focr. Maybe there is a way to speed up the integration?)
  3. Is there a consistent way to get "all" solutions from FindRoot? The solutions I found involve knowledge about the derivatives which I don't have, since I rely on the solutions from F.

This is my first longer post here, if I should clarify/change the way I post my question, please let me know. Any help is appreciated, thanks in advance!

share|improve this question
1  
Is not it possible to use 'NIntegrate'? –  PlatoManiac Mar 14 '13 at 18:35
    
@PlatoManiac: Using NIntegrate did not improve my results in terms of speed. I believe since the solution of F is numerical, the integration in focb and focr is automatically done numerically. At least for certain parameter ranges the smaller error messages ("NIntegrate failed to converge...") when using Integrate indicate this. –  Mitch D Mar 15 '13 at 10:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.