How to minimize a function with the constraint that its derivative should be always greater than 0

Viewed 522

I am trying to optimize a nonlinear function with 1500 variables(instantaneous phase), with the help of fmincon in Matlab. The constraint to the optimum variable is that the difference between consecutive elements in the optimal variable obtained should be greater than 0. How can I implement this in the cost function? I have used a nonlinear constraint:

function [c,ceq] = insta_freq(phase)
f=diff(phase);
c=-1*double(min(f));
ceq = [];

The optimization is performed by:

nonlcon=@insta_freq;
[variable_opt,fval,exitflag,output] = fmincon(fun,ph0,[],[],[],[],[],[],nonlcon,options);

The optimization should be such that the constraint nonlcon<=0 but while optimizing with fmincon, these constraints are not satisfied. Thus, is there any other way to make sure that difference of the optimal variable vector is always greater than 0?

1 Answers

You could try and reduce the constraint tolerance. Also in the question it seems you are referring to the derivatives of the objective function, whereas in the question itself it seems you want every single term to be greater than the preceding one as in x1 <= x2 <= x3 <= ... <= xn. I am suggesting a possible solution for the latter problem (the first one would not even define a local optimum, so I am assuming the reported condition is what you want).

You could rewrite the condition in a matrix for as in A = [ 1 -1 0 ... 0 ; 0 1 -1 0 ... 0 ; .... 1 -1 ] so your constraints are inequality linear constraints, simply written Aineq x <= b where b = [0;...; 0];

you just then call

[variable_opt,fval,exitflag,output] = fmincon(fun,ph0,A,b,[],[],[],[],nonlcon,options);

where A and b are the ones defined above.

Related