필터 지우기
필터 지우기

i want only that child which strickly follow X+Y+Z=9 if not follow than doing process one more time with other element,

조회 수: 2 (최근 30일)
wrappedcolumns = [7 8];
child = parent;
swapoddeven = reshape([2:2:size(parent, 1); 1:2:size(parent, 1)], 1, ]);
child(swapoddeven, swappedcolumns) = child(1:size(parent, 1),swappedcolumns)
after this i process i got child matrix
x y z
1 2 6 =9 valid
6 2 1 =9 valid
2 1 4 =7 not valid
2 1 1 =4 not valid
6 2 8 =16 not valid
1 7 8 =16 not valid
{i want only that child which strickly follow X+Y+Z=9 if not follow than doing process one more time with other element} {i want to find minumum value of [(X(-0.33).^2+(Y-0.33).^2+(Z-0.33).^2] this function where X+Y+Z=9 with genetic algorithm}
  댓글 수: 6
Guillaume
Guillaume 2016년 12월 14일
That code is a total mess, with meaningless variable names (iwant, el, c), half of the lines that don't do anything and bits of code that don't appear to be related.
Simplification of the first part:
[X, Y, Z ] = ndgrid(0:9); %all combinations
XYZ = [X(:), Y(:), Z(:)]; %concatenate into a three column matrix
XYZ = XYZ(sum(XYZ, 2) == 9, :); %only keep rows that sum to 9
eq1 = sum((XYZ - 0.33) .^ 2, 2);
chosenrows = randi(size(XYZ, 1), 1, 6); %your c
entries = XYZ(chosenrows, :);
bins = fliplr(de2bi(entries), 8);
%... rest of the code as normal
I have no idea what your question is.
Steven Lord
Steven Lord 2016년 12월 14일
How about this:
[X, Y] = meshgrid(0:9);
XYZ = [X(:), Y(:), 9-X(:)-Y(:)];
If you have an additional constraint, that Z must contain only nonnegative values:
XYZ(XYZ(:, 3) < 0, :) = [];

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

답변 (0개)

카테고리

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