Beispiel #1
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("HistorySetSnapShot"))
     HSSSTypeType = InputTypes.makeEnumType(
         "HSSSType", "HSSSTypeType",
         ['min', 'max', 'average', 'value', 'timeSlice', 'mixed'])
     inputSpecification.addSub(
         InputData.parameterInputFactory("type", contentType=HSSSTypeType))
     inputSpecification.addSub(
         InputData.parameterInputFactory(
             "numberOfSamples", contentType=InputTypes.IntegerType))
     HSSSExtensionType = InputTypes.makeEnumType("HSSSExtension",
                                                 "HSSSExtensionType",
                                                 ['zeroed', 'extended'])
     inputSpecification.addSub(
         InputData.parameterInputFactory("extension",
                                         contentType=HSSSExtensionType))
     inputSpecification.addSub(
         InputData.parameterInputFactory("pivotParameter",
                                         contentType=InputTypes.StringType))
     inputSpecification.addSub(
         InputData.parameterInputFactory("pivotVar",
                                         contentType=InputTypes.StringType))
     inputSpecification.addSub(
         InputData.parameterInputFactory("pivotVal",
                                         contentType=InputTypes.FloatType))
     inputSpecification.addSub(
         InputData.parameterInputFactory(
             "timeInstant", contentType=InputTypes.IntegerType))
     inputSpecification.addSub(
         InputData.parameterInputFactory(
             "mixed", contentType=InputTypes.StringListType))
     for tag in ['min', 'max', 'average']:
         inputSpecification.addSub(
             InputData.parameterInputFactory(
                 tag, contentType=InputTypes.StringListType))
     valueSub = InputData.parameterInputFactory("value")
     valueSub.addParam("pivotVar", InputTypes.StringType)
     valueSub.addParam("pivotVal", InputTypes.StringType)
     inputSpecification.addSub(valueSub)
     #Should method be in super class?
     inputSpecification.addSub(
         InputData.parameterInputFactory("method",
                                         contentType=InputTypes.StringType))
     return inputSpecification
Beispiel #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.
    """
        inputSpecification = super(ComparisonStatistics,
                                   cls).getInputSpecification()
        KindInputEnumType = InputTypes.makeEnumType(
            "kind", "kindType", ["uniformBins", "equalProbability"])
        KindInput = InputData.parameterInputFactory(
            "kind", contentType=KindInputEnumType)
        KindInput.addParam("numBins", InputTypes.IntegerType, False)
        KindInput.addParam("binMethod", InputTypes.StringType, False)
        inputSpecification.addSub(KindInput)

        ## FIXME: Is this class necessary?
        class CSCompareInput(InputData.ParameterInput):
            """
        class for reading in the compare block in comparison statistics
      """

        CSCompareInput.createClass("compare", False)
        CSDataInput = InputData.parameterInputFactory(
            "data", contentType=InputTypes.StringType)
        CSCompareInput.addSub(CSDataInput)
        CSReferenceInput = InputData.parameterInputFactory("reference")
        CSReferenceInput.addParam("name", InputTypes.StringType, True)
        CSCompareInput.addSub(CSReferenceInput)
        inputSpecification.addSub(CSCompareInput)

        FZInput = InputData.parameterInputFactory(
            "fz", contentType=InputTypes.StringType)  #bool
        inputSpecification.addSub(FZInput)

        CSInterpolationEnumType = InputTypes.makeEnumType(
            "csinterpolation", "csinterpolationType", ["linear", "quadratic"])
        CSInterpolationInput = InputData.parameterInputFactory(
            "interpolation", contentType=CSInterpolationEnumType)
        inputSpecification.addSub(CSInterpolationInput)

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

        return inputSpecification
Beispiel #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 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
Beispiel #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 input of cls.
    """
        inputSpecification = super(ParetoFrontier, cls).getInputSpecification()

        objDataType = InputTypes.makeEnumType("objective", "objectiveType",
                                              ['min', 'max'])

        objective = InputData.parameterInputFactory(
            'objective', contentType=InputTypes.StringType)
        objective.addParam('goal', param_type=objDataType, required=True)
        objective.addParam('upperLimit',
                           param_type=InputTypes.FloatType,
                           required=False)
        objective.addParam('lowerLimit',
                           param_type=InputTypes.FloatType,
                           required=False)
        inputSpecification.addSub(objective)

        return inputSpecification
