Connection of GA and DE

23 views
Skip to first unread message

Jan

unread,
Nov 4, 2019, 6:17:32 PM11/4/19
to deap-users
Hi everyone,

to solve a mixed-integer nonlinear programming problem, I use a connection between a and a DE algorithm. In an upper level, the GA optimized integer variables. For each individual, the DE optimizes the continuous variables and should return these back to the GA for evaluation (basically, the DE algorithm is called in the fitness function of the GA). How can I assign the results from the DE algorithm? 

I tried to return the DE individual (which is a three dimensional array) with the GA fitness function:

def fitness_function(self, individual_ga):
individual_ga = np.array(individual_ga)
de = DifferentialEvolution(self.case_study, self.algorithm_parameter, individual_ga)
de.main()
de_solution = de.de_best_solution
fitness = de.de_best_solution.fitness.values[0]
return fitness, de_solution

But this causes an error as the weights of the GA can only be applied to a scalar and not to an array:

creator.create('FitnessMin_ga', base.Fitness, weights=(1.0, 1.0))

TypeError: Both weights and assigned values must be a sequence of numbers when assigning to values of <class 'deap.creator.FitnessMin_ga'>. Currently assigning value(s) (5.645781083596651e-07, [[array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([ 872.59078028,  780.62620719, 1163.77954564]), array([ 905.7298519 , 1396.29337976, 1116.99213661]), array([900.14285028, 179.0710267 , 844.54358005]), array([103.68612417, 112.66638002, 989.0349853 ])], [array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([0.81329445, 0.26798293, 0.22317012]), array([0.62806097, 0.05827781, 0.11870541]), array([0., 0., 0.])], [array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([0., 0., 0.]), array([0.51854742, 0.16720212, 0.03545263]), array([0., 0., 0.])]]) of <class 'tuple'> to a fitness with weights (1.0, 1.0).

Is there another way how I can assign the DE results to the GA individual?

Thanks!
Jan

François-Michel De Rainville

unread,
Nov 5, 2019, 7:34:53 PM11/5/19
to deap-users
To achieve a two level optimization, I would include the second level optimization as a member function of the first level individual class. Thus the optimization would have the effect of modifying the attributes of the individual.

It is juste an idea, I haven't ever done anything in that sense.


As an other thought, I have somewhere a version of cmaes that works with mixed integer. I'll see if I can integrate it to the library.



--
You received this message because you are subscribed to the Google Groups "deap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deap-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deap-users/66f8c024-66a8-4c7a-b103-23a1439f0ca5%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages