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: Negative value of cost function(objective function)
Replies: 3   Last Post: Jan 2, 2014 2:27 PM

Advanced Search

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

Posts: 1,430
Registered: 11/27/08
Re: Negative value of cost function(objective function)
Posted: Jan 2, 2014 8:34 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 1/1/2014 11:30 PM, Rubayet wrote:
> Hello every one,
> I am developing my cost function as objective function .this function
> is nonlinear & my optimization model is unconstrained nolinear
> model.While i use fminsearch as solver i am gettting negative value
> for my cost function & one of my decision variable among two decision
> variable is also negative. May be fminsearch solver search from its
> default -Inf to Inf. I dont know whats going on? Can any body help me
> to figure out this problem. Please be informed that while i consider
> fixed value for my decision variables & put it into my objective
> function then i get the positive value.So there is no problem in my
> cost(objective) function.But while i run this by using fminsearch
> solver then i found negative value. I guess this is very basic
> problem. Does fminsearch has any default value for search area like
> -Inf to Inf .?.... so that its start taking negative value of my
> decision variable & giving me negative result in final iteration. So i
> am really looking for fruitful solution regarding this problem..
> Regards
> Rubayet

You say that a decision variable is negative in the fminsearch solution,
and you imply that you don't want that to happen. Unconstrained means
any value of a decision variable is OK. So fminsearch is doing what it
is supposed to do.

If you want your decision variables to remain positive, then I suggest
that you use fmincon (assuming that you have Optimization Toolbox), or
else use abs(x) as your decision variables, which keeps the values positive.

Alan Weiss
MATLAB mathematical toolbox documentation

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.