How can I optimize this problem to find the most suitable set of variables to maximize the cost function ?
Mostrar comentarios más antiguos
I want to maximize [(2*n*eo*10*lf)/d -(2*n*eo*3.87*lf)/d]. With constraints (i) lf/wf <= 40; (ii) den*n/2*lf*wf*10 = 3.0015e-8. The variables are n,lf,wf and d.Known constants are eo and den. I am trying to use genetic algorithm to solve this problem but don't seem to be getting a proper answer. I wrote 3 functions, 1 for cost, 1 for constraints. I am giving all the functions below. The variable list is [lf wf d n] in my code.
function eh_pc_generic
clear all; close all; clc;
options = optimset('Display','iter')
ObjectiveFunction = @eh_cost_genetic;
nvars = 4; % Number of variables
LB = [0 2e-6 0 1]; % Lower bound
UB = [Inf Inf Inf Inf]; % Upper bound
A = zeros(1,4);
A(1,1) = 1;
A(1,2) = -40;
B = 0;
ConstraintFunction = @eh_constraint_genetic;
[x,fval] = ga(ObjectiveFunction,nvars,A,B,[],[],LB,UB, ...
ConstraintFunction)
end
function c = eh_cost_genetic(x)
eo = 8.854e-12;
c = -[((2*x(4)*eo*x(1)*10))/x(3)-(2*x(4)*eo*x(1)*3.87)/x(3)]
end
function [cineq,ceq] = eh_constraint_genetic(x)
den = 2331;
cineq = [];
ceq = [(den*10*x(4)*x(2)*(x(4)/2))-3.0015e-8];
end
The three functions needs to be saved with their names.
Any help on how I can optimize these parameters subject to those constraints is highly appreciated.
Thanks
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!