필터 지우기
필터 지우기

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 CenterFile Exchange에서 Get 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