Borrar filtros
Borrar filtros

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 visualizaciones (últimos 30 días)
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 comentarios
Guillaume
Guillaume el 14 de Dic. de 2016
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 el 14 de Dic. de 2016
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, :) = [];

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by