Genetic algorithm - changing only few arguments - errors

I have to run the genetic algorithm by changing only C1,C2,C7 input arguments of the following function DL_Main_DPDPSCM
The remaining arguments are loaded through the file
data = load ('dpdpscm_data.mat');
function [ rho ] = DL_Main_DPDPSCM(x,C1,C2,C3,C4,C5,C6,C7,capae,capai,capaf,rti,rtp )
C1 = x(1);
C2 = x(2);
C7 = x(3);
I have written the fitness function as
fit = @(x) DL_Main_DPDPSCM(x);
[y,fval] = ga(fit,3);
It is showing errors in the user supplied fitness function.
where did i made the mistake and how to correct it

1 comentario

Please don't use the answers as a thread, so adding an answer for every comment made. I've moved your answer into a comment for you.

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de En. de 2018

5 comentarios

Moved an answer into a comment from "Mechanical Engineering"
"when i used nested function as shown in the documentation i am getting the error 'reference to a cleared variable' C1"
Please show your code.
I overcome that error of reference to a cleared variable, because in the main program there is a clear all statement. I removed that statement. But now i am getting the error index exceeds matrix dimensions. I issued the following commands.
fit = @(x) DL_Main_DPDPSCM(x,C1,C2,C3,C4,C5,C6,C7,capae,capai,capaf,rti,rtp);
[y,fval] = ga(fit,3);
Note :- C1 is a (8,4,12) array, C2 -(8,2,12)
C3 - [8,2,2,12] C4 [8,2,4,12], C5[8,2,12]
C6[8,2,12] C7[8,2,12] multi-dimensional arrays.
We need the code for the function where the error message is generated and a copy of the complete error message.
Walter Roberson
Walter Roberson el 29 de En. de 2018
Editada: Walter Roberson el 29 de En. de 2018
Hold on.... Your C1 C2 C7 are all 3d arrays but in your objective function you replace all of those arrays with the scalar value x(1) or x(2) or x(3). You know the x values are individually scalar? If you want to tune the entire array C2 at one time you need to tell ga that the number of variables is at least as high as the number of elements needed to fill the matrix

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Etiquetas

Preguntada:

el 28 de En. de 2018

Editada:

el 29 de En. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by