Beispiel #1
0
    def get_reachable_abs_states(
            self,
            intermediate_state,
            A,
            system_params,
            ):

        state = intermediate_state
        total_num_samples = state.n

        #property_checker = lambda t, Y: Y in system_params.final_cons
        #property_checker = PropertyChecker(system_params.final_cons)
        rchd_concrete_state_array = cp.compute_concrete_plant_output(
                A,
                system_params.plant_sim,
                state,
                total_num_samples)
        #print(rchd_concrete_state_array)
        #exit()

        # ================= DIRECT MANIPULATION ===================
        # of StateArray object
        # rchd_cont_state_array = rchd_concrete_state_array.cont_states

        # for each reached state, get the abstract state
        pi_ref = system_params.pi_ref
        ci_ref = system_params.ci_ref

        abs2rchd_abs_state_ci_pi_list = []
        for rchd_concrete_state in rchd_concrete_state_array.iterable():

            rchd_abs_state = \
                A.get_abs_state_from_concrete_state(rchd_concrete_state)
            ci = rchd_concrete_state.ci
            pi = rchd_concrete_state.pi
            pi_cell = self.cell_id_from_concrete(pi, pi_ref.eps)
            ci_cell = self.cell_id_from_concrete(ci, ci_ref.eps)

#             print('{} -> {} -> {}'.format(
#                 rchd_concrete_state.x,
#                 rchd_abs_state.plant_state.cell_id,
#                 CM.ival_constraints(rchd_abs_state.plant_state.cell_id, self.eps))
#                     )

            if rchd_concrete_state.x in system_params.final_cons:
                assert system_params.is_final(A, rchd_abs_state)
#                     print(rchd_concrete_state)
#                     print(self.get_ival_cons_abs_state(rchd_abs_state.ps))
#                     print(rchd_concrete_state.x)
#                     print(system_params.final_cons)
#                     raise err.Fatal('cant happen!')

            if rchd_abs_state is not None:
                abs2rchd_abs_state_ci_pi_list.append((rchd_abs_state, ci_cell, pi_cell))

                # ##!!##logger.debug('abs_state obtained {} from concrete_state {}'.format(rchd_abs_state, rchd_concrete_state))

        return abs2rchd_abs_state_ci_pi_list
Beispiel #2
0
    def get_reachable_abs_states_sym(
            self,
            sampled_state,
            A,
            system_params,
            ):

        pi_ref = system_params.pi_ref
        state = sampled_state
        total_num_samples = state.n

        #property_checker = lambda t, Y: Y in system_params.final_cons
        property_checker = PropertyChecker(system_params.final_cons)
        rchd_concrete_state_array = cp.compute_concrete_plant_output(
                A,
                system_params.plant_sim,
                state,
                total_num_samples,
                property_checker)

        # ================= DIRECT MANIPULATION ===================
        # of StateArray object
        # rchd_cont_state_array = rchd_concrete_state_array.cont_states

        # for each reached state, get the abstract state

        # abs2rchd_abs_state_set = set()

        abs2rchd_abs_state_ci_pi_list = []
        for rchd_concrete_state in rchd_concrete_state_array.iterable():

            rchd_abs_state = \
                self.get_abs_state_from_concrete_state(rchd_concrete_state)

            # A.get_abs_state_from_concrete_state(rchd_concrete_state)

            ci = rchd_concrete_state.ci
            pi = rchd_concrete_state.pi
            pi_cell = self.cell_id_from_concrete(pi, pi_ref.eps)

            # TODO: which state becomes none?? Verfiy

            if rchd_abs_state is not None:

                # abs2rchd_abs_state_set.add(rchd_abs_state)

                abs2rchd_abs_state_ci_pi_list.append((rchd_abs_state, ci, pi_cell))

                # # ##!!##logger.debug('abs_state obtained {} from concrete_state {}'.format(rchd_abs_state, rchd_concrete_state))
        # return abs2rchd_abs_state_set

        return abs2rchd_abs_state_ci_pi_list
Beispiel #3
0
    def get_reachable_abs_states(
        self,
        intermediate_state,
        A,
        system_params,
    ):

        state = intermediate_state
        total_num_samples = state.n

        property_checker = lambda t, Y: Y in system_params.final_cons
        rchd_concrete_state_array = cp.compute_concrete_plant_output(
            A, system_params.plant_sim, state, total_num_samples,
            property_checker)
        #print(rchd_concrete_state_array)
        #exit()

        # ================= DIRECT MANIPULATION ===================
        # of StateArray object
        # rchd_cont_state_array = rchd_concrete_state_array.cont_states

        # for each reached state, get the abstract state
        pi_ref = system_params.pi_ref
        ci_ref = system_params.ci_ref

        abs2rchd_abs_state_ci_pi_list = []
        for rchd_concrete_state in rchd_concrete_state_array.iterable():

            rchd_abs_state = \
                A.get_abs_state_from_concrete_state(rchd_concrete_state)
            ci = rchd_concrete_state.ci
            pi = rchd_concrete_state.pi
            pi_cell = self.cell_id_from_concrete(pi, pi_ref.eps)
            ci_cell = self.cell_id_from_concrete(ci, ci_ref.eps)

            if rchd_concrete_state.x in system_params.final_cons:
                if not system_params.is_final(A, rchd_abs_state):
                    print(rchd_concrete_state)
                    print(self.get_ival_cons_abs_state(rchd_abs_state.ps))
                    print(rchd_concrete_state.x)
                    print(system_params.final_cons)
                    raise err.Fatal('cant happen!')

            if rchd_abs_state is not None:
                abs2rchd_abs_state_ci_pi_list.append(
                    (rchd_abs_state, ci_cell, pi_cell))

                # ##!!##logger.debug('abs_state obtained {} from concrete_state {}'.format(rchd_abs_state, rchd_concrete_state))

        return abs2rchd_abs_state_ci_pi_list
Beispiel #4
0
    def get_reachable_abs_states_sym(
        self,
        sampled_state,
        A,
        system_params,
    ):

        pi_ref = system_params.pi_ref
        state = sampled_state
        total_num_samples = state.n

        property_checker = lambda t, Y: Y in system_params.final_cons
        rchd_concrete_state_array = cp.compute_concrete_plant_output(
            A, system_params.plant_sim, state, total_num_samples,
            property_checker)

        # ================= DIRECT MANIPULATION ===================
        # of StateArray object
        # rchd_cont_state_array = rchd_concrete_state_array.cont_states

        # for each reached state, get the abstract state

        # abs2rchd_abs_state_set = set()

        abs2rchd_abs_state_ci_pi_list = []
        for rchd_concrete_state in rchd_concrete_state_array.iterable():

            rchd_abs_state = \
                self.get_abs_state_from_concrete_state(rchd_concrete_state)

            # A.get_abs_state_from_concrete_state(rchd_concrete_state)

            ci = rchd_concrete_state.ci
            pi = rchd_concrete_state.pi
            pi_cell = self.cell_id_from_concrete(pi, pi_ref.eps)

            # TODO: which state becomes none?? Verfiy

            if rchd_abs_state is not None:

                # abs2rchd_abs_state_set.add(rchd_abs_state)

                abs2rchd_abs_state_ci_pi_list.append(
                    (rchd_abs_state, ci, pi_cell))

                # # ##!!##logger.debug('abs_state obtained {} from concrete_state {}'.format(rchd_abs_state, rchd_concrete_state))
        # return abs2rchd_abs_state_set

        return abs2rchd_abs_state_ci_pi_list