Пример #1
0
 def localInputAndChecks(self,xmlNode):
   """
     Function to read the portion of the xml input that belongs to this specialized class
     and initialize some stuff based on the inputs got
     @ In, xmlNode, xml.etree.ElementTree.Element, Xml element node
     @ Out, None
   """
   HybridModelBase.localInputAndChecks(self, xmlNode)
   paramInput = HybridModel.getInputSpecification()()
   paramInput.parseNode(xmlNode)
   for child in paramInput.subparts:
     if child.getName() == 'TargetEvaluation':
       self.targetEvaluationInstance = child.value.strip()
     if child.getName() == 'ROM':
       romName = child.value.strip()
       self.romsDictionary[romName] = {'Instance': None, 'Converged': False, 'Valid': False}
     if child.getName() == 'settings':
       for childChild in child.subparts:
         if childChild.getName() == 'maxTrainSize':
           self.romTrainMaxSize = utils.intConversion(childChild.value)
         if childChild.getName() == 'minInitialTrainSize':
           self.romTrainStartSize = utils.intConversion(childChild.value)
         if childChild.getName() == 'tolerance':
           self.romConvergence = utils.floatConversion(childChild.value)
     if child.getName() == 'validationMethod':
       name = child.parameterValues['name']
       self.validationMethod[name] = {}
       for childChild in child.subparts:
         if childChild.getName() == 'threshold':
           self.validationMethod[name]['threshold'] = utils.floatConversion(childChild.value)
       if name != 'CrowdingDistance':
         self.raiseAnError(IOError, "Validation method ", name, " is not implemented yet!")
Пример #2
0
 def returnMap(self,outcomes,name):
   """
     This method returns a map if the ET contains symbolic sequences.
     This is needed since since RAVEN requires numeric values for sequences.
     @ In,  outcomes, list, list that contains all the sequences IDs provided in the ET
     @ In,  name, string, name of the ET
     @ Out, etMap, dict, dictionary containing the map
   """
   # check if outputMap contains string ID for  at least one sequence
   # if outputMap contains all numbers then keep the number ID
   allFloat = True
   for seq in outcomes:
     try:
       float(seq)
     except ValueError:
       allFloat = False
       break
   etMap = {}
   if allFloat == False:
     # create an integer map, and create an integer map file
     root = ET.Element('map')
     root.set('Tree', name)
     for seq in outcomes:
       etMap[seq] = outcomes.index(seq)
       ET.SubElement(root, "sequence", ID=str(outcomes.index(seq))).text = str(seq)
     fileID = name + '_mapping.xml'
     updatedTreeMap = ET.ElementTree(root)
     xmlU.prettify(updatedTreeMap)
     updatedTreeMap.write(fileID)
   else:
     for seq in outcomes:
       etMap[seq] = utils.floatConversion(seq)
   return etMap