Esempio n. 1
0
def runRandomSearch(): #working?
    #evaluate 'a million random solutions and choose the best one
    from random import random
    print("2. Random Probing used", end=" ")
    start= time.clock()
    count=0
    minV=Vector(9999999,999999)
    while time.clock()-start<.1:

        xmin=random()*DOMAIN_LIMIT
        ymin=random()*DOMAIN_LIMIT
        vector= Vector(xmin,ymin)
        minV= minV.minVec(vector)
        count+=1
    print(count, end="")
    print(" probes")
    print("x=",minV[0]," y=",(minV[1]),"cost=",minV.cost())
    print("Time= ",.1)