MATLAB Answers

## FMINCON ERROR: "Failure in initial user-supplied nonlinear constraint function evaluation. FMINCON cannot continue."

Asked by Maziar Isapour

### Maziar Isapour (view profile)

on 6 Dec 2017
Latest activity Commented on by Torsten

### Torsten (view profile)

on 11 Dec 2017
This is a simple nonlinear program. when I run it , I see the error as
Failure in initial user-supplied nonlinear constraint function evaluation. FMINCON cannot continue.
I would appreciate if someone could help me. It's being frustrating. Thanks.
objective = @(x) 1000 - 50*x(1)*x(2) - 41*x(3)*x(2) + 30*x(1) + 30*x(2) + 30*x(3);
x0 = [0 0 0];
disp(['Initial objective: ' num2str(objective(x0))])
A = [];
b = [];
Aeq = [];
beq = [];
lb = zeros(3);
ub = ones(3);
nonlincon = @nlcon;
x = fmincon(objective,x0,A,b,Aeq,beq,lb,ub,nonlincon);
disp(x)

Walter Roberson

### Walter Roberson (view profile)

on 6 Dec 2017
You do not show us the source code for nlcon
Maziar Isapour

### Maziar Isapour (view profile)

on 11 Dec 2017
Hi Walter, this is the code for nlcon. Thank you. function [c] = nlcon(x) c = x(1) + x(2) + x(3) - 3;
Torsten

### Torsten (view profile)

on 11 Dec 2017
objective = @(x) 1000 - 50*x(1)*x(2) - 41*x(3)*x(2) + 30*x(1) + 30*x(2) + 30*x(3);
x0 = [0 0 0];
disp(['Initial objective: ' num2str(objective(x0))])
A = [1 1 1];
b = ;
Aeq = [];
beq = [];
lb = zeros(3);
ub = ones(3);
x = fmincon(objective,x0,A,b,Aeq,beq,lb,ub);
disp(x)
Best wishes
Torsten.

Sign in to comment.