how to write function file containing 2 objectives as the 2 seperated output functions of a neural network with 2 outputs.
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 18 Jun 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 Comments
Walter Roberson
on 19 Jun 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)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!