Beispiel #5
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
Beispiel #6
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
Beispiel #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("HStoPSOperator"))
        inputSpecification.addSub(
            InputData.parameterInputFactory("pivotParameter",
                                            contentType=InputTypes.StringType))
        inputSpecification.addSub(
            InputData.parameterInputFactory("row",
                                            contentType=InputTypes.FloatType))
        inputSpecification.addSub(
            InputData.parameterInputFactory("pivotValue",
                                            contentType=InputTypes.FloatType))
        inputSpecification.addSub(
            InputData.parameterInputFactory("operator",
                                            contentType=InputTypes.StringType))
        PivotStategyType = InputTypes.makeEnumType(
            "PivotStategy", "PivotStategyType",
            ['nearest', 'floor', 'ceiling', 'interpolate'])
        inputSpecification.addSub(
            InputData.parameterInputFactory("pivotStrategy",
                                            contentType=PivotStategyType))
        #Should method be in super class?
        inputSpecification.addSub(
            InputData.parameterInputFactory("method",
                                            contentType=InputTypes.StringType))

        return inputSpecification
Beispiel #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.
 """
     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
Beispiel #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(Metric, cls).getInputSpecification()
    featuresInput = InputData.parameterInputFactory("Features", contentType=InputTypes.StringListType)
    featuresInput.addParam("type", InputTypes.StringType)
    inputSpecification.addSub(featuresInput)
    targetsInput = InputData.parameterInputFactory("Targets", contentType=InputTypes.StringListType)
    targetsInput.addParam("type", InputTypes.StringType)
    inputSpecification.addSub(targetsInput)
    multiOutputInput = InputData.parameterInputFactory("multiOutput", contentType=InputTypes.StringType)
    inputSpecification.addSub(multiOutputInput)
    multiOutput = InputTypes.makeEnumType('MultiOutput', 'MultiOutputType', ['mean','max','min','raw_values'])
    multiOutputInput = InputData.parameterInputFactory("multiOutput", contentType=multiOutput)
    inputSpecification.addSub(multiOutputInput)
    weightInput = InputData.parameterInputFactory("weight", contentType=InputTypes.FloatListType)
    inputSpecification.addSub(weightInput)
    pivotParameterInput = InputData.parameterInputFactory("pivotParameter", contentType=InputTypes.StringType)
    inputSpecification.addSub(pivotParameterInput)
    metricInput = InputData.parameterInputFactory("Metric", contentType=InputTypes.StringType)
    metricInput.addParam("class", InputTypes.StringType, True)
    metricInput.addParam("type", InputTypes.StringType, True)
    inputSpecification.addSub(metricInput)

    return inputSpecification
Beispiel #10
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
Beispiel #11
0
 def getInputSpecification(cls):
     """
   Collects input specifications for this class.
   @ In, cls, class instance
   @ Out, inputSpecs, InputData, specs
 """
     typeEnum = InputTypes.makeEnumType('PMType', 'PMTypeType',
                                        ['standby', 'operating'])
     inputSpecs = super(PMModel, cls).getInputSpecification()
     inputSpecs.description = r"""
   Preventive maintenance reliability models
   """
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'type',
             contentType=typeEnum,
             descr='Type of SSC considered: stand-by or operating'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'rho',
             contentType=InputTypes.InterpretedListType,
             descr='Failure probability on demand'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'Tpm',
             contentType=InputTypes.InterpretedListType,
             descr='Time required to perform PM activities'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'Tr',
             contentType=InputTypes.InterpretedListType,
             descr='Average repair time'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'Tt',
             contentType=InputTypes.InterpretedListType,
             descr='Average test duration'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'Lambda',
             contentType=InputTypes.InterpretedListType,
             descr='Component failure rate'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'Tm',
             contentType=InputTypes.InterpretedListType,
             descr='Preventive maintenance interval'))
     inputSpecs.addSub(
         InputData.parameterInputFactory(
             'Ti',
             contentType=InputTypes.InterpretedListType,
             descr='Surveillance test interval'))
     return inputSpecs
Beispiel #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.
    """
    inputSpecification = super(Code, cls).getInputSpecification()
    inputSpecification.setStrictMode(False) #Code interfaces can allow new elements.
    inputSpecification.addSub(InputData.parameterInputFactory("executable", contentType=InputTypes.StringType))
    inputSpecification.addSub(InputData.parameterInputFactory("walltime", contentType=InputTypes.FloatType))
    inputSpecification.addSub(InputData.parameterInputFactory("preexec", contentType=InputTypes.StringType))

    ## Begin command line arguments tag
    ClargsInput = InputData.parameterInputFactory("clargs")

    ClargsTypeInput = InputTypes.makeEnumType("clargsType","clargsTypeType",["text","input","output","prepend","postpend","python"])
    ClargsInput.addParam("type", ClargsTypeInput, True)

    ClargsInput.addParam("arg", InputTypes.StringType, False)
    ClargsInput.addParam("extension", InputTypes.StringType, False)
    ClargsInput.addParam("delimiter", InputTypes.StringType, False)
    inputSpecification.addSub(ClargsInput)
    ## End command line arguments tag

    ## Begin file arguments tag
    FileargsInput = InputData.parameterInputFactory("fileargs")

    FileargsTypeInput = InputTypes.makeEnumType("fileargsType", "fileargsTypeType",["input","output","moosevpp"])
    FileargsInput.addParam("type", FileargsTypeInput, True)

    FileargsInput.addParam("arg", InputTypes.StringType, False)
    FileargsInput.addParam("extension", InputTypes.StringType, False)
    inputSpecification.addSub(FileargsInput)
    ## End file arguments tag

    return inputSpecification
