7 from random 
import randint
    15         _eval_callback = 
lambda _:
None    38                 for key, value 
in config.items():
    45         def __init__(self, desc, eval_callback, timeout = 60):
    58                 default_values =  [ self.
normalize(param_desc) 
for _, param_desc 
in self._params_desc.items() ]
    67                 es = cma.CMAEvolutionStrategy(default_values, self.
SIGMA)
    77                                 rospy.loginfo(
"==============================" + \
    78                                                           "==============================" )
    79                                 rospy.loginfo(
"Iteration #%d: ", es.itereigenupdated)
    80                                 rospy.loginfo(
"______________________________" + \
    81                                                           "______________________________" )
    83                                         rospy.loginfo(
"\t# of samples: %d", es.best.evalsall )
    85                                         rospy.loginfo(
"\tbest solution found = \n\t\t%s: ", 
    86                                                                         ",\n\t\t".join([ str(key) + 
" : " + str(value) 
    88                                         rospy.loginfo(
"\tbest objective value = \t%f: ", es.best.f )
    91                                 rospy.loginfo(
"______________________________" + \
    92                                                           "______________________________" )
    94                                 rospy.loginfo(
"running experiment for: \n\t %s", repr(list(sol)) )
    96                                 rospy.loginfo(
"objective value = %f: \n", cost)
    99                                 rospy.loginfo(
"==============================" + \
   100                                                           "==============================" )
   102                         es.tell(solutions, costs)
   112                 params = self._params_desc.keys()
   117                 for i 
in range(len(params)):
   120                         config[param] = self.
denormalize(values[i], desc[
"min"], desc[
"max"])                   
   126                 value_range = param_desc[
'max'] - param_desc[
'min']
   127                 value = (param_desc[
'default'] - param_desc[
'min']) / value_range
   131                 value_range = vmax - vmin
   132                 nvalue = value * value_range + vmin
   139                 print "raw values are: {0}".format(values)
   141                 if any(val>1 
or val<0 
for val 
in values):
   149                         print(
"OUT OF BOUND")
   150                         return self.
INF * obj_val
   172                         print "extracted configs are: {0}".format(config)
   174                         print "timeout is: {0}".format(self.
_timeout)                   
   176                         def timeout_wrapper():
   178                         res = timeout_wrapper()
   180                         print "result is: {0}".format(res)
   186                         e = sys.exc_info()[0]
   188                         print(
"experiment timeout. Error: %s" % e)
   189                         print(
"returning infinity")
   194                                 print "Seems something is wrong!! Do you want to continue?"   196                         return self.
INF + randint(-50000, 50000)
   199                         e = sys.exc_info()[0]
   201                         traceback.print_exc()
   203                         print(
"Something went wrong. Error: %s" % e)            
   204                         print(
"returning infinity")
   206                         return self.
INF + randint(-50000, 50000)
 def set_timeout(self, timeout)
def __init__(self, desc, eval_callback, timeout=60)
def set_params_config(self, config)
def denormalize(self, value, vmin, vmax)
def normalize(self, param_desc)
def set_params_desc(self, desc)
def timeout(seconds=10, error_message=os.strerror(errno.ETIME))
def set_eval_callback(self, func)
def extract_config(self, values)