Exemple #1
0
 def getInputSpecification(cls):
   """
     Method to get a reference to a class that specifies the input data for
     class cls.
     @ Out, inputSpecification, InputData.ParameterInput, class to use for
       specifying input of cls.
   """
   specs = super(ARMA, cls).getInputSpecification()
   specs.name = 'arma' # NOTE lowercase because ARMA already has Fourier and no way to resolve right now
   specs.description = r"""TimeSeriesAnalysis algorithm for determining the stochastic
                       characteristics of signal with time-invariant variance"""
   specs.addParam('reduce_memory', param_type=InputTypes.BoolType, required=False,
                  descr=r"""activates a lower memory usage ARMA training. This does tend to result
                        in a slightly slower training time, at the benefit of lower memory usage. For
                        example, in one 1000-length history test, low memory reduced memory usage by 2.3
                        MiB, but increased training time by 0.4 seconds. No change in results has been
                        observed switching between modes. Note that the ARMA must be
                        retrained to change this property; it cannot be applied to serialized ARMAs.
                        \default{False}""")
   specs.addSub(InputData.parameterInputFactory('SignalLag', contentType=InputTypes.FloatType,
                descr=r"""the number of terms in the AutoRegressive term to retain in the
                      regression; typically represented as $P$ in literature."""))
   specs.addSub(InputData.parameterInputFactory('NoiseLag', contentType=InputTypes.FloatType,
                descr=r"""the number of terms in the Moving Average term to retain in the
                      regression; typically represented as $Q$ in literature."""))
   return specs
Exemple #2
0
  def getInputSpecification(cls):
    """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
    ## This will replace the lines above
    inputSpecification = super(LimitSurface, cls).getInputSpecification()

    ParametersInput = InputData.parameterInputFactory("parameters", contentType=InputTypes.StringType)
    inputSpecification.addSub(ParametersInput)

    ToleranceInput = InputData.parameterInputFactory("tolerance", contentType=InputTypes.FloatType)
    inputSpecification.addSub(ToleranceInput)

    SideInput = InputData.parameterInputFactory("side", contentType=InputTypes.StringType)
    inputSpecification.addSub(SideInput)

    ROMInput = InputData.parameterInputFactory("ROM", contentType=InputTypes.StringType)
    ROMInput.addParam("class", InputTypes.StringType)
    ROMInput.addParam("type", InputTypes.StringType)
    inputSpecification.addSub(ROMInput)

    FunctionInput = InputData.parameterInputFactory("Function", contentType=InputTypes.StringType)
    FunctionInput.addParam("class", InputTypes.StringType)
    FunctionInput.addParam("type", InputTypes.StringType)
    inputSpecification.addSub(FunctionInput)

    return inputSpecification
Exemple #3
0
 def getInputSpecification(cls):
     """
   Method to get a reference to a class that specifies the input data for
   class cls.
   @ In, cls, the class for which we are retrieving the specification
   @ Out, inputSpecification, InputData.ParameterInput, class to use for
     specifying input of cls.
 """
     inputSpecification = super().getInputSpecification()
     inputSpecification.setCheckClass(CheckInterfacePP("HistorySetSync"))
     inputSpecification.addSub(
         InputData.parameterInputFactory(
             "numberOfSamples", contentType=InputTypes.IntegerType))
     HSSSyncType = InputTypes.makeEnumType("HSSSync", "HSSSyncType",
                                           ['all', 'grid', 'max', 'min'])
     inputSpecification.addSub(
         InputData.parameterInputFactory("syncMethod",
                                         contentType=HSSSyncType))
     inputSpecification.addSub(
         InputData.parameterInputFactory("pivotParameter",
                                         contentType=InputTypes.StringType))
     inputSpecification.addSub(
         InputData.parameterInputFactory("extension",
                                         contentType=InputTypes.StringType))
     #Should method be in super class?
     inputSpecification.addSub(
         InputData.parameterInputFactory("method",
                                         contentType=InputTypes.StringType))
     return inputSpecification
Exemple #4
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for class "cls".
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for specifying the input of cls.
    """
        spec = OutStreamBase.getInputSpecification()

        types = InputTypes.makeEnumType('FilePrintTypes', 'FilePrintTypes',
                                        cls._availableOutStreamTypes)
        spec.addSub(InputData.parameterInputFactory('type', contentType=types))
        spec.addSub(
            InputData.parameterInputFactory(
                'source', contentType=InputTypes.StringListType))
        spec.addSub(
            InputData.parameterInputFactory(
                'what', contentType=InputTypes.StringListType))
        spec.addSub(
            InputData.parameterInputFactory('filename',
                                            contentType=InputTypes.StringType))
        spec.addSub(
            InputData.parameterInputFactory('clusterLabel',
                                            contentType=InputTypes.StringType))

        # these are in user manual or code, but don't appear to be used/documented ...
        # spec.addSub(InputData.parameterInputFactory('target', contentType=InputTypes.StringListType))
        # spec.addSub(InputData.parameterInputFactory('directory',
        # contentType=InputTypes.StringListType))
        return spec
