You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In developing a Simulation class in SimPEG (simpeg/simpeg#672), I want to be able to readily serialize and deserialize an instance of a Simulation, so we are injecting properties throughout, which gives us serialization, deserialization and validation (thanks @fwkoch!!). Right now, the solvers are attached as the simulation as a class, and the solver_opts are attached to the simulation as a dict. We then instantiate a solver as needed in SimPEG.
State the problem
There are a couple potential snags with this approach
if your solver_opts are not valid, we won't find out until we try and use the solver
It is not readily clear how to serialize the solver class (a Class property is one option New Class property seequent/properties#163, we could also think about serializing / deserializing the name of the class as a string)
Another approach?
We could instantiate the solver with its options and then call it to create Ainv. This would solve the serialization problem and also allow immediate validation of the solver options on its creation.
classBase(properties.HasProperties):
check_accuracy=properties.Bool(
"check the accuracy of the solve?",
default=False
)
accuracy_tol=properties.Float(
"tolerance on the accuracy of the solver",
default=1e-6
)
def__init__(self, **kwargs):
super(Base, self).__init__(**kwargs)
def__call__(self, A):
self.A=A.tocsr()
There are a couple impacts of this within SimPEG. The one that comes to mind is:
right now in the inversion, if a solver is not set for the data misfit, we use the same one as on the simulation, here we would likely want to make a copy of the instance, rather than re-use the same instance (so that factors are not cleared)
The text was updated successfully, but these errors were encountered:
Motivation
In developing a
Simulation
class in SimPEG (simpeg/simpeg#672), I want to be able to readily serialize and deserialize an instance of aSimulation
, so we are injectingproperties
throughout, which gives us serialization, deserialization and validation (thanks @fwkoch!!). Right now, the solvers are attached as the simulation as a class, and the solver_opts are attached to the simulation as a dict. We then instantiate a solver as needed inSimPEG
.State the problem
There are a couple potential snags with this approach
solver_opts
are not valid, we won't find out until we try and use the solversolver
class (aClass
property is one option New Class property seequent/properties#163, we could also think about serializing / deserializing the name of the class as a string)Another approach?
We could instantiate the solver with its options and then call it to create Ainv. This would solve the serialization problem and also allow immediate validation of the solver options on its creation.
so the base class might look like:
There are a couple impacts of this within SimPEG. The one that comes to mind is:
The text was updated successfully, but these errors were encountered: