Minimizing a function using fmincon with special constraints and intervals
Show older comments
I would like to minimize a function using fmincon as follows:
The function to be minimized is: fun = @(x)x(1)^2 + 3*x(2)/x(3) - x(4)^2 ;
The constraints are:
- 1/9 <=x(i)/x(j)<=9, for i,j=1,2,3,4 by considering i<j.
- x(1) + x(2) + x(3) + x(4) = 1;
- x(i) > 0 for i=1,2,3,4.
My challenge is how to apply the first constraint (1) in fmincon. Without the first constraint, I was able to solve it using only the second and the third constraints as follows:
clear; clc
% function to be minimized
fun = @(x)x(1)^2 + 3*x(2)/x(3) - x(4)^2 ;
%initial value
x0=ones(1,4);
%bound limits
lb=0.0001*ones(1,4); % lower bound as x(i)>0
ub=[]; %no upper bound
% normalize x inside fmincon as x(1)+...+x(4) = 1
Aeq = ones(1,4);
beq = 1;
% using Matlab's fmincon
x= fmincon(fun,x0,[],[],Aeq,beq,lb,ub)
I was trying to convert the first constraint into a set of 12 inequalites below. But still I couldn't manage to implement it inside the fmincon. I wonder if you could provide me help. Thank you in advance!
% writing inequalities for: 1/9 <=x(i)/x(j)<=9, for i,j=1,2,3,4 by
% considering i<j.
% (1) for x(i)/x(j)<=9:
x(1)-9*x(2)<=0;
x(1)-9*x(3)<=0;
x(1)-9*x(4)<=0;
x(2)-9*x(3)<=0;
x(2)-9*x(4)<=0;
x(3)-9*x(4)<=0;
%(2) for 1/9<=x(i)/x(j), i,j=1,2,3,4:
1/9*x(2)-x(1)<=0;
1/9*x(3)-x(1)<=0;
1/9*x(4)-x(1)<=0;
1/9*x(3)-x(2)<=0;
1/9*x(4)-x(2)<=0;
1/9*x(4)-x(3)<=0;
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!