Exemple #5
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        inputSpecification = super(EconomicRatio, cls).getInputSpecification()

        for scalar in cls.scalarVals:
            scalarSpecification = InputData.parameterInputFactory(
                scalar, contentType=InputTypes.StringListType)
            scalarSpecification.addParam("prefix", InputTypes.StringType)
            inputSpecification.addSub(scalarSpecification)

        for teal in cls.tealVals:
            tealSpecification = InputData.parameterInputFactory(
                teal, contentType=InputTypes.StringListType)
            if teal in ['sortinoRatio', 'gainLossRatio']:
                tealSpecification.addParam("threshold", InputTypes.StringType)
            elif teal in ['expectedShortfall', 'valueAtRisk']:
                tealSpecification.addParam("threshold", InputTypes.FloatType)
            tealSpecification.addParam("prefix", InputTypes.StringType)
            inputSpecification.addSub(tealSpecification)

        pivotParameterInput = InputData.parameterInputFactory(
            'pivotParameter', contentType=InputTypes.StringType)
        inputSpecification.addSub(pivotParameterInput)

        return inputSpecification
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        inputSpecification = super(ParetoFrontier, cls).getInputSpecification()

        costIDInput = InputData.parameterInputFactory(
            "costID", contentType=InputTypes.StringType)
        costIDInput.addParam("inv", InputTypes.BoolType, True)
        inputSpecification.addSub(costIDInput)

        valueIDInput = InputData.parameterInputFactory(
            "valueID", contentType=InputTypes.StringType)
        valueIDInput.addParam("inv", InputTypes.BoolType, True)
        inputSpecification.addSub(valueIDInput)

        costLimitInput = InputData.parameterInputFactory(
            "costLimit", contentType=InputTypes.FloatType)
        costLimitInput.addParam("type", InputTypes.StringType, True)
        inputSpecification.addSub(costLimitInput)

        valueLimitInput = InputData.parameterInputFactory(
            "valueLimit", contentType=InputTypes.FloatType)
        valueLimitInput.addParam("type", InputTypes.StringType, True)
        inputSpecification.addSub(valueLimitInput)

        return inputSpecification
Exemple #7
0
 def getInputSpecification(cls):
     """
   Method to get a reference to a class that specifies the input data for
   class cls.
   @ In, cls, the class for which we are retrieving the specification
   @ Out, inputSpecification, InputData.ParameterInput, class to use for
     specifying input of cls.
 """
     inputSpecification = super().getInputSpecification()
     inputSpecification.setCheckClass(
         CheckInterfacePP("TypicalHistoryFromHistorySet"))
     inputSpecification.addSub(
         InputData.parameterInputFactory(
             "subseqLen", contentType=InputTypes.IntegerListType))
     inputSpecification.addSub(
         InputData.parameterInputFactory("pivotParameter",
                                         contentType=InputTypes.StringType))
     inputSpecification.addSub(
         InputData.parameterInputFactory("outputLen",
                                         contentType=InputTypes.FloatType))
     #Should method be in super class?
     inputSpecification.addSub(
         InputData.parameterInputFactory("method",
                                         contentType=InputTypes.StringType))
     return inputSpecification
Exemple #8
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        inputSpecification = super(Grid, cls).getInputSpecification()
        # grid input
        gridInput = InputData.parameterInputFactory(
            "grid", contentType=InputTypes.StringType)
        gridInput.addParam("type", InputTypes.StringType)
        gridInput.addParam("construction", InputTypes.StringType)
        gridInput.addParam("steps", InputTypes.IntegerType)
        # old outer distribution input
        oldSubOutDist = inputSpecification.popSub("Distribution")
        newOuterDistributionInput = InputData.parameterInputFactory(
            "Distribution", baseNode=oldSubOutDist)
        # old variable input
        oldSub = inputSpecification.popSub("variable")
        newVariableInput = InputData.parameterInputFactory("variable",
                                                           baseNode=oldSub)
        # update variable input with new grid input
        newVariableInput.addSub(gridInput)
        inputSpecification.addSub(newVariableInput)
        # update outer distribution input with new grid input
        newOuterDistributionInput.addSub(gridInput)
        inputSpecification.addSub(newOuterDistributionInput)

        return inputSpecification
