In[]:=
SolveInnerLoop[S_,Γm_,β_]:=Module[{AggregateProduction,ResultP},​​ ​​ (*ComputeResultP*)​​​​ ResultP=Table[​​{Log[astar[s[[1,n,1]],β,s[[1,n,2]],Γm]]},​​ {n,10}];​​​​ (*ComputeAggregateProduction*)​​ ​​ AggregateProduction=Total[ResultP[[All]]][[1]];​​ ​​Return[AggregateProduction]];​​ ​​​​ objectiveFunction[S_,Γm_,β_]:=-SolveInnerLoop[S,Γm,β];​​​​ ​​ NMinimize[{objectiveFunction[7,Γm,β],0.02<=Γm<=0.06,0.9<=β<=1.06},{Γm,β},Method->"DifferentialEvolution"]​​
Out[]=
{-10.3775,{Γm0.06,β1.06}}