Path: news.mathworks.com!not-for-mail
From: "lovish " <lovishagarwal@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Problem regarding Maximizing a function
Date: Mon, 30 Mar 2009 01:18:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 48
Message-ID: <gqp6k9$q5p$1@fred.mathworks.com>
References: <gqp32v$kum$1@fred.mathworks.com> <gqp50a$i4s$1@fred.mathworks.com>
Reply-To: "lovish " <lovishagarwal@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1238375881 26809 172.30.248.35 (30 Mar 2009 01:18:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 30 Mar 2009 01:18:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1189748
Xref: news.mathworks.com comp.soft-sys.matlab:528558

 I'm working with optimization toolbox using the 'fmincon' solver . The fmincon solver works to minimze a function. There's no inbuilt function to maximize a function. 

The problem that I'm encountering is that for instance
when I need to maximize f(x)= x1 + x2
 s.t  x1+x2<=2 where x1 and x2>=0

I ain't able to do that. I'm setting the function as 

> > function f=objfun(x)
> > f= x1+x2;
> > f=-z;

Instead of getting the values as x1=1 and x2=1 , it it displaying x1=x2=0 and f(x)=0 as it it minimizing the function. How should I modify the function or the conditions in the solver to maximize the function??  I would highly appreciate if someone could help me.

Thanks and Regards,
Lovish


"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gqp50a$i4s$1@fred.mathworks.com>...
> "lovish " <lovishagarwal@gmail.com> wrote in message <gqp32v$kum$1@fred.mathworks.com>...
> > Hi guys,
> > 
> > I am having problems with maximizing a function using optimization tool. I have to maximize
> > 
> > max f(x)= log (x1) + log (x2) + log (x3)
> > 
> > with the constraints that x1+x2 <=1 ; x1+x3<=1
> > 
> > I'm solving it using optimization tool box using fmin solver. The function I have created is 
> 
> There is no solver called fmin in the optimization
> toolbox. So it will be difficult to help you.
> 
> 
> > 
> > function f=objfun(x)
> > f= log(x1)+log(x2)+ log (x3);
> > f=-z;
> > 
> > I have used f=-z in order to maximize the function as fmin minimizes the function f(x) But  it isn't working. Please guide me as to how should I use the toolbox in order to maximize the function.
> > 
> 
> What is not working? What is wrong? What has
> failed? In what way did it fail?
> 
> The crystal ball is cloudy.
> 
> John