Info

此问题已关闭。 请重新打开它进行编辑或回答。

generate crossover process and make matrix of new created childs

1 次查看(过去 30 天)
entry = randi(9,6,3)
now convert this entry matrix in 8 digit binary now change two conecutive element column and created new 8 digit number now this new number convert into decimal and 6*3 size in this new 6*3 matrix each raw sum<=9 if not satisfy than do process with any other digit and raw swappinf and create new raw untill this process do row sum<=9 example
entry(1,:)=7 3 6
entry(2,:)=4 6 8
de2bi(entry(1,1)) : 0 0 0 0 0 1 0 1 =parent1
de2bi(entry(1,2)) : 0 0 0 0 0 0 1 1 =parent2
de2bi(entry(1,3)) : 0 0 0 0 0 1 1 0 =parent3
de2bi(entry(2,1)) : 0 0 0 0 0 1 0 0 =parent4
de2bi(entry(2,2)) : 0 0 0 0 0 1 1 0 =parent5
de2bi(entry(2,3)) : 0 0 0 0 1 0 0 0 =parent6
column swapping [7 8]
parent1 :0 0 0 0 0 1 0 1
paretn2 :0 0 0 0 0 0 1 1
child1 :0 0 0 0 0 1 1 1
child2 :0 0 0 0 0 0 0 1
paretn3 :0 0 0 0 0 1 1 0
paretn4 :0 0 0 0 0 1 0 0
child3 :0 0 0 0 0 1 0 0
child4 :0 0 0 0 0 1 1 0
parent5:0 0 0 0 0 1 1 0
paretn6:0 0 0 0 1 0 0 0
child5 :0 0 0 0 0 1 0 0
child6 :0 0 0 0 1 0 1 0
child 1=7 child2=1,child3=4.child4=6.child5=4 child6=10
7 1 4=12
6 4 10=20
child is not valid than do its process with another raw create again child and check this condition do until row sum<=9
crossover is actually column swapping process in 8 bit digit and create new digit
  3 个评论
Pratik Anandpara
Pratik Anandpara 2016-12-16
编辑:Pratik Anandpara 2016-12-16
this is parent matrix-->
entry = randi(9,6,3)
in next step convert into 8 digit binary and swap 7 & 8 digit of 1&2 element of parent now swap 7&8 digit of parent 1&2 so create some new digit (first six is same only last two change) now that 8 digit convert into decimal than check child1+child2+child3<=9 if not follow than swap again 7&8 digit of child which not satisfy total<=9 ...suppose raw 2 have child4+child5+child6=11 so condition not follow...so child 4 &5,child5&6 ,child 6&4 convert in 8 digit and swap 7&8 digit internally so create new 8 digit and convert in decimal check again –

回答(0 个)

此问题已关闭。

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by