pingspice.analysis.solver.Solver(AV_ListHolder)
class documentation
Part of pingspice.analysis.solver
(View In Hierarchy)
I solve for an optimum combination of alterable values to minimize the
SSE result of my evaluate
method.
Construct me with an instance of av.AV_Manager
, an instance
of analysis.param.Setups
,
and the number of CPU cores I am to use. I will report on the results as my
iterative solution progresses.
Parameters | popsize | Set to the desired number of ade.Individual objects in the
population per parameter. Otherwise, ADE's default will be used. (Ignored
if picklePath is set.) |
wire | Set True to offload evaluations (except for running callbacks)
onto other Python interpreters that I spawn on this computer for that
purpose. Set to a list of Twisted endpoint TCP descriptions to add workers
on other computers as well. | |
picklePath | The path of a compressed pickle of a previous
ade.population.Population instead, to be loaded and used
instead of constructing and setting up a new one. Its names must match my
list of names. None of its Individual objects should
have values outside the bounds of my AV objects. (Not
checked!) | |
savePicklePath | The path where a compressed pickle of my
ade.population.Population population should be automatically
and periodically saved. When differential_evolution
is used (the default), that happens after each generation. Can be the same
as picklePath, if that is specified. |
Method | __init__ | Solver(cfg, avm, setups, N_cores, wire=False,
popsize=None, logHandle=None, picklePath=None,
savePicklePath=None) |
Method | setup | Sets up my local Evaluator and, unless empty is set
True , my Population. |
Method | shutdown | This should only get called once, by setup
if setup of my Population got aborted or by __call__
when it's done. |
Method | save | Saves a compressed pickle of my present population to a file at picklePath. |
Method | info | Prints info about the supplied sse.Result
object to the log or STDOUT, including the alterations made if in 'chatty'
mode. |
Method | addCallback | Call this to register as a callback a function that accepts a sse.Result
object, as well as any other arguments and keywords you provide. |
Method | runCallbacks | Runs, with the supplied 1-D array of values, all callbacks that
have been registered via my addCallback
method. |
Method | evaluate | This is where it all happens! |
Method | differential_evolution | Runs asynchronous differential evolution to determine parameters for my configuration as defined in the class-level stuff above, and in your subclass. |
Method | hoyle | Idiotic creationist alternative to differential_evolution .
Use this if you don't believe in the power of random mutation and natural
selection. Good luck. |
Method | __call__ | Call your instance of me to get the final population after I have performed all heuristic functions defined in my funcList in succession. |
Inherited from AV_ListHolder:
Method | params | Property: A list of the AV objects in my avList that are parameters. |
Method | avListSorted | Property: A copy of my avList, sorted by each AV object's dmpLabel . If
I have no avList for some reason, returns an empty list. |
Method | __len__ | My length is the number of parameter AV objects in my avList. |
Method | getValuesIndexFor | Returns the index in each values list supplied to my __call__
method at which the one and only parameter AV object is found having the
same name as the supplied av. |
Method | checkValues | Checks the supplied list of values to ensure that I have a parameter AV object for every one, and no parameter AV objects not accounted for. |
Method | alterations | Performs component and device parameter alterations based on the supplied list of parameter values, using the two callables supplied as additional arguments. |
Solver(cfg, avm, setups, N_cores,
wire=False,
popsize=None, logHandle=None,
picklePath=None,
savePicklePath=None)
def setup(self, uniform=False, blank=False, empty=False, skipIDs=[]):
Sets up my local Evaluator and, unless empty is set
True
, my Population.
If I am running with one or more WireWorkers, sets up the
TaskQueue
and various support objects for offloading
evaluation to one or more other Python processes.
Parameters | uniform | Use uniform random variates instead of a Latin hypercube (LHS). Using LHS (the default) is usually better because initializes pseudorandom parameter values with minimal clustering. (Ignored if my Population object p was loaded from a compressed pickle.) |
blank | Set True to give the initial individuals an infinite
placeholder SSE instead of being evaluated. (Ignored if my p was
loaded from a compressed pickle.) | |
empty | Set True to have me start with an empty population. (Ignored
if my p was loaded from a compressed pickle.) | |
skipIDs | An optional list or set of setup IDs to skip. |
Saves a compressed pickle of my present population to a file at picklePath.
Prints info about the supplied sse.Result
object to the log or STDOUT, including the alterations made if in 'chatty'
mode.
Call this to register as a callback a function that accepts a sse.Result
object, as well as any other arguments and keywords you provide.
I will run all the callbacks whenever the population reporter calls my
runCallbacks
method, which I register with it as its own callback.
Runs, with the supplied 1-D array of values, all callbacks that
have been registered via my addCallback
method.
Any function-specific args and kw that were provided in the call to addCallback
are also included after the values.
The primary use of this is displaying a plot of the current best set of parameters.
I add the values and a description of this result to the
sse.Result
object. Before doing any of this, I recompute the SSE with my local
evaluator. If my recomputed SSE differs from the SSE supplied as a third
argument, I complain to ADE by setting my Deferred
return
value to the sse.Result
object from my local re-evaluation instead of running my own callbacks with
it.
def evaluate(self, values, xSSE=None):
This is where it all happens!
"Returns" a Deferred
that fires with the
evaluated SSE. If xSSE is set and the evaluated SSE exceeds it, the
"returned" SSE will be higher but beyond that its value is
meaningless. It's a failed challenge that ade will discard and we
should never see it again anywhere, including in reports.
Runs asynchronous differential evolution to determine parameters for my configuration as defined in the class-level stuff above, and in your subclass.
Returns a Deferred
that fires with a
population
object containing the last generation's population.
You can obtain the all-time best individual by calling the population
object's best
method.
Parameters | genFunc | A callable that takes one argument (the generation number) to be called after each generation. |
def hoyle(self, **kw):
Idiotic creationist alternative to differential_evolution
.
Use this if you don't believe in the power of random mutation and natural
selection. Good luck.
"The chance that higher life forms might have emerged in this way is comparable with the chance that a tornado sweeping through a junk-yard might assemble a Boeing 747 from the materials therein" (Hoyle on evolution, Nature, Vol. 294, No. 5837, Nov. 12, 1981, p. 105).
Yeah, well, just try it and see.
def __call__(self, **kw):
Call your instance of me to get the final population after I have performed all heuristic functions defined in my funcList in succession.
Each function starts with the final population of the previous. The first one initiates its own starting population.