@ 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()
Used to make standardized distribution for this poly type. @ In, None @ Out, jacobiElement, Distribution, jacobi distribution """ jacobiElement = ET.Element("jacobi") element = ET.Element("alpha", {}) element.text = "%s" % self.params[1] + 1 jacobiElement.append(element) element = ET.Element("beta", {}) element.text = "%s" % self.params[0] + 1 jacobiElement.append(element) def norm(self, n): """ Normalization constant for polynomials so that integrating two of them w.r.t. the weight factor produces the kroenecker delta. Default is 1. @ In, n, int, polynomial order to get norm of @ Out, norm, float, value of poly norm """ a = self.params[0] b = self.params[1] ###speedup attempt 2### coeff=(2.0*n+a+b+1.0)*\ gamma(n+1)*gamma(n+a+b+1)/(gamma(n+a+1)*gamma(n+b+1))*\ gamma(a+1)*gamma(b+1)/gamma(a+b+2.0) return np.sqrt(coeff) factory = EntityFactory('OrthoPolynomial') factory.registerAllSubtypes(OrthogonalPolynomial)
# 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 March 2, 2020 @author: talbpw """ from utils import utils from EntityFactoryBase import EntityFactory from .Database import DateBase as Database from .HDF5 import HDF5 from .NetCDF import NetCDF factory = EntityFactory('Database', needsRunInfo=True, returnInputParameter=True) factory.registerAllSubtypes(Database)
# # 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 Sept 5 2017 @author: wangc """ #for future compatibility with Python 3----------------------------------------- from __future__ import division, print_function, unicode_literals, absolute_import #End compatibility block for Python 3------------------------------------------- ################################################################################ from EntityFactoryBase import EntityFactory from utils import utils from .CrossValidation import CrossValidation from .SklCrossValidation import SciKitLearn ## [ Add new class here ] factory = EntityFactory('CrossValidation') factory.registerAllSubtypes(CrossValidation)
# 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. """ """ #for future compatibility with Python 3----------------------------------------- from __future__ import division, print_function, unicode_literals, absolute_import #End compatibility block for Python 3------------------------------------------- ################################################################################ from EntityFactoryBase import EntityFactory from .AcceptanceCondition import AcceptanceCondition from .Strict import Strict factory = EntityFactory('AcceptanceCondition') factory.registerAllSubtypes(AcceptanceCondition)
# 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. """ """ #for future compatibility with Python 3----------------------------------------- from __future__ import division, print_function, unicode_literals, absolute_import #End compatibility block for Python 3------------------------------------------- ################################################################################ from EntityFactoryBase import EntityFactory from .GradientApproximater import GradientApproximater from .FiniteDifference import FiniteDifference from .CentralDifference import CentralDifference from .SPSA import SPSA factory = EntityFactory('Gradient') factory.registerAllSubtypes(GradientApproximater)
from .PostProcessors import EconomicRatio # from .PostProcessors import RavenOutput # deprecated for now ## These utilize the optional prequisite library PySide, so don't error if they ## do not import appropriately. try: from .PostProcessors.TopologicalDecomposition import QTopologicalDecomposition from .PostProcessors.DataMining import QDataMining renaming = { '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
if pt in self.active or pt in self.points: continue #remove the candidate if not all of its predecessors are accepted. found=True for j in range(self.N): checkpt = newpt[:] if checkpt[j]==0: continue checkpt[j] -= 1 if tuple(checkpt) not in self.points: found=False break if found: self.active.append(pt) def printOut(self): """ Prints the accepted/established points and the current active set to screen. @ In, None @ Out, None """ self.raiseADebug(' Accepted Points:') for p in self.points: self.raiseADebug(' ',p) self.raiseADebug(' Active Set') for a in self.active: self.raiseADebug(' ',a) factory = EntityFactory('IndexSet') factory.registerAllSubtypes(IndexSet)
# Adaptive samplers 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)
# 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 in 2020 @author: talbpaul """ from .StepManipulator import StepManipulator from .GradientHistory import GradientHistory from .ConjugateGradient import ConjugateGradient from EntityFactoryBase import EntityFactory factory = EntityFactory('StepSizer') factory.registerAllSubtypes(StepManipulator)
# # 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)
# 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)
# # 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 Jul 18 2016 @author: mandd """ from EntityFactoryBase import EntityFactory from utils import utils from .Metric import Metric from .DTW import DTW from .SklMetric import SKL from .PairwiseMetric import PairwiseMetric from .CDFAreaDifference import CDFAreaDifference from .PDFCommonArea import PDFCommonArea from .ScipyMetric import ScipyMetric factory = EntityFactory('Metric') factory.registerAllSubtypes(Metric)
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)
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__), '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)
# 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. """ Factory interface for returning classes and instances from the Time Series Analysis module. """ from EntityFactoryBase import EntityFactory from .TimeSeriesAnalyzer import TimeSeriesAnalyzer from .Fourier import Fourier from .ARMA import ARMA from .Wavelet import Wavelet factory = EntityFactory('TimeSeriesAnalyzer') # TODO map lower case to upper case, because of silly ROM namespace problems aliases = {'Fourier': 'fourier', 'ARMA': 'arma'} factory.registerAllSubtypes(TimeSeriesAnalyzer, alias=aliases)
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)
# 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 12, 2016 @author: maljdp extracted from alfoa, cogljj, crisr (3/5/2013) JobHandler.py """ from EntityFactoryBase import EntityFactory ################################################################################ from utils import utils from .Runner import Runner from .ExternalRunner import ExternalRunner from .InternalRunner import InternalRunner from .InternalThreadedRunner import InternalThreadedRunner factory = EntityFactory('Runner') factory.registerAllSubtypes(Runner)
from SupervisedLearning.NDsplineRom import NDsplineRom 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)
# 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)