The Math Forum

Search All of the Math Forum:

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

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

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

Advanced Search

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

Posts: 33
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


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.



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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.