Exemple #9
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        inputSpecification = super(Stratified, cls).getInputSpecification()

        samplerInitInput = InputData.parameterInputFactory("samplerInit")
        samplerInitInput.addSub(
            InputData.parameterInputFactory(
                "initialSeed", contentType=InputTypes.IntegerType))
        samplerInitInput.addSub(
            InputData.parameterInputFactory(
                "distInit", contentType=InputTypes.IntegerType))

        inputSpecification.addSub(samplerInitInput)

        globalGridInput = InputData.parameterInputFactory(
            "globalGrid", contentType=InputTypes.StringType)

        gridInput = InputData.parameterInputFactory(
            "grid", contentType=InputTypes.StringType)
        gridInput.addParam("name", InputTypes.StringType)
        gridInput.addParam("type", InputTypes.StringType)
        gridInput.addParam("construction", InputTypes.StringType)
        gridInput.addParam("steps", InputTypes.IntegerType)

        globalGridInput.addSub(gridInput)

        inputSpecification.addSub(globalGridInput)

        return inputSpecification
Exemple #10
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        ## This will replace the lines above
        inputSpecification = super(RavenOutput, cls).getInputSpecification()

        inputSpecification.addSub(
            InputData.parameterInputFactory("dynamic",
                                            contentType=InputData.StringType))

        FileType = InputData.parameterInputFactory("File")
        FileType.addParam("name", InputData.StringType, required=True)
        FileType.addParam("ID", InputData.FloatType)
        OutputType = InputData.parameterInputFactory(
            "output", contentType=InputData.StringType)
        OutputType.addParam("name", InputData.StringType, required=True)
        FileType.addSub(OutputType)
        inputSpecification.addSub(FileType)

        return inputSpecification
Exemple #11
0
 def getInputSpecification(cls):
     """
   Collects input specifications for this class.
   @ In, None
   @ Out, inputSpecs, InputData, specs
 """
     inputSpecs = super(LogLinearModel, cls).getInputSpecification()
     inputSpecs.description = r"""
   Log Linear reliability models: lambda(t) = exp(alpha + (t-t0)*(beta))
   This is called Cox-Lewis model.
   """
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'alpha',
             contentType=InputTypes.InterpretedListType,
             descr='Shape parameter'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'beta',
             contentType=InputTypes.InterpretedListType,
             descr='The inverse is the scale parameter'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'Tm',
             contentType=InputTypes.InterpretedListType,
             descr='Mission time'))
     return inputSpecs
Exemple #12
0
 def getInputSpecification(cls):
     """
   Method to get a reference to a class that specifies the input data for class cls.
   @ In, cls, the class for which we are retrieving the specification
   @ Out, inputSpecification, InputData.ParameterInput, class to use for specifying input of cls.
 """
     specs = super(RavenSampled, cls).getInputSpecification()
     specs.description = 'Base class for Optimizers whose iterative sampling is performed through RAVEN.'
     # initialization: add sampling-based options
     init = specs.getSub('samplerInit')
     limit = InputData.parameterInputFactory(
         'limit',
         contentType=InputTypes.IntegerType,
         printPriority=100,
         descr=
         r"""limits the number of Model evaluations that may be performed as part of this optimization.
           For example, a limit of 100 means at most 100 total Model evaluations may be performed."""
     )
     whenSolnExpEnum = InputTypes.makeEnumType('whenWriteEnum',
                                               'whenWriteType',
                                               ['final', 'every'])
     write = InputData.parameterInputFactory(
         'writeSteps',
         contentType=whenSolnExpEnum,
         printPriority=100,
         descr=
         r"""delineates when the \xmlNode{SolutionExport} DataObject should be written to. In case
           of \xmlString{final}, only the final optimal solution for each trajectory will be written.
           In case of \xmlString{every}, the \xmlNode{SolutionExport} will be updated with each iteration
           of the Optimizer.""")
     init.addSub(limit)
     init.addSub(write)
     return specs
Exemple #13
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        inputSpecification = super(FactorialDesign,
                                   cls).getInputSpecification()

        factorialSettingsInput = InputData.parameterInputFactory(
            "FactorialSettings")
        algorithmTypeInput = InputData.parameterInputFactory(
            "algorithmType", contentType=InputData.StringType)
        factorialSettingsInput.addSub(algorithmTypeInput)

        factorialSettingsInput.addSub(
            InputData.parameterInputFactory("gen",
                                            contentType=InputData.StringType))
        factorialSettingsInput.addSub(
            InputData.parameterInputFactory("genMap",
                                            contentType=InputData.StringType))

        inputSpecification.addSub(factorialSettingsInput)

        return inputSpecification
