1515from math import sin
1616from math import sqrt
1717
18- #--- FUNCTIONS ----------------------------------------------------------------+
18+ from landscapes .utils import prod
19+ from landscapes .utils import safe_division as safe_div
1920
21+ #--- FUNCTIONS ----------------------------------------------------------------+
2022
2123def ackley (xy ):
2224 '''
@@ -84,6 +86,38 @@ def adjiman(xy):
8486 return (cos (x ) * sin (y )) - (x / (y ** 2.0 + 1.0 ))
8587
8688
89+ def amgm (x ):
90+ '''AMGM: Arithmetic Mean-Geometric Mean (Mishra's Function No.11)
91+
92+ Parameters
93+ ----------
94+ x : list, len(x)>=2
95+
96+ Returns
97+ -------
98+ float
99+
100+ Notes
101+ -----
102+ global minimum: f(x*)=0 at x*=(x_i -> x_1,=x_2,...,=x_3)
103+ bounds: x_i in [0,10] for i=2,...,n
104+
105+ *There are an infinite number of global minimums when all values of x are
106+ non-negative and equal.
107+
108+ f(1,1) = 0
109+ f(6,6,6) = 0
110+ f(0.5, 0.5, 0.5, 0.5) = 0
111+ etc...
112+ '''
113+ assert len (x ) >= 2 , 'len(x) must be >= 2'
114+
115+ d = len (x )
116+ a = sum ([abs (v ) for v in x ]) / d
117+ b = abs (prod (x ))** (1 / d )
118+ return (a - b )** 2
119+
120+
87121def bartels_conn (xy ):
88122 '''Bartels Conn Function
89123
@@ -123,6 +157,30 @@ def beale(xy):
123157 (2.625 - x + x * y ** 3 )** 2 )
124158
125159
160+ def bent_cigar (x ):
161+ '''Bent Cigar
162+
163+ Parameters
164+ ----------
165+ x : list
166+
167+ Returns
168+ -------
169+ float
170+
171+ Notes
172+ -----
173+ global minimum: f(x*)=0 at x*=(0,...,0)
174+ bounds: x_i in [-100,100] for i=1,...,n
175+
176+ References
177+ ----------
178+ https://al-roomi.org/benchmarks/unconstrained/n-dimensions/164-bent-cigar-function
179+ '''
180+
181+ return x [0 ]** 2 + 1e6 * sum ([v ** 2 for v in x [1 :]])
182+
183+
126184def bird (xy ):
127185 '''Bird Function
128186
@@ -389,6 +447,78 @@ def camel_hump_6(xy):
389447 return a + b + c
390448
391449
450+ def carrom_table (xy ):
451+ '''Carrom Table
452+
453+ Parameters
454+ ----------
455+ xy : list
456+
457+ Returns
458+ -------
459+ float
460+
461+ References
462+ ----------
463+ [1] S. K. Mishra, “Global Optimization By Differential Evolution and
464+ Particle Swarm Methods: Evaluation On Some Benchmark Functions,” Munich
465+ Research Papers in Economics, [Available Online]:
466+ http://mpra.ub.uni-muenchen.de/1005/
467+ '''
468+
469+ x , y = xy [0 ], xy [1 ]
470+ return (exp (2 * abs (1 - (sqrt (x ** 2 + y ** 2 )/ pi ))) * cos (x )** 2 * cos (y )** 2 ) / - 30.0
471+
472+
473+ def chichinadze (xy ):
474+ '''Chichinadze
475+
476+ Parameters
477+ ----------
478+ xy : list
479+
480+ Returns
481+ -------
482+ float
483+
484+ Notes
485+ -----
486+ global minimum: f(x*) = -42.9443870 at x*=(6.189866586965680, 0.5)
487+ bounds: x_i in [-30, 30] for i=1,2
488+ '''
489+
490+ x , y = xy [0 ], xy [1 ]
491+ return (
492+ x ** 2 - 12 * x + 11 +
493+ 10 * cos (pi * x / 2 ) + 8 * sin (5 * pi * x / 2 ) -
494+ 1.0 / sqrt (5 )* exp (- ((y - 0.5 )** 2 )/ 2 ))
495+
496+
497+ def chung_reynolds (x ):
498+ '''Chung Reynolds
499+
500+ Parameters
501+ ----------
502+ x : list
503+
504+ Returns
505+ -------
506+ float
507+
508+ Notes
509+ -----
510+ global minimum: f(x*)=0 at x*=(0,...,0)
511+ bounds: x_i in [-100,100] for i=1,...,n
512+
513+ References
514+ ----------
515+ C. J. Chung, R. G. Reynolds, “CAEP: An Evolution-Based Tool for Real-Valued
516+ Function Optimization Using Cultural Algorithms,” International Journal on
517+ Artificial Intelligence Tool, vol. 7, no. 3, pp. 239-291, 1998.
518+ '''
519+ return sphere (x )** 2
520+
521+
392522def colville (xy ):
393523 '''Colville Function
394524
@@ -422,6 +552,32 @@ def colville(xy):
422552 return a + b + c + d + e + f
423553
424554
555+ def cosine_mixture (x ):
556+ '''COSINE MIXTURE
557+
558+ Parameters
559+ ----------
560+ x : list
561+
562+ Returns
563+ -------
564+ float
565+
566+ Notes
567+ -----
568+ global minimum: f(x_i)=-0.1N for x_i=0 for i=1,...,n
569+ bounds: x_i in [-1, 1] for i=1,...,n
570+
571+ References
572+ ----------
573+ M. M. Ali, C. Khompatraporn, Z. B. Zabinsky, “A Numerical Evaluation of
574+ Several Stochastic Algorithms on Selected Continuous Global Optimization
575+ Test Problems,” Journal of Global Optimization, vol. 31, pp. 635-672, 2005.
576+ '''
577+
578+ return - 0.1 * sum ([cos (5 * pi * v ) for v in x ]) - sum ([v ** 2 for v in x ])
579+
580+
425581def cross_in_tray (xy ):
426582 '''
427583 Cross-in-tray Fucntion
@@ -437,6 +593,86 @@ def cross_in_tray(xy):
437593 return - 0.0001 * (abs (sin (x )* sin (y )* exp (abs (100 - (sqrt (x ** 2 + y ** 2 )/ pi ))))+ 1 )** 0.1
438594
439595
596+ def csendes (x ):
597+ '''Csendes
598+
599+ Parameters
600+ ----------
601+ x : list
602+
603+ Returns
604+ -------
605+ float
606+
607+ Notes
608+ -----
609+ global minimum f(x*)=0 for x*=(0,...,0)
610+ bounds: x_i in [-1,1] for i=1,...,n
611+
612+ References
613+ ----------
614+ T. Csendes, D. Ratz, “Subdivision Direction Selection in Interval Methods
615+ for Global Optimization,” SIAM Journal on Numerical Analysis, vol. 34,
616+ no. 3, pp. 922-938.
617+ '''
618+
619+ return sum ([v ** 6 * (2 + sin (safe_div (1 ,v ))) for v in x ])
620+
621+
622+ def cube (xy ):
623+ '''CUBE
624+
625+ Parameters
626+ ----------
627+ xy : list of length 2
628+
629+ Returns
630+ -------
631+ float
632+
633+ Notes
634+ -----
635+ global minimum: f(x*)=0 at x*=(0,0)
636+ bounds: x_i in [-10, 10] for i=1,2
637+ '''
638+
639+ x , y = xy [0 ], xy [1 ]
640+ return 100 * (y - x ** 3 )** 2 + (1 - x )** 2
641+
642+
643+ def damavandi (xy ):
644+ '''Damavandi
645+
646+ Parameters
647+ ----------
648+ xy : list
649+
650+ Returns
651+ -------
652+ float
653+
654+ Notes
655+ -----
656+ global minimum: f(x*)=0 at x*=(2,2)
657+ bounds: x_i in [0,14] for i=1,2
658+
659+ References
660+ ----------
661+ N. Damavandi, S. Safavi-Naeini, “A Hybrid Evolutionary Programming Method
662+ for Circuit Optimization,” IEEE Transaction on Circuit and Systems I,
663+ vol. 52, no. 5, pp.902-910, 2005.
664+ '''
665+
666+ x , y = xy [0 ], xy [1 ]
667+ # division by zero causes errors...
668+ if x == 2 and y == 2 : return 0
669+ n = sin (pi * (x - 2 )) * sin (pi * (y - 2 ))
670+ d = pi ** 2 * (x - 2 ) * (y - 2 )
671+ a = 1.0 - (abs (n / d ))** 5
672+ b = 2.0 + (x - 7 )** 2 + 2 * (y - 7 )** 2
673+ return a * b
674+
675+
440676def deckkers_aarts (xy ):
441677 '''Deckkers-Aarts Function
442678
@@ -550,6 +786,34 @@ def exponential(x):
550786 return - exp (- 0.5 * sum ([v ** 2 for v in x ]))
551787
552788
789+ def freudenstein_roth (xy ):
790+ '''Freudenstein Roth
791+
792+ Parameters
793+ ----------
794+ xy : list
795+
796+ Returns
797+ -------
798+ float
799+
800+ Notes
801+ -----
802+ global minimum: f(x*)=0 at x*=(5,4)
803+ bounds: x_i in [-10,10] for i=1,2
804+
805+ References
806+ ----------
807+ S. S. Rao, “Engineering Optimization: Theory and Practice,”
808+ John Wiley & Sons, 2009.
809+ '''
810+
811+ x , y = xy [0 ], xy [1 ]
812+ a = (x - 13 + ((5 - y )* y - 2 )* y )** 2
813+ b = (x - 29 + ((y + 1 )* y - 14 )* y )** 2
814+ return a + b
815+
816+
553817def goldstein_price (xy ):
554818 '''
555819 Goldstein-Price Function
@@ -870,6 +1134,33 @@ def qing(x):
8701134 return sum ([(v ** 2 - (i + 1 ))** 2 for i , v in enumerate (x )])
8711135
8721136
1137+ def quartic (x ):
1138+ '''Quartic Function (does not include noise term)
1139+
1140+ Parameters
1141+ ----------
1142+ x : list
1143+
1144+ Returns
1145+ -------
1146+ float
1147+
1148+ Notes
1149+ -----
1150+ global minimum: f(x*)=0 at x*=(0,...,0)
1151+ bounds: x_i in [-1.28, 1.28] for i=1,...,n
1152+
1153+ References
1154+ ----------
1155+ R. Storn, K. Price, “Differntial Evolution - A Simple and Efficient Adaptive
1156+ Scheme for Global Optimization over Continuous Spaces,” Technical Report
1157+ no. TR-95-012, International Computer Science Institute, Berkeley, CA, 1996.
1158+ [Available Online]: http://www1.icsi.berkeley.edu/~storn/TR-95-012.pdf
1159+ '''
1160+
1161+ return sum ([(i + 1 )* v ** 4 for i , v in enumerate (x )])
1162+
1163+
8731164def rastrigin (x , safe_mode = False ):
8741165 '''Rastrigin Function
8751166
0 commit comments