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

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]
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

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]
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_params

dict 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

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 associated with a training set of parameters by iteratively evaluating a surrogate for the approximation error on the training set and adding the worst approximated vector (according to the surrogate) to the basis.

The constructed basis is extracted from the surrogate 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

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.