Exemple #14
0
 def getInputSpecification(cls):
     """
   Method to get a reference to a class that specifies the input data for class cls.
   @ In, cls, the class for which we are retrieving the specification
   @ Out, inputSpecification, InputData.ParameterInput, class to use for specifying input of cls.
 """
     specs = InputData.parameterInputFactory(cls.__name__,
                                             ordered=False,
                                             strictMode=True)
     specs.description = 'Base class for Step Manipulation algorithms in the GradientDescent Optimizer.'
     specs.addSub(
         InputData.parameterInputFactory(
             'initialStepScale',
             contentType=InputTypes.FloatType,
             descr=
             r"""specifies the scale of the initial step in the optimization, in percent of the
           size of the problem. The size of the problem is defined as the hyperdiagonal of the
           input space, composed of the input variables. A value of 1 indicates the first step
           can reach from the lowest value of all inputs to the highest point of all inputs,
           which is too large for all problems with more than one optimization variable. In general this
           should be smaller as the number of optimization variables increases, but large enough
           that the first step is meaningful for the problem. This scaling factor should always
           be less than $1/\sqrt{N}$, where $N$ is the number of optimization variables. \default{0.05} """
         ))
     return specs
Exemple #15
0
    def getInputSpecification(cls):
        """
      Collects input specifications for this class.
      @ In, None
      @ Out, inputSpecs, InputData, specs
    """
        inputSpecs = super(ExponWeibullModel, cls).getInputSpecification()
        inputSpecs.description = r"""
      Exponential Weibull reliability models
      """
        inputSpecs.addSub(
            InputData.parameterInputFactory(
                'alpha',
                contentType=InputTypes.InterpretedListType,
                descr='Shape parameter of exponentiation'))
        inputSpecs.addSub(
            InputData.parameterInputFactory(
                'beta',
                contentType=InputTypes.InterpretedListType,
                descr='Scale parameter'))
        inputSpecs.addSub(
            InputData.parameterInputFactory(
                'gamma',
                contentType=InputTypes.InterpretedListType,
                descr='Shape parameter of the non-exponentiation Weibull law'))

        return inputSpecs
