Re: Constrained Optimization

• To: mathgroup at smc.vnet.net
• Subject: [mg57674] Re: Constrained Optimization
• Date: Fri, 3 Jun 2005 05:35:01 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```On 6/2/05 at 5:16 AM, seckendorff at alphatec.de (Caspar von
Seckendorff) wrote:

>I'd like to do constrained optimization with Mathematica 5.1 on a
>function that is defined piecewise. Unfortunately Maximize[] does
>not work  as I expected. A short & simple example to illustrate:

>f[x_,y_]:= (x-x^2) y
>Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, x]

>As a result I get: "The objective function (x-x^2) y contains a
>nonconstant expression y independent of variables {x}."

You can avoid this error by adding y as one of the parameters to be maximized, i.e., doing

Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, {x,y}]

But this won't be any better since the constraints you've given aren't adequate to determine a maximum. (For any value of x satisfying your constraints, f increases linearly with y without bound.)

>Obviously for this Maximization, knowing that y > 0 I can do the
>following to get the desired value for x:

>Maximize[{x-x^2, 1/5 <= x <= 2/5}, x]
>Out[]= {6/25, {x -> 2/5}}

>Is there a way to achieve this without manual intervention?

You can achieve the same result by doing

Maximize[{f[x, y], 1/5 <= x <= 2/5, y == 0}, {x,y}]

or

Maximize[{f[x, 1], 1/5 <= x <= 2/5}, x]
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: simple set operations
• Next by Date: Re: Constrained Optimization
• Previous by thread: Re: sum the elements of a list
• Next by thread: Re: Constrained Optimization