Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: fmincon problem
Replies: 5   Last Post: Jul 18, 2011 3:22 PM

 Messages: [ Previous | Next ]
fmincon problem
Posted: Jul 18, 2011 2:24 AM

Hello,

I am trying to run a simple fmincon code. However, the optimal solution is not maintaining the constraints.

The code is given below:

%% Main program

W0 = [300 300 300];

options = optimset('Algorithm','active-set');
[W,fval,exitflag] = fmincon(@myfun_direct,W0,[],[],[],[],0,900,@mycon_direct,options);

------------
% Obkjective function program

function f = myfun_direct(W)

f = - sum(W.*log2(1 + (200 * RhoRad)./W));

-----
% Constraint function program

function [c,ceq] = mycon_direct(W)

c = [40*ones(length(W),1)-(W.*log2(1 + (200 * RhoRad)./W))' ; sum(W)-900];

ceq = [];

----------

After I run the code, one of the W value comes out to be negative !!! However, I explicitly set a bound for W (between 0 and 900). So, it should not happen !

Beside, one of the inequality constraint does not get satisfied, too ! I want all entries in the c vector to be negative. But some of them come out to be negative !

Any help will be really appreciated.

Thanks,

Nazmul

Date Subject Author