Beispiel #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(DTW, cls).getInputSpecification()
        orderInputType = InputTypes.makeEnumType("order", "orderType",
                                                 ["0", "1"])
        inputSpecification.addSub(InputData.parameterInputFactory(
            "order", contentType=orderInputType),
                                  quantity=InputData.Quantity.one)
        inputSpecification.addSub(InputData.parameterInputFactory(
            "localDistance", contentType=InputTypes.StringType),
                                  quantity=InputData.Quantity.one)

        return inputSpecification
Beispiel #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.
 """
     inputSpecification = super(FTImporter, cls).getInputSpecification()
     fileAllowedFormats = InputTypes.makeEnumType("FTFileFormat",
                                                  "FTFileFormatType",
                                                  ["OpenPSA"])
     inputSpecification.addSub(
         InputData.parameterInputFactory("fileFormat",
                                         contentType=fileAllowedFormats))
     inputSpecification.addSub(
         InputData.parameterInputFactory("topEventID",
                                         contentType=InputTypes.StringType))
     return inputSpecification
Beispiel #15
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(DateBase, cls).getInputSpecification()
     inputSpecification.addParam("directory", InputTypes.StringType)
     inputSpecification.addParam("filename", InputTypes.StringType)
     inputSpecification.addParam(
         "readMode",
         InputTypes.makeEnumType("readMode", "readModeType",
                                 ["overwrite", "read"]), True)
     inputSpecification.addSub(
         InputData.parameterInputFactory(
             "variables", contentType=InputTypes.StringListType))
     return inputSpecification
Beispiel #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(Model, cls).getInputSpecification()
    inputSpecification.addParam("subType", InputTypes.StringType, True)

    ## Begin alias tag
    AliasInput = InputData.parameterInputFactory("alias", contentType=InputTypes.StringType)
    AliasInput.addParam("variable", InputTypes.StringType, True)
    AliasTypeInput = InputTypes.makeEnumType("aliasType","aliasTypeType",["input","output"])
    AliasInput.addParam("type", AliasTypeInput, True)
    inputSpecification.addSub(AliasInput)
    ## End alias tag

    return inputSpecification
Beispiel #17
0
 def getInputSpecs(cls):
     """
   Collects input specifications for this class.
   @ In, specs, InputData, specs
   @ Out, specs, InputData, specs
 """
     specs = InputData.parameterInputFactory('Capex')
     specs = CashFlow.getInputSpecs(specs)
     specs.addSub(
         InputData.parameterInputFactory('reference',
                                         contentType=InputTypes.FloatType))
     specs.addSub(
         InputData.parameterInputFactory('X',
                                         contentType=InputTypes.FloatType))
     deprec = InputData.parameterInputFactory(
         'depreciation', contentType=InputTypes.InterpretedListType)
     deprecSchemes = InputTypes.makeEnumType('deprec_types', 'deprec_types',
                                             ['MACRS', 'custom'])
     deprec.addParam('scheme', param_type=deprecSchemes, required=True)
     specs.addSub(deprec)
     return specs
Beispiel #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("dataObjectLabelFilter"))
     DOLFDataTypeType = InputTypes.makeEnumType("DOLFDataType",
                                                "DOLFDataTypeType",
                                                ['HistorySet', 'PointSet'])
     inputSpecification.addSubSimple("dataType", DOLFDataTypeType)
     inputSpecification.addSubSimple("label", InputTypes.StringType)
     inputSpecification.addSubSimple("clusterIDs",
                                     InputTypes.IntegerListType)
     #Should method be in super class?
     inputSpecification.addSubSimple("method",
                                     contentType=InputTypes.StringType)
     return inputSpecification
Beispiel #19
0
  outside.set('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema')
  ET.SubElement(outside, 'xsd:element', {'name':outerElement.getName(),
                                         'type':outerElement.getName()+'_type'})
  outerElement.generateXSD(outside, {})
  return outside

#
#
#
#
class RavenBase(ParameterInput):
  """
    This can be used as a base class for things that inherit from BaseType
  """
RavenBase.createClass("RavenBase", baseNode=None)
verbs = InputTypes.makeEnumType('verbosity', 'verbosityType', ['silent', 'quiet', 'all', 'debug'])
RavenBase.addParam("verbosity", param_type=verbs, descr='Desired verbosity of messages coming from this entity') #XXX should be enumeration


#
#
#
#
def doDent(d, p=0, style='  '):
  """
    Creates an indent based on desired level
    @ In, d, int, number of indents to add nominally
    @ In, p, int, number of additional indents
    @ In, style, str, optional, characters for indenting
    @ Out, dent, str, indent string
  """
Beispiel #20
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, specs, InputData.ParameterInput, class to use for specifying input of cls.
    """
    specs = super(Optimizer, cls).getInputSpecification()
    specs.description = 'Optimizers'

    # objective variable
    specs.addSub(InputData.parameterInputFactory('objective', contentType=InputTypes.StringType, strictMode=True,
        printPriority=90, # more important than <variable>
        descr=r"""Name of the response variable (or ``objective function'') that should be optimized
        (minimized or maximized)."""))

    # modify Sampler variable nodes
    variable = specs.getSub('variable')
    variable.addSub(InputData.parameterInputFactory('initial', contentType=InputTypes.FloatListType,
        descr=r"""indicates the initial values where independent trajectories for this optimization
              effort should begin. The number of entries should be the same for all variables, unless
              a variable is initialized with a sampler (see \xmlNode{samplerInit} below). Note these
              entries are ordered; that is, if the optimization variables are $x$ and $y$, and the initial
              values for $x$ are \xmlString{1, 2, 3, 4} and initial values for $y$ are \xmlString{5, 6, 7, 8},
              then there will be four starting trajectories beginning at the locations (1, 5), (2, 6),
              (3, 7), and (4, 8)."""))

    # initialization
    ## TODO similar to MonteCarlo and other samplers, maybe overlap?
    init = InputData.parameterInputFactory('samplerInit', strictMode=True,
        printPriority=105, # more important than <variable>
        descr=r"""collection of nodes that describe the initialization of the optimization algorithm.""")
    seed = InputData.parameterInputFactory('initialSeed', contentType=InputTypes.IntegerType,
        descr=r"""seed for random number generation. Note that by default RAVEN uses an internal seed,
              so this seed must be changed to observe changed behavior. \default{RAVEN-determined}""")
    minMaxEnum = InputTypes.makeEnumType('MinMax', 'MinMaxType', ['min', 'max'])
    minMax = InputData.parameterInputFactory('type', contentType=minMaxEnum,
        descr=r"""the type of optimization to perform. \xmlString{min} will search for the lowest
              \xmlNode{objective} value, while \xmlString{max} will search for the highest value.""")
    init.addSub(seed)
    init.addSub(minMax)
    specs.addSub(init)

    ConstraintInput = InputData.parameterInputFactory('Constraint', contentType=InputTypes.StringType, strictMode=True,
        printPriority=150,
        descr=r"""name of \xmlNode{Function} which contains explicit constraints for the sampling of
              the input space of the Model. From a practical point of view, this XML node must contain
              the name of a function defined in the \xmlNode{Functions} block (see Section~\ref{sec:functions}).
              This external function must contain a method called ``constrain'', which returns True for
              inputs satisfying the explicit constraints and False otherwise.""")
    ConstraintInput.addParam("class", InputTypes.StringType, True,
        descr=r"""RAVEN class for this source. Options include \xmlString{Functions}. """)
    ConstraintInput.addParam("type", InputTypes.StringType, True,
        descr=r"""RAVEN type for this source. Options include \xmlNode{External}.""")


    ImplicitConstraintInput =  InputData.parameterInputFactory('ImplicitConstraint', contentType=InputTypes.StringType, strictMode=True,
        printPriority=150,
        descr=r"""name of \xmlNode{Function} which contains implicit constraints of the Model. From a practical
              point of view, this XML node must contain the name of a function defined in the \xmlNode{Functions}
              block (see Section~\ref{sec:functions}). This external function must contain a method called
              ``implicitConstrain'', which returns True for outputs satisfying the implicit constraints and False otherwise.""")
    ImplicitConstraintInput.addParam("class", InputTypes.StringType, True,
        descr=r"""RAVEN class for this source. Options include \xmlString{Functions}. """)
    ImplicitConstraintInput.addParam("type", InputTypes.StringType, True,
        descr=r"""RAVEN type for this source. Options include \xmlNode{External}.""")

    specs.addSub(ConstraintInput)
    specs.addSub(ImplicitConstraintInput)


    # assembled objects

    specs.addSub(InputData.assemblyInputFactory('Sampler', contentType=InputTypes.StringType, strictMode=True,
        printPriority=175,
        descr=r"""name of a Sampler that can be used to initialize the starting points for the trajectories
              of some of the variables. From a practical point of view, this XML node must contain the
              name of a Sampler defined in the \xmlNode{Samplers} block (see Section~\ref{subsec:onceThroughSamplers}).
              The Sampler will be used to initialize the trajectories' initial points for some or all
              of the variables. For example, if the Sampler selected samples only 2 of the 5 optimization
              variables, the \xmlNode{initial} XML node is required only for the remaining 3 variables."""))
    return specs
