MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Numerical optimization

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120137] Re: Numerical optimization
  • From: Dana DeLouis <dana01 at me.com>
  • Date: Sat, 9 Jul 2011 07:33:32 -0400 (EDT)

...Do[NMaximize[{f, "Constraints"}, {s, p1, p2}], {c2, 0, 1, 0.1}, {g, 0, 1, 0.1}]

Hi.  You may have a function f, but you didn't pass it any parameters.
For constraints, it looks like a string variable.
We want to constrain the changing cells.  The other two variables are fixed via the table function.
Let's do a simple linear function where the output is easily observed.

f[p1_,p2_,s_,c2_,g_]:=p1+p2+s+c2+g

We want constraints that don't make the problem unbounded.
The constraints are for the 3 changing variables.

const = {0<=p1<=100,0<=p2<=100,0<=s<=100};

Then...

Table[
Maximize[{f[p1,p2,s,c2,g],const},{p1,p2,s}],
{c2,0,1,0.1},{g,0,1,0.1}]


The output is easy to see for this simple example.
Adjust your function accordingly.

Lots of different options. 
Here's one idea that just looks at the value.

t=Table[
Maximize[{f[p1,p2,s,c2,g],const},{p1,p2,s}]//First,
{c2,0,1,0.1},{g,0,1,0.1}];

MatrixPlot[t]

= = = = = = = = = =
HTH  : >)
Dana DeLouis
$Version
8.0 for Mac OS X x86 (64-bit) (November 6, 2010)





On Jul 8, 5:00 am, Equilib <pette... at gmail.com> wrote:
> Hi all,
> I'm new to numerical optimization routines and since I get no results
> I worry that I may have made errors in my setup. I would like to
> maximize function f(p1,p2,s,c2,g) using the variables p1, p2, s. The
> parameters c2 and g are both in the interval (0,1). Hence I want a
> large matrix with solutions to the maximization problem for all
> combinations of c2 and g.
>
> I set it up as follows:
> Do[NMaximize[{f, "Constraints"}, {s, p1, p2}], {c2, 0, 1, 0.1}, {g, 0,
> 1, 0.1}]
>
> but get a page full of different error mesages and no output. Can
> anyone see the programming errors and maybe suggest an alternative
> route?
>
> Thanks a lot,
> Petter




  • Prev by Date: Re: sequence of functions
  • Next by Date: Re: How to write a "proper" math document
  • Previous by thread: Re: Numerical optimization
  • Next by thread: Re: Numerical optimization