Example #1
0
from SupervisedLearning.SciKitLearn        import SciKitLearn
from SupervisedLearning.SyntheticHistory   import SyntheticHistory
from SupervisedLearning.pickledROM         import pickledROM
from SupervisedLearning.PolyExponential    import PolyExponential
from SupervisedLearning.DynamicModeDecomposition import DynamicModeDecomposition
from SupervisedLearning.ROMCollection      import Collection, Segments, Clusters, Interpolated
from .KerasClassifier import KerasClassifier
from SupervisedLearning.KerasMLPClassifier import KerasMLPClassifier
from SupervisedLearning.KerasConvNetClassifier import KerasConvNetClassifier
from SupervisedLearning.KerasLSTMClassifier import KerasLSTMClassifier
from SupervisedLearning.ROMCollection      import Collection, Segments, Clusters

################################################################################

factory = EntityFactory('supervisedLearning')
factory.registerType('NDspline'              , NDsplineRom)
factory.registerType('NDinvDistWeight'       , NDinvDistWeight)
factory.registerType('NDsplineRom'           , NDsplineRom)
factory.registerType('SciKitLearn'           , SciKitLearn)
factory.registerType('GaussPolynomialRom'    , GaussPolynomialRom)
factory.registerType('HDMRRom'               , HDMRRom)
factory.registerType('MSR'                   , MSR)
factory.registerType('ARMA'                  , ARMA)
factory.registerType('SyntheticHistory'      , SyntheticHistory)
factory.registerType('pickledROM'            , pickledROM)
factory.registerType('PolyExponential'       , PolyExponential)
factory.registerType('DMD'                   , DynamicModeDecomposition)
factory.registerType('Segments'              , Segments)
factory.registerType('Clusters'              , Clusters)
factory.registerType('Interpolated'          , Interpolated)
factory.registerType('KerasMLPClassifier'    , KerasMLPClassifier)
Example #2
0
__moduleInterfaceList = []
startDir = os.path.join(os.path.dirname(__file__), 'PostProcessorFunctions')
for dirr, _, _ in os.walk(startDir):
    __moduleInterfaceList.extend(glob(os.path.join(dirr, "*.py")))
    utils.add_path(dirr)
__moduleImportedList = []

factory = EntityFactory('InterfacedPostProcessor')
for moduleIndex in range(len(__moduleInterfaceList)):
    if 'class' in open(__moduleInterfaceList[moduleIndex]).read():
        __moduleImportedList.append(
            utils.importFromPath(__moduleInterfaceList[moduleIndex], False))
        for key, modClass in inspect.getmembers(__moduleImportedList[-1],
                                                inspect.isclass):
            # in this way we can get all the class methods
            classMethods = [
                method for method in dir(modClass)
                if callable(getattr(modClass, method))
            ]
            if 'run' in classMethods:
                factory.registerType(key, modClass)


def interfaceClasses():
    """
    This returns the classes available
    @ In, None
    @ Out, interfaceClasses, list of classes available
  """
    return list(factory._registeredTypes.values())
Example #3
0
from glob import glob
import inspect
#External Modules End--------------------------------------------------------------------------------

#Internal Modules------------------------------------------------------------------------------------
from EntityFactoryBase import EntityFactory
from utils import utils
#Internal Modules End--------------------------------------------------------------------------------

__moduleInterfaceList = []
startDir = os.path.join(os.path.dirname(__file__), 'CodeInterfaces')
for dirr, _, _ in os.walk(startDir):
    __moduleInterfaceList.extend(glob(os.path.join(dirr, "*.py")))
    utils.add_path(dirr)
__moduleImportedList = []

factory = EntityFactory('Code')
for moduleIndex in range(len(__moduleInterfaceList)):
    if 'class' in open(__moduleInterfaceList[moduleIndex]).read():
        __moduleImportedList.append(
            utils.importFromPath(__moduleInterfaceList[moduleIndex], False))
        for key, modClass in inspect.getmembers(__moduleImportedList[-1],
                                                inspect.isclass):
            # in this way we can get all the class methods
            classMethods = [
                method for method in dir(modClass)
                if callable(getattr(modClass, method))
            ]
            if 'createNewInput' in classMethods:
                factory.registerType(key.replace("Interface", ""), modClass)
Example #4
0
from Samplers.AdaptiveSampler import AdaptiveSampler
from Samplers.LimitSurfaceSearch import LimitSurfaceSearch
from Samplers.AdaptiveSobol import AdaptiveSobol
from Samplers.AdaptiveSparseGrid import AdaptiveSparseGrid
from Samplers.AdaptiveMonteCarlo import AdaptiveMonteCarlo

# Dynamic Event Tree-based Samplers
from Samplers.DynamicEventTree import DynamicEventTree
from Samplers.AdaptiveDynamicEventTree import AdaptiveDynamicEventTree

# MCMC Samplers
from .MCMC import Metropolis
from .MCMC import AdaptiveMetropolis

