Example #1
0
def stage_0_read(reactor_id):
    children = None
    if reactor_id==None:
        children = database_manager.fetch_children()
    elif isinstance(reactor_id,list):
        children = database_manager.fetch_children_subset(id=reactor_id)
    hanashi.create_new_batch(np.array([[None] for i in range(len(reactor_id))]),servers=reactor_id)
    hanashi.step()
Example #2
0
def uniform(alpha):
    with open("../data/spectra/neutral_spectrum_components.json") as f:
        coefficients = json.load(f)["coefficients"]
        coefficients = np.array(coefficients)
        coefficients = alpha * coefficients
        hanashi.create_new_batch(
            coefficients.reshape((1, coefficients.shape[0])))
        hanashi.step()
Example #3
0
 def resolution_search_step(self):
     print(datetime.datetime.now().strftime("[%D - %H:%M:%S]") + "Resolution search step start.")
     set_time(self.time_color)
     self.set_color()
     shared_memory.set("batch_done", False)
     hanashi.step()
     wait(lambda : shared_memory.get('batch_done'))
     self.previous_color_results = self.color_results[:]
     self.color_results = self.get_variations()
     print(datetime.datetime.now().strftime("[%D - %H:%M:%S]") + "Resolution search step end.")
Example #4
0
def fitness(X_cube, mode="volume", high=None, low=None, E=1):
    """
        mode: str
            -volume: expects the energy constranint to be smaller than a threshold
            -surface: expects the energy constraint to be equal to a threshold
        """
    high = np.ones(X_cube.shape[1]) if not high else high
    low = np.zeros(X_cube.shape[1]) if not low else low
    scale = np.array([high, low])
    if mode == "volume":
        X = hypercube_to_simplex(X_cube.copy(), scale)
    elif mode == "surface":
        #In this case there is a dimension reduction
        X = hypercube_to_simplex(X_cube.copy(), scale)
        u = E - X.sum(axis=1)
        u = u.reshape((u.shape[0], 1))
        X = np.hstack([u, X])
    print(X)
    shared_memory.set('batch_done', False)
    batch = hanashi.create_new_batch(X)
    R = hanashi.step()
    wait(lambda: shared_memory.get('batch_done'))
    id = batch["id"]
    Y = hanashi.get_from_id(id, return_request_id=True)
    Y = {u[1]: u[0] for u in Y}
    y = [Y[k] for k in np.array(R)[:, 2].astype(int)]
    return np.array(y).ravel()
Example #5
0
def push():
    """
    Pushes all assignments to the children servers.
    """
    if request.method == "GET":
        notification = hanashi.step()
        return notification, 200