Beispiel #21
0
    def get_input_specs(cls):
        """
      Collects input specifications for this class.
      @ In, None
      @ Out, input_specs, InputData, specs
    """
        input_specs = InputData.parameterInputFactory(
            'Case',
            ordered=False,
            baseNode=None,
            descr=
            r"""The \xmlNode{Case} node contains the general physics and economics information
                required for a HERON workflow to be created and solved.""")
        input_specs.addParam(
            'name',
            param_type=InputTypes.StringType,
            required=True,
            descr=
            r"""the name by which this analysis should be referred within HERON."""
        )

        mode_options = InputTypes.makeEnumType('ModeOptions',
                                               'ModeOptionsType',
                                               ['min', 'max', 'sweep'])
        desc_mode_options = r"""determines whether the ``outer'' RAVEN should perform minimization,
                        maximization, or a parametric study."""
        econ_metrics = InputTypes.makeEnumType('EconMetrics',
                                               'EconMetricsTypes',
                                               ['NPV', 'lcoe'])
        desc_econ_metrics = r"""indicates the economic metric that should be used for the HERON analysis. For most cases, this
                        should be NPV."""

        # not yet implemented TODO
        # input_specs.addSub(InputData.parameterInputFactory('mode', contentType=mode_options, strictMode=True, descr=desc_mode_options))
        # input_specs.addSub(InputData.parameterInputFactory('metric', contentType=econ_metrics, descr=desc_econ_metrics))
        # input_specs.addSub(InputData.parameterInputFactory('differential', contentType=InputTypes.BoolType, strictMode=True,
        #     descr=r"""(not implemented) allows differentiation between two HERON runs as a desired economic metric."""
        input_specs.addSub(
            InputData.parameterInputFactory(
                'num_arma_samples',
                contentType=InputTypes.IntegerType,
                descr=
                r"""provides the number of synthetic histories that should be considered per system configuration
              in order to obtain a reasonable representation of the economic metric. Sometimes referred to as
              ``inner samples'' or ``denoisings''."""))

        # time discretization
        time_discr = InputData.parameterInputFactory(
            'time_discretization',
            descr=
            r"""node that defines how within-cycle time discretization should be handled for
        solving the dispatch.""")
        time_discr.addSub(
            InputData.parameterInputFactory(
                'time_variable',
                contentType=InputTypes.StringType,
                descr=
                r"""name for the \texttt{time} variable used in this simulation. \default{time}"""
            ))
        time_discr.addSub(
            InputData.parameterInputFactory(
                'start_time',
                contentType=InputTypes.FloatType,
                descr=
                r"""value for \texttt{time} variable at which the inner dispatch should begin. \default{0}"""
            ))
        time_discr.addSub(
            InputData.parameterInputFactory(
                'end_time',
                contentType=InputTypes.FloatType,
                descr=
                r"""value for \texttt{time} variable at which the inner dispatch should end. If not specified,
              both \xmlNode{time_interval} and \xmlNode{num_timesteps} must be defined."""
            ))
        time_discr.addSub(
            InputData.parameterInputFactory(
                'num_steps',
                contentType=InputTypes.IntegerType,
                descr=r"""number of discrete time steps for the inner dispatch.
              Either this node or \xmlNode{time_interval} must be defined."""))
        time_discr.addSub(
            InputData.parameterInputFactory(
                'time_interval',
                contentType=InputTypes.FloatType,
                descr=
                r"""length of a time step for the inner dispatch, in units of the time variable (not indices).
              Either this node or \xmlNode{num_timesteps} must be defined. Note that if an integer number of
              intervals do not fit between \xmlNode{start_time} and \xmlNode{end_time}, an error will be raised."""
            ))
        input_specs.addSub(time_discr)

        # economics global settings
        econ = InputData.parameterInputFactory(
            'economics',
            ordered=False,
            descr=
            r"""node containing general economic setting in which to perform HERON analysis."""
        )
        econ.addSub(
            InputData.parameterInputFactory(
                'ProjectTime',
                contentType=InputTypes.FloatType,
                descr=
                r"""the number of cycles (usually years) for the HERON analysis to cover."""
            ))
        econ.addSub(
            InputData.parameterInputFactory(
                'DiscountRate',
                contentType=InputTypes.FloatType,
                descr=
                r"""rate representing the time value of money to the firm used to discount cash flows
              in the multicycle economic analysis. Passed to the CashFlow module."""
            ))
        econ.addSub(
            InputData.parameterInputFactory(
                'tax',
                contentType=InputTypes.FloatType,
                descr=r"""the taxation rate, a metric which represents the
               rate at which the firm is taxed. Passed to the CashFlow module."""
            ))
        econ.addSub(
            InputData.parameterInputFactory(
                'inflation',
                contentType=InputTypes.FloatType,
                descr=
                r"""a metric which represents the rate at which the average price of goods and
              services in an economy increases over a cycle, usually a year.
              Passed to the CashFlow module."""))
        econ.addSub(
            InputData.parameterInputFactory(
                'verbosity',
                contentType=InputTypes.IntegerType,
                descr=
                r"""the level of output to print from the CashFlow calculations. Passed to the CashFlow
              module.""")
        )  # is this actually CashFlow verbosity or is it really HERON verbosity?
        input_specs.addSub(econ)

        # increments for resources
        dispatch = InputData.parameterInputFactory(
            'dispatcher',
            ordered=False,
            descr=
            r"""This node defines the dispatch strategy and options to use in the ``inner'' run."""
        )
        # TODO get types directly from Factory!
        dispatch_options = InputTypes.makeEnumType(
            'DispatchOptions', 'DispatchOptionsType',
            [d for d in known_dispatchers])
        dispatch.addSub(
            InputData.parameterInputFactory(
                'type',
                contentType=dispatch_options,
                descr=r"""the name of the ``inner'' dispatch strategy to use."""
            ))
        incr = InputData.parameterInputFactory(
            'increment',
            contentType=InputTypes.FloatType,
            descr=
            r"""When performing an incremental resource balance as part of a dispatch solve, this
              determines the size of incremental adjustments to make for the given resource. If this
              value is large, then the solve is accelerated, but may miss critical inflection points
              in economical tradeoff. If this value is small, the solve may take much longer."""
        )
        incr.addParam(
            'resource',
            param_type=InputTypes.StringType,
            required=True,
            descr=
            r"""indicates the resource for which this increment is being defined."""
        )
        dispatch.addSub(incr)
        input_specs.addSub(dispatch)

        return input_specs
