 
 
 
 
 
 
Re: Optimizing a function with a list as a parameter
- To: mathgroup at smc.vnet.net
- Subject: [mg103119] Re: Optimizing a function with a list as a parameter
- From: kostka <kostka at gmail.com>
- Date: Tue, 8 Sep 2009 06:00:16 -0400 (EDT)
- References: <h829kh$3s4$1@smc.vnet.net>
On Sep 6, 11:36 pm, Mike Miller <michael.g.mil... at gmail.com> wrote:
> I have a time-series like function which gives an output based on a
> list of real numbers(i.e. you can run the function on a list of
> 1,2,3,... real numbers). The issue I'm encountering is how to maximize
> the function for a given list length(subject to a set of constraints).
> I could fix the function to a fixed number of real numbers(i.e. f
> [x_Real, y_Real] instead of f[x_List]) and treat x and y as the first
> two elements of the list, and call Maximize on the function, but this
> is not really elegant. I want to be able to easily change the number
> of elements in the list.
>
> What is the best way to optimize a function like I described, which
> takes a list as an argument, for a fixed list length?
>
> Thanks,
> Mike
Mike,
You could do something like the following:
1) define whatever the function
2) make a list of variables
and then have your optimization routine:
3) use Variables to capture what those variables are
4) optimize using the obtained variables
In[1]:= f[x_] := Total[Abs[x]]
x = {a, b, c}
vars = Variables[x]
Minimize[f[x], vars]
Out[2]= {a, b, c}
Out[3]= {a, b, c}
Out[4]= {0, {a -> 0, b -> 0, c -> 0}}
Regards,
Tim

