MATLAB Answers

0

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

Asked by Maziar Isapour on 6 Dec 2017
Latest activity Commented on by Torsten
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)

  3 Comments

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

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 = [3];
Aeq = [];
beq = [];
lb = zeros(3);
ub = ones(3);
x = fmincon(objective,x0,A,b,Aeq,beq,lb,ub);
disp(x)

Best wishes

Torsten.

Log in to comment.

Tags

0 Answers

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today