plan4dial.for_generating.parsers.pddl_parser

This module contains all the files necessary to convert from the HOVOR configuration to PDDL. This PDDL is later used to generate the controller/tree that determines how the conversation is navigated.

Authors: - Rebecca De Venezia

Functions

get_init_fluents(context_variables)

Convert the initial state of context variables to a PDDL initial state.

get_precond_fluents(context_variables, ...)

Convert an action precondition to PDDL fluents.

get_update_fluents(context_variables, updates)

Converts the update configuration of an action outcome to PDDL fluents.

parse_to_pddl(loaded_yaml)

Converts the loaded YAML file to a PDDL specification.

_action_to_pddl(context_variables: Dict, act: str, act_config: Dict) str[source]

Converts an action from the YAML configuration to PDDL.

Parameters:
  • context_variables (Dict) – The configuration of all context variables.

  • act (str) – The action name.

  • act_config (Dict) – The action configuration.

Returns:

The converted action.

Return type:

str

_actions_to_pddl(loaded_yaml: Dict) str[source]

Converts actions from the YAML to PDDL format.

Parameters:

loaded_yaml (Dict) – The loaded YAML configuration.

Returns:

The converted actions.

Return type:

str

_fluents_to_pddl(fluents: List[str], tabs: int, name_wrap: str | None = None, and_wrap: bool = False, outer_brackets: bool = True) str[source]

Converts a list of fluents to PDDL. Adds tabs, outer brackets, names and “and” wraps as appropriate.

Parameters:
  • fluents (List[str]) – A list of the string versions of the fluents.

  • tabs (int) – The “base” indentation of the fluents.

  • outer_brackets (bool. optional) – Setting to wrap the final statement with outer brackets, i.e. (outcome ...) Defaults to True.

  • name_wrap (str, optional) – Setting to wrap fluents with a name, i.e. :predicates. Defaults to None.

  • and_wrap (bool, optional) –

    Setting to wrap fluents with an “and”, i.e.

    :precondition
        (and (...))
    

    Defaults to False.

Returns:

The converted PDDL fluents.

Return type:

str

_get_is_fflag(context_variables: Dict, v_name: str) bool[source]

Determines if the provided variable has a “known” setting of type fflag.

Parameters:
  • context_variables (Dict) – The configuration of all context variables.

  • v_name (str) – The name of the variable.

Returns:

Indicates if the provided variable has a “known” setting of type fflag.

Return type:

bool

_parse_predicates(context_variables: Dict) List[str][source]

Converts the context variables to PDDL predicates.

Parameters:

context_variables (Dict) – The configuration of all context variables.

Returns:

The collection of converted predicates.

Return type:

List[str]

_return_certainty_fluents(v_name: str, is_fflag: bool, certainty: str) List[str][source]

Returns the fluent version of the certainty setting of a context variable depending on the setting supplied.

Parameters:
  • v_name (str) – The name of the variable.

  • is_fflag (bool) – Describes if the variable’s “known” type is fflag, in which case the “Uncertain” option can be considered.

  • certainty (str) – The certainty setting of this context variable.

Returns:

The list of fluents that reflect the certainty setting for the context variable supplied.

Return type:

List[str]

_return_flag_value_fluent(v_name: str, is_fflag: bool, value: bool | str) str[source]

Returns the fluent version of a flag or fflag context variable depending on the setting supplied.

Parameters:
  • v_name (str) – The name of the variable.

  • is_fflag (bool) – Describes if the variable is of type fflag, in which case the “maybe” option can be considered.

  • value (bool or str) – The value setting of this context variable.

Returns:

The fluent version of a flag or fflag context variable depending on the setting supplied.

Return type:

str

get_init_fluents(context_variables: Dict) Tuple[Set[str], Set[str]][source]

Convert the initial state of context variables to a PDDL initial state.

Parameters:

context_variables (Dict) – The configuration of all context variables.

Returns:

The partial initial state, which indicates all fluents that are initially true; used in the PDDL. Also returns the complete initial state, which indicates the state of all fluents in the initial state. Used by the rollout configuration.

Return type:

Tuple[Set[str], Set[str]]

get_precond_fluents(context_variables: Dict, conditions: List[str | bool]) Set[str][source]

Convert an action precondition to PDDL fluents.

Parameters:
  • context_variables (Dict) – The configuration of all context variables.

  • conditions (List[Union[str, bool]]) – The conditions to be converted.

Returns:

The set of converted fluents.

Return type:

Set[str]

get_update_fluents(context_variables: Dict, updates: Dict) Set[str][source]

Converts the update configuration of an action outcome to PDDL fluents.

Parameters:
  • context_variables (Dict) – The configuration of all context variables.

  • updates (Dict) – The update configuration.

Returns:

The set of fluents that were added by the outcome update.

Return type:

Set[str]

parse_to_pddl(loaded_yaml: Dict) Tuple[str, str][source]

Converts the loaded YAML file to a PDDL specification.

Parameters:

loaded_yaml (Dict) – The loaded YAML configuration.

Returns:

The generated PDDL domain and problem.

Return type:

Tuple[str, str]