Exemple #16
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for specifying input of cls
    """
        inputSpecification = super(SPSA, cls).getInputSpecification()

        # add additional parameters to "parameter"
        param = inputSpecification.popSub('parameter')
        param.addSub(
            InputData.parameterInputFactory('gamma',
                                            contentType=InputData.FloatType,
                                            strictMode=True))
        param.addSub(
            InputData.parameterInputFactory('c',
                                            contentType=InputData.FloatType,
                                            strictMode=True))
        param.addSub(
            InputData.parameterInputFactory('a',
                                            contentType=InputData.FloatType,
                                            strictMode=True))
        param.addSub(
            InputData.parameterInputFactory('alpha',
                                            contentType=InputData.FloatType,
                                            strictMode=True))
        param.addSub(
            InputData.parameterInputFactory('A',
                                            contentType=InputData.FloatType,
                                            strictMode=True))

        inputSpecification.addSub(param)
        return inputSpecification
Exemple #17
0
 def getInputSpecification(cls):
     """
   Collects input specifications for this class.
   @ In, None
   @ Out, inputSpecs, InputData, specs
 """
     inputSpecs = super(PowerLawModel, cls).getInputSpecification()
     inputSpecs.description = r"""
   Power Law reliability models: lambda(t) = lambda + alpha*(t-t0)**(beta)
   Other names for the power law model are: the Duane Model and the AMSAA (Army Materials System Analysis Activity)
   model.
   """
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'alpha',
             contentType=InputTypes.InterpretedListType,
             descr='Scale Parameter'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'beta',
             contentType=InputTypes.InterpretedListType,
             descr='Shape parameter'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'lambda',
             contentType=InputTypes.InterpretedListType,
             descr='initial failure rate'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'Tm',
             contentType=InputTypes.InterpretedListType,
             descr='Mission time'))
     return inputSpecs
Exemple #18
0
 def getInputSpecification(cls):
     """
   Method to get a reference to a class that specifies the input data for
   class cls.
   @ In, cls, the class for which we are retrieving the specification
   @ Out, inputSpecification, InputData.ParameterInput, class to use for
     specifying input of cls.
 """
     inputSpecification = super().getInputSpecification()
     inputSpecification.setCheckClass(
         CheckInterfacePP("riskMeasuresDiscrete"))
     inputSpecification.addSubSimple("measures", InputTypes.StringListType)
     variableSub = InputData.parameterInputFactory(
         "variable", contentType=InputTypes.StringType)
     variableSub.addParam("R0values", InputTypes.FloatListType)
     variableSub.addParam("R1values", InputTypes.FloatListType)
     inputSpecification.addSub(variableSub)
     targetSub = InputData.parameterInputFactory(
         "target", contentType=InputTypes.StringType)
     targetSub.addParam("values", InputTypes.FloatListType)
     inputSpecification.addSub(targetSub)
     dataSub = InputData.parameterInputFactory("data")
     dataSub.addParam("freq", InputTypes.FloatType)
     inputSpecification.addSub(dataSub)
     inputSpecification.addSubSimple("temporalID", InputTypes.StringType)
     #Should method be in super class?
     inputSpecification.addSubSimple("method",
                                     contentType=InputTypes.StringType)
     return inputSpecification
Exemple #19
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        inputSpecification = super(EnsembleForward,
                                   cls).getInputSpecification()

        #It would be nice if Factory.knownTypes could be used to do that,
        # but that seems to cause recursive problems
        inputSpecification.addSub(MonteCarlo.getInputSpecification())
        inputSpecification.addSub(Grid.getInputSpecification())
        inputSpecification.addSub(Stratified.getInputSpecification())
        inputSpecification.addSub(FactorialDesign.getInputSpecification())
        inputSpecification.addSub(
            ResponseSurfaceDesign.getInputSpecification())
        inputSpecification.addSub(CustomSampler.getInputSpecification())

        samplerInitInput = InputData.parameterInputFactory("samplerInit")

        samplerInitInput.addSub(
            InputData.parameterInputFactory(
                "initialSeed", contentType=InputTypes.IntegerType))

        inputSpecification.addSub(samplerInitInput)
        return inputSpecification
Exemple #20
0
    def getInputSpecs(cls, specs):
        """
      Collects input specifications for this class.
      @ In, specs, InputData, specs
      @ Out, specs, InputData, specs
    """
        # ONLY appends to existinc specs!
        #cf = InputData.parameterInputFactory('CashFlow')

        specs.addParam('name', param_type=InputTypes.StringType, required=True)
        specs.addParam('tax', param_type=InputTypes.BoolType, required=False)
        infl = InputTypes.makeEnumType(
            'inflation_types', 'inflation_type',
            ['real', 'none'])  # "nominal" not yet implemented
        specs.addParam('inflation', param_type=infl, required=False)
        specs.addParam('mult_target',
                       param_type=InputTypes.BoolType,
                       required=False)
        specs.addParam('multiply',
                       param_type=InputTypes.StringType,
                       required=False)

        specs.addSub(
            InputData.parameterInputFactory(
                'driver', contentType=InputTypes.InterpretedListType))
        specs.addSub(
            InputData.parameterInputFactory(
                'alpha', contentType=InputTypes.InterpretedListType))
        return specs
Exemple #21
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        inputSpecification = super(CustomSampler, cls).getInputSpecification()
        sourceInput = InputData.parameterInputFactory(
            "Source", contentType=InputData.StringType)
        sourceInput.addParam("type", InputData.StringType)
        sourceInput.addParam("class", InputData.StringType)
        inputSpecification.addSub(sourceInput)

        inputSpecification.addSub(
            InputData.parameterInputFactory(
                'index', contentType=InputData.IntegerListType))

        # add "nameInSource" attribute to <variable>
        var = inputSpecification.popSub('variable')
        var.addParam("nameInSource", InputData.StringType, required=False)
        inputSpecification.addSub(var)

        return inputSpecification
Exemple #22
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        inputSpecification = super(AdaptiveSparseGrid,
                                   cls).getInputSpecification()

        convergenceInput = InputData.parameterInputFactory(
            "Convergence", contentType=InputTypes.StringType)
        convergenceInput.addParam("target", InputTypes.StringType, True)
        convergenceInput.addParam("maxPolyOrder", InputTypes.IntegerType)
        convergenceInput.addParam("persistence", InputTypes.IntegerType)

        inputSpecification.addSub(convergenceInput)

        inputSpecification.addSub(InputData.parameterInputFactory("logFile"))
        inputSpecification.addSub(
            InputData.parameterInputFactory(
                "maxRuns", contentType=InputTypes.IntegerType))

        targetEvaluationInput = InputData.parameterInputFactory(
            "TargetEvaluation", contentType=InputTypes.StringType)
        targetEvaluationInput.addParam("type", InputTypes.StringType)
        targetEvaluationInput.addParam("class", InputTypes.StringType)
        inputSpecification.addSub(targetEvaluationInput)

        return inputSpecification
Exemple #23
0
 def get_input_specs(cls, name, disallowed=None):
   """
     Template for parameters that can take a scalar, an ARMA history, or a function
     @ In, name, string, name for spec (tag)
     @ In, disallowed, list(str), names of options not to be included
     @ Out, spec, InputData, value-based spec
   """
   if disallowed is None:
     disallowed = []
   spec = InputData.parameterInputFactory(name,
       descr=r"""This value can be taken from any \emph{one} of the sources described below.""")
   # for when the value is fixed (takes precedence over "sweep" and "opt") ...
   spec.addSub(InputData.parameterInputFactory('fixed_value', contentType=InputTypes.FloatType,
       descr=r"""indicates this value is a fixed value, given by the value of this node."""))
   # for when the value is parametric (only in "sweep" mode)
   spec.addSub(InputData.parameterInputFactory('sweep_values', contentType=InputTypes.FloatListType,
       descr=r"""indicates this value is parametric. The value of this node should contain
             two floats, representing the minimum and maximum values to sweep between."""))
   # for when the value is optimized (only in "min" or "max" mode)
   spec.addSub(InputData.parameterInputFactory('opt_bounds', contentType=InputTypes.FloatListType,
       descr=r"""indicates this value is an optimization variable. The optimization limits should
             be given in the value of this node as two float values."""))
   # for when the value is time-dependent and given by an ARMA
   arma = InputData.parameterInputFactory('ARMA', contentType=InputTypes.StringType,
       descr=r"""indicates that this value will be taken from synthetically-generated signals,
             which will be provided to the dispatch at run time by RAVEN from trained models. The value
             of this node should be the name of a synthetic history generator in the
             \xmlNode{DataGenerator} node.""")
   arma.addParam('variable', param_type=InputTypes.StringType,
       descr=r"""indicates which variable coming from the synthetic histories this value should be taken from.""")
   spec.addSub(arma)
   # for when the value comes from evaluating a function
   func = InputData.parameterInputFactory('Function', contentType=InputTypes.StringType,
       descr=r"""indicates this value should be taken from a Python function, as described
             in the \xmlNode{DataGenerators} node.""")
   func.addParam('method', param_type=InputTypes.StringType,
       descr=r"""the name of the \xmlNode{DataGenerator} from which this value should be taken.""")
   spec.addSub(func)
   # for when the value comes from another variable
   var = InputData.parameterInputFactory('variable', contentType=InputTypes.StringType,
       descr=r"""the name of the variable from the named function that will provide this value.""")
   spec.addSub(var)
   # for when linear coefficients are provided
   linear = InputData.parameterInputFactory('linear',
       descr=r"""indicates that linear coefficients will be provided to calculate values.""")
   lin_rate = InputData.parameterInputFactory('rate', contentType=InputTypes.FloatType,
       descr=r"""linear coefficient for the indicated \xmlAttr{resource}.""")
   lin_rate.addParam('resource', param_type=InputTypes.StringType,
       descr=r"""indicates the resource for which the linear transfer rate is being provided in this node.""")
   linear.addSub(lin_rate)
   spec.addSub(linear)
   # for when the result obtained needs to grow from year to year
   growth = InputData.parameterInputFactory('growth', contentType=InputTypes.FloatType,
       descr=r"""if this node is given, the value will be adjusted from cycle to cycle by the provided amount.""")
   growth_mode = InputTypes.makeEnumType('growthType', 'growthType', ['linear', 'exponential'])
   growth.addParam('mode', param_type=growth_mode, required=True,
       descr=r"""determines whether the growth factor should be taken as linear or exponential (compounding).""")
   spec.addSub(growth)
   return spec
Exemple #24
0
  def getInputSpecification(cls):
    """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
    inputSpecification = super(MonteCarlo, cls).getInputSpecification()

    samplerInitInput = InputData.parameterInputFactory("samplerInit")
    limitInput = InputData.parameterInputFactory("limit", contentType=InputTypes.IntegerType)
    samplerInitInput.addSub(limitInput)
    initialSeedInput = InputData.parameterInputFactory("initialSeed", contentType=InputTypes.IntegerType)
    samplerInitInput.addSub(initialSeedInput)
    distInitInput = InputData.parameterInputFactory("distInit", contentType=InputTypes.StringType)
    distSubInput = InputData.parameterInputFactory("distribution")
    distSubInput.addParam("name", InputTypes.StringType)
    distSubInput.addSub(InputData.parameterInputFactory("initialGridDisc", contentType=InputTypes.IntegerType))
    distSubInput.addSub(InputData.parameterInputFactory("tolerance", contentType=InputTypes.FloatType))

    distInitInput.addSub(distSubInput)
    samplerInitInput.addSub(distInitInput)
    samplingTypeInput = InputData.parameterInputFactory("samplingType", contentType=InputTypes.StringType)
    samplerInitInput.addSub(samplingTypeInput)
    reseedEachIterationInput = InputData.parameterInputFactory("reseedEachIteration", contentType=InputTypes.StringType)
    samplerInitInput.addSub(reseedEachIterationInput)


    inputSpecification.addSub(samplerInitInput)

    return inputSpecification
