Pythonic way to iterate through multidimensional space?
Frank Miles
fpm at u.washington.edu
Tue Aug 5 16:57:49 EDT 2014
On Tue, 05 Aug 2014 20:06:05 +0000, Frank Miles wrote:
> I need to evaluate a complicated function over a multidimensional space
> as part of an optimization problem. This is a somewhat general problem
> in which the number of dimensions and the function being evaluated can
> vary from problem to problem.
>
> I've got a working version (with loads of conditionals, and it only works
> to #dimensions <= 10), but I'd like something simpler and clearer and
> less hard-coded.
>
> I've web-searched for some plausible method, but haven't found anything
> "nice". Any recommendations where I should look, or what technique should
> be used?
>
> TIA!
Ahhhh.... should have waited. The answer: itertools.product! very nice
More information about the Python-list
mailing list