Exemplo n.º 1
0
def _createObjFunctionCalculator():
    targVal = 0
    blankObjFunct = objFuncts.createSimpleTargValObjFunction(
        "blank"
    )  #We effectively calculate the objective function within the workflow, so are basically mocking out the objFuncttion calculator
    propsWithObjFunct = SimpleNamespace(**{"objval": (targVal, blankObjFunct)})
    objFunctCalculator = objFunctCalc.ObjectiveFunctionContrib(
        propsWithObjFunct)
    return objFunctCalculator
 def testAddPropAffectsObjFunct(self):
     targVal = 0.0
     extraProp = ("hcp", "e0", targVal)
     self.testObjA.addProp(
         *extraProp,
         weight=2.0,
         objFunct=objCmpFuncts.createSimpleTargValObjFunction("blank"))
     calcVals = SimpleNamespace(**{"hcp_v0": 2, "hcp_b0": 3, "hcp_e0": 7})
     expObjFunct = 19
     actObjFunct = self.testObjA.calculateObjFunction(calcVals)
     self.assertEqual(expObjFunct, actObjFunct)
	def addProp(self, structKey, prop:"v0,e0,b0", targVal, weight=1.0, objFunct=None ):
		if objFunct is None:
			objFunct = objCmpFuncts.createSimpleTargValObjFunction("relRootSqrDev".lower())

		self._propList.append(prop)
		self._structList.append(structKey)
		self._objFunctList.append(objFunct)
		self._weightList.append(weight)
		self._targVals.append(targVal)

		self._checkAllListsEqualLen()
		self._checkNoDuplicateProperties()
 def setUp(self):
     self.propList = ["v0", "b0"]
     self.structList = ["hcp", "hcp"]
     self.targVals = [0.0 for x in range(len(self.propList))]
     self.weightList = [1.0 for x in range(len(self.propList))]
     self.objFunctList = [
         objCmpFuncts.createSimpleTargValObjFunction("blank")
         for x in range(len(self.propList))
     ]
     self.inpLists = [
         self.propList, self.structList, self.targVals, self.weightList,
         self.objFunctList
     ]
     self.testObjA = tCode.EosObjFunctCalculator(self.propList,
                                                 self.structList,
                                                 self.targVals,
                                                 self.weightList,
                                                 self.objFunctList)
 def setUp(self):
     self.testFunction = tCode.createSimpleTargValObjFunction(
         "SqRDeV")  #Weird caps to make sure case-insensitive
     self.testFunctNoOverflowProt = tCode.createSimpleTargValObjFunction(
         "SqRDeV", catchOverflow=False)