def __init__(self): """ Default Constructor that will initialize member variables with reasonable defaults or empty lists/dictionaries where applicable. @ In, None @ Out, None """ AdaptiveSampler.__init__(self) self._initialValues = { } # dict stores the user provided initial values, i.e. {var: val} self._updateValues = { } # dict stores input variables values for the current MCMC iteration, i.e. {var:val} self._proposal = { } # dict stores the proposal distributions for input variables, i.e. {var:dist} self._priorFuns = { } # dict stores the prior functions for input variables, i.e. {var:fun} self._burnIn = 0 # integers indicate how many samples will be discarded self._likelihood = None # stores the output from the likelihood self._logLikelihood = False # True if the user provided likelihood is in log format self._availProposal = { 'normal': Distributions.Normal(0.0, 1.0), 'uniform': Distributions.Uniform(-1.0, 1.0) } # available proposal distributions self._acceptDist = Distributions.Uniform( 0.0, 1.0) # uniform distribution for accept/rejection purpose self.toBeCalibrated = {} # parameters that will be calibrated # assembler objects self.addAssemblerObject('proposal', InputData.Quantity.zero_to_infinity) self.addAssemblerObject('probabilityFunction', InputData.Quantity.zero_to_infinity)
def __init__(self): """ Constructor. @ In, None @ Out, None """ AdaptiveSampler.__init__(self) ## Instance Variable Initialization # public # _protected self._seed = None # random seed to apply self._minMax = 'min' # maximization or minimization? self._activeTraj = [] # tracks live trajectories self._cancelledTraj = {} # tracks cancelled trajectories, and reasons self._convergedTraj = {} # tracks converged trajectories, and values obtained self._numRepeatSamples = 1 # number of times to repeat sampling (e.g. denoising) self._objectiveVar = None # objective variable for optimization self._initialValues = None # initial variable values (trajectory starting locations), list of dicts self._variableBounds = None # dictionary of upper/lower bounds for each variable (may be inf?) self._trajCounter = 0 # tracks numbers to assign to trajectories self._initSampler = None # sampler to use for picking initial seeds self._constraintFunctions = [] # list of constraint functions self._impConstraintFunctions = [] # list of implicit constraint functions # __private # additional methods self.addAssemblerObject('Constraint', '-1') # Explicit (input-based) constraints self.addAssemblerObject('ImplicitConstraint', '-1') # Implicit constraints self.addAssemblerObject('Sampler', '-1') # This Sampler can be used to initialize the optimization initial points (e.g. partially replace the <initial> blocks for some variables) # register adaptive sample identification criteria self.registerIdentifier('traj') # the trajectory of interest
def __init__(self): """ Default Constructor that will initialize member variables with reasonable defaults or empty lists/dictionaries where applicable. @ In, None @ Out, None """ AdaptiveSampler.__init__(self) self.onlySampleAfterCollecting = True self._initialValues = {} # dict stores the user provided initial values, i.e. {var: val} self._updateValues = {} # dict stores input variables values for the current MCMC iteration, i.e. {var:val} self._proposal = {} # dict stores the proposal distributions for input variables, i.e. {var:dist} self._proposalDist = {} # dist stores the input variables for each proposal distribution, i.e. {distName:[(var,dim)]} self._priorFuns = {} # dict stores the prior functions for input variables, i.e. {var:fun} self._burnIn = 0 # integers indicate how many samples will be discarded self._likelihood = None # stores the output from the likelihood self._logLikelihood = False # True if the user provided likelihood is in log format self._availProposal = {'normal': Distributions.Normal, 'multivariateNormal': Distributions.MultivariateNormal} # available proposal distributions self._acceptDist = Distributions.Uniform(0.0, 1.0) # uniform distribution for accept/rejection purpose self.toBeCalibrated = {} # parameters that will be calibrated self._correlated = False # True if input variables are correlated else False self.netLogPosterior = 0.0 # log-posterior vs iteration self._localReady = True # True if the submitted job finished self._currentRlz = None # dict stores the current realizations, i.e. {var: val} self._acceptRate = 1. # The accept rate for MCMC self._acceptCount = 1 # The total number of accepted samples self._tune = True # Tune the scaling parameter if True self._tuneInterval = 100 # the number of sample steps for each tuning of scaling parameter self._scaling = 1.0 # The initial scaling parameter self._countsUntilTune = self._tuneInterval # The remain number of sample steps until the next tuning self._acceptInTune = 0 # The accepted number of samples for given tune interval self._accepted = False # The indication of current samples, True if accepted otherwise False self._stdProposalDefault = 0.2 # the initial scaling of the std of proposal distribution (only apply to default) # assembler objects self.addAssemblerObject('proposal', InputData.Quantity.zero_to_infinity) self.addAssemblerObject('probabilityFunction', InputData.Quantity.zero_to_infinity)