Minimization and Optimization. Minimize output by optimizing inputs
7 次查看(过去 30 天)
显示 更早的评论
Hello
Trying to minimize the output by finding the optimium input values. I am unable to construct the minimization part of the code with the constrains I have. Any help would be greatly appreciated.
% Objective:Optimize the lengths to minimze the power using a new variable.
a = 0.1:20;
b = 0.1:20;
d = a + 0.1:20;
c = b + 0.1:20;
e = d + 0.1:20
%Constants
k= 2;
w=1;
v=1.5
%Variables and their constrains
AB = sqrt(a.^2 + b.^2);
BC = sqrt( c.^2 + ((e-d)/2).^2 );
CS = sqrt( c.^2 + ((e-d)/2).^2 );
VAB = sqrt(((((a.*v).^2/(((b.^2).*4))) + (v^2)/2 )));
% VBS = sqrt(((a*v)^2/((4*b*b)) + (v^2)/2 ));
VCS = ((2*c)./(e-d)).*sqrt(AB.^2);
VBC= CS.^2 + BC.^2;
%Actual Power
%P = (AB.*VAB + BC.*VBC + CS.*VCS).*k*w; % Power
%
% Objective
%To search and find the values for a, b, c d and e to minimize power (P)
% Not sure how to write the function for above
% fun = @(x)(x(:,1) + x(:,2) + x(:,3) + x(:,4) + x(:,5)).*k.*w;
%
% [X1, X2, X3, X4, X5] = ndgrid(0:.1:2); % Should I give this condition in a nested loop?
%
% X = [X1(:), X2(:), X3(:), X4(:), X5(:)];
%
% P = fun(X);
% [bestP, idx] = min(P(:))
% best_X = X(idx,:)
0 个评论
采纳的回答
Alan Weiss
2021-10-6
Sounds like you would be best served with the Problem-Based Optimization Workflow. Declare the variables that can change as optimization variables, set the problem objective to P, and call solve.
Alan Weiss
MATLAB mathematical toolbox documentation
7 个评论
Alan Weiss
2021-10-7
If you look at the objective function value
[sol,fval] = solve(prob,x0)
you find that the different solutions all have the same objective function value. So there are many solutions. Is this unexpected? This is not something that I can tell you how to fix. it is for you to determine whether the problem is formulated correctly.
Alan Weiss
MATLAB mathematical toolbox documentation
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!