Exemple #25
0
def train(args):

    data = InputData(args.input, args.min_count, args.sample)
    output_file_name = args.output
    emb_size = len(data.word2id)
    emb_dimension = args.dim
    batch_size = args.mb
    window_size = args.window
    n_negs = args.n_negs
    iteration = args.iters
    initial_lr = args.lr
    use_cuda = args.cuda

    skip_gram_model = SkipGramModel(emb_size, emb_dimension)
    if use_cuda: skip_gram_model = skip_gram_model.cuda()

    optimizer = optim.SGD(skip_gram_model.parameters(), lr=initial_lr)

    pair_count = data.evaluate_pair_count(window_size)
    batch_count = iteration * pair_count / batch_size
    process_bar = tqdm(range(int(batch_count)))

    # skip_gram_model.save_embedding(
    #     data.id2word, 'begin_embedding.txt', use_cuda)

    for i in process_bar:
        pos_pairs = data.get_batch_pairs(batch_size, window_size)
        neg_v = data.get_neg_v_neg_sampling(pos_pairs, n_negs)
        pos_u = [pair[0] for pair in pos_pairs]
        pos_v = [pair[1] for pair in pos_pairs]

        pos_u = torch.LongTensor(pos_u)
        pos_v = torch.LongTensor(pos_v)
        neg_v = torch.LongTensor(neg_v)
        if use_cuda:
            pos_u = pos_u.cuda()
            pos_v = pos_v.cuda()
            neg_v = neg_v.cuda()

        optimizer.zero_grad()
        loss = skip_gram_model(pos_u, pos_v, neg_v)
        loss.backward()
        optimizer.step()

        process_bar.set_description(
            "\rLoss: %0.8f, lr: %0.6f" %
            (loss.item(), optimizer.param_groups[0]['lr']))

        if i * batch_size % 100000 == 0:
            lr = initial_lr * (1.0 - 1.0 * i / batch_count)
            for param_group in optimizer.param_groups:
                param_group['lr'] = lr

    skip_gram_model.save_embedding(data.id2word, output_file_name, use_cuda)
