Example #1
0
    def __init__(self):
        """
      Default Constructor that will initialize member variables with reasonable
      defaults or empty lists/dictionaries where applicable.
      @ In, None
      @ Out, None
    """
        BaseType.__init__(self)
        Assembler.__init__(self)
        self.counter = 0  # Counter of the samples performed (better the input generated!!!). It is reset by calling the function self.initialize
        self.auxcnt = 0  # Aux counter of samples performed (for its usage check initialize method)
        self.limit = sys.maxsize  # maximum number of Samples (for example, Monte Carlo = Number of HistorySet to run, DET = Unlimited)
        self.toBeSampled = {
        }  # Sampling mapping dictionary {'Variable Name':'name of the distribution'}
        self.dependentSample = {
        }  # Sampling mapping dictionary for dependent variables {'Variable Name':'name of the external function'}
        self.distDict = {
        }  # Contains the instance of the distribution to be used, it is created every time the sampler is initialized. keys are the variable names
        self.funcDict = {
        }  # Contains the instance of the function     to be used, it is created every time the sampler is initialized. keys are the variable names
        self.values = {
        }  # for each variable the current value {'var name':value}
        self.inputInfo = {
        }  # depending on the sampler several different type of keywarded information could be present only one is mandatory, see below
        self.initSeed = None  # if not provided the seed is randomly generated at the istanciation of the sampler, the step can override the seed by sending in another seed
        self.inputInfo[
            'SampledVars'] = self.values  # this is the location where to get the values of the sampled variables
        self.inputInfo['SampledVarsPb'] = {
        }  # this is the location where to get the probability of the sampled variables
        self.inputInfo[
            'PointProbability'] = None  # this is the location where the point wise probability is stored (probability associated to a sampled point)
        self.inputInfo['crowDist'] = {
        }  # Stores a dictionary that contains the information to create a crow distribution.  Stored as a json object
        self.constants = {}  # In this dictionary
        self.reseedAtEachIteration = False  # Logical flag. True if every newer evaluation is performed after a new reseeding
        self.FIXME = False  # FIXME flag
        self.printTag = self.type  # prefix for all prints (sampler type)
        self.restartData = None  # presampled points to restart from
        self.restartTolerance = 1e-15  # strictness with which to find matches in the restart data

        self._endJobRunnable = sys.maxsize  # max number of inputs creatable by the sampler right after a job ends (e.g., infinite for MC, 1 for Adaptive, etc)

        ######
        self.variables2distributionsMapping = {
        }  # for each variable 'varName'  , the following informations are included:  'varName': {'dim': 1, 'reducedDim': 1,'totDim': 2, 'name': 'distName'} ; dim = dimension of the variable; reducedDim = dimension of the variable in the transformed space; totDim = total dimensionality of its associated distribution
        self.distributions2variablesMapping = {
        }  # for each variable 'distName' , the following informations are included: 'distName': [{'var1': 1}, {'var2': 2}]} where for each var it is indicated the var dimension
        self.NDSamplingParams = {
        }  # this dictionary contains a dictionary for each ND distribution (key). This latter dictionary contains the initialization parameters of the ND inverseCDF ('initialGridDisc' and 'tolerance')
        ######
        self.addAssemblerObject('Restart', '-n', True)

        #used for PCA analysis
        self.variablesTransformationDict = {
        }  # for each variable 'modelName', the following informations are included: {'modelName': {latentVariables:[latentVar1, latentVar2, ...], manifestVariables:[manifestVar1,manifestVar2,...]}}
        self.transformationMethod = {
        }  # transformation method used in variablesTransformation node {'modelName':method}
        self.entitiesToRemove = [
        ]  # This variable is used in order to make sure the transformation info is printed once in the output xml file.
Example #2
0
 def __init__(self, messageHandler):
   """
     Constructor
     @ In, messageHandler, MessageHandler, message handler object
     @ Out, None
   """
   Assembler.__init__(self)
   self.type = self.__class__.__name__  # pp type
   self.name = self.__class__.__name__  # pp name
   self.messageHandler = messageHandler
