optimization of multivariable function with nonlinear constraints

I am trying to find the optimum value of a parameter (alpha) for the following expression
function = -x(1)*y(1)*c + x(2)*y(2)*c + alpha*x(1)*x(2)
which x(1), y(1), x(2), y(2) and c have a wide range values
x(1) = x(2) = linspace(0,10,10)
y(1) = y(2) = linspace(0,2,10)
c = linspace(0,100,10)
and constraints are
-x(1)*y(1) + 2*y(1)*c - alpha*x(1)*x(2) < 0
x(2)*y(2) + 2*y(2)*c - alpha*x(1)*x(2) < 0
the goal is to find the alpha values for each set of variables: x(1), y(1), x(2), y(2) and c such that the function has the minimum values.
For example:
what would be the value of alpha for x(1) = 5, x(2) = 3, y(1) =2,y(2)=1 and c=70 which the function is minimum. Basically the code should calculate all different alpha values for all x(1), y(1), x(2), y(2) and c variables.

댓글 수: 1

Matt J
Matt J 2021년 1월 30일
편집: Matt J 2021년 1월 30일
The title of your post inaccurately describes the constraints as nonlinear. They are in fact linear in alpha (which is what matters).

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2021년 1월 30일
편집: Matt J 2021년 1월 30일
Because the objective function is a positive-sloped line in alpha for all x1,x2 combinations, the minimizing alpha is simply the smallest value that satifies the constraints. This can be obtained, for all combinations as,
[X1,X2,Y1,Y2,C]=ndgrid(linspace(0,10,10),linspace(0,10,10),...
linspace(0,2,10), linspace(0,2,10),linspace(0,100,10));
X1X2 = X1.*X2;
infeasible = X1X2==0 & ( (2*Y1.*C-X1.*Y1)>0 | (2*Y2+X2.*Y2)>0 );
invariant = X1X2==0 & ~infeasible;
minAlpha = max( (2*Y1.*C-X1.*Y1)./X1X2 , (2*Y2+X2.*Y2)./X1X2 ); %combinations of solutions
minAlpha(infeasible)=nan;
minAlpha(invariant)=0;

댓글 수: 5

@Matt J Thank you for the code. I think the code you wrote is optimizing the conditions instead to find the optimum value of alpha to minimize the objective fucntion that I wrote above. My goal is to find the optimum value for alpha to minimize this function
function = -x(1)*y(1)*c + x(2)*y(2)*c + alpha*x(1)*x(2)
and the boundery conditions are
-x(1)*y(1) + 2*y(1)*c - alpha*x(1)*x(2) < 0
x(2)*y(2) + 2*y(2)*c - alpha*x(1)*x(2) < 0
No, my code is finding the optimum value(s) of alpha.
Boy
Boy 2021년 1월 31일
편집: Boy 2021년 1월 31일
@Matt JThanks!
is there a way that I can export the alpha vales and corresponding values: x(1), x(2), y(1), y(2) and c in an .csv file?
@Matt J Thanks!
You're quite welcome, but please Accept-click the answer to indicate that your question is resolved.
is there a way that I can export the alpha vales and corresponding values: x(1), x(2), y(1), y(2) and c in an .csv file?
writematrix([X1(:),X2(:),Y1(:),Y2(:),C(:), minAlpha(:)] , 'FileName.csv')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기

질문:

Boy
2021년 1월 29일

댓글:

Boy
2021년 1월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by