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 inrb_greedy
.Not intended to be used directly.
- 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 aRemoteObject
.- return_all_values
See below.
Returns
If
return_all_values
isTrue
, anNumPy array
of the estimated errors. Ifreturn_all_values
isFalse
, the maximum estimated error as first return value and the corresponding parameter as second return value.
- class pymor.algorithms.greedy.WeakGreedySurrogate[source]¶
Bases:
pymor.core.base.BasicObject
Surrogate for the approximation error in
weak_greedy
.- 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 aRemoteObject
.- return_all_values
See below.
Returns
If
return_all_values
isTrue
, anNumPy array
of the estimated errors. Ifreturn_all_values
isFalse
, the maximum estimated error as first return value and the corresponding parameter as second return value.
- 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 areduce
method, such thatreductor.reduce()
yields the reduced model, and anexted_basis
method, such thatreductor.extend_basis(U, copy_U=False, **extension_params)
extends the current reduced basis by the vectors contained inU
. For an example seeCoerciveRBReductor
.- 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 offom
for allparameter 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
isFalse
, use this function to calculate the norm of the error. IfNone
, 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 thereductor.extend_basis
method. IfNone
,'gram_schmidt'
basis extension will be used as a default for stationary problems (fom.solve
returnsVectorArrays
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 aftermax_extensions
extension steps.- pool
If not
None
, aWorkerPool
to use for parallelization. Parallelization needs to be supported bysurrogate
.
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.