4. rafcontpp.model package

4.1. Submodules

4.2. rafcontpp.model.datastore module

class rafcontpp.model.datastore.Datastore(state_pools, sm_name, sm_save_dir, planner, planner_script_path, planner_argv, facts_path, type_db_path, keep_related_files, file_save_dir='/tmp')[source]

Bases: object

Datastore is a datastore, which holds all data of the plugin. Every module can get, and store its data here.

Constructor of Datastore
Parameters:
  • state_pools – a list of file paths.
  • sm_name – the name of the state machine which will be generated.
  • sm_save_dir – the directory, where to save the generated state machine.
  • planner – the name / script path of the used planner.
  • planner_argv – a String array, with arguments for the planner.
  • facts_path – path of the facts file.
  • type_db_path – path of the type_db.
  • keep_related_files – true, if generated files e.g. the domain file or the plan should be saved.
  • file_save_dir – a path, where to save all related files.
add_generated_file(file_name)[source]
add_state_pools(state_pools, set_pool)[source]
Parameters:
  • state_pools – the state pools to add
  • set_pool – if true, state pools are not added, but set, and old list gets lost.
generate_into_state()[source]
get_action_state_map()[source]
get_available_actions()[source]
get_available_predicates()[source]
get_available_types()[source]
get_built_in_planners()[source]
get_domain_path()[source]
get_facts_path()[source]
get_file_save_dir()[source]
get_generated_files()[source]
get_pddl_action_map()[source]
get_pddl_facts_representation()[source]
get_plan()[source]
get_planner()[source]
get_planner_argv()[source]
get_planner_script_path()[source]
get_runtime_data_path()[source]
get_sm_name()[source]
get_sm_save_dir()[source]
get_state_action_map()[source]
get_state_pools()[source]
get_target_state()[source]
get_type_db_path()[source]
register_thread(interruptable_thread)[source]

gets a thread, addes it synchronized to a global map, and returns the map key (which is the register time.).

Parameters:interruptable_thread – A InterruptableThread, the datastore should store.
Returns:long: The key used to register the thread. (That’s the register time as unixtimestamp.)
remove_thread(key)[source]

Receives a timestamp as key, and removes the thread synchronized from the global map.

Parameters:key – The time, the thread was registered
Returns:Boolean: True, if removing was successful, false otherwise
save_datastore_parts_in_file(file_path)[source]

save_datastore_parts_in_file saves all plugin inputs, which are present in the datastore in a file.

Parameters:file_path – The path of the configuration file
Returns:void
set_action_state_map(action_state_map)[source]
set_available_actions(available_actions)[source]
set_available_predicates(available_predicates)[source]
set_available_types(availabe_types)[source]
set_domain_path(domain_path)[source]
set_facts_path(facts_path)[source]
set_file_save_dir(file_save_dir)[source]
set_generate_into_state(plan_into_state)[source]
set_pddl_action_map(action_map)[source]
set_pddl_facts_representation(facts_representation)[source]
set_plan(plan)[source]
set_planner(planner)[source]
set_planner_argv(planner_argv)[source]
set_planner_script_path(psp)[source]
set_runtime_data_path(runtime_data_path)[source]
set_sm_name(name)[source]
set_sm_save_dir(sm_save_dir)[source]
set_state_action_map(state_action_map)[source]
set_target_state(target_state)[source]
set_type_db_path(type_db)[source]
set_use_runtime_path_as_ref(use)[source]
use_runtime_path_as_ref()[source]
validate_ds()[source]

validate_ds runs some checks on the state_pools, the sm-save_dir, the facts_path, the type_db_path, and the file_save_dir. if a check fails, it raises a ValueError.

Returns:void
rafcontpp.model.datastore.datastore_from_file(file_path)[source]

datastore_from_file tries to create a partial datastore (just input values, no clculated ones) from a .json file e.g. config file. if there is no config file present, it returns a datastore with default values

Parameters:file_path – the path to the config file
Returns:Datastore: A partial initialized datastore, or a datastore with default values.
rafcontpp.model.datastore.get_planning_threads()[source]
Returns:{long: InterruptableThread}: A copy of the planning_threads dict.

4.3. rafcontpp.model.interruptable_thread module

class rafcontpp.model.interruptable_thread.InterruptableThread(group=None, target=None, name=None, args=(), kwargs={})[source]

Bases: threading.Thread

