I get following error after implementing the attached code.

Error Message

"fmincon stopped because the size of the current step is less than the default value of the step size tolerance but constraints are not satisfied to within the selected value of the constraint tolerance."


rho = (1/3)*eye(3);

v1 = sdpvar(3,1);
v2 = sdpvar(3,1);
v3 = sdpvar(3,1);
v4 = sdpvar(3,1);
v5 = sdpvar(3,1);

obj2 = trace((v1*v1' + v2*v2'+v3*v3'+v4*v4'+v5*v5')*rho);

cons2 = [sum(v1.*v1) == 1; sum(v2.*v2) == 1;sum(v3.*v3) == 1;sum(v4.*v4) == 1;sum(v5.*v5) == 1; sum(v1.*v2) == 0;sum(v2.*v3) == 0;sum(v3.*v4) == 0;sum(v4.*v5) == 0;sum(v5.*v1) == 0];

ops2 = sdpsettings('solver','fmincon');

optimize(cons2, -obj2, ops2);

obj2 = double(obj2)

I tried changing tolerances by adding following code.

options = optimset('TolX',1e-30,'TolFun', 1e-6)

I tried different values, but it doesn't work. Any suggestions to debug it will be helpful.Suggestions to reformulate the problem or use another solver will also be appreciated (in case fmincon is not the best solver for this problem).


1 Answer 1


FMINCON is not able to find a feasible point starting at what I think is the default value provided by YALMIP of all variables being zero vectors. Local solvers, such as FMINCON, may have trouble finding feasible points to non-convexly-constrained problems such as this, annd may be dependent on having an adequate starting point in order to even find a feasible point.

In this case, I just picked somewhat arbitrarily starting values (which are infeasible, by the way) for all variables being vectors of ones, and FMINCON quickly found what turned out to be the globally optimal solution.

Alternatively, I used YALMIP's BMIBNB global optimizer, with FMINCON as upper solver, and even without providing any non-default starting value, BMIBNB solved the problem to global optimality almost immediately.

Here is what I used instead of your optimize command:

% FMINCON with non-default starting values
optimize(cons2, -obj2,sdpsettings('solver','fmincon','usex0',1))

% BMIBNB, with FMINCON as upper solver, default starting values --> produces global optimum
optimize(cons2, -obj2,sdpsettings('solver','bmibnb','bmibnb.uppersolver','fmincon')


BTW, I don't think your non-default tolerance settings would have helped, but they were not used. Given that you are using YALMIP, you need to specify any non-default solver options in sdpsettings as discussed at https://yalmip.github.io/command/sdpsettings/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.