Multi candidate structure

23 views
Skip to first unread message

bhi...@gmail.com

unread,
Feb 4, 2020, 12:11:27 PM2/4/20
to Inspyred
I wanted to create a candidate with 2 sub chronomoses(n columns, m+1 rows). So m rows of the candidate would have integers while the last row would have real positive numbers. I am aware of how to create each row individually but how do i create a canddaite solution with various data types.

Here are my thoughts/ideas, create a dual structure where the first m rows are combines to form a nxm column 1 row solution and leave the last real number row separately. This way the crossovers/mutations only operate one their respective sub candidates. This feels easier in my head.

Alternatively, i create a really long candidate with all the values. The variator/mutators will need to be carefully defined such that it only mutates the solution in such a way

Aaron Garrett

unread,
Feb 4, 2020, 12:27:25 PM2/4/20
to Inspyred
Well, you could do what you describe and then make a custom variator (or two or three or ...). Something like this maybe?

@inspyred.ec.variators.mutator
def my_subchromosome_mutator(random, candidate, args):
   m = args['m']
   n = args['n']
   sub1 = candidate[:m*n]
   sub2 = candidate[m*n:]
   mut1 = inspyred.ec.variators.gaussian_mutation(random, [sub1], args)  # These variators could be different. Doesn't matter.
   mut2 = inspyred.ec.variators.gaussian_mutation(random, [sub2], args)
   return mut1 + mut2  # This would be a nxm+n element list that represents the full candidate, if I understood your situation correctly.
                       # If you need to make it back into a rectangular matrix, you could do that here before you return.

--
Aaron Garrett



--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inspyred+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inspyred/18e6c3f6-196d-4103-aa8d-063ce4cac907%40googlegroups.com.

bhi...@gmail.com

unread,
Feb 16, 2020, 12:50:11 PM2/16/20
to Inspyred
So just to confirm your idea,

I would create a custom variator/mutator, that splits my chromosome and calls on another variator/mutators for each of them?

As for the args m and n, would i just add those to the end of the evolve command like i didn in the example below?

final_pop = es.evolve(generator=generate_rastrigin,
                      evaluator=evaluate_rastrigin,
                      pop_size=100,
                      maximize=False,
                      bounder=ec.Bounder(-5.12, 5.12),
                      max_evaluations=20000,
                      mutation_rate=0.25,
                      num_inputs=3,
                      m = 10,
                      n = 5,)
To unsubscribe from this group and stop receiving emails from it, send an email to insp...@googlegroups.com.

Aaron Garrett

unread,
Feb 16, 2020, 3:43:21 PM2/16/20
to Inspyred
Yes, that's right. You can do whatever you like with the different parts, not just use the existing variators. But those would be the easiest to apply, I would think.

--
Aaron Garrett



To unsubscribe from this group and stop receiving emails from it, send an email to inspyred+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inspyred/44902719-53b5-402a-a667-abf75492c8c7%40googlegroups.com.

bhi...@gmail.com

unread,
Feb 16, 2020, 6:42:58 PM2/16/20
to Inspyred
What about the args question?

Aaron Garrett

unread,
Feb 16, 2020, 6:48:52 PM2/16/20
to Inspyred
The whole thing was correct. The args are passed in through evolve just like you presumed.

--
Aaron Garrett



To unsubscribe from this group and stop receiving emails from it, send an email to inspyred+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inspyred/4887be12-7c6a-4e65-8ec9-4f3d74ca9143%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages