fmincon, the size of the current step is less than the value of the step size tolerance, but constraints are not satisfied

14 views (last 30 days)
hi, I am working on a non-linear optimization problem.
I try to find the upper bound with fmincon, then currently facing this problem:
fmincon stopped because the size of the current step is less than the value of the step size tolerance but constraints are not satisfied to within the value of the constraint tolerance.
And I have to formulated it in the following way
Here is my current code:
H = zeros(4);
H(3,3) = 1; H(4,4) = 1;
c = [1 1 0 0]';
Q1 = zeros(4); Q1(1, 2) = 0.5; Q1(2, 1) = 0.5; Q1(2, 3) = 0.5; Q1(3, 2) = 0.5;
Q2 = zeros(4); Q2(1, 2) = 0.5; Q2(2, 1) = 0.5;
Q3 = zeros(4); Q3(2, 3) = 0.5; Q3(3, 2) = 0.5;
Q = [Q1; Q2; Q3];
A = zeros(3,4); A(2,4) = 1; A(3,1) = 1;
b = [2 3 5]';
lb = [0 0 0 0]'; ub = [10 4 10 10]';
objective = @(x) x'*H*x + c'*x;
x_0 = 0.5 * (lb + ub); % Use average as initial value
A_nlp = []; b_nlp = [];
Aeq_nlp = []; beq_nlp = [];
function [c, c_eq] = NonLinearConstraint(x)
c = []; % No nonlinear inequalities
for i = 1:m % Loop over the matrices defining the quadratic constraints
Qi = Q((i-1)*n+1:i*n,:);
c_eq(i)= x'*Qi*x - A(i,:)*x - b(i);
end
end
nonlcon = @NonLinearConstraint;
options = optimoptions('fmincon','Display','iter','Algorithm','sqp');
[~, fval] = fmincon(objective, x_0, A_nlp, b_nlp, Aeq_nlp, beq_nlp, lb, ub, nonlcon, options);
It could not satisfy the constraint function. I also tried a few other optimoptions (different algorithm, step size ..)
Could anyone give me some advice how to fix this?
Thank you for your time!
  4 Comments

Sign in to comment.

Accepted Answer

Bruno Luong
Bruno Luong on 4 Jan 2021
I beleive the correct sign of A is "+"
c_eq(i)= x'*Qi*x + A(i,:)*x - b(i);

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!