examples/learn_search_space/__init__.py
def shrink_bbox_space(hist_tasks, curr_task):
    """Shrink search space with bounding box representation according to the historical knowledge"""
    hist_bound = np.zeros((2, len(curr_task["space"])))
    adj_bound = np.zeros((2, len(curr_task["space"])))

    hist_opt, curr_bound = rep_task(hist_tasks, curr_task)

    hist_bound[0, :] = np.min(hist_opt, axis=0)
    hist_bound[1, :] = np.max(hist_opt, axis=0)

    adj_bound[0, :] = np.max(np.stack((hist_bound[0], curr_bound[0])), axis=0)
    adj_bound[1, :] = np.min(np.stack((hist_bound[1], curr_bound[1])), axis=0)

    if np.any(adj_bound[0] > adj_bound[1]):
        return  # if no intersection, reture curr setting space
    for i in range(len(curr_task["space"])):
        key_item = next(iter(curr_task["space"][i].keys()))
        curr_task["space"][i][key_item][0] = adj_bound[0, i]
        curr_task["space"][i][key_item][1] = adj_bound[1, i]
    return
Shrink search space with bounding box representation according to the historical knowledge
Shrink search space with bounding box representation according to the historical knowledge
Shrink search space with bounding box representation according to the historical knowledge
def shrink_bbox_space(hist_tasks, curr_task):
    hist_bound = np.zeros((2, len(curr_task["space"])))
    adj_bound = np.zeros((2, len(curr_task["space"])))
    hist_opt, curr_bound = rep_task(hist_tasks, curr_task)
    hist_bound[0, :] = np.min(hist_opt, axis=0)
    hist_bound[1, :] = np.max(hist_opt, axis=0)
    adj_bound[0, :] = np.max(np.stack((hist_bound[0], curr_bound[0])), axis=0)
    adj_bound[1, :] = np.min(np.stack((hist_bound[1], curr_bound[1])), axis=0)
    if np.any(adj_bound[0] > adj_bound[1]):
        return  
    for i in range(len(curr_task["space"])):
        key_item = next(iter(curr_task["space"][i].keys()))
        curr_task["space"][i][key_item][0] = adj_bound[0, i]
        curr_task["space"][i][key_item][1] = adj_bound[1, i]
    return
def shrink_bbox_space ( hist_tasks , curr_task ) : hist_bound = np . zeros ( ( 2 , len ( curr_task [ "space" ] ) ) ) adj_bound = np . zeros ( ( 2 , len ( curr_task [ "space" ] ) ) ) hist_opt , curr_bound = rep_task ( hist_tasks , curr_task ) hist_bound [ 0 , : ] = np . min ( hist_opt , axis = 0 ) hist_bound [ 1 , : ] = np . max ( hist_opt , axis = 0 ) adj_bound [ 0 , : ] = np . max ( np . stack ( ( hist_bound [ 0 ] , curr_bound [ 0 ] ) ) , axis = 0 ) adj_bound [ 1 , : ] = np . min ( np . stack ( ( hist_bound [ 1 ] , curr_bound [ 1 ] ) ) , axis = 0 ) if np . any ( adj_bound [ 0 ] > adj_bound [ 1 ] ) : return for i in range ( len ( curr_task [ "space" ] ) ) : key_item = next ( iter ( curr_task [ "space" ] [ i ] . keys ( ) ) ) curr_task [ "space" ] [ i ] [ key_item ] [ 0 ] = adj_bound [ 0 , i ] curr_task [ "space" ] [ i ] [ key_item ] [ 1 ] = adj_bound [ 1 , i ] return
Shrink search space with bounding box representation according to the historical knowledge
Shrink search space with bounding box representation according to the historical knowledge
"""Shrink search space with bounding box representation according to the historical knowledge""" # if no intersection, reture curr setting space
hist_tasks
curr_task