Beispiel #1
0
 def __init__(self, input_box: Box, state_box: Box, refinement_list: list):
     """
     :param input_box: allowed inputs
     :param state_box: The state space where the hybridization is consturcteed
     :param refinement_list: List of the state dimensions that can be refined during hybridization
     """
     self.state_cell = StateCell(state_box.get_range())
     self.input_box = input_box
     self.state_cell.refinement_list = refinement_list
     self.size = 1
Beispiel #2
0
 def intersects(self, box: ztp.Box):
     state_range = box.get_range()
     state_patch = self.winset.get_patch(state_range)
     if state_patch is not None and np.any(state_patch > 0):
         return True
     return False
Beispiel #3
0
 def is_included(self, box: ztp.Box):
     state_range = box.get_range()
     state_patch = self.winset.get_patch(state_range)
     if state_patch is not None and np.all(state_patch > 0):
         return True
     return False
Beispiel #4
0
def compute_pre2(F, n_time_steps, X: StateCell, input_range: Box, target: Box):
    winning_size = np.zeros(target.center.shape)
    input_range_multi = input_range.get_range()
    input_range_multi = Box(np.tile(input_range_multi, (n_time_steps, 1)))
    X_new = deepcopy(X)
    cell_list = [X_new]
    while cell_list:
        cell = cell_list.pop(0)
        if cell.fully_solved():
            continue
        if np.all(cell.as_box().get_bounding_box_size() <
                  target.get_bounding_box_size() / 16):
            continue
        if np.all(cell.as_box().get_bounding_box_size() < winning_size / 2):
            print("not worth it")
            break
        cell.compute_multistep_affine(F, n_time_steps, input_range)
        assert isinstance(cell.multi_step_dynamics, AffineSys)
        ru = cell.multi_step_dynamics.get_ru(input_range_multi)
        ru_inv = copy(ru)
        ru_inv.center = -ru_inv.center
        pre_target_over = target.minkowski_sum(
            cell.multi_step_dynamics.W).minkowski_sum(ru_inv)
        if np.all(target.get_bounding_box_size() >=
                  cell.multi_step_dynamics.W.get_bounding_box_size()):
            target_under = target.get_bounding_box()
            target_under.generators = target.generators - cell.multi_step_dynamics.W.get_bounding_box(
            ).generators
            target_under.center = target_under.center - cell.multi_step_dynamics.W.center
            pre_target_under = target_under.minkowski_sum(ru_inv)
        else:
            pre_target_under = None
        sub_list = [cell]
        while sub_list:
            sub_cell = sub_list.pop(0)
            if np.all(
                    sub_cell.as_box().get_bounding_box_size() < winning_size /
                    2):
                print("not worth it")
                break
            if np.all(sub_cell.as_box().get_bounding_box_size() <
                      target.get_bounding_box_size() / 16):
                continue
            assert isinstance(sub_cell.multi_step_dynamics, AffineSys)
            rx = sub_cell.multi_step_dynamics.get_rx(sub_cell.as_box())
            if pre_target_over.intersects(rx):
                if pre_target_over.contains(rx):
                    if pre_target_under and pre_target_under.contains(rx):
                        winning_size = np.maximum(
                            winning_size,
                            sub_cell.as_box().get_bounding_box_size())
                        sub_cell.is_winning = True
                    else:
                        sub_cell.split_cell()
                        cell_list = cell_list + sub_cell.children
                else:
                    sub_cell.split_cell()
                    sub_list = sub_list + sub_cell.children
            else:
                continue
    return X_new