Exemple #26
0
 def getInputSpecification(cls):
   """
     Method to get a reference to a class that specifies the input data for the class cls.
     @ In, cls, the class for which we are retrieving the specification
     @ Out, inputSpecification, InputData.ParameterInput, class to use for
       specifying input of cls.
   """
   inputSpecification = super(MCSImporter, cls).getInputSpecification()
   inputSpecification.addSub(InputData.parameterInputFactory("expand",       contentType=InputTypes.BoolType))
   inputSpecification.addSub(InputData.parameterInputFactory("BElistColumn", contentType=InputTypes.StringType))
   return inputSpecification
Exemple #27
0
 def getInputSpecification(cls):
   """
     Collects input specifications for this class.
     @ In, None
     @ Out, inputSpecs, InputData, specs
   """
   inputSpecs = InputData.parameterInputFactory('ReliabilityModel')
   inputSpecs.addParam('type', param_type=InputTypes.StringType,
       descr='The reliablity model object identifier')
   inputSpecs.addSub(InputData.parameterInputFactory('Td', contentType=InputTypes.InterpretedListType,
       descr='The time delay before the onset of failure'))
   return inputSpecs
Exemple #28
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        ## This will replace the lines above
        inputSpecification = super(TopologicalDecomposition,
                                   cls).getInputSpecification()

        TDGraphInput = InputData.parameterInputFactory(
            "graph", contentType=InputData.StringType)
        inputSpecification.addSub(TDGraphInput)

        TDGradientInput = InputData.parameterInputFactory(
            "gradient", contentType=InputData.StringType)
        inputSpecification.addSub(TDGradientInput)

        TDBetaInput = InputData.parameterInputFactory(
            "beta", contentType=InputData.FloatType)
        inputSpecification.addSub(TDBetaInput)

        TDKNNInput = InputData.parameterInputFactory(
            "knn", contentType=InputData.IntegerType)
        inputSpecification.addSub(TDKNNInput)

        TDWeightedInput = InputData.parameterInputFactory(
            "weighted", contentType=InputData.StringType)  #bool
        inputSpecification.addSub(TDWeightedInput)

        TDPersistenceInput = InputData.parameterInputFactory(
            "persistence", contentType=InputData.StringType)
        inputSpecification.addSub(TDPersistenceInput)

        TDSimplificationInput = InputData.parameterInputFactory(
            "simplification", contentType=InputData.FloatType)
        inputSpecification.addSub(TDSimplificationInput)

        TDParametersInput = InputData.parameterInputFactory(
            "parameters", contentType=InputData.StringType)
        inputSpecification.addSub(TDParametersInput)

        TDResponseInput = InputData.parameterInputFactory(
            "response", contentType=InputData.StringType)
        inputSpecification.addSub(TDResponseInput)

        TDNormalizationInput = InputData.parameterInputFactory(
            "normalization", contentType=InputData.StringType)
        inputSpecification.addSub(TDNormalizationInput)

        return inputSpecification
