Changeset 135
- Timestamp:
- 04/04/09 09:35:06 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/mystic/differential_evolution.py
r124 r135 164 164 iteration. It is called as callback(xk), where xk is 165 165 the current parameter vector. [default = None] 166 disp -- non-zero to print convergence messages. 166 167 167 168 """ … … 172 173 ScalingFactor=0.7 #multiplier for mutation impact 173 174 callback=None #user-supplied function, called after each step 175 disp=0 #non-zero to print convergence messages 174 176 if kwds.has_key('strategy'): strategy = kwds['strategy'] 175 177 if kwds.has_key('CrossProbability'): \ … … 177 179 if kwds.has_key('ScalingFactor'): ScalingFactor = kwds['ScalingFactor'] 178 180 if kwds.has_key('callback'): callback = kwds['callback'] 181 if kwds.has_key('disp'): disp = kwds['disp'] 179 182 #------------------------------------------------------------- 180 183 … … 233 236 234 237 signal.signal(signal.SIGINT,signal.default_int_handler) 238 239 # code below here pushes output to scipy.optimize.fmin interface 240 fval = self.bestEnergy 241 warnflag = 0 242 243 if fcalls[0] >= self._maxfun: 244 warnflag = 1 245 if disp: 246 print "Warning: Maximum number of function evaluations has "\ 247 "been exceeded." 248 elif generation >= self._maxiter: 249 warnflag = 2 250 if disp: 251 print "Warning: Maximum number of iterations has been exceeded" 252 else: 253 if disp: 254 print "Optimization terminated successfully." 255 print " Current function value: %f" % fval 256 print " Iterations: %d" % generation 257 print " Function evaluations: %d" % fcalls[0] 235 258 236 259 return … … 282 305 iteration. It is called as callback(xk), where xk is 283 306 the current parameter vector. [default = None] 307 disp -- non-zero to print convergence messages. 284 308 285 309 """ … … 290 314 ScalingFactor=0.7 #multiplier for mutation impact 291 315 callback=None #user-supplied function, called after each step 316 disp=0 #non-zero to print convergence messages 292 317 if kwds.has_key('strategy'): strategy = kwds['strategy'] 293 318 if kwds.has_key('CrossProbability'): \ … … 295 320 if kwds.has_key('ScalingFactor'): ScalingFactor = kwds['ScalingFactor'] 296 321 if kwds.has_key('callback'): callback = kwds['callback'] 322 if kwds.has_key('disp'): disp = kwds['disp'] 297 323 #------------------------------------------------------------- 298 324 … … 355 381 356 382 signal.signal(signal.SIGINT,signal.default_int_handler) 383 384 # code below here pushes output to scipy.optimize.fmin interface 385 fval = self.bestEnergy 386 warnflag = 0 387 388 if fcalls[0] >= self._maxfun: 389 warnflag = 1 390 if disp: 391 print "Warning: Maximum number of function evaluations has "\ 392 "been exceeded." 393 elif generation >= self._maxiter: 394 warnflag = 2 395 if disp: 396 print "Warning: Maximum number of iterations has been exceeded" 397 else: 398 if disp: 399 print "Optimization terminated successfully." 400 print " Current function value: %f" % fval 401 print " Iterations: %d" % generation 402 print " Function evaluations: %d" % fcalls[0] 357 403 358 404 return
Note: See TracChangeset
for help on using the changeset viewer.