← Back to team overview

libadjoint team mailing list archive

Re: r379

 

> To me, a Constant just means that it is "constant in space and time".
> Doesn't mean it's exactly known, or not variable from one model run
> to another. For example, in the mantle, the exact Rayleigh number isn't
> known -- it makes good sense for it to be a Constant in the model, but
> optimised as part of the assimilation.

I understand your example but I am still not convinced that Constant
is the right choice here.
To me, Constant is just a special case for an Expression; therefore
even though it is constant in
time and space, it is not a scalar value but a non-discretised
function in space (the documentation
says: "Create constant-valued function with given value."). This is
also reflected by the fact that there
 exists a Constant.eval((x, y)) function to evaluate the Constant at a
particular point in space.

Now, let's use the fact that the type of the Parameter and the
gradient are always the same.
Therefore, the gradient of a Constant is a non-discretised function in
space, hence an Expression
(note that it in general it will not be a Constant).

So I think the current ScalarParameter implementation
has some issues: First ScalarParameter is a misleading name (maybe
ConstantParameter or
ExpressionParameter). Second the gradient of a ScalarParameter should
not return a single number
but an Expression. Third I have no good idea how this gradient
Expression can be computed. In my
opinion, the main difficulty is the fact that Constant/Expression are
non-discretised functions that can
be written as a compact analytical format (e.g. 1.0 or sin(x)).
However, the gradient will in general not
be representable in a compact analytical format and so I do not see a
nice way to fix this.

On the other side, a Real function is a scalar, so this is what you
really want in your Rayleigh example.
The resulting gradient will therefore be a scalar as well as expected.

To make a long story short, I think we can only compute gradients with
respect to dicretised objects -
and that is not the case for Constant/Expression objects.


Follow ups

References