Parameters

class decida.Parameters.Parameters(parent=None, specs=None, **kwargs)

Bases: decida.ItclObjectx.ItclObjectx

synopsis:

Parameter set manager class.

Parameters manages a set of instances of the Parameter class. Each Parameter instance has associated current value and ranges.

LevMar and Fitter use the Parameters instance to manage the optimization.

constructor arguments:

**kwargs (dict)

keyword=value specifications: configuration-options

configuration options:

verbose (bool, default=False)

If verbose is True, print more information if available.

gui (bool, default=True)

flag to indicate that a Parameters graphical user-interface should be displayed. Not currently implemented

example (from test_Parameters):

from decida.Parameters import Parameters
#-----------------------------------------------------------------
# specs:
# name, initial_value, include,
#     lower_limited, upper_limited, lower_limit, upper_limit
#-----------------------------------------------------------------
parobj = Parameters(specs=(
   ("L" , 150e-12, True, True, False, 0.0, 0.0),
   ("Co", 250e-15, True, True, False, 0.0, 0.0),
   ("Cu", 120e-15, True, True, False, 0.0, 0.0),
   ("C1",  25e-15, True, True, False, 0.0, 0.0),
   ("C2",  30e-15, True, True, False, 0.0, 0.0),
))
parobj.show("L")
parobj.modify("L", tied="1.0/(math.pow(2*math.pi*10e9,2)*Co)")
parobj.values([L,Co,Cu,C1,C2])
parobj.show("L")

public methods:

  • public methods from ItclObjectx

  • indexing:

    • <parameters_object>[“<parameter_name>”] returns the
      current value of the parameter named <parameter_name>
    • <parameters_object>[“<config_option>”] returns the
      value of the configuration option named <config_option>
    • <parameters_object>[“<parameter_name>”]=<value> sets the
      current value of the parameter named <parameter_name> to <value>
    • <parameters_object>[“<config_option>”]=<value> sets the
      value of the configuration option named <config_option> to <value>
  • length:

    • len(<parameters_object>) returns the number of parameters in the parameter set.
  • parameter-attributes :

    • each parameter instance has the following attributes, many which pertain only to Levenberg-Marquardt optimization:

      attribute: default value: description:
      initial_value 0.0 first value of parameter
      current_value 0.0 current value of parameter
      include True parameter is not fixed
      lower_limited True parameter has a lower-limit
      lower_limit 0.0 the lower-limit
      upper_limited False parameter has an upper-limit
      upper_limit 0.0 the upper-limit
      step 0.0 absolute step for derivatives
      relative_step 0.0 relative step for derivatives
      side 1 side to take derivatives: 1=forward, -1=reverse 2=two-sided
      minstep 0.0 minimum iteration step (not used)
      maxstep 0.0 maximum iteration step
      tied “” expression to tie parameter with other parameters
      print True print parameter value at each iteration
  • parameter-conditions:

    • parameters can be checked for the following conditions:
    condition: description:
    fixed parameter is not allowed to vary
    included parameter is allowed to vary (free or tied)
    tied parameter is tied others by an expression
    untied not tied
    free parameter is allowed to vary
    limited parameter is limited (upper or lower)
    step_limited value of parameter change for one iteration is limited
    at_upper_limit parameter current value is at upper-limit
    at_lower_limit parameter current value is at lower-limit
    within_limits parameter current value is within limits
    correct_limits parameter upper_limit > lower_limit
    correct_step_limits parameter maxstep > minstep
add(par, **kwargs)

add a parameter and specifications to the parameter set.

arguments:

par (str)

parameter name to add.

**kwargs (dict):

<attribute>=<value> specifications for the parameter

results:

  • The parameter set is appended with par.
  • The attributes of the parameter are set to specified values.
check(par, condition, verbose=False)

check a parameter condition.

arguments:

par (str)

parameter to check

condition (str)

parameter condition to check

verbose (bool, default=False)

enable or disable verbose mode.

results:

  • if condition is True for parameter par, return True, else False.
check_any_free_limited()

check whether any free parameters are limited.

results:

  • Check to see if any free parameters are limited.
check_any_free_step_limited()

check whether any free parameters are step limited.

results:

  • Check to see if any free parameters are step limited.
check_correct_limits()

check whether parameter limits are consistent.

results:

  • Check to see if all parameters have attributes lower_limit < upper_limit.
check_correct_step_limits()

check whether parameter step limits are consistent.

results:

  • Check to see if all parameters have attributes minstep < maxstep.
check_within_limits()

check whether parameter current value is within limits.

results:

  • Check to see if all parameters have current value within the range lower_limit, upper_limit, if the parameter is limited.
free_indices()
return list of parameter indices for paramteres that
are free to vary.

results:

  • Returns a list of indices (within the parameter set) of parameters that have the attribute “free”.
free_pars()

return list of parameters that are free to vary.

results:

  • Returns a list of parameters that have the attribute “free”.
free_values(values=None)

set or return free parameter values.

arguments:

values (list or tuple, default=None)

list of values to set free parameters current value attribute. if values is not specified, return a list of free parameter current values.

results:

  • Every free parameter current value is set to a value in the value list, if values is specified.
  • If values is not specified, return the list of free parameter current values.
list_of_attr(condition)

return bool list of checked condition for each parameter.

arguments:

condition (str)

condition string for checking parameter set.

results:

  • Returns list of boolean values for whether or not the condition is met by each parameter.
list_of_pars(condition)

return list of parameters with condition.

arguments:

condition (str)

condition string for filtering parameter set.

results:

  • parameter list is returned with pars with condition True.
modify(par, **kwargs)

modify a parameter’s attributes

arguments:

par (str)

parameter name to modify.

**kwargs (dict)

<attribute>=<value> specifications for the parameter

results:

  • The attributes of the parameter are modified.
pars()

return parameter names.

results:

  • list of parameter names in the parameter set is returned.
reset()

reset all parameters to initial values

results:

  • parameters are reset to initial values.
show(par=None)

show parameters and attributes.

arguments:

par (str, default=None)

parameter name to show. If not specified, all parameters are shown.

results:

  • parameter name and attributes of the specified parameter, or all parameters if par is not specified, are displayed.
values(values=None)

set or return parameter values.

arguments:

values (list or tuple, default=None)

list of values to set parameters current value attribute. if values is not specified, return a list of parameter current values.

results:

  • Every parameter current value is set to a value in the value list, if values is specified.
  • If values is not specified, return the list of parameter current values.