Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Muhammad

Posts: 29
Registered: 3/21/08
fmincon problem
Posted: Jul 18, 2011 2:24 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.