Exemple #29
0
  def getInputSpecification(cls):
    """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
    inputSpecification = super(LimitSurfaceSearch, cls).getInputSpecification()

    convergenceInput = InputData.parameterInputFactory("Convergence", contentType=InputTypes.FloatType)
    convergenceInput.addParam("limit", InputTypes.IntegerType)
    convergenceInput.addParam("forceIteration", InputTypes.StringType)
    convergenceInput.addParam("weight", InputTypes.StringType)
    convergenceInput.addParam("persistence", InputTypes.IntegerType)
    convergenceInput.addParam("subGridTol", InputTypes.FloatType)

    inputSpecification.addSub(convergenceInput)

    batchStrategyInput = InputData.parameterInputFactory("batchStrategy",
                                                         contentType=InputTypes.StringType)
    inputSpecification.addSub(batchStrategyInput)

    maxBatchSizeInput = InputData.parameterInputFactory("maxBatchSize", contentType=InputTypes.IntegerType)
    inputSpecification.addSub(maxBatchSizeInput)
    scoringInput = InputData.parameterInputFactory("scoring", contentType=InputTypes.StringType)
    inputSpecification.addSub(scoringInput)
    simplificationInput = InputData.parameterInputFactory("simplification", contentType=InputTypes.FloatType)
    inputSpecification.addSub(simplificationInput)

    thicknessInput = InputData.parameterInputFactory("thickness", contentType=InputTypes.IntegerType)
    inputSpecification.addSub(thicknessInput)

    thresholdInput = InputData.parameterInputFactory("threshold", contentType=InputTypes.FloatType)
    inputSpecification.addSub(thresholdInput)

    romInput = InputData.parameterInputFactory("ROM", contentType=InputTypes.StringType)
    romInput.addParam("type", InputTypes.StringType)
    romInput.addParam("class", InputTypes.StringType)
    inputSpecification.addSub(romInput)

    targetEvaluationInput = InputData.parameterInputFactory("TargetEvaluation", contentType=InputTypes.StringType)
    targetEvaluationInput.addParam("type", InputTypes.StringType)
    targetEvaluationInput.addParam("class", InputTypes.StringType)
    inputSpecification.addSub(targetEvaluationInput)

    functionInput = InputData.parameterInputFactory("Function", contentType=InputTypes.StringType)
    functionInput.addParam("type", InputTypes.StringType)
    functionInput.addParam("class", InputTypes.StringType)
    inputSpecification.addSub(functionInput)

    return inputSpecification
Exemple #30
0
    def getInputSpecification(cls):
        """
      Method to get a reference to a class that specifies the input data for
      class cls.
      @ In, cls, the class for which we are retrieving the specification
      @ Out, inputSpecification, InputData.ParameterInput, class to use for
        specifying input of cls.
    """
        ## This will replace the lines above
        inputSpecification = super(LimitSurfaceIntegral,
                                   cls).getInputSpecification()

        LSIVariableInput = InputData.parameterInputFactory("variable")
        LSIVariableInput.addParam("name", InputTypes.StringType)
        LSIDistributionInput = InputData.parameterInputFactory(
            "distribution", contentType=InputTypes.StringType)
        LSIDistributionInput.addParam("class", InputTypes.StringType, True)
        LSIDistributionInput.addParam("type", InputTypes.StringType, True)
        LSIVariableInput.addSub(LSIDistributionInput)
        LSILowerBoundInput = InputData.parameterInputFactory(
            "lowerBound", contentType=InputTypes.FloatType)
        LSIVariableInput.addSub(LSILowerBoundInput)
        LSIUpperBoundInput = InputData.parameterInputFactory(
            "upperBound", contentType=InputTypes.FloatType)
        LSIVariableInput.addSub(LSIUpperBoundInput)
        inputSpecification.addSub(LSIVariableInput)

        LSIToleranceInput = InputData.parameterInputFactory(
            "tolerance", contentType=InputTypes.FloatType)
        inputSpecification.addSub(LSIToleranceInput)

        LSIIntegralTypeInput = InputData.parameterInputFactory(
            "integralType", contentType=InputTypes.StringType)
        inputSpecification.addSub(LSIIntegralTypeInput)

        LSISeedInput = InputData.parameterInputFactory(
            "seed", contentType=InputTypes.IntegerType)
        inputSpecification.addSub(LSISeedInput)

        LSITargetInput = InputData.parameterInputFactory(
            "target", contentType=InputTypes.StringType)
        inputSpecification.addSub(LSITargetInput)

        LSIOutputNameInput = InputData.parameterInputFactory(
            "outputName", contentType=InputTypes.StringType)
        inputSpecification.addSub(LSIOutputNameInput)

        LSIOutputNameInput = InputData.parameterInputFactory(
            "computeBounds", contentType=InputTypes.BoolType)
        inputSpecification.addSub(LSIOutputNameInput)

        return inputSpecification