Example #3
0
 def __init__(self, messageHandler):
   """
     Constructor
     @ In, messageHandler, MessageHandler, message handler object
     @ Out, None
   """
   Assembler.__init__(self)
   self.type = self.__class__.__name__  # pp type
   self.name = self.__class__.__name__  # pp name
   self.messageHandler = messageHandler
   self.metadataKeys = set()            # list of registered metadata keys to expected in this postprocessor
   self.metadataParams = {}             # dictionary of registered metadata keys with respect to their indexes, i.e. {key:list(indexes)}
Example #4
0
  def __init__(self):
    """
      Default Constructor that will initialize member variables with reasonable
      defaults or empty lists/dictionaries where applicable.
      @ In, None
      @ Out, None
    """
    #FIXME: Since the similarity of this class with the base sampler, we should merge this
    BaseType.__init__(self)
    Assembler.__init__(self)
    self.counter                        = {}                        # Dict containing counters used for based and derived class
    self.counter['mdlEval']             = 0                         # Counter of the model evaluation performed (better the input generated!!!). It is reset by calling the function self.initialize
    self.counter['varsUpdate']          = 0                         # Counter of the optimization iteration.
    self.limit                          = {}                        # Dict containing limits for each counter
    self.limit['mdlEval']               = sys.maxsize               # Maximum number of the loss function evaluation
    self.limit['varsUpdate']            = sys.maxsize               # Maximum number of the optimization iteration.
    self.initSeed                       = None                      # Seed for random number generators
    self.optVars                        = None                      # Decision variables for optimization
    self.optVarsInit                    = {}                        # Dict containing upper/lower bounds and initial of each decision variables
    self.optVarsInit['upperBound']      = {}                        # Dict containing upper bounds of each decision variables
    self.optVarsInit['lowerBound']      = {}                        # Dict containing lower bounds of each decision variables
    self.optVarsInit['initial']         = {}                        # Dict containing initial values of each decision variables
    self.optVarsInit['ranges']          = {}                        # Dict of the ranges (min and max) of each variable's domain
    self.optVarsHist                    = {}                        # History of normalized decision variables for each iteration
    self.nVar                           = 0                         # Number of decision variables
    self.objVar                         = None                      # Objective variable to be optimized
    self.optType                        = None                      # Either maximize or minimize
    self.optTraj                        = None                      # Identifiers of parallel optimization trajectories
    self.thresholdTrajRemoval           = None                      # Threshold used to determine the convergence of parallel optimization trajectories
    self.paramDict                      = {}                        # Dict containing additional parameters for derived class
    self.absConvergenceTol              = 0.0                       # Convergence threshold (absolute value)
    self.relConvergenceTol              = 1.e-3                     # Convergence threshold (relative value)
    self.solutionExport                 = None                      #This is the data used to export the solution (it could also not be present)
    self.values                         = {}                        # for each variable the current value {'var name':value}
    self.inputInfo                      = {}                        # depending on the optimizer several different type of keywarded information could be present only one is mandatory, see below
    self.inputInfo['SampledVars'     ]  = self.values               # this is the location where to get the values of the sampled variables
    self.constants                      = {}                        # dictionary of constants variables
    self.FIXME                          = False                     # FIXME flag
    self.printTag                       = self.type                 # prefix for all prints (optimizer type)

    self._endJobRunnable                = sys.maxsize               # max number of inputs creatable by the optimizer right after a job ends

    self.constraintFunction             = None                      # External constraint function, could be not present
    self.mdlEvalHist                    = None                      # Containing information of all model evaluation
    self.objSearchingROM                = None                      # ROM used internally for fast loss function evaluation

    self.addAssemblerObject('Restart' ,'-n',True)
    self.addAssemblerObject('TargetEvaluation','1')
    self.addAssemblerObject('Function','-1')
Example #5
0
 def __init__(self,runInfoDict):
   """
     Constructor
     @ In, runInfoDict, dict, the dictionary containing the runInfo (read in the XML input file)
     @ Out, None
   """
   BaseType.__init__(self)
   Assembler.__init__(self)
   #if alias are defined in the input it defines a mapping between the variable names in the framework and the one for the generation of the input
   #self.alias[framework variable name] = [input code name]. For Example, for a MooseBasedApp, the alias would be self.alias['internal_variable_name'] = 'Material|Fuel|thermal_conductivity'
   self.alias    = {'input':{},'output':{}}
   self.subType  = ''
   self.runQueue = []
   self.printTag = 'MODEL'
   self.createWorkingDir = False