Beispiel #22
0
  def get_input_specs(cls):
    """
      Collects input specifications for this class.
      @ In, None
      @ Out, input_specs, InputData, specs
    """
    cf = InputData.parameterInputFactory('CashFlow')
    cf.description = r"""node for defining a CashFlow for a particular Component. This HERON
               CashFlow will be used to generate a TEAL CashFlow from RAVEN's TEAL plugin. Note a CashFlow generally
               takes the form $C = \alpha \left(\frac{D}{D'}\right)^x$, aggregated depending
               on the \xmlAttr{type}. For more information, see the TEAL plugin for RAVEN."""

    cf.addParam('name', param_type=InputTypes.StringType, required=True,
        descr=r"""the name by which this CashFlow will be identified as part of this component. The
              general name is prefixed by the component name, such as ComponentName$\vert$CashFlowName. """)
    cf_type_enum = InputTypes.makeEnumType('CFType', 'CFType', ['one-time', 'repeating'])
    cf.addParam('type', param_type=cf_type_enum, required=True,
        descr=r"""the type of CashFlow to calculate. \xmlString(one-time) is suitable for capital
              expenditure CashFlows, while \xmlString(repeating) is used for repeating costs such as
              operations and maintenance (fixed or variable), market sales, or similar.""")
    cf.addParam('taxable', param_type=InputTypes.BoolType, required=True,
        descr=r"""determines whether this CashFlow is taxed every cycle. """)
    cf.addParam('inflation', param_type=InputTypes.StringType, required=True,
        descr=r"""determines how inflation affects this CashFlow every cycle. See the CashFlow submodule
              of RAVEN.""")
    cf.addParam('mult_target', param_type=InputTypes.BoolType, required=True,
        descr=r"""indicates whether this parameter should be a target of the multiplication factor
              for NPV matching analyses.""")
    period_enum = InputTypes.makeEnumType('period_opts', 'period_opts', ['hour', 'year'])
    cf.addParam('period', param_type=period_enum, required=False,
        descr=r"""for a \xmlNode{CashFlow} with \xmlAttr{type} \xmlString{repeating}, indicates whether
              the CashFlow repeats every time step (\xmlString{hour}) or every cycle (\xmlString{year})).
              Generally, CashFlows such as fixed operations and maintenance costs are per-cycle, whereas
              variable costs such as fuel and maintenance as well as sales are repeated every time step.""")

    driver = ValuedParam.get_input_specs('driver')
    driver.descr = r"""indicates the main driver for this CashFlow, such as the number of units sold
                   or the size of the constructed unit. Corresponds to $D$ in the CashFlow equation."""
    cf.addSub(driver)

    reference_price = ValuedParam.get_input_specs('reference_price')
    reference_price.descr = r"""indicates the cash value of the reference number of units sold.
                            corresponds to $\alpha$ in the CashFlow equation. If \xmlNode{reference_driver}
                            is 1, then this is the price-per-unit for the CashFlow."""
    cf.addSub(reference_price)

    reference_driver = ValuedParam.get_input_specs('reference_driver')
    reference_driver.desecr = r"""determines the number of units sold to which the \xmlNode{reference_price}
                              refers. Corresponds to $\prime D$ in the CashFlow equation. """
    cf.addSub(reference_driver)

    x = ValuedParam.get_input_specs('scaling_factor_x')
    x.descr = r"""determines the scaling factor for this CashFlow. Corresponds to $x$ in the CashFlow
              equation. If $x$ is less than one, the per-unit price decreases as the units sold increases
              above the \xmlNode{reference_driver}, and vice versa."""
    cf.addSub(x)

    depreciate = InputData.parameterInputFactory('depreciate', contentType=InputTypes.IntegerType)
    depreciate.descr = r"""indicates the number of cycles over which this CashFlow should be depreciated.
                       Depreciation schemes are assumed to be MACRS and available cycles are listed
                       in the CashFlow submodule of RAVEN."""
    cf.addSub(depreciate)

    return cf