How do I minimize one output and constrain the value of another?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jiashu Huang
el 22 de Sept. de 2020
Comentada: Ameer Hamza
el 25 de Sept. de 2020
Hello,
I have a function which takes in a vector v and gives two outputs p and q. I wish to minimize output p while keeping output q at a certain value i choose. Is there any way I can do this with ga ?
Thank you.
Respuesta aceptada
Ameer Hamza
el 22 de Sept. de 2020
Yes, it is possible. However, it might be better of you divide it into two different functions to avoid redundant calculations. However, if speed is not a concern, then you can do something like this.
function [p q] = myObjective(v)
% calculates p and q
end
Then call ga() like this
v_sol = ga(@myObjective, 2, [], [], [], [], [], [], @nlcon)
function [c ceq] = nlcon(v)
q_ = 1; % suppose you want the value of q to be 1.
[~, q] = myObjective(v)
ceq = q - q_;
c = []
end
2 comentarios
Más respuestas (0)
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!