フィルターのクリア

How to optimize a system with 5 optimization variables, 4 of them are in the objective function and the 5th is in the constriants?

3 ビュー (過去 30 日間)
Let's assume that we need to optimize a function f with 5 optimization variables (V,W,X,Y,Z)
the fitness function it self includes 4 variables i.e. f= V*W*X*Y
and the 5th variable Z is in the constraints i.e constraint1 = 5*V - Z =0; constraint2 = 5*W - Z =0;
do i include the variable Z in the fitness function to be function f = objFcn(V,W,X,Y,Z) and there is no stetments of Z in the fitness function, or do i put it in the constraints function i,e.
n = constraints(V,W,Z) and put the two constraints and it will give me no enough input arguments

採用された回答

Matt J
Matt J 2023 年 1 月 8 日
編集済み: Matt J 2023 年 1 月 8 日
If you are using the Solver-Based framework, you must pass all the unknowns both to the objective and constraints as a vector p=[V,W,X,Y,Z]. The optimation solvers do not know or care which variables are actually used in either place. So, it will not be f = objFcn(V,W,X,Y,Z), but rather f=objFcn(p). Additonally, when you have linear equality constraints, as in your case, you will express them using matrix multiplication Aeq*p=beq, where Aeq is a 5-column matrix,
Aeq=[5,0,0,0,-1;
0,5,0,0,-1 ]
beq=[0;0]
If you are using the Problem-Based framework, then you are free to separate them, although this is not required,
V=optimvar('V',___);
W=optimvar('W',___);
X=optimvar('X',___);
Y=optimvar('Y',___);
Z=optimvar('Z',___);
f=fcn2optimexpr( @objFcn, V,W,X,Y);
Con.constraint1 = 5*V - Z =0;
Con.constraint2 = 5*W - Z =0;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by