pymor.parameters.functionals¶
Module Contents¶
- class pymor.parameters.functionals.BaseMaxThetaParameterFunctional(thetas_prime, thetas, mu_bar, gamma_mu_bar=1.0, name=None)[source]¶
Bases:
ParameterFunctionalImplements a generalization of the max-theta approach from [Haa17] (Exercise 5.12).
Let V denote a Hilbert space and let a: V x V -> K denote a continuous bilinear form or l: V -> K a continuous linear functional, either with affine decomposition
a(u, v, mu) = sum_{q = 1}^Q theta_q(mu) a_q(u, v)
or
l(v, mu) = sum_{q = 1}^Q theta_q(mu) l_q(v)
for Q coefficient
ParameterFunctionaltheta_1, …, theta_Q and continuous bilinear forms a_1, …, a_Q: V x V -> K or continuous linear functionals l_q: V -> K. Let mu_bar be a parameter with respect to which the continuity constant of a(., ., mu_bar) or l(., mu_bar) is known, i.e. we known gamma_mu_bar > 0, s.t.a(u, v, mu_bar) <= gamma_mu_bar |u|_V |v|_V
or:
l(v, mu_bar) <= gamma_mu_bar |v|_V.
The max-theta approach (in its generalized form) from [Haa17] (Exercise 5.12) allows to obtain a computable bound for the continuity constant of another bilinear form a_prime(., ., mu) or linear form l_prime(., mu) with the same affine decomposition but different theta_prime_q for arbitrary parameters mu, since
a_prime(u, v, mu=mu) <= |max_{q = 1}^Q theta_prime_q(mu)/theta_q(mu_bar)| |a(u, v, mu=mu_bar)|
or
l_prime(v, mu=mu) <= |max_{q = 1}^Q theta_prime_q(mu)/theta_q(mu_bar)| |l(v, mu=mu_bar)|,
if all theta_q(mu_bar) != 0.
Given a list of the thetas, the
parameter valuesmu_bar and the constant gamma_mu_bar, this functional thus evaluates to|gamma_mu_bar * max_{q = 1}^Q theta_prime_q(mu)/theta_q(mu_bar)|
Note that we also get an upper bound if theta_prime_q(mu) == 0 for any q. However, if theta_prime_q(mu) == 0 for at least one q, we need to use the absolute value in the denominator, i.e.
|gamma_mu_bar * max_{q = 1}^Q theta_prime_q(mu)/|theta_q(mu_bar)| |
- Parameters:
thetas – List or tuple of
ParameterFunctionalof the base bilinear form a which is used for estimation.thetas_prime – List or tuple of
ParameterFunctionalof the bilinear form a_prime for the numerator of the MaxThetaParameterFunctional.mu_bar – Parameter associated with gamma_mu_bar.
gamma_mu_bar – Known continuity constant of the base bilinear form a.
name – Name of the functional.
Methods
Return the functionals's derivative with respect to a given parameter.
Evaluate the functional for given
parameter valuesmu.- abstract d_mu(component, index=())[source]¶
Return the functionals’s derivative with respect to a given parameter.
- evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.
- class pymor.parameters.functionals.ConjugateParameterFunctional(functional, name=None)[source]¶
Bases:
ParameterFunctionalConjugate of a given
ParameterFunctional.Evaluates a given
ParameterFunctionaland returns the complex conjugate of the value.- Parameters:
functional – The
ParameterFunctionalof which the complex conjugate is taken.name – Name of the functional.
Methods
Return the functionals's derivative with respect to a given parameter.
Evaluate the functional for given
parameter valuesmu.- d_mu(parameter, index=0)[source]¶
Return the functionals’s derivative with respect to a given parameter.
- evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.
- class pymor.parameters.functionals.ConstantParameterFunctional(constant_value, name=None)[source]¶
Bases:
ParameterFunctionalParameterFunctionalreturning a constant value for each parameter.- Parameters:
constant_value – value of the functional
name – Name of the functional.
Methods
Return the functionals's derivative with respect to a given parameter.
Evaluate the functional for given
parameter valuesmu.- d_mu(parameter, index=0)[source]¶
Return the functionals’s derivative with respect to a given parameter.
- evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.
- class pymor.parameters.functionals.ExpressionParameterFunctional(expression, parameters, name=None, derivative_expressions=None, second_derivative_expressions=None)[source]¶
Bases:
GenericParameterFunctionalTurns a Python expression given as a string into a
ParameterFunctional.Some
NumPyarithmetic functions likesin,log,minare supported. For a full list see thefunctionsclass attribute.Warning
evalis used to evaluate the given expression. Using this class with expression strings from untrusted sources will cause mayhem and destruction!- Parameters:
expression – A Python expression in the parameter components of the given
parameters.parameters – The
Parametersthe functional depends on.name – The name of the functional.
derivative_expressions – A dict containing a Python expression for the partial derivatives of each parameter component.
second_derivative_expressions – A dict containing a list of dicts of Python expressions for all second order partial derivatives of each parameter component i and j.
- class pymor.parameters.functionals.GenericParameterFunctional(mapping, parameters, name=None, derivative_mappings=None, second_derivative_mappings=None)[source]¶
Bases:
ParameterFunctionalA wrapper making an arbitrary Python function a
ParameterFunctional.Note that a GenericParameterFunctional can only be
pickledif the function it is wrapping can be pickled. For this reason, it is usually preferable to useExpressionParameterFunctionalinstead ofGenericParameterFunctional.- Parameters:
mapping – The function to wrap. The function has signature
mapping(mu).parameters – The
Parametersthe functional depends on.name – The name of the functional.
derivative_mappings – A dict containing all partial derivatives of each
Parameterand index with the signaturederivative_mappings[parameter][index](mu)second_derivative_mappings – A dict containing all second order partial derivatives of each
Parameterand index with the signaturesecond_derivative_mappings[parameter_i][index_i][parameter_j][index_j](mu)
Methods
Return the functionals's derivative with respect to a given parameter.
Evaluate the functional for given
parameter valuesmu.- d_mu(parameter, index=0)[source]¶
Return the functionals’s derivative with respect to a given parameter.
- evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.
- class pymor.parameters.functionals.LincombParameterFunctional(functionals, coefficients, name=None)[source]¶
Bases:
ParameterFunctionalA
ParameterFunctionalrepresenting a linear combination ofParameterFunctionals.The coefficients must be provided as scalars.
- Parameters:
functionals – List of
ParameterFunctionalswhose linear combination is formed.coefficients – A list of scalar coefficients.
name – Name of the functional.
Methods
Return the functionals's derivative with respect to a given parameter.
Evaluate the functional for given
parameter valuesmu.- d_mu(parameter, index=0)[source]¶
Return the functionals’s derivative with respect to a given parameter.
- evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.
- class pymor.parameters.functionals.MaxThetaParameterFunctional(thetas, mu_bar, gamma_mu_bar=1.0, name=None)[source]¶
Bases:
BaseMaxThetaParameterFunctionalParameterFunctionalimplementing the max-theta approach from [Haa17] (Exercise 5.12).This is a specialized version of BaseMaxThetaParameterFunctional which allows to obtain a computable bound for the continuity constant of the actual a(., ., mu) or l(., mu) for arbitrary parameters mu, since
a(u, v, mu=mu) <= |max_{q = 1}^Q theta_q(mu)/theta_q(mu_bar)| |a(u, v, mu=mu_bar)|
or
l(v, mu=mu) <= |max_{q = 1}^Q theta_q(mu)/theta_q(mu_bar)| |l(v, mu=mu_bar)|,
if all theta_q(mu_bar) != 0.
Given a list of the thetas, the
parameter valuesmu_bar and the constant gamma_mu_bar, this functional thus evaluates to|gamma_mu_bar * max{q = 1}^Q theta_q(mu)/theta_q(mu_bar)|
- Parameters:
thetas – List or tuple of
ParameterFunctionals.mu_bar – Parameter associated with gamma_mu_bar.
gamma_mu_bar – Known continuity constant.
name – Name of the functional.
- class pymor.parameters.functionals.MinThetaParameterFunctional(thetas, mu_bar, alpha_mu_bar=1.0, name=None)[source]¶
Bases:
ParameterFunctionalParameterFunctionalimplementing the min-theta approach from [Haa17] (Prop. 2.35).Let V denote a Hilbert space and let a: V x V -> K denote a parametric coercive bilinear form with affine decomposition
a(u, v, mu) = sum_{q = 1}^Q theta_q(mu) a_q(u, v),
for Q positive coefficient
ParameterFunctionaltheta_1, …, theta_Q and positive semi-definite component bilinear forms a_1, …, a_Q: V x V -> K. Let mu_bar be a parameter with respect to which the coercivity constant of a(., ., mu_bar) is known, i.e. we known alpha_mu_bar > 0, s.t.alpha_mu_bar |u|_V^2 <= a(u, u, mu=mu_bar).
The min-theta approach from [Haa17] (Proposition 2.35) allows to obtain a computable bound for the coercivity constant of a(., ., mu) for arbitrary parameters mu, since
a(u, u, mu=mu) >= min_{q = 1}^Q theta_q(mu)/theta_q(mu_bar) a(u, u, mu=mu_bar).
Given a list of the thetas, the
parameter valuesmu_bar and the constant alpha_mu_bar, this functional thus evaluates toalpha_mu_bar * min_{q = 1}^Q theta_q(mu)/theta_q(mu_bar)
- Parameters:
thetas – List or tuple of
ParameterFunctionals.mu_bar – Parameter associated with alpha_mu_bar.
alpha_mu_bar – Known coercivity constant.
name – Name of the functional.
Methods
Evaluate the functional for given
parameter valuesmu.- evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.
- class pymor.parameters.functionals.ParameterFunctional[source]¶
Bases:
pymor.parameters.base.ParametricObjectInterface for
Parameterfunctionals.A parameter functional is simply a function mapping
Parametersto a number.Methods
Return the functionals's derivative with respect to a given parameter.
Evaluate the functional for given
parameter valuesmu.- d_mu(parameter, index=0)[source]¶
Return the functionals’s derivative with respect to a given parameter.
- abstract evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.
- class pymor.parameters.functionals.ProductParameterFunctional(factors, name=None)[source]¶
Bases:
ParameterFunctionalForms the product of a list of
ParameterFunctionalsor numbers.- Parameters:
factors – A list of
ParameterFunctionalsor numbers.name – Name of the functional.
Methods
Return the functionals's derivative with respect to a given parameter.
Evaluate the functional for given
parameter valuesmu.- d_mu(parameter, index=0)[source]¶
Return the functionals’s derivative with respect to a given parameter.
- evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.
- class pymor.parameters.functionals.ProjectionParameterFunctional(parameter, size=1, index=None, name=None)[source]¶
Bases:
ParameterFunctionalParameterFunctionalreturning a component value of the given parameter.For given parameter map
mu, this functional evaluates tomu[parameter][index]
- Parameters:
parameter – The name of the parameter to return.
size – The size of the parameter.
index – See above.
name – Name of the functional.
Methods
Return the functionals's derivative with respect to a given parameter.
Evaluate the functional for given
parameter valuesmu.- d_mu(parameter, index=0)[source]¶
Return the functionals’s derivative with respect to a given parameter.
- evaluate(mu=None)[source]¶
Evaluate the functional for given
parameter valuesmu.