[SciPy-dev] Abstract vectors in optimization

David Cournapeau david@ar.media.kyoto-u.ac...
Mon Jan 5 23:27:23 CST 2009


Hi Ben,

Ben FrantzDale wrote:
> I've started playing with SciPy for numerical optimization. So far, it
> looks like a great set of useful algorithm implementations.
>
> If I understand the architecture correctly, there is one change that
> could make these libraries even more powerful, particularly for
> large-scale scientific computing. The optimization algorithms seem to
> be designed to work only with NumPy vectors. Mathematically, though,
> many of these algorithms can operate on an arbitrary Hilbert space, so
> the algoirhtms can be slightly rewritten to work with any objects that
> support addition, scalar multiplication, and provide an inner product,
> and a few other things.

It may be true mathematically, but I don't think it is such a useful
abstraction for implementation. The few other things is what matters the
most, actually. For example, many if not most scipy algorithms depend on
advanced features provided by numpy, such as slicing, broadcasting,
etc... Implementing everything in scipy in terms of an abstract object
with only the operations implied by Euclidean structures would be quite
awkward.

>
> If these functions could be made more general in this way, I could see
> the SciPy optimization tools being extremely useful for large-scale
> optimization problems in which people already have the cost function,
> its gradient, and the representation of a state vector implemented
> (e.g., in C++).

You can already do that with some effort, depending on the memory
representation of your state vector: you make a numpy array from your
data (you can of course almost always convert to a numpy array anyway,
but I assume you want to avoid copies, since you talk about large-scale
optimization).

I want to ask: why would you *not* want to use numpy ? What does it
bring to you ?

cheers,

David


More information about the Scipy-dev mailing list