Minimization and Optimization. Minimize output by optimizing inputs

5 ビュー (過去 30 日間)
Anand Rathnam
Anand Rathnam 2021 年 10 月 6 日
コメント済み: Anand Rathnam 2021 年 10 月 11 日
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,:)

採用された回答

Alan Weiss
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 件のコメント
Anand Rathnam
Anand Rathnam 2021 年 10 月 11 日
Got it! Thank you @Alan Weiss

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by