Re: OON: "Subclassing" algorithms

From: Theodore Papadopoulo (Theodore.Papadopoulo@sophia.inria.fr)
Date: Thu Apr 24 1997 - 11:35:48 EST


> Suppose I have an algorithm for a specific problem, and an
> implementation that works. Now I want to tackle a similar problem that
> can be solved by a similar algorithm. All it takes is perhaps the
> modification of one step, or the addition of one. I would like to be
> able to "inherit" the working implementation while just replacing or
> adding small parts of it. And of course I do not want to modify the
> existing (supposedly well tested) code.

> One possibility would be to write each step as a function and call
> these function via pointers that can be substituted. But that would be
> a very inefficient solution; what I want is fully optimized code for
> all versions of the algorithm. So I would certainly need the source
> code of everything.

> Has any work been done on this kind of problem? Or is it a stupid
> idea due to some limitations I have overlooked?

    I do not believe this is a stupid idea... if it is, we are at least
two that are playing around with it. Actually, I have played with it in
a project of mine involving writting some optimization software for which
I want to have variants: i.e. I wanted to have different method to estimate
functions, derivatives, to rescale the problem and so on... My first idea was
to encapsulate all these functionnalities into classes all deriving from a
common base and to write my algorithm in terms of these.

But, more recently, I am in the middle of a template era, so that I decided
to template my algorithm with these classes (instead of using the base class).
The potential benefit is a more efficient result as all my functionnality
class functions are small and will be usually inlined with a good compiler.
But I have not yet finished the work... Overall, I'm not yet sure of the
benefit of this approach that might lead to a lot of code bloat.... The
potential benefit is having function evaluations inlined which will save a lot
of copies of arrays while preserving a nice and friendly interface for the
user.

Does anyone else can provide some insight ?

    Theo.

 --------------------------------------------------------------------
 Theodore Papadopoulo
 Email: papadop@sophia.inria.fr Tel: (33) 93 65 76 01
 --------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:05 EST