pingspice.circuit.av.AV_Manager(object)
class documentation
Part of pingspice.circuit.av
(View In Hierarchy)
I manage all of your AV
objects. You can
iterate me for all of the AV objects that have been added to me, in
sequence.
Parameters | knowns | Known parameter values. Each entry, keyed by parameter name, contains
either a single known value or a 2-sequence defining a different (usually
tighter) lower and upper bound than your ParameterFinder
subclass does with its f.av calls. (type: dict) |
ID | A specific setup ID I am to start with. Used for unit tests. (type: int) | |
twp | Known twiddle percentage: Set to a non-zero percentage value
to treats knowns as midpoint of range with endpoints +/- supplied
percentage. See the explanation in applyKnowns . (type: float) | |
verbose | Set True to get warnings about known values or lower/upper
bounds being outside the lower/upper bound of the AV object as defined in
its f.av call. Not particularly useful. (type: bool) |
Method | __init__ | AV_Manager(knowns={}, ID=0, twp=None, verbose=False) |
Method | __len__ | My length is the number of AV objects in my avList. |
Method | __iter__ | I can iterate over the AV objects that are in my avLlist when you start the iteration. |
Method | knownParams | Returns a dict of known parameters, keyed by their AV names and each containing the known AV object's default/known value. |
Method | namerator | Generates all my AV objects, each parent and all its children, with the parameter name. |
Method | IDerator | Generates my AV objects associated with the specified setup ID. |
Method | paramerator | Generates the names of my parameter AV objects associated with the specified setup ID. |
Method | setSetupID | Sets the setup ID for all AV objects added hereafter with add . Call
this each time you want to add AV objects for a different setup. |
Method | setRelationships | Sets the relationships of the supplied AV object av
with respect to all others (except av) in my list. |
Method | applyKnowns | Applies any known value or value range from my knowns dict to the supplied av object. |
Method | add | Adds the supplied av object to me for my current setup ID, if I don't have it already. |
Method | addFromCall | Adds the supplied av object to me for my current setup ID,
from a call to an Elements
instance. If it's already been added from another call, makes a copy. |
Method | finalize | Goes over my AV list to ensure that every child of every parent has been
included, both up and down the ancestry chain, even ones that weren't
supplied via a call to add . |
Method | paramsFromText | Returns a dict of parameters with their names and values parsed from the supplied text. Any known parameters are included as well. |
AV_Manager(knowns={}, ID=0, twp=None, verbose=False)
I can iterate over the AV objects that are in my avLlist when you start the iteration.
The iteration does not change if you add or remove AV objects to my avList during it, and doing that does not raise an exception.
Returns a dict of known parameters, keyed by their AV names and each containing the known AV object's default/known value.
Generates all my AV objects, each parent and all its children, with the parameter name.
You can supply an AV object to be excluded.
Generates the names of my parameter AV objects associated with the specified setup ID.
Sets the setup ID for all AV objects added hereafter with add
. Call
this each time you want to add AV objects for a different setup.
Sets the relationships of the supplied AV
object av
with respect to all others (except av) in my list.
The processing is different if av is a parent or child.
Parent AV Object
First, I have the parent av object adopt any orphan
AV
objects having the same name.
Then, if its vbRoot is None
, it's potentially a
parameter AV
object. However, there can only be one
parameter object for each name, so I check for any other same-name parent
with None
as its vbRoot. If I find one (and I only
should find one), I set the supplied av object's vbRoot to
that, preserving the existing AV
object's status as sole
parameter.
As a sanity check, I continue looking through my av list even after
finding an existing parameter AV
object, just to make sure
that there is no second parameter AV object for the name of the
supplied av object. If there is somehow, I raise an exception.
Child AV Object
If av is a child with a parent and a live ValueBasis
,
there's nothing that needs to be done to it. If it's an orphan or its
vb attribute is boolean False
, however, I look
through my list to see if there's a parent of the same name and, if so,
have that parent AV
object adopt it. See AV.adopt
.
A non-orphan child can be "adopted" with no harm done. The
call to AV.adopt
just
has the effect of making sure its vb, index, and
container are all referencing those objects of a same-name
parent.
Applies any known value or value range from my knowns dict to the supplied av object.
If I have a known value (or, more typically, a narrower range of values)
for the name of an AV object, and it's not an orphan, I will call its setVB_known
method with that. I don't do this for an orphan because it will eventually
get its vb attribute set to reference a parent's ValueBasis
.
Including a single value in knowns for a given name will completely exclude AV objects with that name from parameter finding. You usually won't want to do this, because models seldom have parameters that are 100% independent of all others. Freezing a parameter at what looks like an optimum value may seem like a good idea, and it does reduce the Differential Evolution search space, but runs the risk of hanging part of your model onto a local minimum. It's usually better to use the twp constructor keyword and let even seemingly optimal values twiddle around a bit.
Including a range (typically but not necessarily narrower) in knowns for a given name will cause parameter finding to be done for that lower/upper bound rather than the one that was used to define the AV object.
Adds the supplied av object to me for my current setup ID, if I don't have it already.
Later, after you're done adding AV objects to me, you can conduct analyses with a list of altered parameter values. The bounds and transformations of each parameter value will be defined by my AV objects that are not children of other AV objects (and do not have a known value), in the sequence they were added.
If the AV object is not a child of another AV object, it must have a ValueBasis
object with either default or minMax attributes set to define
its acceptable range of values.
Before appending the AV object to my avList, I do the following to it:
-
Apply any known value or (usually tightened) value range for its name,
with a call to
applyKnowns
. -
Associate it with my current setup ID, with a call to the AV object's
associateWith
method. -
Set parent and child relationships affecting it, with a call to
setRelationships
.
Adds the supplied av object to me for my current setup ID,
from a call to an Elements
instance. If it's already been added from another call, makes a copy.
Returns the AV object that was added, original or copy.
Goes over my AV list to ensure that every child of every parent has been
included, both up and down the ancestry chain, even ones that weren't
supplied via a call to add
.
Checks to make sure that I am maintaining a known AV object for each parameter name in my knowns dict that has a definitely known value. For any that are missing, logs a line of text with a warning message.