Abstract base Driver Class, follow up from #350
Created by: PhilipVinc
@femtobit , @gcarleo This is a branched version of #350, (rebased on master, BTW). Since it changes quite a few things, I did not want to push to your branch.
Major changes compared to @femtobit PR are.
- I created a Base Abstract Class
AbstractVariationalMonteCarlo
(name to be bikeshedded) which handles most IO, observables, run, iter.- Subclasses should implement the methods
advance(self, n_steps)
estimate_stats(self, operator)
info(self, depth)
- Subclasses should implement the methods
All subclasses should then happily inherit all fancy functionality like Json output, progress bars, handling of observables...
-
I moved QSR, SteadyState and VMC to be sublcasses of the base class. We could in principle move more common stuff to the base class (sampler, machines...) but I'm not sure it's worth it.
-
If there is a quantity that is iteratively minimised, as in the case of VMC/Steadystate, then simply keeping
self._stats
up to date (As we currently do) will update the progress bar display and the JSON output. When this is null (as in QSR) this data is not printed/used.
Minor changes:
- I moved all JSON logic to another file
- I moved all
create_optimizer_fun
to another file, since they were now tri-plicated - I implemented a very trivial
pytree_map
in pure python that handles lists and dicts. It can surely be improved.
I briefly tested this with netket.variational.Vmc
and netket.variational.steadystate
and it seems to work. If you like this setup, I could finish up the tests...
Moreover, I have not yet modified variational.py
and netket.Vmc
(as I think it will be deprecated). Making it a different constructor to netket.variational.Vmc
seems the easier way to keep this deprecation around while reducing duplicated code.