Example #1
0
def getxy_rel_ignoramous_force_min_samples(cell1, cell2, force, N, sim, t0=0):
    """getxy_rel_ignoramous

    Parameters
    ----------
    force : force to return non-zero samples. Will loop for infinitiy
            if none exists.
    """
    xl = []
    yl = []
    sat_count = 0
    if __debug__:
        obs_cells = set()
    while True:
        x_array, y_array = getxy_ignoramous(cell1, N, sim, t0=0)
        if __debug__:
            for i in y_array:
                obs_cells.add(CM.cell_from_concrete(i, cell1.eps))
            print('reachable cells:', obs_cells)

        # satisfying indexes
        sat_array = cell2.ival_constraints.sat(y_array)
        sat_count += np.sum(sat_array)
        xl.append(x_array[sat_array])
        yl.append(y_array[sat_array])
        # If no sample is found and force is True, must keep sampling till
        # satisfying samples are found
        if (sat_count >= MIN_TRAIN) or (not force):
            break
        if __debug__:
            print('re-sampling, count:', sat_count)

    print('found samples: ', sat_count)
    return np.vstack(xl), np.vstack(yl)
Example #2
0
def getxy_rel_ignoramous(cell1, cell2, force, N, sim, t0=0):
    """getxy_rel_ignoramous

    Parameters
    ----------
    force : force to return non-zero samples. Will loop for infinitiy
            if none exists.
    """
    xl = []
    yl = []
    sat_count = 0
    iter_count = itertools.count()
    print(cell1.ival_constraints)
    print(cell2.ival_constraints)
    if __debug__:
        obs_cells = set()
    while next(iter_count) <= MAX_ITER:
        x_array, y_array = getxy_ignoramous(cell1, N, sim, t0=0)
        if __debug__:
            for i in y_array:
                obs_cells.add(CM.cell_from_concrete(i, cell1.eps))
            print('reachable cells:', obs_cells)
        # satisfying indexes
        sat_array = cell2.ival_constraints.sat(y_array)
        sat_count += np.sum(sat_array)
        xl.append(x_array[sat_array])
        yl.append(y_array[sat_array])
        if sat_count >= MIN_TRAIN:
            break
        # If no sample is found and force is True, must keep sampling till
        # satisfying samples are found
    if __debug__:
        if sat_count < MIN_TRAIN:
            err.warn('Fewer than MIN_TRAIN samples found!')
    print('found samples: ', sat_count)
    return np.vstack(xl), np.vstack(yl)
Example #3
0
 def cell_id_from_concrete(self, X, eps):
     # the cell is same as cell_id so...
     return CM.cell_from_concrete(X, eps)
Example #4
0
 def cell_id_from_concrete(self, X, eps):
     # the cell is same as cell_id so...
     return CM.cell_from_concrete(X, eps)