本文整理汇总了Python中Vector.cost方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.cost方法的具体用法?Python Vector.cost怎么用?Python Vector.cost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.cost方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: step
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import cost [as 别名]
def step(p1,p2):#radius=1
X1 = Vector(p1,p2)
for t in frange(0, pi*2, pi/4):
X = Vector(p1 + (cos(t)), p2 + (sin(t)))
if X.cost() < X1.cost():
X1.equals(X)
return X1
示例2: runRandomSearch
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import cost [as 别名]
def runRandomSearch():
startTime = clock()
vector = Vector(random()*DOMAIN_LIMIT,random()*DOMAIN_LIMIT)
minc= vector.cost()
while(clock() - startTime < MAX_RUN_TIME):
global PROBE_COUNT1
PROBE_COUNT1+=1
vector = Vector(random()*DOMAIN_LIMIT,random()*DOMAIN_LIMIT)
if(vector.cost() < minc):
minc = vector.cost()
print('2. Random Probing used', PROBE_COUNT1, 'probes.')
print('Vector =', vector, 'Cost =', round(minc,5))
print('---Search time =', round(clock() - startTime, 2), 'seconds\n')
示例3: nextTriangle
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import cost [as 别名]
def nextTriangle(A,B,C):
[B,C,A] = Vector.sort([A,B,C])
D = B + C - A
E = 3* (B+C)/ 2- 2*A
F = (3* (B+C)- 2*A)/4
G = (2* A+ B+ C)/4
if F.cost() < G.cost():
X = Vector(F)
else:
X = Vector(G)
#case 1: vertex A moves to D or E
if D.cost() < A.cost() and E.cost() < A.cost():
A.equals(E)
elif D.cost() < A.cost():
A.equals(D)
#case 2: vertex A moves to F or G
elif X.cost() < A.cost():
A.equals(X)
#case 3: vertex A moves to H and vertex C moves to I
else:
H = (A + B)/2
I = (B + C)/2
A.equals(H)
C.equals(I)
return A,B,C