It’s a usual thread, but its interruptable.

A thread that is interruptable.

_bootstrap()
_bootstrap_inner()
_delete()

Remove current thread from the dict of currently running threads.

_exc_info()

exc_info() -> (type, value, traceback)

Return information about the most recent exception caught by an except clause in the current stack frame or in an older stack frame.

_initialized = False
_reset_internal_locks(is_alive)
_set_ident()
_set_tstate_lock()

Set a lock object which will be released by the interpreter when the underlying thread state (see pystate.h) gets deleted.

_stop()
_wait_for_tstate_lock(block=True, timeout=-1)
daemon

A boolean value indicating whether this thread is a daemon thread.

This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.

The entire Python program exits when no alive non-daemon threads are left.

getName()
ident

Thread identifier of this thread or None if it has not been started.

This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.

interrupt()[source]

Sets the Threads interrupted flag.

isAlive()

Return whether the thread is alive.

This method is deprecated, use is_alive() instead.

isDaemon()
is_alive()

Return whether the thread is alive.

This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.

is_interrupted()[source]
Returns:Boolean: True if the Interrupted Flag is set. False otherwise.
join(timeout=None)

Wait until the thread terminates.

This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.

When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be join()ed many times.

join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.

name

A string used for identification purposes only.

It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

setDaemon(daemonic)
setName(name)
start()

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

rafcontpp.model.interruptable_thread.current_thread()[source]

current thread returns the current interruptable thread, it was called from.

Returns:InterruptableThread: The current interruptable thread, or None if current thread is not interruptable.

4.4. rafcontpp.model.pddl_action_representation module

class rafcontpp.model.pddl_action_representation.PddlActionRepresentation(name, action, predicates, types, requirements, parameters)[source]

Bases: object

This Module represents a PDDL Action. Currently just name, predicates, types, requirements and parameters.

Parameters:
  • name – The name of the action.
  • action – The pddl action as string.
  • predicates – A list of predicates used in the action.
  • types – A list of types used in the action.
  • requirements – A list of requirements.
  • parameters – The parameter names of the action without the ? symbol.
rafcontpp.model.pddl_action_representation.action_to_upper(action)[source]
action to upper receives an action in pddl_action_representation, and returns it in upper case.
Parameters:action – A action in PddlActionRepresentation
Returns:PddlActionRepresentation: The action in upper case

4.5. rafcontpp.model.pddl_facts_representation module

class rafcontpp.model.pddl_facts_representation.PddlFactsRepresentation(facts_string, obj_type_map, domain_name, problem_name)[source]

Bases: object

This is the representation of the pddl facts file (not completed yet.)

Parameters:
  • facts_string – The facts file content as string.
  • obj_type_map – A map, containing all objects with their types.
  • domain_name – The name of the domain the facts file is for.
  • problem_name – The name of the problem / task.
get_original_object_name(object_name)[source]

takes the name of an object, which is now maybe uppercase, or lowercase, and returns the original format.

Parameters:object_name – The maybe changed representation of an object (maybe uppercase now).
Returns:String: The object name in original format, or the given object_name, if no original was found.

4.6. rafcontpp.model.plan_step module

class rafcontpp.model.plan_step.PlanStep(name, parameter)[source]

Bases: object

Intern format, to represent a pddl-plan step. In this format, a plan step is splitted into the action name, and the action parameters.

Represents a step of the plan, in other words one parameterized action of the plan.

Parameters:
  • name – The name of the action as String.
  • args – The parameters of the action as [String].

4.7. rafcontpp.model.planner_interface module

class rafcontpp.model.planner_interface.PlannerInterface[source]

Bases: object

plan_scenario(domain_path, facts_path, planner_argv, storage_path)[source]

plan_scenario, uses the given arguments to plan a task, parse the plan into a list of PlanSteps, and returns them in a PlanningReport.

Parameters:
  • domain_path – The absolute path of the domain file as string.
  • facts_path – The absolute path of the facts file as string.
  • planner_argv – Some additional planner args as string array.
  • storage_path – The location, where to save all produced artefacts (like a plan file) in. as string.
Returns:

PlanningReport: A PlanningReport (rafcontpp.model.planning_report).

4.8. rafcontpp.model.planning_report module

class rafcontpp.model.planning_report.PlanningReport(planning_successful, plan, generated_files, error_message='No Error!')[source]

Bases: object