factory = EntityFactory('Sampler')
factory.registerType('MonteCarlo', MonteCarlo)
factory.registerType('Grid', Grid)
factory.registerType('Stratified', Stratified)
factory.registerType('FactorialDesign', FactorialDesign)
factory.registerType('ResponseSurfaceDesign', ResponseSurfaceDesign)
factory.registerType('Sobol', Sobol)
factory.registerType('SparseGridCollocation', SparseGridCollocation)
factory.registerType('CustomSampler', CustomSampler)
factory.registerType('EnsembleForward', EnsembleForward)
factory.registerType('LimitSurfaceSearch', LimitSurfaceSearch)
factory.registerType('AdaptiveSobol', AdaptiveSobol)
factory.registerType('AdaptiveSparseGrid', AdaptiveSparseGrid)
factory.registerType('DynamicEventTree', DynamicEventTree)
factory.registerType('AdaptiveDynamicEventTree', AdaptiveDynamicEventTree)
factory.registerType('AdaptiveMonteCarlo', AdaptiveMonteCarlo)
factory.registerType('Metropolis', Metropolis)
Example #5
0
      @ In, None
      @ Out, keys, list, list of available methods in this Function module (imported module)
    """
        return self.__actionDictionary.keys()

    def parameterNames(self):
        """
      Get a list of the variables this function needs
      @ In, None
      @ Out, __inputVariables, list, the parameter names
    """
        return self.__inputVariables[:]


factory = EntityFactory('function',
                        needsRunInfo=True,
                        returnInputParameter=True)
factory.registerType('External', External)

# add input specifications in FunctionCollection
FunctionCollection.addSub(External.getInputSpecification())


def returnInputParameter():
    """
    Function returns the InputParameterClass that can be used to parse the
    whole collection.
    @ Out, returnInputParameter, FunctionCollection, class for parsing.
  """
    return FunctionCollection()
Example #6
0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
  Created on May 21, 2016
  @author: chenj
"""

from EntityFactoryBase import EntityFactory

################################################################################
from .Optimizer import Optimizer
from .RavenSampled import RavenSampled
from .GradientDescent import GradientDescent
from .SimulatedAnnealing import SimulatedAnnealing
from .GeneticAlgorithm import GeneticAlgorithm

factory = EntityFactory('Optimizer')
factory.registerType('GradientDescent', GradientDescent)
factory.registerType('SimulatedAnnealing', SimulatedAnnealing)
factory.registerType('GeneticAlgorithm', GeneticAlgorithm)
Example #7
0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
  Created on April 5, 2016
  @author: maljdp
  extracted from alfoa (11/14/2013) OutStreamManager.py
"""

from EntityFactoryBase import EntityFactory

from utils import utils

from .OutStreamBase import OutStreamBase
from .FilePrint import FilePrint
from .GeneralPlot import GeneralPlot
# from .DataMining import DataMining
# from .VDCComparison import VDCComparison

factory = EntityFactory('OutStreamBase')
factory.registerType('Print', FilePrint)
factory.registerType('Plot', GeneralPlot)
Example #8
0
      Pickle dump method hook.
      @ In, None
      @ Out, stateDict, dict, dict of objets needed to restore instance
    """
        stateDict = File.__getstate__(self)
        stateDict['perturbed'] = self.perturbed
        stateDict['subDirectory'] = self.subDirectory
        stateDict['alias'] = self.alias
        return stateDict

    def __setstate__(self, stateDict):
        """
      Pickle load method hook.
      @ In, stateDict, dict, of objets needed to restore instance
      @ Out, None
    """
        File.__setstate__(self, stateDict)
        self.perturbed = stateDict['perturbed']
        self.subDirectory = stateDict['subDirectory']
        self.alias = stateDict['alias']


#
#
#
#
factory = EntityFactory('Files')
factory.registerType('RAVEN', RAVENGenerated)
factory.registerType('CSV', CSV)
factory.registerType('Input', UserGenerated)
Example #9
0
        'QTopologicalDecomposition': 'TopologicalDecomposition',
        'QDataMining': 'DataMining'
    }
except ImportError:
    renaming = {}

factory = EntityFactory('Model', needsRunInfo=True)
factory.registerAllSubtypes(Model, alias=renaming)

# #here the class methods are called to fill the information about the usage of the classes
for className in factory.knownTypes():
    classType = factory.returnClass(className, None)
    classType.generateValidateDict()
    classType.specializeValidateDict()

factory.registerType('External', ExternalPostProcessor)


def validate(className, role, what, caller):
    """
    This is the general interface for the validation of a model usage
    @ In, className, string, the name of the class
    @ In, role, string, the role assumed in the Step
    @ In, what, string, type of object
    @ In, caller, instance, the instance of the caller
    @ Out, None
  """
    if className in factory.knownTypes():
        return factory.returnClass(className,
                                   caller).localValidateMethod(role, what)
    else:
Example #10
0
# Copyright 2017 Battelle Energy Alliance, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Created on September 16, 2015
@author: maljdp
extracted from alfoa (2/16/2013) DataObjects.py
"""
from EntityFactoryBase import EntityFactory

from DataObjects.DataObject import DataObject
from DataObjects.DataSet import DataSet
from DataObjects.PointSet import PointSet
from DataObjects.HistorySet import HistorySet

factory = EntityFactory('DataObject')
factory.registerType('DataSet', DataSet)
factory.registerType('HistorySet', HistorySet)
factory.registerType('PointSet', PointSet)