pymor.algorithms.greedy

Module Contents

class pymor.algorithms.greedy.RBSurrogate(fom, reductor, use_error_estimator, error_norm, extension_params, pool)[source]

Bases: WeakGreedySurrogate

Surrogate for the weak_greedy error used in rb_greedy.

Not intended to be used directly.

Methods

evaluate

Evaluate the surrogate for given parameters.

extend

Extend the approximation basis.

evaluate(mus, return_all_values=False)[source]

Evaluate the surrogate for given parameters.

Parameters:
  • mus – List of parameters for which to estimate the approximation error. When parallelization is used, mus can be a RemoteObject.

  • return_all_values – See below.

Returns:

  • If return_all_values is True, an NumPy array of the estimated errors.

  • If return_all_values is False, the maximum estimated error as first

  • return value and the corresponding parameter as second return value.

extend(mu)[source]

Extend the approximation basis.

Parameters:

mu – A parameter from the training_set for which to add the corresponding vector \(v_\mu\) to the approximation basis.

class pymor.algorithms.greedy.WeakGreedySurrogate[source]

Bases: pymor.core.base.BasicObject

Surrogate for the approximation error in weak_greedy.

Methods

evaluate

Evaluate the surrogate for given parameters.

extend

Extend the approximation basis.

abstract evaluate(mus, return_all_values=False)[source]

Evaluate the surrogate for given parameters.

Parameters:
  • mus – List of parameters for which to estimate the approximation error. When parallelization is used, mus can be a RemoteObject.

  • return_all_values – See below.

Returns:

  • If return_all_values is True, an NumPy array of the estimated errors.

  • If return_all_values is False, the maximum estimated error as first

  • return value and the corresponding parameter as second return value.

abstract extend(mu)[source]

Extend the approximation basis.

Parameters:

mu – A parameter from the training_set for which to add the corresponding vector \(v_\mu\) to the approximation basis.

pymor.algorithms.greedy.rb_greedy(fom, reductor, training_set, use_error_estimator=True, error_norm=None, atol=None, rtol=None, max_extensions=None, extension_params=None, pool=None)[source]

Weak Greedy basis generation using the RB approximation error as surrogate.

This algorithm generates a reduced basis using the weak greedy algorithm [BCD+11], where the approximation error is estimated from computing solutions of the reduced order model for the current reduced basis and then estimating the model reduction error.

Parameters:
  • fom – The Model to reduce.

  • reductor – Reductor for reducing the given Model. This has to be an object with a reduce method, such that reductor.reduce() yields the reduced model, and an exted_basis method, such that reductor.extend_basis(U, copy_U=False, **extension_params) extends the current reduced basis by the vectors contained in U. For an example see CoerciveRBReductor.

  • training_set – The training set of Parameters on which to perform the greedy search.

  • use_error_estimator – If False, exactly compute the model reduction error by also computing the solution of fom for all parameter values of the training set. This is mainly useful when no estimator for the model reduction error is available.

  • error_norm – If use_error_estimator is False, use this function to calculate the norm of the error. If None, the Euclidean norm is used.

  • atol – See weak_greedy.

  • rtol – See weak_greedy.

  • max_extensions – See weak_greedy.

  • extension_paramsdict of parameters passed to the reductor.extend_basis method. If None, 'gram_schmidt' basis extension will be used as a default for stationary problems (fom.solve returns VectorArrays of length 1) and 'pod' basis extension (adding a single POD mode) for instationary problems.

  • pool – See weak_greedy.

Returns:

data – Dict with the following fields:

rom:

The reduced Model obtained for the computed basis.

max_errs:

Sequence of maximum errors during the greedy run.

max_err_mus:

The parameters corresponding to max_errs.

extensions:

Number of performed basis extensions.

time:

Total runtime of the algorithm.

pymor.algorithms.greedy.weak_greedy(surrogate, training_set, atol=None, rtol=None, max_extensions=None, pool=None)[source]

Weak greedy basis generation algorithm [BCD+11].

This algorithm generates an approximation basis for a given set of vectors

\[\mathcal{M} := \{v_{\mu} \,|\, \mu \in \mathcal{S}_{\text{train}}\}.\]

In each iteration of the algorithm, a vector \(v_{\mu^*}\) from \(\mathcal{M}\) is determined which maximizes the estimated best-approxmiation error w.r.t. the current basis. Then, the basis is extended with \(v_{\mu^*}\).

The algorithm expects a surrogate, which can estimate the best-approximation error for any given \(v_\mu\), \(\mu \in \mathcal{S}_{\text{train}}\), where the training_set \(\mathcal{S}_{\text{train}}\) is a list of arbitrary Python objects (not necessarily Mu instances). Further the surrogate needs to be able to extend the approximation basis with \(v_\mu\) for any given \(\mu \in \mathcal{S}_{\text{train}}\).

The constructed basis has to be extracted from the surrogate by the user after termination of the algorithm.

Parameters:
  • surrogate – An instance of WeakGreedySurrogate representing the surrogate for the approximation error.

  • training_set – The set of (parameter) samples on which to perform the greedy search.

  • atol – If not None, stop the algorithm if the maximum (estimated) error on the training set drops below this value.

  • rtol – If not None, stop the algorithm if the maximum (estimated) relative error on the training set drops below this value.

  • max_extensions – If not None, stop the algorithm after max_extensions extension steps.

  • pool – If not None, a WorkerPool to use for parallelization. Parallelization needs to be supported by surrogate.

Returns:

data – Dict with the following fields:

max_errs:

Sequence of maximum estimated errors during the greedy run.

max_err_mus:

The parameters corresponding to max_errs.

extensions:

Number of performed basis extensions.

time:

Total runtime of the algorithm.