PlanningReport is a report, generated by the Planner Interface. It contains the information, if planning was successful, the found plan, and in case an Error Message, as well as a refernce to all files, which where generated by the planner or the planner Interface.

Parameters:
  • planning_successful – A Boolean to indicate, if planning was successful.
  • plan – The Plan as [PlanStep]
  • generated_files – A list, containing the names of all generated files.
  • error_message – An error message, in case something went wrong.
get_error_message()[source]
Returns:String: An error message, in case something went wrong.
get_generated_files()[source]
Returns:[String]: A list, containing all names of files, generated by the planner.
get_plan()[source]
Returns:[PlanStep]: Returns the Plan.
planning_successful()[source]
Returns:Boolean: True if planning was successful, false otherwhise

4.9. rafcontpp.model.type_tree module

class rafcontpp.model.type_tree.TypeTree(type_name)[source]

Bases: object

A class that helps to create a pddl-type-tree TypeTree is a datastructure that helps to create a pddl-type-tree out of a type databse containing type:parent entries. although it is a type tree, it has no advantages of a tree-datastructure. so its not sorted in a way, and is not fast in searching or inserting!

Needs the name of a type, and returns a type-tree-node. the node it self is a TypeTree.

Parameters:type_name – The name of a Type, can’t be None!
Return TypeTree:
 A TypeTree object
_TypeTree__insert(type_name, parent_name)

__insert takes a typeName and a parentName, and inserts the typeName as child of the parentName into the tree.

Parameters:
  • type_name – The name of the type to insert
  • parent_name – The direct parent of the type to insert
Returns:

Boolean: True if insert was successful, false otherwise. (for example if the parent is not in the tree yet.)

add_type_branch(type_name, type_dict)[source]

addTypeBranch does not only add the given type, but also the whole branch. this means it also adds all parents, all children and their children to the type tree.

Parameters:
  • type_name – The name of a type.
  • type_dict – A type dictionary, containing the type.
Returns:

Boolean: True if insert was successfull, false otherwise.

get_as_list()[source]

Takes the Tree, and writes all its elements into a list

Returns:[String]: A list, contining all types of the tree
get_as_pddl_string()[source]

Returns a string in pddl notation representing the type-tree.

Returns:String: Returns the typetree as pddl conform string.
get_parent_of(type_name)[source]

get_parent_of receives a type name, and searchs in the tree for it’s parent.

Parameters:type_name – A type name
Returns:String: The parent name or None if the type has no parent or is not in tree.
get_smallest_parent(type_a, type_b)[source]

gets two types and finds their smallest parent. E.g. given a type t1 and a type t2: if: t2 is parent of t1, it will return t2 if t1 is the parent of t2, it will return t1 if t3 is the parent of t1 and t2, it will return t3 if t1 or t2 is not in the tree, it will return None.

Parameters:
  • type_a – A type a
  • type_b – A type b
Returns:

String: The smallest parent, or None

get_sub_tree(type_to_search)[source]

get_sub_tree gets a type, and returns the subtree, with the type as root.

Parameters:type_to_search – The root of the subtree to get
Returns:TypeTree: A sub tree, or None if the type is not in the tree.
insert(type_name, parent_name)[source]

insert takes a typeName and a parentName, and inserts it into the tree. insert does not work, if the parent is not in the tree yet.

Parameters:
  • type_name – The name of the type to insert.
  • parent_name – The direct parent of the type to insert.
Returns:

Boolean: True if insert was successful, false otherwise. (for example if the parent is not in the tree yet.)

is_in_tree(type_to_search)[source]

isInTree searchs the typeTree for a specific type, and returns true, if the tree contains the type. unfortunately the tree is not sorted, and has a complexity of O(n)

Parameters:type_name – The name of the type to search.
Returns:Boolean: True if the tree contains the type, else false.
is_parent_of(parent, child)[source]

is_parent_of receives two types, and returns true, if the first type it the parent of the second type.

Parameters:
  • parent – The maybe parent type.
  • child – The maybe child type.
Returns:

Boolean: True, if the parent is really the parent of the child, false otherwise.

recursive_insert(type_name, type_dict)[source]

recursiveInsert needs a typeName and a typeDict and inserts the type with it’s parents into the tree.

Parameters:
  • type_name – The name of a type.
  • type_dict – A type dicitonary, containing the type.
Returns:

Boolean: True if insert was successfull, false otherwise.

4.10. Module contents