New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add compute() to Model #1113
add compute() to Model #1113
Conversation
For me this looks very good. |
Since the |
Done. |
This should now be ready to be merged. |
Codecov Report
|
I meant this part:
|
Right .. |
With this PR,
Model
gets a newcompute
method which realizes the computation of the model's solution and of derived quantities such as outputs or error estimates.solve
,output
andestimate_error
are implemented by callingcompute
with appropriate arguments.By relying on a central method, we can avoid having to pass computed values from the outside, e.g. the solution to
estimate_error
. (Note that it might depend on theModel
which values have to be passed.)compute
returns a dict of all computed values.solve
, etc. remain as convenience methods.compute
can be easily extended to return further quantities of interest. E.g. an optionalstages
argument might indicate to return intermediate Newton stages as an additional item of the return value.Model.compute
has a default implementation which relays individual computational tasks to dedicated_compute_solution
,_compute_output
, etc. methods which allow to more easily customizecompute
when subclassing. Before these methods are called_compute
is called in which, e.g., simultaneous solution and output computation can be realized. For values that already have been computed, the respective_compute_...
methods will then be skipped.The signature of
compute
should stay stable for the foreseeable future. The base class implementation may change in the future.I decided to keep automatic caching of the solution in the default implementation of
compute
. In particular, for models using_compute_solution
, a call tom.output(mu)
will not trigger an additional solution of the model, whenm.solve(mu)
has been called before for the samemu
and caching is enabled.The
solve_d_mu
andoutput_d_mu
methods from Towards linear optimization (dual problem, sensitivity problem, output gradient) #1110 will also make use ofcompute
.See discussion in #1095.
Documentation still needs to be updated.
@pymor/pymor-devs, @HenKlei, @TiKeil, while not much has changed internally, this PR will significantly affect the user expercience. Please take a close look.