How to use the causality.common.delinearize_fluent_vec 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 compute_possible_action_seqs(self, unreachable_fluent_states):
        """
        uses the known_action_seqs to compute closest transitions to the unreachable states, then uses the perceptual model to propose action sequeneces to arrive at that fluent state
        :param unreachable_fluent_states: list of linear fluent states that are unreachable
        :param known_action_seqs: list of known fluent states that are reachable and corresponding action_seqs to achieve them
        :param perceptual_model: the perceptually causal model
        :return: a dict of possible action_seqs to bring the sequence to the the unreachable states
                 each key is an unreachable state, each value is a tuple between a starting (known) fluent and a list of possible action sequences
        """

        # each key is an unreachable state, each value is a tuple between a starting (known) fluent and a list of possible action sequences
        unreachable_fluent_to_possible_action_seq = dict()
        for unreachable_fluent in unreachable_fluent_states:
            unreachable_fluent_vec = common.delinearize_fluent_vec(
                unreachable_fluent, self.n_fluents
            )

            # find the closest reachable fluents to unreachable fluent states
            distances, starting_fluents = self.compute_closest_fluents(
                unreachable_fluent_vec, self.known_action_seqs
            )

            possible_action_seqs = []
            # compute possible action_seqs using each starting reachable fluent
            for starting_fluent in starting_fluents:
                starting_fluent_vec = common.delinearize_fluent_vec(
                    starting_fluent, self.n_fluents
                )

                possible_action_seqs.append(
github mjedmonds / OpenLock / causality / causal_planner.py View on Github external
# each key is an unreachable state, each value is a tuple between a starting (known) fluent and a list of possible action sequences
        unreachable_fluent_to_possible_action_seq = dict()
        for unreachable_fluent in unreachable_fluent_states:
            unreachable_fluent_vec = common.delinearize_fluent_vec(
                unreachable_fluent, self.n_fluents
            )

            # find the closest reachable fluents to unreachable fluent states
            distances, starting_fluents = self.compute_closest_fluents(
                unreachable_fluent_vec, self.known_action_seqs
            )

            possible_action_seqs = []
            # compute possible action_seqs using each starting reachable fluent
            for starting_fluent in starting_fluents:
                starting_fluent_vec = common.delinearize_fluent_vec(
                    starting_fluent, self.n_fluents
                )

                possible_action_seqs.append(
                    (
                        starting_fluent,
                        self.compute_perceptual_action_seq(
                            starting_fluent_vec, unreachable_fluent_vec
                        ),
                    )
                )

            unreachable_fluent_to_possible_action_seq[
                unreachable_fluent
            ] = possible_action_seqs