📄 ipp.h
字号:
/********************************************************************* * File: ipp.h * Description: Types and structures for the IPP planner. * * Author: Joerg Hoffmann / Frank Rittinger / Andreas Schoen * Contact: hoffmann@informatik.uni-freiburg.de * *********************************************************************/ /********************************************************************* * (C) Copyright 1998 Albert Ludwigs University Freiburg * Institute of Computer Science * * All rights reserved. Use of this software is permitted for * non-commercial research purposes, and it may be copied only * for that use. All copies must include this copyright message. * This software is made available AS IS, and neither the authors * nor the Albert Ludwigs University Freiburg make any warranty * about the software or its performance. *********************************************************************/#ifndef __IPP_H#define __IPP_H#include <stdlib.h>#include <stdio.h>#include <strings.h>#include <ctype.h>#include <sys/types.h>#include <sys/times.h>/* * ------------------------------------ DEFINES ---------------------------- *//*********************** * MEANINGLESS HELPERS * ***********************//* if this is defined, memory consumption gets recorded */#define MEMORY_INFO/* fprintf s are parametrized with OUT */#define ERR stderr#define OUT stdout/* * The following constants are for exit_codes for shellscripts */#ifndef ERROR_CODES#define ERROR_CODES#define EXIT_FAILURE 1 /* for not yet classified errors */#define NOT_SUPPORTED_ERROR_CODE 2#define BADDOMAIN_ERROR_CODE 3#define FCT_PARSE_ERROR_CODE 4#define FCT_MISSING_ERROR_CODE 5#define OPS_PARSE_ERROR_CODE 6#define OPS_MISSING_ERROR_CODE 7#define PARSE_ERROR_CODE 8#define USAGE_ERROR_CODE 9#define OTHER_ERROR_CODE 10 #define INTERNAL_ERROR_CODE 11 /* these errors should never happen finally */#define TRAFO_INTERNAL_ERROR_CODE 12#endif/* strcmp returns 0 if two strings are equal, which is not nice */#define SAME 0/**************** * PARSING ETC. * ****************//* type of quantifier, used for parsing */#define NO_QUANT '-'#define ALL_QUANT 'A'#define EX_QUANT 'E'#define ANY_PRED 0#define EQ 1#define EQ_STR "eq"#define NOT_EQ 2#define NOT_PRED '!'#define NOT_EQ_PRED "!eq"#define NO_SOLUTION "NO SOLUTION\n"/* * The following constants are for pl1 expression preprocessing. */#define LIT_CONST 1#define AND_CONST 2#define OR_CONST 3#define IMPLY_CONST 4#define NOT_CONST 5#define EXISTS_CONST 6 #define FORALL_CONST 7#define LBRACK_CONST 8#define RBRACK_CONST 9#define VAR_CONST 10#define ENDNOT_CONST 11#define HIDDEN_STR "#"#define AXIOM_STR "AXIOM"#define NAME_STR "name\0"#define VARIABLE_STR "variable\0"#define STANDARD_TYPE "OBJECT\0"#define GOAL_OP_STR "#REACHGOAL"#define GOAL_REACHED "#GOALREACHED"#define EITHER_STR "EITHER"/*************************** * SOME ARBITRARY SETTINGS * ***************************//* maximal string length */#define MAX_LENGTH 256 /* marks border between connected items */#define CONNECTOR "~"/* der blanke wahnsinn */#define NOOP "noop"/************************ * INSTANTIATION LIMITS * ************************/#define MAX_CONSTANTS_TABLE 500#define MAX_PREDICATES_TABLE 50#define MAX_TYPES_TABLE 200#define MAX_ARITY 6#define MAX_VARS 15#define MAX_RELEVANT_FACTS 10000/* i think this is VERY generous... *//****************************** * GRAPH AND SEARCHING LIMITS * ******************************/#define MAX_PLAN 300#define ARRAY_SIZE 50#define MEMO_HASHSIZE 4#define MEMO_HASH 3/**************** * CODE DEFINES * ****************//* define boolean types if not allready defined */#ifndef Booltypedef unsigned char Bool;#ifndef TRUE /* we assume that FALSE is also not defined */#define TRUE 1#define FALSE 0#endif /* TRUE */#endif /* Bool *//* Check allocated memory */#define CHECK_PTR(p) if (NULL == (p)) { \ exit(1);}/* add elapsed time from main local time vars to specified val */#define TIME( val ) val += ( float ) ( ( end.tms_utime - start.tms_utime + \ end.tms_stime - start.tms_stime ) / 100.0 )/* compute the adress of negative fact in fact array */#define NEG_ADR( index ) gnum_relevant_facts + index/* * ------------------------------ DATA STRUCTURES ---------------------------- *//******************* * GENERAL HELPERS * *******************//* This holds all command line switches */struct _command_line { char path[MAX_LENGTH]; char ops_file_name[MAX_LENGTH]; char fct_file_name[MAX_LENGTH]; int display_info; Bool write_graph; char *save_name; Bool do_subset; int min_time; Bool rifo_on; Bool rifo_meta_on; int rifo_union; int rifo_filter; /* for various debugging informations */ int debug;};/* different reasons for program termination */typedef enum {MEMORY, SYNTAX_ERROR , IO_ERROR} TermReason;typedef unsigned int BitVector, *BitVector_pointer;typedef struct _Integers { int index; struct _Integers *next;} Integers, *Integers_ptr;typedef char *String;typedef struct _StringIntegers { char *name; Integers *integers;} StringIntegers;typedef int *int_pointer;typedef int IntArray[ARRAY_SIZE];typedef char *Token;/*********** * PARSING * ***********//* A list of strings */typedef struct _TokenList { char *item; struct _TokenList *next;} TokenList;/* list of string lists */typedef struct _FactList { TokenList *item; struct _FactList *next;} FactList;/* structure to store typed-list-of <name>/<variable>, * as they are declared in PDDL files */typedef struct _TypedList { char *name; /* each item in this list is the name of a type which * our type is the union of (EITHER - types ...) * * usually, this will default to a single-item TokenList. */ TokenList *type; /* after first sweep, this will contain the number in type table */ int n; struct _TypedList *next;} TypedList;/* only needed to parse in the predicates and their arg * definitions */typedef struct _TypedListList { char *predicate; TypedList *args; struct _TypedListList *next;} TypedListList;/* This type indicates whether a node in the pddl tree stands for * an atomic expression, a junctor or a quantor. */typedef enum _Connective{ATOM, NOT, AND, OR, ALL, EX, WHEN, TRU, FAL, EMPTY, DUMMY, NEUTRAL} Connective;/* * This is a node in the tree to parse PDDL files */typedef struct _PlNode { /* type of the node */ Connective connective; /* only for parsing: the var args in quantifiers */ TypedList *parse_vars; /* AND, OR, NOT, WHEN => NULL * ALL, EX => the quantified variable with its type * ATOM => the atom as predicate->param1->param2->... */ TokenList *atom; /* (a) for AND, OR this is the list of sons(a AND b AND c...), * (b) for the rest this is the son, e.g. a subtree that is negated * (c) for WHEN, the first son is the condition and the next son * is the effect */ struct _PlNode *sons; /* if you have a list of sons, they are connected by next */ struct _PlNode *next;} PlNode;/* * This resembles an uninstantiated PDDL operator */typedef struct _PlOperator { TokenList *name; /* the params, as they are declared in domain file */ TypedList *parse_params; /* params is a list of variable/type pairs, such that: * factlist->item = [variable] -> [type] */ FactList *params; PlNode *preconds; PlNode *effects; /* only important for PDDL where :VARS may be added to the param list * which must be hidden when writing the plan to an output file */ int number_of_real_params; struct _PlOperator *next;} PlOperator;/* the type_tree structure is used to deal with types and subclasses * of types */typedef struct TYPETREE_LIST *type_tree_list, type_tree_list_elt;typedef struct TYPETREE { char *name; /* an object type */ type_tree_list sub_types;} *type_tree, type_tree_elt;struct TYPETREE_LIST { type_tree item; struct TYPETREE_LIST *next;};/***************** * INSTANTIATION * *****************/typedef int ArgArray[MAX_ARITY];typedef struct _CodeNode { /* type of node */ Connective connective; /* in quantifier nodes: number of var (in operator), type of var */ short int var, var_type; /* in atoms: number of predicate (-1 is EQ) * number of arguments (negative: num of var-1, positive: num of object) */ short int predicate; ArgArray arguments; /* speedup: in atomic inertia test, we need only check for TRU/FAL * properties if we have yet never visited that node or if we actually * change the instantiation of one of the variables in the atom */ Bool visited; struct _CodeNode *sons; struct _CodeNode *next;} CodeNode, *CodeNode_pointer;typedef struct _CodeOperator { char *name; short int var_types[MAX_VARS], num_vars, inst_table[MAX_VARS]; CodeNode *preconds; CodeNode *conditionals; /* only important for PDDL where :VARS may be added to the param list * which must be hidden when writing the plan to an output file */ int number_of_real_params; struct _CodeOperator *next;} CodeOperator;/* actually, this structure is not needed. * just for debugging and info: * stores (in grelevant_facts) the relevant fact to it's index */typedef struct _Relevant_Fact { short int predicate; ArgArray arguments;} RelevantFact, *RelevantFact_pointer;/**************************** * BITVECTOR REPRESENTATION * ****************************/typedef struct _FactInfo { BitVector *vector; Integers *indices;} FactInfo;typedef struct _FactInfoPair { FactInfo *positive; FactInfo *negative;} FactInfoPair;typedef struct _Effect { FactInfo *p_conds; FactInfo *n_conds; FactInfo *p_effects; FactInfo *n_effects; struct _Effect *next;} Effect;typedef struct _BitOperator { char *name; short int num_vars, inst_table[MAX_VARS]; FactInfo *p_preconds; FactInfo *n_preconds; Effect *unconditional; Effect *conditionals; struct _BitOperator *next;} BitOperator;/********************** * BUILDING THE GRAPH * **********************//* * Literature: e.g. Technical report 88 * "Extending Planning Graphs to an ADL Subset" * * more detailed description of current implementation * forthcoming, see IPP - Homepage * * ... or have a look into * "The efficient Implementation of the Planning Graph in STAN", * D.Long and M.Fox, JAIR, 10, 1999 *//* * ...some preliminary definitions, used in the graph nodes */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -