pymor.parameters.functionals

Module Contents

class pymor.parameters.functionals.BaseMaxThetaParameterFunctional(thetas_prime, thetas, mu_bar, gamma_mu_bar=1.0, name=None)[source]

Bases: ParameterFunctional

Implements 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 ParameterFunctional theta_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 values mu_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 ParameterFunctional of the base bilinear form a which is used for estimation.

thetas_prime

List or tuple of ParameterFunctional of 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

d_mu

Return the functionals's derivative with respect to a given parameter.

evaluate

Evaluate the functional for given parameter values mu.

abstract d_mu(component, index=())[source]

Return the functionals’s derivative with respect to a given parameter.

Parameters

parameter

The Parameter w.r.t. which to return the derivative.

index

Index of the Parameter’s component w.r.t which to return the derivative.

Returns

New ParameterFunctional representing the partial derivative.

evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.

class pymor.parameters.functionals.ConjugateParameterFunctional(functional, name=None)[source]

Bases: ParameterFunctional

Conjugate of a given ParameterFunctional.

Evaluates a given ParameterFunctional and returns the complex conjugate of the value.

Parameters

functional

The ParameterFunctional of which the complex conjugate is taken.

name

Name of the functional.

Methods

d_mu

Return the functionals's derivative with respect to a given parameter.

evaluate

Evaluate the functional for given parameter values mu.

d_mu(parameter, index=0)[source]

Return the functionals’s derivative with respect to a given parameter.

Parameters

parameter

The Parameter w.r.t. which to return the derivative.

index

Index of the Parameter’s component w.r.t which to return the derivative.

Returns

New ParameterFunctional representing the partial derivative.

evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.

class pymor.parameters.functionals.ConstantParameterFunctional(constant_value, name=None)[source]

Bases: ParameterFunctional

ParameterFunctional returning a constant value for each parameter.

Parameters

constant_value

value of the functional

name

Name of the functional.

Methods

d_mu

Return the functionals's derivative with respect to a given parameter.

evaluate

Evaluate the functional for given parameter values mu.

d_mu(parameter, index=0)[source]

Return the functionals’s derivative with respect to a given parameter.

Parameters

parameter

The Parameter w.r.t. which to return the derivative.

index

Index of the Parameter’s component w.r.t which to return the derivative.

Returns

New ParameterFunctional representing the partial derivative.

evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.

class pymor.parameters.functionals.ExpressionParameterFunctional(expression, parameters, name=None, derivative_expressions=None, second_derivative_expressions=None)[source]

Bases: GenericParameterFunctional

Turns a Python expression given as a string into a ParameterFunctional.

Some NumPy arithmetic functions like sin, log, min are supported. For a full list see the functions class attribute.

Warning

eval is 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 Parameters the 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: ParameterFunctional

A wrapper making an arbitrary Python function a ParameterFunctional.

Note that a GenericParameterFunctional can only be pickled if the function it is wrapping can be pickled. For this reason, it is usually preferable to use ExpressionParameterFunctional instead of GenericParameterFunctional.

Parameters

mapping

The function to wrap. The function has signature mapping(mu).

parameters

The Parameters the functional depends on.

name

The name of the functional.

derivative_mappings

A dict containing all partial derivatives of each Parameter and index with the signature derivative_mappings[parameter][index](mu)

second_derivative_mappings

A dict containing all second order partial derivatives of each Parameter and index with the signature second_derivative_mappings[parameter_i][index_i][parameter_j][index_j](mu)

Methods

d_mu

Return the functionals's derivative with respect to a given parameter.

evaluate

Evaluate the functional for given parameter values mu.

d_mu(parameter, index=0)[source]

Return the functionals’s derivative with respect to a given parameter.

Parameters

parameter

The Parameter w.r.t. which to return the derivative.

index

Index of the Parameter’s component w.r.t which to return the derivative.

Returns

