Esempio n. 1
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 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)
Esempio n. 2
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.
"""
"""
#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)
Esempio n. 3
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.
"""
"""
#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)
Esempio n. 4
0
      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)
Esempio n. 5
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 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)
Esempio n. 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 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)
Esempio n. 7
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.
"""
  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)
Esempio n. 8
0
      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)
Esempio n. 9
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 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)
Esempio n. 10
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 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)
Esempio n. 11
0
# 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
    @ In, role, string, the role assumed in the Step