Changeset 338 for branches/alta/mystic-0.2a1/test_problems_unconstrained.py
- Timestamp:
- 07/21/10 09:10:59 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alta/mystic-0.2a1/test_problems_unconstrained.py
r323 r338 4 4 """ 5 5 from math import * 6 import numpy 6 7 7 8 def peaks(x_vector): … … 46 47 47 48 #print venkataraman_corner([1., 1.]) 49 50 #--------------------------------------------------------------------- 51 # Below: functions from http://www.geatbx.com/docu/fcnindex-01.html 52 # that are not already in mystic.models. 53 # Another good source of test problems: 54 # http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO.htm 55 56 def rastrigin(x): 57 """Rastrigin's function. Global minimum at xi=0, f(x)=0. Contains 58 many local minima regularly distributed. Can be n-dimensional. 59 xi in [-5.12, 5.12] 60 http://www.geatbx.com/docu/fcnindex-01.html""" 61 x = numpy.asarray(x) 62 return 10.*len(x) + numpy.sum(x**2 - 10*numpy.cos(2.*pi*x)) 63 64 #print 'Rastrigin:', rastrigin([0., 0.]) 65 66 def schwefel(x): 67 """'Schwefel's function [Sch81] is deceptive in that the global minimum is 68 geometrically distant, over the parameter space, from the next best local 69 minima. Therefore, the search algorithms are potentially prone to convergence 70 in the wrong direction.' - http://www.geatbx.com/docu/fcnindex-01.html 71 xi in [-500, 500] 72 global minimum: f(x) = -n*418.9829, xi=420.9687 73 Can be n-dimensional. 74 """ 75 x = numpy.asarray(x) 76 return numpy.sum(-x*numpy.sin(abs(x)**0.5)) 77 78 #print "Schwefel:", schwefel([420.9687, 420.9687, 420.9687]) 79 #print -3.*418.9829 80 81 def ackley(x): 82 """Ackley's Path function. 83 xi in [-32.768., 32.768] 84 global minimum f(x)=0 at xi=0 85 can be n-dimensional. http://www.geatbx.com/docu/fcnindex-01.html""" 86 x = numpy.asarray(x) 87 n = len(x) 88 return -20.*exp(-0.2*sqrt(1./n*numpy.sum(x**2))) - exp(1./n*numpy.sum( 89 numpy.cos(2.*pi*x))) + 20. + exp(1) 90 91 #print "Ackley:", ackley([0., 0.]) 92 93 def easom(x): 94 """'The Easom function [Eas90] is a unimodal test function, where the global 95 minimum has a small area relative to the search space. The function was 96 inverted for minimization.' - http://www.geatbx.com/docu/fcnindex-01.html 97 Global minimum f(x1, x2) = -1 at (x1, x2) = (pi, pi) 98 xi in -100, 100. 2-dimensional.""" 99 x1 = x[0] 100 x2 = x[1] 101 return -cos(x1)*cos(x2)*exp(-(x1-pi)**2 + (x2 - pi)**2) 102 103 #print "Easom:", easom([pi, pi]) 104
Note: See TracChangeset
for help on using the changeset viewer.