How to use the causality.common.tabulate function in causality

To help you get started, we’ve selected a few causality examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mjedmonds / OpenLock / causality / causal_planner.py View on Github external
def extract_reachable_states_from_demonstration(self, fluents, actions):
        """
        determines all reachable states from a demonstration and the corresponding action sequences to reach each state.
        :param fluents: 2d-array of fluent states observed in the demonstration
        :param actions: 2d-array of actions executed in the demonstration
        :return: known_action_seqs: contains a linear index for each fluent state reachable and a list of action sequences capable of reaching the state
        """

        # setup fluent space
        fluent_space = common.tabulate(self.fluent_labels)

        # setup known action_seqs
        known_action_seqs = dict()
        action_seq = []
        for i in range(0, fluents.shape[0]):
            fluent_vec = fluents[i]

            if i == 0:
                self.initial_fluent_state = fluent_vec
                continue

            prev_action_val = actions[i - 1]

            lin_fluent_vec = common.linearize_fluent_vec(fluents[i])
            action_executed = np.where(prev_action_val > 0)[
                0
github mjedmonds / OpenLock / causality / counterfactuals.py View on Github external
def main():
    data_dir = "../OpenLock/scenario_outputs/action_reversal/output_node_"
    trial_name = "ex1_extended"

    perceptual_model = cc.PerceptualModel(data_dir + trial_name + ".mat")

    # tabulate full fluent space
    fluent_space = cc.tabulate(perceptual_model.fluents)

    print("All done!")