Revision 1121 trunk/src/nh99/amoeba.cpp
amoeba.cpp (revision 1121)  

70  70 
} 
71  71 
if (nfunk >= NMAX) 
72  72 
{ 
73 
cerr << "NMAX exceeded" << endl;


73 
cerr << "NMAX exceeded" << endl;


74  74 
} 
75  75 
nfunk += 2; 
76  76 
ytry=amxxx(p,y,psum,ndim,ihi,1.0); 
...  ...  
117  117 
dmatrix& p=(dmatrix&) _p; 
118  118 
dvector& y=(dvector&) _y; 
119  119 
dvector& psum=(dvector&) _psum; 
120 
int j;


121 
double fac1,fac2,ytry;


120 
int j;


121 
double fac1,fac2,ytry;


122  122  
123 
dvector ptry(1,ndim);


124 
fac1=(1.0fac)/ndim;


125 
fac2=fac1fac;


126 
for (j=1;j<=ndim;j++) ptry[j]=psum[j]*fac1p[ihi][j]*fac2;


123 
dvector ptry(1,ndim);


124 
fac1=(1.0fac)/ndim;


125 
fac2=fac1fac;


126 
for (j=1;j<=ndim;j++) ptry[j]=psum[j]*fac1p[ihi][j]*fac2;


127  127  
128 
dvariable vf=0.0; 

129 
vf=initial_params::reset(dvar_vector(ptry)); 

130 
*objective_function_value::pobjfun=0.0; 

131 
userfunction(); 

132 
vf+=*objective_function_value::pobjfun; 

133 
ytry=value(vf); 

128  134  
129 
dvariable vf=0.0; 

130 
vf=initial_params::reset(dvar_vector(ptry)); 

131 
*objective_function_value::pobjfun=0.0; 

132 
userfunction(); 

133 
vf+=*objective_function_value::pobjfun; 

134 
ytry=value(vf); 

135  
136 
if (ytry < y[ihi]) { 

137 
y[ihi]=ytry; 

138 
for (j=1;j<=ndim;j++) { 

139 
psum[j] += ptry[j]p[ihi][j]; 

140 
p[ihi][j]=ptry[j]; 

141 
} 

142 
} 

143 
return ytry; 

135 
if (ytry < y[ihi]) { 

136 
y[ihi]=ytry; 

137 
for (j=1;j<=ndim;j++) { 

138 
psum[j] += ptry[j]p[ihi][j]; 

139 
p[ihi][j]=ptry[j]; 

140 
} 

141 
} 

142 
return ytry; 

144  143 
} 
145  144 
#undef NRANSI 
146  145 
Also available in: Unified diff