필터 지우기
필터 지우기

how can i generate this chromosome?

조회 수: 2 (최근 30일)
ghazwan alsoufi
ghazwan alsoufi 2014년 9월 9일
댓글: isuru senevirathne 2018년 5월 24일
how can i generate this chromosome? I tried to generate randomly this chromosome [2 2 3 1 2 3 1 1 3]. this chromosome represents that I have 3 jobs and each job has 3 tasks. I need this chromosome to use genetic algorithm.

채택된 답변

Joseph Cheng
Joseph Cheng 2014년 9월 9일
I would start by creating an array containing the numbers you want in it and then using randperm to generate a random random order.
Numjobs = 3;
NumTask = 3;
chromosome = repmat(1:NumTask,Numjobs,1);
order = randperm(NumTask*Numjobs);
chromosome = chromosome(order)
  댓글 수: 2
ghazwan alsoufi
ghazwan alsoufi 2014년 9월 9일
thank you. It is work perfectly.
ghazwan alsoufi
ghazwan alsoufi 2014년 9월 9일
how can I use this chromosome in population. for example if I want to find 100 chromosome.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

sejo
sejo 2014년 9월 9일
hy, try this:
chrom=randi([1,3],1,9)
  댓글 수: 2
ghazwan alsoufi
ghazwan alsoufi 2014년 9월 9일
Thank you very much for your answer. But I need to repeat each number three times like [1 2 1 3 2 2 3 1 3]
isuru senevirathne
isuru senevirathne 2018년 5월 24일
chrom=randi([1,10],1,9)
you can not make to repeat each number in three times , becuse it is randomly generate

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by