|
|
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
global RhoRad
RhoRad = [1 0.1 0.5];
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)
global RhoRad
f = - sum(W.*log2(1 + (200 * RhoRad)./W));
----- % Constraint function program
function [c,ceq] = mycon_direct(W)
global RhoRad
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
|
|