New ParameterFunctional representing the partial derivative.

evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.

class pymor.parameters.functionals.LincombParameterFunctional(functionals, coefficients, name=None)[source]

Bases: ParameterFunctional

A ParameterFunctional representing a linear combination of ParameterFunctionals.

The coefficients must be provided as scalars.

Parameters

functionals

List of ParameterFunctionals whose linear combination is formed.

coefficients

A list of scalar coefficients.

name

Name of the functional.

functionals[source]
coefficients[source]

Methods

d_mu

Return the functionals's derivative with respect to a given parameter.

evaluate

Evaluate the functional for given parameter values mu.

d_mu(parameter, index=0)[source]

Return the functionals’s derivative with respect to a given parameter.

Parameters

parameter

The Parameter w.r.t. which to return the derivative.

index

Index of the Parameter’s component w.r.t which to return the derivative.

Returns

New ParameterFunctional representing the partial derivative.

evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.

class pymor.parameters.functionals.MaxThetaParameterFunctional(thetas, mu_bar, gamma_mu_bar=1.0, name=None)[source]

Bases: BaseMaxThetaParameterFunctional

ParameterFunctional implementing 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 values mu_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 ParameterFunctional

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: ParameterFunctional

ParameterFunctional implementing 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 ParameterFunctional theta_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 values mu_bar and the constant alpha_mu_bar, this functional thus evaluates to

alpha_mu_bar * min_{q = 1}^Q theta_q(mu)/theta_q(mu_bar)

Parameters

thetas

List or tuple of ParameterFunctional

mu_bar

Parameter associated with alpha_mu_bar.

alpha_mu_bar

Known coercivity constant.

name

Name of the functional.

Methods

evaluate

Evaluate the functional for given parameter values mu.

evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.

class pymor.parameters.functionals.ParameterFunctional[source]

Bases: pymor.parameters.base.ParametricObject

Interface for Parameter functionals.

A parameter functional is simply a function mapping Parameters to a number.

Methods

d_mu

Return the functionals's derivative with respect to a given parameter.

evaluate

Evaluate the functional for given parameter values mu.

d_mu(parameter, index=0)[source]

Return the functionals’s derivative with respect to a given parameter.

Parameters

parameter

The Parameter w.r.t. which to return the derivative.

index

Index of the Parameter’s component w.r.t which to return the derivative.

Returns

New ParameterFunctional representing the partial derivative.

abstract evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.

class pymor.parameters.functionals.ProductParameterFunctional(factors, name=None)[source]

Bases: ParameterFunctional

Forms the product of a list of ParameterFunctionals or numbers.

Parameters

factors

A list of ParameterFunctionals or numbers.

name

Name of the functional.

Methods

d_mu

Return the functionals's derivative with respect to a given parameter.

evaluate

Evaluate the functional for given parameter values mu.

d_mu(parameter, index=0)[source]

Return the functionals’s derivative with respect to a given parameter.

Parameters

parameter

The Parameter w.r.t. which to return the derivative.

index

Index of the Parameter’s component w.r.t which to return the derivative.

Returns

New ParameterFunctional representing the partial derivative.

evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.

class pymor.parameters.functionals.ProjectionParameterFunctional(parameter, size=1, index=None, name=None)[source]

Bases: ParameterFunctional

ParameterFunctional returning a component value of the given parameter.

For given parameter map mu, this functional evaluates to

mu[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

d_mu

Return the functionals's derivative with respect to a given parameter.

evaluate

Evaluate the functional for given parameter values mu.

d_mu(parameter, index=0)[source]

Return the functionals’s derivative with respect to a given parameter.

Parameters

parameter

The Parameter w.r.t. which to return the derivative.

index

Index of the Parameter’s component w.r.t which to return the derivative.

Returns

New ParameterFunctional representing the partial derivative.

evaluate(mu=None)[source]

Evaluate the functional for given parameter values mu.