From 7eb39d1a2b3001481db117603e5b0a3915fd0c3e Mon Sep 17 00:00:00 2001 From: sfop Date: Tue, 30 Aug 2016 18:19:39 +0200 Subject: [PATCH] Script execution --- script/Alignment/Optimization_search.py | 31 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/script/Alignment/Optimization_search.py b/script/Alignment/Optimization_search.py index 34c8e6c..a1af581 100644 --- a/script/Alignment/Optimization_search.py +++ b/script/Alignment/Optimization_search.py @@ -1,33 +1,44 @@ ################################################################################################### # Using bsearch(Binary Search) and hsearch(Hill Climbing Search) to find optimum ################################################################################################### - - + run("camtool") +add_device(CamTool("image_stats", prefix = "SINEG01-DSCR190:", latch = True, camera = "SINEG01-DSCR190"), True) + +image_stats.start() +image_stats.setNumberOfImages(5) + +laser_off() +image_stats.captureBackground(10) +laser_on() +image_stats.setNumberOfImages(5) +image_stats.enableBackground (True) + + +def before_sample(): + image_stats.update() + class FitnessFunction(ReadonlyRegisterBase): def doRead(self): + r = lscan(gun_solenoid, [image_stats.com_x_mean, image_stats.com_y_mean] , 110.0, 120.0, 1.0, 0.1, before_read = before_sample) return 1000.0 - (math.pow(ao1.take()-18, 2) + math.pow(ao2.take()-6, 2)) add_device(FitnessFunction("fitness"), True) -#Plot Fitness Function -r = ascan([ao1, ao2], fitness, [0.0,0.0], [21.0,26.0], [1.0, 1.0], title = "Fitness") + +""" #Binary Search strategy = "Normal" # or "Boundary" or "FullNeighborhood" r = bsearch([ao1, ao2], fitness, [0.0,0.0], [21.0,26.0], [0.1, 0.1], maximum=True, strategy = strategy, latency = 0.01, title = "Binary Search") -#Relative search: -#ao1.write(10.5); ao2.write(13.0) -#r = bsearch([ao1, ao2], fitness, [-10.5,-13.0], [10.5,13.0], [0.1, 0.1],relative = True, maximum=True, strategy = "Normal", title = "Binary Search") print "--------------- Binary Search -----------------" print r print r.print() print len(r.getRecords()) - + """ #Hill Climbing Search -ao1.write(10.5); ao2.write(13.0) -r = hsearch([ao1, ao2], fitness,[0.0,0.0], [21.0,26.0], [1.0, 1.0], [0.1, 0.1], 1, relative = False, maximum=True, latency = 0.01, title = "Hill Climbing") +r = hsearch([gsx, gsy, gsrx, gsry], fitness,[-1.0,-1.0,-1.0,-1.0], [1.0,1.0,1.0,1.0], [0.1, 0.1, 0.1, 0.1], [0.01, 0.01, 0.01, 0.01], 3, relative = False, maximum=False, latency = 0.01, title = "Hill Climbing") print "--------------- Hill Climbing Search -----------------" print r print r.print()