fmincon violates my constraints?

2 views (last 30 days)
Tao
Tao on 26 May 2015
Commented: Alan Weiss on 26 May 2015
To be simple, my constraint function is like below:
function [ c, ceq ] = ctr( x, a, b)
[F] = f(x, a, b);
c(1) = -F;
ceq(1) = .....;
end
where x is the vector I'm going to optimize, and F is calculated through the function f, and I want to constraint F greater than 0. However, during the optimization using fmincon, the code crashes and saying "constraint function is not defined at ....", then I check my constraint function and found F is smaller than 0.
Could anyone explain why?
  1 Comment
Alan Weiss
Alan Weiss on 26 May 2015
You didn't show us your nonlinear constraint code or your fmincon call. So how are we supposed to answer you?
Please give us real nonlinear constraint code, and your complete fmincon call, I mean something like
[x,fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
and give us the definitionse of your arguments, such as
fun = @(x)objfun(x,a,b)
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!