[Date Index]
[Thread Index]
[Author Index]
Simple Optimization Problem: Using BinCounts within objective
*To*: mathgroup at smc.vnet.net
*Subject*: [mg103785] Simple Optimization Problem: Using BinCounts within objective
*From*: Chris <uk.org.microserf at googlemail.com>
*Date*: Mon, 5 Oct 2009 13:58:21 -0400 (EDT)
Hi
I need to optimize a function that is defined in terms of BinCounts;
the arguments that I want to maximize over define the bin cutpoints.
I think the problem is that Mathematica expands the objective function
in terms of the arguments before they have been given numerical
values, so BinCounts complains that the bin specification is not "a
list containing real values, Infinity, and -Infinity".
I think the following is a minimal example of the kind of thing I'm
trying to do and what's happening. I'd be very grateful for advice on
how to address this problem.
Thanks
Chris
data = RandomReal[1, 30]; (* Create 30 real-valued random numbers. *)
In[574]:= f[a_, b_, c_] := BinCounts[data, {{0, a, b, c, 1}}] (*
Define a function to bin the values according to a spec. *)
In[576]:= g[a_, b_, c_] := Max[f[a, b, c]] - Min[f[a, b, c]] (* Define
the objective function. *)
In[584]:= NMaximize[{g[a, b, c], 0 < a < b < c < 1}, {a, b, c}] (*
Attempt to maximize g, with sensible constraints. *)
During evaluation of In[584]:= BinCounts::cvals: The bin specification
{{0,a,b,c,1}} is not a list containing real values, Infinity, and -
Infinity. >>
During evaluation of In[584]:= BinCounts::cvals: The bin specification
{{0,a,b,c,1}} is not a list containing real values, Infinity, and -
Infinity. >>
During evaluation of In[584]:= BinCounts::cvals: The bin specification
{{0,a,b,c,1}} is not a list containing real values, Infinity, and -
Infinity. >>
During evaluation of In[584]:= General::stop: Further output of
BinCounts::cvals will be suppressed during this calculation. >>
Out[584]= {0., {a -> 0., b -> 0., c -> 1.}}
Prev by Date:
**Re: Re: confused about == vs === in this equality**
Next by Date:
**Why does not AbsoluteOptions[] work on a panel?**
Previous by thread:
**Re: Re: How to find which variable caused the trigger in Manipulate[]**
Next by thread:
**Re: Simple Optimization Problem: Using BinCounts within**
| |