how to write function file containing 2 objectives as the 2 seperated output functions of a neural network with 2 outputs.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
i seperated 2 outputs of the single function {i.e, for "f = @(t) sim(net,t')"} by using
row1 = @(v) v(1,:);
first_output_function =@(t) row1(sim(net,t'));
similarly i got
row2 =@(v) v(2,:);
second_output_function =@(t) row2(sim(net,t'));
Now i want to create a function file with them as 2 objectives {i.e, 1st output function is 1st objective and 2nd output is 2nd objective) and access it as a objective function in genetic algorithm
note: i know that we can actually write
objFcn = @(t) sim(net,t')
though we have multiple outputs, but still i need this so that sometimes i should be able to change one of the objectives.
I hope i was able to explain my question clearly.
0 comentarios
Respuestas (1)
Walter Roberson
el 18 de Jun. de 2015
Go ahead and do that. Just be warned that if you call upon both objective functions then sim() would be run twice, once for the first objective function and once for the second objective function.
csim = @(t) cachedcall(@sim, net, t');
row1 = @(v) v(1,:);
row2 = @(v) v(2,:);
first_output_function =@(t) row1(csim(t));
second_output_function = @(t) row2(csim(t));
3 comentarios
Walter Roberson
el 19 de Jun. de 2015
gamultiobj does not take vector of objective functions as an argument. gamultiobj takes as an argument a single function that returns a vector of objective values.
It is recommended that you write your objective function to be vectorized; see http://www.mathworks.com/help/gads/computing-objective-functions.html . In that case, the output should have one column per objective function.
Basically you should be invoking something like
[X,FVAL] = gamultiobj(@(t) sim(net,t').', nvars, [], [], [], [], LB, UB)
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!