Re: Convex crossover in genetic algorithm
- To: mathgroup at smc.vnet.net
- Subject: [mg112666] Re: Convex crossover in genetic algorithm
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 25 Sep 2010 02:21:08 -0400 (EDT)
On 9/24/10 at 5:39 AM, lightnation at naver.com (lightnation) wrote: >If you are interested in the genetic algorithm, please help me make >coding about convex crossover. The coding below is convex crossover >in RCGA. It's working, but the convergence is not so good. Please >correct me. (The whole algorithm is posted in this. >http://blog.daum.net/lightnation/5846116) Are you aware Mathematica already has this functionality built-in? That is: In[1]:= obj = x^2 + 2 y^2 - 0.3 Cos[3 Pi x] - 0.4 Cos[4 Pi y] + 0.7; constraints = {-1 <= x <= 1, -1 <= y <= 1}; In[4]:= NMaximize[{obj, And @@ constraints}, {x, y}, Method -> {"DifferentialEvolution", "ScalingFactor" -> .1}] Out[4]= {3.60426,{x->1.,y->-0.805358}} Here, I tweaked the ScalingFactor since the default value fails to find a maximum. But note, allowing NMaximize to automatically choose the method finds a maximum, i.e., In[5]:= NMaximize[{obj, And @@ constraints}, {x, y}] Out[5]= {3.60426,{x->1.,y->0.805358}} More information about methods used by NMaximize and NMinimize can be found in tutorial/ConstrainedOptimizationGlobalNumerical Included here are details of various options for the methods not described in the basic documentation for NMaximize, i.e., the main documentation page in the Documentation Center for NMaximize