本文整理汇总了Python中objective函数的典型用法代码示例。如果您正苦于以下问题:Python objective函数的具体用法?Python objective怎么用?Python objective使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了objective函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init_objective
def test_init_objective():
def __normsquared(v):
return square(norm(v))
variables = {'dL' : [array([1,0,0]) for _ in range(4)],
'ddc': [array([0.5,0,0]) for i in range (4)],
'x' : array([ [0 for _ in range (6)] for _ in range(4)]),
'c' : array([ [0 for _ in range (3)] for _ in range(4)]),
'dc' : array([ [0 for _ in range (3)] for _ in range(4)])}
params = {'x_end' : [i for i in range(6)], 'simulate' : lambda(_): variables}
# test each cost individually
objective = init_objective([["min_dL", 1]], params)
assert(objective(variables)==4.)
objective = init_objective([["min_dL", 0.5]], params)
assert(objective(variables)==2.)
objective = init_objective([["min_ddc", 1]], params)
assert(objective(variables)==1.)
objective = init_objective([["min_ddc", 2]], params)
assert(objective(variables)==2.)
objective = init_objective([["end_reached", 1]], params)
assert(objective(variables)==__normsquared(array(params['x_end'][0:3])) + 0.5 * __normsquared(array(params['x_end'][3:6])))
objective = init_objective([["end_reached", 2]], params)
assert(objective(variables)==2* (__normsquared(array(params['x_end'][0:3])) + 0.5 * __normsquared(array(params['x_end'][3:6]))))
objective = init_objective([["min_dL", 0.5],["min_ddc", 2],["end_reached", 1]], params)
assert(objective(variables)==2 + 2 + __normsquared(array(params['x_end'][0:3])) + 0.5 * __normsquared(array(params['x_end'][3:6])))
print "test_init_objective exited normally"
示例2: testInsertObjectiveLongDesc140AndIdBacklogNoExists
def testInsertObjectiveLongDesc140AndIdBacklogNoExists(self):
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Pxsydy", 1)
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective(20 * "Llxmxry", 99, True)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例3: testInsertWrongAllParameters
def testInsertWrongAllParameters(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog('Xstryctyrzs','Mxtyrzx',1)
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective(13500,0,'True or False')
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct('Xstryctyrzs')
示例4: testInsertNoneAllParameters
def testInsertNoneAllParameters(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Mxtyrzx", 1)
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective(None, 0, None)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例5: testInsertObjectiveLongDesc1AndIdBacklogNotExistsObjTypeExists
def testInsertObjectiveLongDesc1AndIdBacklogNotExistsObjTypeExists(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Pxcxs prxfysxrys", 1)
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective("L", 7, False)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例6: testInsertObjectiveIdBacklogNoExists
def testInsertObjectiveIdBacklogNoExists(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Cxmplyczdz", 1)
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective("Dxs pyrczylcs", 99, True)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例7: testInsertObjectiveIdBacklogInvalid
def testInsertObjectiveIdBacklogInvalid(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Hxrys dz szxñy", 1)
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective("Xstsdpxr", 0, False)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例8: testDeleteObjectiveNotExist
def testDeleteObjectiveNotExist(self):
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Dxfxcxl dy zlvxdpr", 1)
findId = oBacklog.findName("Xstryctyrzs")
idBacklog = findId[0].BL_idBacklog
# Inicio de la prueba.
oObj = objective()
result = oObj.deleteObjective("Txrmynzr dx pzszr", idBacklog)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例9: testDeleteObjectiveInvalid
def testDeleteObjectiveInvalid(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Dxfxcxl dy zlvxdpr", 1)
findId = oBacklog.findName("Xstryctyrzs")
idBacklog = findId[0].BL_idBacklog
# Inicio de la prueba.
oObj = objective()
result = oObj.deleteObjective("", idBacklog)
self.assertFalse(result, "Id no válido")
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例10: testInsertWrongObjType
def testInsertWrongObjType(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Mxtyrzx yxtxnsy", 1)
findId = oBacklog.findName("Xstryctyrzs")
idBacklog = findId[0].BL_idBacklog
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective("Estudiar bastante", idBacklog, "Falseeeee")
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例11: testInsertNoneString
def testInsertNoneString(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Mxtyrzx yxtxnsy", 1)
findId = oBacklog.findName("Xstryctyrzs")
idBacklog = findId[0].BL_idBacklog
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective(None, idBacklog, False)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例12: testInsertObjectiveLongDesc0AndIdBacklogExistsObjTypeExists
def testInsertObjectiveLongDesc0AndIdBacklogExistsObjTypeExists(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Pxsydy", 1)
findId = oBacklog.findName("Xstryctyrzs")
idBacklog = findId[0].BL_idBacklog
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective("", idBacklog, True)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例13: testInsertNotString
def testInsertNotString(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog('Xstryctyrzs','Pxsydy',1)
findId = oBacklog.findName('Xstryctyrzs')
idBacklog = findId[0].BL_idBacklog
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective(4350,idBacklog,True)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct('Xstryctyrzs')
示例14: testInsertObjectiveObjTypeInvalid
def testInsertObjectiveObjTypeInvalid(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Hxrys dz szxñy", 1)
findId = oBacklog.findName("Xstryctyrzs")
idBacklog = findId[0].BL_idBacklog
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective("Xstzdyfr", idBacklog, "Falseee")
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")
示例15: testInsertObjectiveLongDesc141
def testInsertObjectiveLongDesc141(self):
# Insertamos los datos necesarios.
oBacklog = backlog()
oBacklog.insertBacklog("Xstryctyrzs", "Dx qytrx crxdytts", 1)
findId = oBacklog.findName("Xstryctyrzs")
idBacklog = findId[0].BL_idBacklog
# Inicio de la prueba.
oObj = objective()
result = oObj.insertObjective(20 * "Llxmxry" + "s", idBacklog, True)
self.assertFalse(result)
# Eliminamos los datos insertados.
oBacklog.deleteProduct("Xstryctyrzs")