diff --git a/.gitignore b/.gitignore index 0c1615723..9fec616e3 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ src/PLASMA/TinyXml/test/textfile.txt src/PLASMA/Utils/test/writeTest.xml src/Java/PSEngine/generated/* \#*# +PSEngineAdditionalClasses \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..59c0b11dd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: cpp +compiler: + - gcc + - clang +env: + - OPTIMIZE=0 COVERAGE=0 + - OPTIMIZE=1 COVERAGE=0 + - OPTIMIZE=0 COVERAGE=1 +matrix: + exclude: + - compiler: clang + env: OPTIMIZE=0 COVERAGE=1 +before_install: sudo pip install cpp-coveralls +install: sudo add-apt-repository --yes ppa:kalakris/cmake && sudo apt-get update -qq && sudo apt-get install cmake libboost-dev libcppunit-dev libantlr3c-dev antlr swig +script: mkdir build && cd build && cmake -DOPTIMIZE=$OPTIMIZE -DCOVERAGE=$COVERAGE .. && make -j2 && ctest +after_success: + - coveralls --gcov-options '\-lp' \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 25ad07517..a4ab32a48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,42 @@ -cmake_minimum_required(VERSION 2.6) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -cmake_policy(SET CMP0042 OLD) #TODO: figure out what this means -endif(COMMAND cmake_policy) +cmake_minimum_required(VERSION 2.8.8) +if((CMAKE_MAJOR_VERSION GREATER 3) OR (CMAKE_MAJOR_VERSION EQUAL 3)) + if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) + cmake_policy(SET CMP0042 OLD) #TODO: figure out what this means + endif(COMMAND cmake_policy) +endif((CMAKE_MAJOR_VERSION GREATER 3) OR (CMAKE_MAJOR_VERSION EQUAL 3)) + +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") +project(Europa2 C CXX Java) add_definitions(-DTIXML_USE_STL=1) enable_testing() set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) +#Options to support: +# * optimized/not +option(OPTIMIZE "Build optimized" FALSE) +# * shared/not option(SHARED "Build shared libraries" TRUE) set(BUILD_SHARED_LIBS ${SHARED}) -add_subdirectory(src) \ No newline at end of file +# * 64/32-bit +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(SIXTYFOUR TRUE) +endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +option(SIXTYFOUR "Build for 64-bit" ${SIXTYFOUR}) +# * modules? +# * coverage +option(COVERAGE "Build with coverage info" FALSE) + +set(EUROPA_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) +set(CppUnit_FIND_QUIETLY TRUE) + +if(OPTIMIZE) + set(EUROPA_SUFFIX "_o") +else() + set(EUROPA_SUFFIX "_g") +endif(OPTIMIZE) + +add_subdirectory(src) +install(EXPORT Europa2 DESTINATION ${EUROPA_ROOT}/dist/europa) +install(DIRECTORY ${EUROPA_ROOT}/bin DESTINATION ${EUROPA_ROOT}/dist/europa) +install(DIRECTORY ${EUROPA_ROOT}/config DESTINATION ${EUROPA_ROOT}/dist/europa) +install(DIRECTORY ${EUROPA_ROOT}/bin/.makeproject DESTINATION ${EUROPA_ROOT}/dist/bin) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 000000000..f393661de --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# EUROPA + +[![Build Status](https://travis-ci.org/nasa/europa.svg?branch=master)](https://travis-ci.org/nasa/europa) + Coverity Scan Build Status + +[![Coverage Status](https://coveralls.io/repos/nasa/europa/badge.png)](https://coveralls.io/r/nasa/europa) + +**EUROPA is available under [NASA's Open Source Agreement (NOSA) ](http://opensource.arc.nasa.gov/page/nosa-software-agreement)** + +Welcome! EUROPA is a framework to model and tackle problems in Planning, Scheduling and Constraint Programming. EUROPA is typically embedded in a host application. It is designed to be expressive, efficient, extendable and configurable. It includes: + +- **A Plan Database:** The technology cornerstone of EUROPA for storage and manipulation of plans as they are initialized and refined. The EUROPA Plan Database integrates a rich representation for actions, states, objects and constraints with powerful algorithms for automated reasoning, propagation, querying and manipulation. +- **A Problem Solver:** A core solver to automatically find and fix flaws in the plan database. It can be configured to plan, schedule or both. It can be easily customized to integrate specialized heuristics and resolution operations. +- **A Tool Box:** Europa includes a debugger for instrumentation and visualization of applications. It also includes a very high-level, declarative modeling language for describing problem domains and partial-plans. + +[Learn more...](//github.com/nasa/europa/wiki/What-Is-Europa) + +EUROPA was developed at NASA's Ames Research Center and is available under NASA's open source agreement [(NOSA)](http://opensource.arc.nasa.gov/page/nosa-software-agreement) + +|**Getting Started**|**Documentation**|**Development**| +|-------------------|-----------------|---------------| +|[Download](https://github.com/nasa/europa/wiki/Europa-Download)|[Background/Overview](https://github.com/nasa/europa/wiki/Europa-Background)|[Building EUROPA](https://github.com/nasa/europa/wiki/Building-Europa)| +|[Installation](https://github.com/nasa/europa/wiki/Europa-Installation)|[User Documentation](https://github.com/nasa/europa/wiki/Europa-Docs)|[Automated Builds](https://github.com/nasa/europa/wiki/Nightly-Builds)| +|[Quick Start](https://github.com/nasa/europa/wiki/Quick-Start)|[Examples](https://github.com/nasa/europa/wiki/Europa-Examples)|[Developer Notes](https://github.com/nasa/europa/wiki/Misc-Development)| +||[Publications](https://github.com/nasa/europa/wiki/Europa-Publications)|[Product Roadmap](https://github.com/nasa/europa/wiki/Europa-Roadmap)| +|||[People](https://github.com/nasa/europa/wiki/Europa-Team)| + +For questions, please use the [europa-users](http://groups.google.com/group/europa-users) google group. diff --git a/bin/.makeproject/CMakeLists.txt b/bin/.makeproject/CMakeLists.txt new file mode 100644 index 000000000..4fb23f5f6 --- /dev/null +++ b/bin/.makeproject/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 2.8.8) +set(PROJECT %%Project%%) + +project(${PROJECT}) +include($ENV{EUROPA_HOME}/Europa2.cmake) + +if(${APPLE}) + set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) +else(${APPLE}) + find_package(JNI REQUIRED) +endif(${APPLE}) +include_directories(${JNI_INCLUDE_DIRS}) + +if(OPTIMIZE) + set(EUROPA_SUFFIX "_o") +else() + set(EUROPA_SUFFIX "_g") +endif(OPTIMIZE) + +file(GLOB children RELATIVE $ENV{EUROPA_HOME} $ENV{EUROPA_HOME}/*) +foreach(child ${children}) + if(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}/base) + include_directories($ENV{EUROPA_HOME}/${child}/component) + endif(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) +endforeach(child) + +#project-swig +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}) +set_source_files_properties(${PROJECT}.i PROPERTIES CPLUSPLUS ON) +set_source_files_properties(${PROJECT}.i PROPERTIES SWIG_FLAGS "-package;psengine;-includeall") +swig_add_module(${PROJECT} java ${PROJECT}.i) + + +#project-lib +add_library(${PROJECT}${EUROPA_SUFFIX} ${swig_generated_file_fullname} ${PROJECT}CustomCode.cc Module${PROJECT}.cc) + + +#project-rt +add_executable(${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-Main.cc ${PROJECT}CustomCode.cc Module${PROJECT}.cc) +target_link_libraries(${PROJECT}-planner${EUROPA_SUFFIX}_rt System${EUROPA_SUFFIX} Resource${EUROPA_SUFFIX} Solvers${EUROPA_SUFFIX} NDDL${EUROPA_SUFFIX} TemporalNetwork${EUROPA_SUFFIX} RulesEngine${EUROPA_SUFFIX} ConstraintEngine${EUROPA_SUFFIX} Utils${EUROPA_SUFFIX} TinyXml${EUROPA_SUFFIX}) + +#run-project +add_custom_target(run-project + DEPENDS ${PROJECT}-planner${EUROPA_SUFFIX}_rt + COMMAND ./${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-initial-state.nddl PlannerConfig.xml > RUN_${PROJECT}-planner${EUROPA_SUFFIX}_rt.${PROJECT}-initial-state.nddl.PlannerConfig.xml.output) + +#project_jar +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + +#find_jar(europa_jar PSEngine.jar PATHS $ENV{EUROPA_HOME}) +add_jar(${PROJECT}Jar + SOURCES + ${PROJECT}.java + ${PROJECT}JNI.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/${PROJECT}/Main.java + INCLUDE_JARS + $ENV{EUROPA_HOME}/PSEngine.jar + $ENV{EUROPA_HOME}/PSUISwing.jar + OUTPUT_NAME ${PROJECT} + ENTRY_POINT ${PROJECT}/Main + ) + +add_dependencies(${PROJECT}Jar ${PROJECT}${EUROPA_SUFFIX}) + diff --git a/bin/.makeproject/ModuleTemplate.cc b/bin/.makeproject/ModuleTemplate.cc index cde93b71d..855ac8db9 100644 --- a/bin/.makeproject/ModuleTemplate.cc +++ b/bin/.makeproject/ModuleTemplate.cc @@ -12,9 +12,9 @@ namespace EUROPA { // static C init method to get handle when loading module as shared library extern "C" { - ModuleId initializeModule() + Module* initializeModule() { - return (new Module%%Project%%())->getId(); + return (new Module%%Project%%()); } } diff --git a/bin/.makeproject/Template-Main.cc b/bin/.makeproject/Template-Main.cc index 2f6117c8d..61d9fb576 100644 --- a/bin/.makeproject/Template-Main.cc +++ b/bin/.makeproject/Template-Main.cc @@ -51,10 +51,14 @@ bool solve(const char* plannerConfig, PSEngine* engine = PSEngine::makeInstance(); engine->start(); - #ifndef USE_EUROPA_DLL - engine->addModule((new Module%%Project%%())); - #endif - engine->executeScript("nddl",nddlFile,true/*isFile*/); +#ifndef USE_EUROPA_DLL + engine->addModule((new Module%%Project%%())); +#endif + std::string errors = engine->executeScript("nddl",nddlFile,true/*isFile*/); + if(!errors.empty()) { + std::cout << errors << std::endl; + return false; + } PSSolver* solver = engine->createSolver(plannerConfig); runSolver(solver,startHorizon,endHorizon,maxSteps); diff --git a/bin/checkreqs b/bin/checkreqs deleted file mode 100755 index e190bb62b..000000000 --- a/bin/checkreqs +++ /dev/null @@ -1,366 +0,0 @@ -#!/bin/sh -# -# The checkreqs script checks for the EUROPA2 build requirements -# (jam, java, gcc, doxygen) and runs them to check that the correct -# versions are in the path. -# -JAMVERSTR="Minimum Jam version is 2.4" -MINJAM_I=2 -MINJAM_J=4 -JAMPATH="/usr/local/beta/bin" -BADJAM=0 -BADOSTYPE=1 -GCCVERSTR="Minimum gcc version is 3.3.3" -MINGCC_I=3 -MINGCC_J=3 -MINGCC_K=3 -GCCPATH="/usr/local/beta/gcc-3.3.3/bin" -BADGCC=0 -JAVAVERSTR="Minimum Java version is 1.5.0" -MINJAVA_I=1 -MINJAVA_J=5 -MINJAVA_K=0 -JAVAPATH="/usr/local/jdk1.5.0/bin" -BADJAVA=0 -DOXVERSTR="Minimum Doxygen version is 1.2.14" -MINDOX_I=1 -MINDOX_J=2 -MINDOX_K=14 -DOXPATH="/usr/local/bin" -BADDOX=0 -BADPATH=0 -BADENVV=0 -BADJH=0 -BADBAL=0 -BADLL=0 - -echo "Checking for required software versions:" - - -# $OSTYPE can have multiple vals in Linux so handle it in one place (here) -os=$OSTYPE -case $OSTYPE in *linux* ) - os="linux" ;; -esac - -#Check for minimum Jam version -JAMVER=`jam -v | egrep "Jam [0-9]\.[0-9]+" | cut -d" " -f2` -if [ -n "$JAMVER" ] -then - i=`echo $JAMVER | cut -d. -f1` - j=`echo $JAMVER | cut -d. -f2` -# ignore version info after the "r" as in 2.5rc3 - j=`echo $j | cut -dr -f1` - if [ $i -lt $MINJAM_I ] - then - BADJAM=1 - else - if [ $i -eq $MINJAM_I -a $j -lt $MINJAM_J ] - then - BADJAM=1 - fi - fi - if [ $BADJAM -eq 1 ] - then - echo " Jam version found is too old for build: version " $JAMVER - echo " " $JAMVERSTR - fi -else - echo "Did not find any version of Jam in search path" - BADJAM=1 -fi -if [ $BADJAM -eq 0 ] -then - echo " Found Jam version $JAMVER" -fi - -#Check for minimum gcc version -GCCVER=`gcc -v 2>&1 | egrep 'gcc version [0-9]\.[0-9]+' | cut -d" " -f3` -if [ -n "$GCCVER" ] -then - i=`echo $GCCVER | cut -d. -f1` - j=`echo $GCCVER | cut -d. -f2` - k=`echo $GCCVER | cut -d. -f3` -# ignore version info after the "_" as in 3.3.3_01 - k=`echo $k | cut -d_ -f1` - if [ $i -lt $MINGCC_I ] - then - BADGCC=1 - else - if [ $i -le $MINGCC_I -a $j -lt $MINGCC_J ] - then - BADGCC=1 - else - if [ $os != darwin ] - then - if [ $i -le $MINGCC_I -a $j -le $MINGCC_J -a $k -lt $MINGCC_K ] - then - BADGCC=1 - fi - fi - fi - fi - if [ $BADGCC -eq 1 ] - then - echo " gcc version found is too old for build: version " $GCCVER - echo " " $GCCVERSTR - fi -else - BADGCC=1 - echo "Did not find any version of gcc in search path" -fi -if [ $BADGCC -eq 0 ] -then - echo " Found gcc version $GCCVER" -fi - - -#Check for minimum Java version -JAVAVER=`java -version 2>&1 | egrep 'java version .[0-9]\.[0-9]+\.[0-9]+' | cut -d"\"" -f2` -if [ -n "$JAVAVER" ] -then - i=`echo $JAVAVER | cut -d. -f1` - j=`echo $JAVAVER | cut -d. -f2` - k=`echo $JAVAVER | cut -d. -f3` -# ignore version info after the "_" as in 1.4.2_05 - k=`echo $k | cut -d_ -f1` - if [ $i -lt $MINJAVA_I ] - then - BADJAVA=1 - else - if [ $i -le $MINJAVA_I -a $j -lt $MINJAVA_J ] - then - BADJAVA=1 - else - if [ $i -le $MINJAVA_I -a $j -le $MINJAVA_J -a $k -lt $MINJAVA_K ] - then - BADJAVA=1 - fi - fi - fi - if [ $BADJAVA -eq 1 ] - then - echo " Java version found is too old for build: version " $JAVAVER - echo " " $JAVAVERSTR - fi -else - BADJAVA=1 - echo "Did not find any version of java in search path" -fi - -if [ $BADJAVA -eq 0 ] -then - echo " Found java version $JAVAVER" -fi - -#Check for minimum Doxygen version -DOXVER=`doxygen -h 2>&1 | egrep 'Doxygen version [0-9]\.[0-9]+\.[0-9]+' | cut -d" " -f3` -if [ -n "$DOXVER" ] -then - i=`echo $DOXVER | cut -d. -f1` - j=`echo $DOXVER | cut -d. -f2` - k=`echo $DOXVER | cut -d. -f3` -# ignore version info after the "_" as in 1.2.16_xx - k=`echo $k | cut -d_ -f1` - if [ $i -lt $MINDOX_I ] - then - BADDOX=1 - else - if [ $i -le $MINDOX_I -a $j -lt $MINDOX_J ] - then - BADDOX=1 - else - if [ $i -le $MINDOX_I -a $j -le $MINDOX_J -a $k -lt $MINDOX_K ] - then - BADDOX=1 - fi - fi - fi - if [ $BADDOX -eq 1 ] - then - echo " Doxygen version found is too old for build: version " $DOXVER - echo " " $DOXVERSTR - fi -else - BADDOX=1 - echo "Did not find any version of Doxygen in search path" -fi - -if [ $BADDOX -eq 0 ] -then - echo " Found doxygen version $DOXVER" -fi - -#These are some suggested actions if version is missing or too old -if [ $BADJAM -eq 1 ] -then - echo "Your path to Jam may be set wrong." - if [ $os = solaris ] - then - echo "Be sure to include $JAMPATH in your path." - else - if [ $os = linux ] - then - echo "Use: find /usr -name 'jam2.*'" - echo "to help locate the required Jam executable." - fi - fi -fi - - -if [ $BADGCC -eq 1 ] -then - echo "Your path to gcc may be set wrong." - if [ $os = solaris ] - then - echo "Be sure to include $GCCPATH in your path." - else - if [ $os = linux ] - then - echo "Use: find /usr -name gcc-3.3.3" - echo "to help locate the required gcc executable." - fi - fi -fi - - -if [ $BADJAVA -eq 1 ] -then - echo "Your path to Java may be set wrong." - if [ $os = solaris ] - then - echo "Be sure to include $JAVAPATH in your path." - else - if [ $os = linux ] - then - echo "Use: find /usr -name 'jdk1.*'" - echo "to help locate the required gcc executable." - fi - fi -fi - -if [ $BADDOX -eq 1 ] -then - echo "Your path to Doxygen may be set wrong." - if [ $os = solaris ] - then - echo "Be sure to include $DOXPATH in your path." - else - if [ $os = linux ] - then - echo "Use: find /usr -name doxygen" - echo "to help locate the required doxygen executable." - fi - fi -fi - -if [ $BADJAM -eq 1 -o $BADGCC -eq 1 -o $BADJAVA -eq 1 -o $BADDOX -eq 1 ] -then - BADPATH=1 -else - echo "Path includes required versions to build EUROPA2" -fi - -echo "Checking for required environment variables:" - -#Check OS type set to a known OS -if [ $os = darwin ] -then - BADOSTYPE=0 -fi - -if [ $os = solaris ] -then - BADOSTYPE=0 -fi - -if [ $os = linux ] -then - BADOSTYPE=0 -fi - -if [ $BADOSTYPE -eq 1 ] -then - echo " [PROBLEM!] Unknown OSTYPE " $os - echo " Known values are darwin, solaris, and *linux* (ie gnu-linux, linux, linux-gnu, etc)." -else - echo " OSTYPE is set to " $os -fi - -if [ -z "$ANT_HOME" ] -then - ANT_HOME_SET=0 - ANT_HOME=$PWD/ext/ant - echo "ANT_HOME is not set, using $ANT_HOME" -else - ANT_HOME_SET=1 - echo "ANT_HOME is set to $ANT_HOME" -fi - -ANTTEST=`$ANT_HOME/bin/ant -f "checkant.xml"` -if [ $? -eq 0 ] -then - echo " Ant self test successful." -else - echo "$ANTTEST" - if [ $ANT_HOME_SET -eq 1 ] - then - echo " Suggest unsetting \$ANT_HOME" - else - echo " Suggest installing Apache Ant from http://ant.apache.org and setting \$ANT_HOME accordingly" - fi -fi - -if [ -z "$JAVA_HOME" ] -then - echo "JAVA_HOME environment variable missing or not set" - BADJH=1 -else - echo " JAVA_HOME is set to " $JAVA_HOME -fi - -#check load library -if [ $os = darwin ] -then - if [ -z "$DYLD_LIBRARY_PATH" ] - then - echo " DYLD_LIBRARY_PATH environment variable missing or not set" - BADLL=1 - else - echo " DYLD_LIBRARY_PATH is set to " $DYLD_LIBRARY_PATH - fi -else - if [ -z "$LD_LIBRARY_PATH" ] - then - echo " LD_LIBRARY environment variable missing or not set" - BADLL=1 - else - echo " LD_LIBRARY_PATH is set to " $LD_LIBRARY_PATH - fi -fi - -if [ $os = darwin ] -then - if [ "$DYLD_BIND_AT_LAUNCH" != YES ] - then - echo "DYLD_BIND_AT_LAUNCH environment variable missing or not set to YES" - BADENV=1 - else - echo " DYLD_BIND_AT_LAUNCH is set to " $DYLD_BIND_AT_LAUNCH - fi -fi - -if [ $BADJH -eq 1 -o $BADPATH -eq 1 -o $BADLL -eq 1 ] -then - BADENVV=1 - echo "Environment variables may not be set correctly to build EUROPA2" -else - echo "Required environment variables are present" -fi - -if [ $BADPATH -eq 1 -o $BADENVV -eq 1 ] -then - exit 1 -fi - -exit 0 diff --git a/build.xml b/build.xml deleted file mode 100644 index b84047d26..000000000 --- a/build.xml +++ /dev/null @@ -1,625 +0,0 @@ - - - EUROPA's Master build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/circle.yml b/circle.yml new file mode 100644 index 000000000..4bf2c3a25 --- /dev/null +++ b/circle.yml @@ -0,0 +1,12 @@ +dependencies: + pre: + - sudo apt-get update; sudo pip install cpp-coveralls; sudo add-apt-repository --yes ppa:kalakris/cmake && sudo apt-get update -qq && sudo apt-get install cmake libboost-dev libcppunit-dev antlr swig; sudo apt-get install jam doxygen libantlr3c-3.2-0 libcppunit-1.13-0 ant subversion gcc-4.8 swig; + - wget http://www.antlr3.org/download/C/libantlr3c-3.4.tar.gz -O /tmp/libantlr3c-3.4.tar.gz + - tar -zxf /tmp/libantlr3c-3.4.tar.gz + - pushd libantlr3c-3.4 && ./configure --prefix=/usr --enable-64bit && make && sudo make install && popd + post: + - mkdir build && cd build && cmake -DOPTIMIZE=0 -DCOVERAGE=1 .. && make -j2 + - cd $HOME && tar -zcvf europa.zip europa && cp europa.zip $CIRCLE_ARTIFACTS +test: + override: + - cd build && ctest; diff --git a/config/PlannerConfig.xml b/config/PlannerConfig.xml index 4a75e61f2..b4dc7b16a 100644 --- a/config/PlannerConfig.xml +++ b/config/PlannerConfig.xml @@ -1,6 +1,13 @@ + + + + + + + diff --git a/documentation/doxygen.cfg b/documentation/doxygen.cfg index 349129ae3..9aeb3a1e5 100644 --- a/documentation/doxygen.cfg +++ b/documentation/doxygen.cfg @@ -1219,3 +1219,6 @@ DOT_CLEANUP = YES # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO + +INCLUDE_GRPAH = YES +INCLUDED_BY_GRAPH = YES diff --git a/examples/BlocksWorld/CMakeLists.txt b/examples/BlocksWorld/CMakeLists.txt new file mode 100644 index 000000000..13e486193 --- /dev/null +++ b/examples/BlocksWorld/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 2.8.8) +set(PROJECT BlocksWorld) + +project(${PROJECT}) +include($ENV{EUROPA_HOME}/Europa2.cmake) + +if(${APPLE}) + set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) +else(${APPLE}) + find_package(JNI REQUIRED) +endif(${APPLE}) +include_directories(${JNI_INCLUDE_DIRS}) + +if(OPTIMIZE) + set(EUROPA_SUFFIX "_o") +else() + set(EUROPA_SUFFIX "_g") +endif(OPTIMIZE) + +file(GLOB children RELATIVE $ENV{EUROPA_HOME} $ENV{EUROPA_HOME}/*) +foreach(child ${children}) + if(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}/base) + include_directories($ENV{EUROPA_HOME}/${child}/component) + endif(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) +endforeach(child) + +#project-swig +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}) +set_source_files_properties(${PROJECT}.i PROPERTIES CPLUSPLUS ON) +set_source_files_properties(${PROJECT}.i PROPERTIES SWIG_FLAGS "-package;psengine;-includeall") +swig_add_module(${PROJECT} java ${PROJECT}.i) + + +#project-lib +add_library(${PROJECT}${EUROPA_SUFFIX} ${swig_generated_file_fullname} ${PROJECT}CustomCode.cc Module${PROJECT}.cc) + + +#project-rt +add_executable(${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-Main.cc ${PROJECT}CustomCode.cc Module${PROJECT}.cc) +target_link_libraries(${PROJECT}-planner${EUROPA_SUFFIX}_rt System${EUROPA_SUFFIX} Resource${EUROPA_SUFFIX} Solvers${EUROPA_SUFFIX} NDDL${EUROPA_SUFFIX} TemporalNetwork${EUROPA_SUFFIX} RulesEngine${EUROPA_SUFFIX} ConstraintEngine${EUROPA_SUFFIX} Utils${EUROPA_SUFFIX} TinyXml${EUROPA_SUFFIX}) + +#run-project +add_custom_target(run-project + DEPENDS ${PROJECT}-planner${EUROPA_SUFFIX}_rt + COMMAND ./${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-initial-state.nddl PlannerConfig.xml > RUN_${PROJECT}-planner${EUROPA_SUFFIX}_rt.${PROJECT}-initial-state.nddl.PlannerConfig.xml.output) + +#project_jar +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + +#find_jar(europa_jar PSEngine.jar PATHS $ENV{EUROPA_HOME}) +add_jar(${PROJECT}Jar + SOURCES + ${PROJECT}.java + ${PROJECT}JNI.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/BlocksWorld/Main.java + INCLUDE_JARS + $ENV{EUROPA_HOME}/PSEngine.jar + $ENV{EUROPA_HOME}/PSUISwing.jar + OUTPUT_NAME ${PROJECT} + ENTRY_POINT BlocksWorld/Main + ) + +add_dependencies(${PROJECT}Jar ${PROJECT}${EUROPA_SUFFIX}) + diff --git a/examples/BlocksWorld/ModuleBlocksWorld.cc b/examples/BlocksWorld/ModuleBlocksWorld.cc index bda6fefd0..19fb02715 100644 --- a/examples/BlocksWorld/ModuleBlocksWorld.cc +++ b/examples/BlocksWorld/ModuleBlocksWorld.cc @@ -10,9 +10,9 @@ namespace EUROPA { // static C init method to get handle when loading module as shared library extern "C" { - ModuleId initializeModule() + Module* initializeModule() { - return (new ModuleBlocksWorld())->getId(); + return new ModuleBlocksWorld(); } } diff --git a/examples/BlocksWorld/java/BlocksWorld/BlockHistoryEntry.java b/examples/BlocksWorld/java/BlocksWorld/BlockHistoryEntry.java index d69c06da7..5da521636 100644 --- a/examples/BlocksWorld/java/BlocksWorld/BlockHistoryEntry.java +++ b/examples/BlocksWorld/java/BlocksWorld/BlockHistoryEntry.java @@ -6,7 +6,7 @@ public class BlockHistoryEntry protected Integer step_; protected String towers_; protected String opHistory_; - + public BlockHistoryEntry(Integer idx,Integer step,String towers,String opHistory) { idx_ = idx; @@ -14,7 +14,7 @@ public BlockHistoryEntry(Integer idx,Integer step,String towers,String opHistory towers_ = towers; opHistory_ = opHistory; } - + public Integer getIndex() { return idx_; } public Integer getStepNumber() { return step_; } public String getTowers() { return towers_; } diff --git a/examples/BlocksWorld/java/BlocksWorld/BlockWorld.java b/examples/BlocksWorld/java/BlocksWorld/BlockWorld.java index 3eff102ed..95b677404 100644 --- a/examples/BlocksWorld/java/BlocksWorld/BlockWorld.java +++ b/examples/BlocksWorld/java/BlocksWorld/BlockWorld.java @@ -10,22 +10,22 @@ public class BlockWorld { protected List> towers_; protected Map> blockToTower_; - + public BlockWorld() { towers_ = new Vector(); blockToTower_ = new HashMap(); } - + public List> getTowers() { return towers_; } - + public void addBlock(String name,String state,String bottomBlock, PSToken a) { //System.out.println("BlockWorld.add("+name+","+state+","+bottomBlock+")"); List tower = blockToTower_.get(name); if (tower == null) { - tower = new Vector(); + tower = new Vector(); towers_.add(tower); blockToTower_.put(name, tower); } @@ -35,16 +35,16 @@ public void addBlock(String name,String state,String bottomBlock, PSToken a) buf.append(name).append("=").append(state).append(bottomBlock != null ? "-"+bottomBlock : "") .append("(").append(getBounds(a)).append(")"); String towerValue = buf.toString(); - + if (state.equals("OnTable")) { - if (idx == -1) + if (idx == -1) tower.add(0,towerValue); else tower.set(idx,towerValue); } - + if (state.equals("On")) { - + // Add Bottom if we need to int bottomIdx = -1; for (int i=0;i tower : towers_) { buf.append("{"); for (int i=0;i 0) buf.append(","); - buf.append(tower.get(i)); + buf.append(tower.get(i)); } buf.append("} "); } - + return buf.toString(); } @@ -92,32 +92,32 @@ public static Object safeBound(int bound) return "-INF"; if (bound > INF) return "INF"; - + return bound; } public static String valueToString(PSVarValue v) { String type = v.getType().toString(); - + if ("STRING".equals(type)) return v.asString(); if ("INTEGER".equals(type)) - return new Integer(v.asInt()).toString(); + return new Integer(v.asInt()).toString(); if ("DOUBLE".equals(type)) return new Double(v.asDouble()).toString(); if ("BOOLEAN".equals(type)) return new Boolean(v.asBoolean()).toString(); if ("OBJECT".equals(type)) return v.asObject().getEntityName(); - + return "ERROR!!! UNKNOWN TYPE :" + type; } public static String varValueToString(PSVariable var) - { - if (var.isSingleton()) - return valueToString(var.getSingletonValue()); + { + if (var.isSingleton()) + return valueToString(var.getSingletonValue()); else if (var.isInterval()) { StringBuffer buf = new StringBuffer(); buf.append("[").append(var.getLowerBound()).append(",") @@ -136,20 +136,20 @@ else if (var.isEnumerated()) { buf.append("]"); return buf.toString(); } - + throw new RuntimeException("Unexpected ERROR: variable "+var.getEntityName()+" is not one of {Singleton, Interval, Enumeration}"); } public static String getBounds(PSToken t) { StringBuffer buf = new StringBuffer(); - + buf.append("[") .append(varValueToString(t.getStart())) .append(",") .append(varValueToString(t.getEnd())) .append("]"); - + return buf.toString(); - } + } } diff --git a/examples/BlocksWorld/java/BlocksWorld/BlockWorldHistoryPanel.java b/examples/BlocksWorld/java/BlocksWorld/BlockWorldHistoryPanel.java index dd9688d71..d75d94251 100644 --- a/examples/BlocksWorld/java/BlocksWorld/BlockWorldHistoryPanel.java +++ b/examples/BlocksWorld/java/BlocksWorld/BlockWorldHistoryPanel.java @@ -24,15 +24,15 @@ public class BlockWorldHistoryPanel protected int currentIdx_; protected JTextField gotoIdx_; protected JLabel status_; - + public BlockWorldHistoryPanel() { history_ = new Vector(); blockWorldHistory_ = new Vector(); - + historyTable_ = new JTable(); currentIdx_ = -1; - + JPanel buttonPanel = new JPanel(new FlowLayout()); JButton b; b = new JButton("<<"); b.addActionListener(this);b.setActionCommand("prev"); buttonPanel.add(b); @@ -40,29 +40,29 @@ public BlockWorldHistoryPanel() b = new JButton("Go To Step"); b.addActionListener(this);b.setActionCommand("goto"); buttonPanel.add(b); gotoIdx_ = new JTextField(6); buttonPanel.add(gotoIdx_); - + status_ = new JLabel(""); JPanel statusPanel = new JPanel(new FlowLayout()); statusPanel.add(status_); - + setLayout(new BorderLayout()); add(BorderLayout.NORTH,buttonPanel); - add(BorderLayout.CENTER,new JScrollPane(historyTable_)); + add(BorderLayout.CENTER,new JScrollPane(historyTable_)); add(BorderLayout.SOUTH,statusPanel); - + updateStatus(); } public List getHistory() { return history_; } public List getBlockWorldHistory() { return blockWorldHistory_; } - - protected void updateStatus() - { - status_.setText("Currently showing step "+(currentIdx_+1)+" out of "+blockWorldHistory_.size()+" available"); + + protected void updateStatus() + { + status_.setText("Currently showing step "+(currentIdx_+1)+" out of "+blockWorldHistory_.size()+" available"); } - - public void showStep(int step) - { + + public void showStep(int step) + { if (step>=0 && step rowIndex) diff --git a/examples/BlocksWorld/java/BlocksWorld/Main.java b/examples/BlocksWorld/java/BlocksWorld/Main.java index 98265df96..426a3d1de 100644 --- a/examples/BlocksWorld/java/BlocksWorld/Main.java +++ b/examples/BlocksWorld/java/BlocksWorld/Main.java @@ -6,14 +6,14 @@ import org.ops.ui.main.swing.PSDesktop; import bsh.Interpreter; -class Main +class Main { protected static PSEngine psEngine_; - - public static void main(String args[]) + + public static void main(String args[]) { String debugMode = args[0]; - PSUtil.loadLibraries(debugMode); + PSUtil.loadLibraries(debugMode); psEngine_ = PSEngine.makeInstance(); psEngine_.start(); @@ -29,7 +29,7 @@ public static void main(String args[]) } catch (Exception e) { throw new RuntimeException(e); - } + } } else { @@ -42,28 +42,28 @@ protected static void loadCustomCode(String debugMode) { //Load module with any custom code if it exists: String libName = "BlocksWorld_" + debugMode; - String fullLibName = LibraryLoader.getResolvedName(libName); + String fullLibName = LibraryLoader.getResolvedName(libName); if(fullLibName == null) { // Run 'make' to compile the library if you need it: - System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); + System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); } else { // WARNING: Shared library loaded twice (see ticket #164) System.load(fullLibName); psEngine_.loadModule(fullLibName); - } + } } - - static class ShutdownHook extends Thread + + static class ShutdownHook extends Thread { public ShutdownHook() { super("ShutdownHook"); } - - public void run() + + public void run() { psEngine_.shutdown(); } - } + } } diff --git a/examples/Light/CMakeLists.txt b/examples/Light/CMakeLists.txt new file mode 100644 index 000000000..132bd7d16 --- /dev/null +++ b/examples/Light/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 2.8.8) +set(PROJECT Light) + +project(${PROJECT}) +include($ENV{EUROPA_HOME}/Europa2.cmake) + +if(${APPLE}) + set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) +else(${APPLE}) + find_package(JNI REQUIRED) +endif(${APPLE}) +include_directories(${JNI_INCLUDE_DIRS}) + +if(OPTIMIZE) + set(EUROPA_SUFFIX "_o") +else() + set(EUROPA_SUFFIX "_g") +endif(OPTIMIZE) + +file(GLOB children RELATIVE $ENV{EUROPA_HOME} $ENV{EUROPA_HOME}/*) +foreach(child ${children}) + if(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}/base) + include_directories($ENV{EUROPA_HOME}/${child}/component) + endif(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) +endforeach(child) + +#project-swig +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}) +set_source_files_properties(${PROJECT}.i PROPERTIES CPLUSPLUS ON) +set_source_files_properties(${PROJECT}.i PROPERTIES SWIG_FLAGS "-package;psengine;-includeall") +swig_add_module(${PROJECT} java ${PROJECT}.i) + + +#project-lib +add_library(${PROJECT}${EUROPA_SUFFIX} ${swig_generated_file_fullname} ${PROJECT}CustomCode.cc Module${PROJECT}.cc) + + +#project-rt +add_executable(${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-Main.cc ${PROJECT}CustomCode.cc Module${PROJECT}.cc) +target_link_libraries(${PROJECT}-planner${EUROPA_SUFFIX}_rt System${EUROPA_SUFFIX} Resource${EUROPA_SUFFIX} Solvers${EUROPA_SUFFIX} NDDL${EUROPA_SUFFIX} TemporalNetwork${EUROPA_SUFFIX} RulesEngine${EUROPA_SUFFIX} ConstraintEngine${EUROPA_SUFFIX} Utils${EUROPA_SUFFIX} TinyXml${EUROPA_SUFFIX}) + +#run-project +add_custom_target(run-project + DEPENDS ${PROJECT}-planner${EUROPA_SUFFIX}_rt + COMMAND ./${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-initial-state.nddl PlannerConfig.xml > RUN_${PROJECT}-planner${EUROPA_SUFFIX}_rt.${PROJECT}-initial-state.nddl.PlannerConfig.xml.output) + +#project_jar +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + +#find_jar(europa_jar PSEngine.jar PATHS $ENV{EUROPA_HOME}) +add_jar(${PROJECT}Jar + SOURCES + ${PROJECT}.java + ${PROJECT}JNI.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/Light/Main.java + INCLUDE_JARS + $ENV{EUROPA_HOME}/PSEngine.jar + $ENV{EUROPA_HOME}/PSUISwing.jar + OUTPUT_NAME ${PROJECT} + ENTRY_POINT Light/Main + ) + +add_dependencies(${PROJECT}Jar ${PROJECT}${EUROPA_SUFFIX}) + diff --git a/examples/Light/ModuleLight.cc b/examples/Light/ModuleLight.cc index 4c71b686f..c5f0e6874 100644 --- a/examples/Light/ModuleLight.cc +++ b/examples/Light/ModuleLight.cc @@ -10,9 +10,9 @@ namespace EUROPA { // static C init method to get handle when loading module as shared library extern "C" { - ModuleId initializeModule() + Module* initializeModule() { - return (new ModuleLight())->getId(); + return (new ModuleLight()); } } diff --git a/examples/Light/java/Light/Main.java b/examples/Light/java/Light/Main.java index ec303c835..f4731a0db 100644 --- a/examples/Light/java/Light/Main.java +++ b/examples/Light/java/Light/Main.java @@ -6,20 +6,20 @@ import org.ops.ui.main.swing.PSDesktop; import bsh.Interpreter; -class Main +class Main { protected static PSEngine psEngine_; - - public static void main(String args[]) + + public static void main(String args[]) { String debugMode = args[0]; - PSUtil.loadLibraries(debugMode); + PSUtil.loadLibraries(debugMode); psEngine_ = PSEngine.makeInstance(); psEngine_.start(); Runtime.getRuntime().addShutdownHook(new ShutdownHook()); loadCustomCode(debugMode); - + if(args.length > 2 && args[2].equals("nogui")) { Interpreter bshInterpreter_ = new bsh.Interpreter(); @@ -29,7 +29,7 @@ public static void main(String args[]) } catch (Exception e) { throw new RuntimeException(e); - } + } } else { @@ -42,28 +42,28 @@ protected static void loadCustomCode(String debugMode) { //Load module with any custom code if it exists: String libName = "Light_" + debugMode; - String fullLibName = LibraryLoader.getResolvedName(libName); + String fullLibName = LibraryLoader.getResolvedName(libName); if(fullLibName == null) { // Run 'make' to compile the library if you need it: - System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); + System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); } else { // WARNING: Shared library loaded twice (see ticket #164) System.load(fullLibName); psEngine_.loadModule(fullLibName); - } + } } - - static class ShutdownHook extends Thread + + static class ShutdownHook extends Thread { public ShutdownHook() { super("ShutdownHook"); } - - public void run() + + public void run() { psEngine_.shutdown(); } - } + } } diff --git a/examples/NQueens/CMakeLists.txt b/examples/NQueens/CMakeLists.txt new file mode 100644 index 000000000..d34c7c940 --- /dev/null +++ b/examples/NQueens/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 2.8.8) +set(PROJECT NQueens) + +project(${PROJECT}) +include($ENV{EUROPA_HOME}/Europa2.cmake) + +if(${APPLE}) + set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) +else(${APPLE}) + find_package(JNI REQUIRED) +endif(${APPLE}) +include_directories(${JNI_INCLUDE_DIRS}) + +if(OPTIMIZE) + set(EUROPA_SUFFIX "_o") +else() + set(EUROPA_SUFFIX "_g") +endif(OPTIMIZE) + +file(GLOB children RELATIVE $ENV{EUROPA_HOME} $ENV{EUROPA_HOME}/*) +foreach(child ${children}) + if(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}/base) + include_directories($ENV{EUROPA_HOME}/${child}/component) + endif(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) +endforeach(child) + +#project-swig +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}) +set_source_files_properties(${PROJECT}.i PROPERTIES CPLUSPLUS ON) +set_source_files_properties(${PROJECT}.i PROPERTIES SWIG_FLAGS "-package;psengine;-includeall") +swig_add_module(${PROJECT} java ${PROJECT}.i) + + +#project-lib +add_library(${PROJECT}${EUROPA_SUFFIX} ${swig_generated_file_fullname} ${PROJECT}CustomCode.cc Module${PROJECT}.cc) + + +#project-rt +add_executable(${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-Main.cc ${PROJECT}CustomCode.cc Module${PROJECT}.cc) +target_link_libraries(${PROJECT}-planner${EUROPA_SUFFIX}_rt System${EUROPA_SUFFIX} Resource${EUROPA_SUFFIX} Solvers${EUROPA_SUFFIX} NDDL${EUROPA_SUFFIX} TemporalNetwork${EUROPA_SUFFIX} RulesEngine${EUROPA_SUFFIX} ConstraintEngine${EUROPA_SUFFIX} Utils${EUROPA_SUFFIX} TinyXml${EUROPA_SUFFIX}) + +#run-project +add_custom_target(run-project + DEPENDS ${PROJECT}-planner${EUROPA_SUFFIX}_rt + COMMAND ./${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-initial-state.nddl PlannerConfig.xml > RUN_${PROJECT}-planner${EUROPA_SUFFIX}_rt.${PROJECT}-initial-state.nddl.PlannerConfig.xml.output) + +#project_jar +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + +#find_jar(europa_jar PSEngine.jar PATHS $ENV{EUROPA_HOME}) +add_jar(${PROJECT}Jar + SOURCES + ${PROJECT}.java + ${PROJECT}JNI.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/NQueens/Main.java + INCLUDE_JARS + $ENV{EUROPA_HOME}/PSEngine.jar + $ENV{EUROPA_HOME}/PSUISwing.jar + OUTPUT_NAME ${PROJECT} + ENTRY_POINT NQueens/Main + ) + +add_dependencies(${PROJECT}Jar ${PROJECT}${EUROPA_SUFFIX}) + diff --git a/examples/NQueens/java/NQueens/Main.java b/examples/NQueens/java/NQueens/Main.java index f83ad6a2c..6d356f606 100644 --- a/examples/NQueens/java/NQueens/Main.java +++ b/examples/NQueens/java/NQueens/Main.java @@ -6,20 +6,20 @@ import org.ops.ui.main.swing.PSDesktop; import bsh.Interpreter; -class Main +class Main { protected static PSEngine psEngine_; - - public static void main(String args[]) + + public static void main(String args[]) { String debugMode = args[0]; - PSUtil.loadLibraries(debugMode); + PSUtil.loadLibraries(debugMode); psEngine_ = PSEngine.makeInstance(); psEngine_.start(); Runtime.getRuntime().addShutdownHook(new ShutdownHook()); loadCustomCode(debugMode); - + if(args.length > 2 && args[2].equals("nogui")) { Interpreter bshInterpreter_ = new bsh.Interpreter(); @@ -29,7 +29,7 @@ public static void main(String args[]) } catch (Exception e) { throw new RuntimeException(e); - } + } } else { @@ -42,28 +42,28 @@ protected static void loadCustomCode(String debugMode) { //Load module with any custom code if it exists: String libName = "NQueens_" + debugMode; - String fullLibName = LibraryLoader.getResolvedName(libName); + String fullLibName = LibraryLoader.getResolvedName(libName); if(fullLibName == null) { // Run 'make' to compile the library if you need it: - System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); + System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); } else { // WARNING: Shared library loaded twice (see ticket #164) System.load(fullLibName); psEngine_.loadModule(fullLibName); - } + } } - - static class ShutdownHook extends Thread + + static class ShutdownHook extends Thread { public ShutdownHook() { super("ShutdownHook"); } - - public void run() + + public void run() { psEngine_.shutdown(); } - } + } } diff --git a/examples/NQueens/java/NQueens/NQueensPanel.java b/examples/NQueens/java/NQueens/NQueensPanel.java index 5ff1af285..c727aa95e 100644 --- a/examples/NQueens/java/NQueens/NQueensPanel.java +++ b/examples/NQueens/java/NQueens/NQueensPanel.java @@ -11,7 +11,7 @@ import psengine.*; -public class NQueensPanel +public class NQueensPanel extends MouseAdapter implements TSNQueensSolver.SolverObserver { @@ -25,9 +25,9 @@ public class NQueensPanel protected List solutions_; protected int curSolution_; protected JButton nextBtn_,prevBtn_; - + public NQueensPanel(PSEngine psengine, - int queenCnt, + int queenCnt, JTextArea mouseInfo) { createUIPanel(psengine,queenCnt,mouseInfo); @@ -36,9 +36,9 @@ public NQueensPanel(PSEngine psengine, solutions_ = new Vector(); curSolution_ = -1; } - + public JPanel getUIPanel() { return uiPanel_; } - + public void createUIPanel(PSEngine psengine,int queenCnt, JTextArea mouseInfo) { uiPanel_ = new JPanel(new BorderLayout()); @@ -65,24 +65,24 @@ public void createUIPanel(PSEngine psengine,int queenCnt, JTextArea mouseInfo) prevBtn_.setEnabled(false); bottomPanel.add(prevBtn_); bottomPanel.add(nextBtn_); - + solverPanel.add(BorderLayout.NORTH,topPanel); solverPanel.add(BorderLayout.CENTER,solverBoard_); solverPanel.add(BorderLayout.SOUTH,bottomPanel); - + tabbedPane_ = new JTabbedPane(); tabbedPane_.addTab("Current State",new NQueensBoard(psengine,queenCnt,mouseInfo,false)); tabbedPane_.addTab("Solver",solverPanel); - uiPanel_.add(tabbedPane_); + uiPanel_.add(tabbedPane_); } - + public void mouseClicked(MouseEvent e) { try { - if (e.getSource()==solveBtn_) { + if (e.getSource()==solveBtn_) { SolverRunner handler = new SolverRunner(); - handler.start(); + handler.start(); } if (e.getSource()==nextBtn_) { setCurrentSolution(curSolution_+1); @@ -94,12 +94,12 @@ public void mouseClicked(MouseEvent e) catch (Exception ex) { throw new RuntimeException(ex); } - } - + } + class SolverRunner extends Thread { - public void run() + public void run() { solveBtn_.setEnabled(false); tabbedPane_.setEnabledAt(0,false); @@ -107,15 +107,15 @@ public void run() solver_.solve(maxIter); tabbedPane_.setEnabledAt(0,true); solveBtn_.setEnabled(true); - } + } } - public void iterationCompleted(int iteration) + public void iterationCompleted(int iteration) { SwingUtilities.invokeLater(new Updater1(iteration)); } - public void newSolutionFound(int iteration, List queenPositions, List queenViolations) + public void newSolutionFound(int iteration, List queenPositions, List queenViolations) { solutions_.add(new Object[]{new Integer(iteration),queenPositions,queenViolations}); SwingUtilities.invokeLater(new Updater2()); @@ -125,7 +125,7 @@ protected void setCurrentSolution(int i) { if (i >= solutions_.size() || i < 0) return; - + curSolution_=i; if (curSolution_==solutions_.size()-1) @@ -140,22 +140,22 @@ protected void setCurrentSolution(int i) solverBoard_.setSolution((Object[])solutions_.get(curSolution_)); } - + class Updater1 implements Runnable { int iteration_; - + public Updater1(int i) { iteration_ = i; } - + public void run() { - iterationCount_.setText("Iteration : "+iteration_); - } + iterationCount_.setText("Iteration : "+iteration_); + } } - + class Updater2 implements Runnable { public void run() { setCurrentSolution(solutions_.size()-1); - } + } } } diff --git a/examples/NQueens/java/NQueens/TSNQueensSolver.java b/examples/NQueens/java/NQueens/TSNQueensSolver.java index b6a14906f..f48dba2c1 100644 --- a/examples/NQueens/java/NQueens/TSNQueensSolver.java +++ b/examples/NQueens/java/NQueens/TSNQueensSolver.java @@ -21,16 +21,16 @@ public class TSNQueensSolver protected List observers_; protected int bestIter_; protected double bestCost_; - + public interface SolverObserver { public void iterationCompleted(int iteration); public void newSolutionFound(int iteration,List queenPositions,List queenViolations); } - + public TSNQueensSolver(int n,PSEngine engine) { - psengine_ = engine; + psengine_ = engine; tabuList_ = new HashMap(); queenCnt_ = n; observers_ = new Vector(); @@ -38,22 +38,22 @@ public TSNQueensSolver(int n,PSEngine engine) public void addObserver(SolverObserver o) { observers_.add(o); } public void removeObserver(SolverObserver o) { observers_.remove(o); } - + void notifyIterationCompleted(int iteration) { - dbgout(iteration+":"+queensToString()); + dbgout(iteration+":"+queensToString()); for (int i=0;i queenValues = new Vector(); List queenViolations = new Vector(); - - PSVariableList l = psengine_.getGlobalVariables(); - + + PSVariableList l = psengine_.getGlobalVariables(); + for (int i=0;i maxViolation) { maxVar = i; maxViolation = v.getViolation(); } - } - + } + return l.get(maxVar); } @@ -116,13 +116,13 @@ static class Move { public int slot_; public double violation_; - + public Move(int slot,double violation) { slot_ = slot; violation_ = violation; } - public int compareTo(Object obj) + public int compareTo(Object obj) { Move rhs = (Move)obj; @@ -130,15 +130,15 @@ public int compareTo(Object obj) return -1; else if (violation_ > rhs.violation_) return 1; - else + else return 0; - } + } } - + SortedSet getMoves(PSVariable queen,int curPos) { SortedSet moves = new TreeSet(); - + for (int i=0;i getMoves(PSVariable queen,int curPos) moves.add(new Move(i,v)); } } - + return moves; } public void solve(int maxIter) { init(); - + for (int i=0;psengine_.getViolation() > 0 && i < maxIter;i++) { PSVariable queenToMove = getQueenWithMaxViolation(); int curPos = queenToMove.getSingletonValue().asInt(); - + boolean moved = false; - SortedSet moves = getMoves(queenToMove,curPos); + SortedSet moves = getMoves(queenToMove,curPos); for (Move m : moves) { moved = makeMove(queenToMove,curPos,m,false); if (moved) break; } - - if (!moved) + + if (!moved) makeMove(queenToMove,curPos,moves.first(),true); - - checkSolution(); // See if we have a new best solution + + checkSolution(); // See if we have a new best solution notifyIterationCompleted(curIteration_++); - - if (curIteration_-bestIter_ > 50) + + if (curIteration_-bestIter_ > 50) restart(); } } - + protected void checkSolution() { double cost = psengine_.getViolation(); @@ -185,25 +185,25 @@ protected void checkSolution() bestCost_ = cost; bestIter_ = curIteration_; notifyNewSolutionFound(curIteration_); - } + } } - + void addToTabuList(PSVariable queenToMove,int orig,int dest) { String key = queenToMove.getEntityName() + "_" +orig+"_"+dest; - tabuList_.put(key,curIteration_+tabuTenure_); + tabuList_.put(key,curIteration_+tabuTenure_); } - + boolean isTabu(PSVariable queenToMove,int orig,int dest) { String key = queenToMove.getEntityName() + "_" +orig+"_"+dest; Integer iteration = (Integer)tabuList_.get(key); if (iteration == null) return false; - + return (iteration.intValue() > curIteration_); } - + boolean makeMove(PSVariable queenToMove,int curPos,Move m,boolean force) { if (force) @@ -212,18 +212,18 @@ boolean makeMove(PSVariable queenToMove,int curPos,Move m,boolean force) if (force || !isTabu(queenToMove,curPos,m.slot_)) { PSVarValue value = PSVarValue.getInstance(m.slot_); queenToMove.specifyValue(value); - dbgout("Moved queen "+queenToMove.getEntityName()+" from "+curPos+" to "+m.slot_); + dbgout("Moved queen "+queenToMove.getEntityName()+" from "+curPos+" to "+m.slot_); addToTabuList(queenToMove,curPos,m.slot_); return true; } - + return false; } - + String queensToString() { StringBuffer buf = new StringBuffer(); - + buf.append("{"); for (int i=0; i0) @@ -232,8 +232,8 @@ String queensToString() } buf.append("}"); buf.append(" violation:").append(psengine_.getViolation()); - + return buf.toString(); - } + } } diff --git a/examples/Rover/CMakeLists.txt b/examples/Rover/CMakeLists.txt new file mode 100644 index 000000000..e0696d50d --- /dev/null +++ b/examples/Rover/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 2.8.8) +set(PROJECT Rover) + +project(${PROJECT}) +include($ENV{EUROPA_HOME}/Europa2.cmake) + +if(${APPLE}) + set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) +else(${APPLE}) + find_package(JNI REQUIRED) +endif(${APPLE}) +include_directories(${JNI_INCLUDE_DIRS}) + +if(OPTIMIZE) + set(EUROPA_SUFFIX "_o") +else() + set(EUROPA_SUFFIX "_g") +endif(OPTIMIZE) + +file(GLOB children RELATIVE $ENV{EUROPA_HOME} $ENV{EUROPA_HOME}/*) +foreach(child ${children}) + if(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}/base) + include_directories($ENV{EUROPA_HOME}/${child}/component) + endif(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) +endforeach(child) + +#project-swig +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}) +set_source_files_properties(${PROJECT}.i PROPERTIES CPLUSPLUS ON) +set_source_files_properties(${PROJECT}.i PROPERTIES SWIG_FLAGS "-package;psengine;-includeall") +swig_add_module(${PROJECT} java ${PROJECT}.i) + + +#project-lib +add_library(${PROJECT}${EUROPA_SUFFIX} ${swig_generated_file_fullname} ${PROJECT}CustomCode.cc Module${PROJECT}.cc) + + +#project-rt +add_executable(${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-Main.cc ${PROJECT}CustomCode.cc Module${PROJECT}.cc) +target_link_libraries(${PROJECT}-planner${EUROPA_SUFFIX}_rt System${EUROPA_SUFFIX} Resource${EUROPA_SUFFIX} Solvers${EUROPA_SUFFIX} NDDL${EUROPA_SUFFIX} TemporalNetwork${EUROPA_SUFFIX} RulesEngine${EUROPA_SUFFIX} ConstraintEngine${EUROPA_SUFFIX} Utils${EUROPA_SUFFIX} TinyXml${EUROPA_SUFFIX}) + +#run-project +add_custom_target(run-project + DEPENDS ${PROJECT}-planner${EUROPA_SUFFIX}_rt + COMMAND ./${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-initial-state.nddl PlannerConfig.xml > RUN_${PROJECT}-planner${EUROPA_SUFFIX}_rt.${PROJECT}-initial-state.nddl.PlannerConfig.xml.output) + +#project_jar +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + +#find_jar(europa_jar PSEngine.jar PATHS $ENV{EUROPA_HOME}) +add_jar(${PROJECT}Jar + SOURCES + ${PROJECT}.java + ${PROJECT}JNI.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/Rover/Main.java + INCLUDE_JARS + $ENV{EUROPA_HOME}/PSEngine.jar + $ENV{EUROPA_HOME}/PSUISwing.jar + OUTPUT_NAME ${PROJECT} + ENTRY_POINT Rover/Main + ) + +add_dependencies(${PROJECT}Jar ${PROJECT}${EUROPA_SUFFIX}) + diff --git a/examples/Rover/ModuleRover.cc b/examples/Rover/ModuleRover.cc index b94e5546e..bb9893230 100644 --- a/examples/Rover/ModuleRover.cc +++ b/examples/Rover/ModuleRover.cc @@ -10,9 +10,9 @@ namespace EUROPA { // static C init method to get handle when loading module as shared library extern "C" { - ModuleId initializeModule() + Module* initializeModule() { - return (new ModuleRover())->getId(); + return new ModuleRover(); } } diff --git a/examples/Rover/java/Rover/Main.java b/examples/Rover/java/Rover/Main.java index 31f6bc415..dc60f5303 100644 --- a/examples/Rover/java/Rover/Main.java +++ b/examples/Rover/java/Rover/Main.java @@ -6,20 +6,20 @@ import org.ops.ui.main.swing.PSDesktop; import bsh.Interpreter; -class Main +class Main { protected static PSEngine psEngine_; - - public static void main(String args[]) + + public static void main(String args[]) { String debugMode = args[0]; - PSUtil.loadLibraries(debugMode); + PSUtil.loadLibraries(debugMode); psEngine_ = PSEngine.makeInstance(); psEngine_.start(); Runtime.getRuntime().addShutdownHook(new ShutdownHook()); loadCustomCode(debugMode); - + if(args.length > 2 && args[2].equals("nogui")) { Interpreter bshInterpreter_ = new bsh.Interpreter(); @@ -29,7 +29,7 @@ public static void main(String args[]) } catch (Exception e) { throw new RuntimeException(e); - } + } } else { @@ -42,28 +42,28 @@ protected static void loadCustomCode(String debugMode) { //Load module with any custom code if it exists: String libName = "Rover_" + debugMode; - String fullLibName = LibraryLoader.getResolvedName(libName); + String fullLibName = LibraryLoader.getResolvedName(libName); if(fullLibName == null) { // Run 'make' to compile the library if you need it: - System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); + System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); } else { // WARNING: Shared library loaded twice (see ticket #164) System.load(fullLibName); psEngine_.loadModule(fullLibName); - } + } } - - static class ShutdownHook extends Thread + + static class ShutdownHook extends Thread { public ShutdownHook() { super("ShutdownHook"); } - - public void run() + + public void run() { psEngine_.shutdown(); } - } + } } diff --git a/examples/Shopping/CMakeLists.txt b/examples/Shopping/CMakeLists.txt new file mode 100644 index 000000000..ef74f1406 --- /dev/null +++ b/examples/Shopping/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 2.8.8) +set(PROJECT Shopping) + +project(${PROJECT}) +include($ENV{EUROPA_HOME}/Europa2.cmake) + +if(${APPLE}) + set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) +else(${APPLE}) + find_package(JNI REQUIRED) +endif(${APPLE}) +include_directories(${JNI_INCLUDE_DIRS}) + +if(OPTIMIZE) + set(EUROPA_SUFFIX "_o") +else() + set(EUROPA_SUFFIX "_g") +endif(OPTIMIZE) + +file(GLOB children RELATIVE $ENV{EUROPA_HOME} $ENV{EUROPA_HOME}/*) +foreach(child ${children}) + if(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}/base) + include_directories($ENV{EUROPA_HOME}/${child}/component) + endif(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) +endforeach(child) + +#project-swig +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}) +set_source_files_properties(${PROJECT}.i PROPERTIES CPLUSPLUS ON) +set_source_files_properties(${PROJECT}.i PROPERTIES SWIG_FLAGS "-package;psengine;-includeall") +swig_add_module(${PROJECT} java ${PROJECT}.i) + + +#project-lib +add_library(${PROJECT}${EUROPA_SUFFIX} ${swig_generated_file_fullname} ${PROJECT}CustomCode.cc Module${PROJECT}.cc) + + +#project-rt +add_executable(${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-Main.cc ${PROJECT}CustomCode.cc Module${PROJECT}.cc) +target_link_libraries(${PROJECT}-planner${EUROPA_SUFFIX}_rt System${EUROPA_SUFFIX} Resource${EUROPA_SUFFIX} Solvers${EUROPA_SUFFIX} NDDL${EUROPA_SUFFIX} TemporalNetwork${EUROPA_SUFFIX} RulesEngine${EUROPA_SUFFIX} ConstraintEngine${EUROPA_SUFFIX} Utils${EUROPA_SUFFIX} TinyXml${EUROPA_SUFFIX}) + +#run-project +add_custom_target(run-project + DEPENDS ${PROJECT}-planner${EUROPA_SUFFIX}_rt + COMMAND ./${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-initial-state.nddl PlannerConfig.xml > RUN_${PROJECT}-planner${EUROPA_SUFFIX}_rt.${PROJECT}-initial-state.nddl.PlannerConfig.xml.output) + +#project_jar +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + +#find_jar(europa_jar PSEngine.jar PATHS $ENV{EUROPA_HOME}) +add_jar(${PROJECT}Jar + SOURCES + ${PROJECT}.java + ${PROJECT}JNI.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/Shopping/Main.java + INCLUDE_JARS + $ENV{EUROPA_HOME}/PSEngine.jar + $ENV{EUROPA_HOME}/PSUISwing.jar + OUTPUT_NAME ${PROJECT} + ENTRY_POINT Shopping/Main + ) + +add_dependencies(${PROJECT}Jar ${PROJECT}${EUROPA_SUFFIX}) + diff --git a/examples/Shopping/java/Shopping/Main.java b/examples/Shopping/java/Shopping/Main.java index 44d471293..7f2e6dac0 100644 --- a/examples/Shopping/java/Shopping/Main.java +++ b/examples/Shopping/java/Shopping/Main.java @@ -6,20 +6,20 @@ import org.ops.ui.main.swing.PSDesktop; import bsh.Interpreter; -class Main +class Main { protected static PSEngine psEngine_; - - public static void main(String args[]) + + public static void main(String args[]) { String debugMode = args[0]; - PSUtil.loadLibraries(debugMode); + PSUtil.loadLibraries(debugMode); psEngine_ = PSEngine.makeInstance(); psEngine_.start(); Runtime.getRuntime().addShutdownHook(new ShutdownHook()); loadCustomCode(debugMode); - + if(args.length > 2 && args[2].equals("nogui")) { Interpreter bshInterpreter_ = new bsh.Interpreter(); @@ -29,7 +29,7 @@ public static void main(String args[]) } catch (Exception e) { throw new RuntimeException(e); - } + } } else { @@ -42,28 +42,28 @@ protected static void loadCustomCode(String debugMode) { //Load module with any custom code if it exists: String libName = "Shopping_" + debugMode; - String fullLibName = LibraryLoader.getResolvedName(libName); + String fullLibName = LibraryLoader.getResolvedName(libName); if(fullLibName == null) { // Run 'make' to compile the library if you need it: - System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); + System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); } else { // WARNING: Shared library loaded twice (see ticket #164) System.load(fullLibName); psEngine_.loadModule(fullLibName); - } + } } - - static class ShutdownHook extends Thread + + static class ShutdownHook extends Thread { public ShutdownHook() { super("ShutdownHook"); } - - public void run() + + public void run() { psEngine_.shutdown(); } - } + } } diff --git a/examples/UBO/CMakeLists.txt b/examples/UBO/CMakeLists.txt new file mode 100644 index 000000000..c75b86b01 --- /dev/null +++ b/examples/UBO/CMakeLists.txt @@ -0,0 +1,89 @@ +cmake_minimum_required(VERSION 2.8.8) +set(PROJECT UBO) + +project(${PROJECT}) +include($ENV{EUROPA_HOME}/Europa2.cmake) + +if(${APPLE}) + set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) +else(${APPLE}) + find_package(JNI REQUIRED) +endif(${APPLE}) +include_directories(${JNI_INCLUDE_DIRS}) + +if(OPTIMIZE) + set(EUROPA_SUFFIX "_o") +else() + set(EUROPA_SUFFIX "_g") +endif(OPTIMIZE) + +file(GLOB children RELATIVE $ENV{EUROPA_HOME} $ENV{EUROPA_HOME}/*) +foreach(child ${children}) + if(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}) + include_directories($ENV{EUROPA_HOME}/${child}/base) + include_directories($ENV{EUROPA_HOME}/${child}/component) + endif(IS_DIRECTORY $ENV{EUROPA_HOME}/${child}) +endforeach(child) + +#project-swig +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}) +set_source_files_properties(${PROJECT}.i PROPERTIES CPLUSPLUS ON) +set_source_files_properties(${PROJECT}.i PROPERTIES SWIG_FLAGS "-package;psengine;-includeall") +swig_add_module(${PROJECT} java ${PROJECT}.i) + + +#project-lib +add_library(${PROJECT}${EUROPA_SUFFIX} ${swig_generated_file_fullname} ${PROJECT}CustomCode.cc Module${PROJECT}.cc) + + +#project-rt +add_executable(${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-Main.cc ${PROJECT}CustomCode.cc Module${PROJECT}.cc) +target_link_libraries(${PROJECT}-planner${EUROPA_SUFFIX}_rt System${EUROPA_SUFFIX} Resource${EUROPA_SUFFIX} Solvers${EUROPA_SUFFIX} NDDL${EUROPA_SUFFIX} TemporalNetwork${EUROPA_SUFFIX} RulesEngine${EUROPA_SUFFIX} ConstraintEngine${EUROPA_SUFFIX} Utils${EUROPA_SUFFIX} TinyXml${EUROPA_SUFFIX}) + +#run-project +add_custom_target(run-project + DEPENDS ${PROJECT}-planner${EUROPA_SUFFIX}_rt + COMMAND ./${PROJECT}-planner${EUROPA_SUFFIX}_rt ${PROJECT}-initial-state.nddl PlannerConfig.xml > RUN_${PROJECT}-planner${EUROPA_SUFFIX}_rt.${PROJECT}-initial-state.nddl.PlannerConfig.xml.output) + +#project_jar +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + +#find_jar(europa_jar PSEngine.jar PATHS $ENV{EUROPA_HOME}) +add_jar(${PROJECT}Jar + SOURCES + ${PROJECT}.java + ${PROJECT}JNI.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/ExhaustiveSolver.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/HybridSolver.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/IFlatIRelaxSolver.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/Main.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/PSResourceWrapper.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/PlanHistoryEntry.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/Precedence.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/RCPSPResource.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/RCPSPSolver.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/RCPSPSolverBase.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/RCPSPUtil.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/Resource.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/ResourceBase.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/ResourceProfile.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/ResourceViolationInfo.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/SolDistExhaustiveSolver.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/UBOSolverListener.java + ${CMAKE_CURRENT_SOURCE_DIR}/java/UBO/Main.java + INCLUDE_JARS + $ENV{EUROPA_HOME}/PSEngine.jar + $ENV{EUROPA_HOME}/PSUISwing.jar + OUTPUT_NAME ${PROJECT} + ENTRY_POINT UBO/Main + ) + +add_dependencies(${PROJECT}Jar ${PROJECT}${EUROPA_SUFFIX}) + diff --git a/examples/UBO/ModuleUBO.cc b/examples/UBO/ModuleUBO.cc index 98cb9117c..7c35aa18d 100644 --- a/examples/UBO/ModuleUBO.cc +++ b/examples/UBO/ModuleUBO.cc @@ -10,9 +10,9 @@ namespace EUROPA { // static C init method to get handle when loading module as shared library extern "C" { - ModuleId initializeModule() + Module* initializeModule() { - return (new ModuleUBO())->getId(); + return (new ModuleUBO()); } } diff --git a/examples/UBO/java/UBO/ExhaustiveSolver.java b/examples/UBO/java/UBO/ExhaustiveSolver.java index 41d857f7d..dd7b895e6 100644 --- a/examples/UBO/java/UBO/ExhaustiveSolver.java +++ b/examples/UBO/java/UBO/ExhaustiveSolver.java @@ -5,7 +5,7 @@ * This is an exhaustive solver used by the Hybrid solver, it uses : * - The incoming precedenceOracle to guide precedence selection at each decision point * - the incoming upper bound to prune the search tree faster. - * TODO: this was a very quick implementation to try the hybrid idea, it doesn't scale very well. + * TODO: this was a very quick implementation to try the hybrid idea, it doesn't scale very well. * use ideas from best performing B&B solvers for this problem, combined with the oracle and strengthened bound, it should kick ass. */ import java.util.List; @@ -19,27 +19,27 @@ import psengine.util.SimpleTimer; public class ExhaustiveSolver - extends RCPSPSolverBase + extends RCPSPSolverBase { List decisionStack_ = new Vector(); int lowerBound_; int upperBound_; SortedSet precedenceOracle_; DecisionPoint curDP_; - + public ExhaustiveSolver() - { + { } - + public void solve( - PSEngine psengine, - long timeout, + PSEngine psengine, + long timeout, int bound, - boolean usePSResources) + boolean usePSResources) { // TODO: get this to work solve(psengine,timeout,bound,Integer.MAX_VALUE,null,null,null); - } + } public void solve( PSEngine psengine, @@ -54,7 +54,7 @@ public void solve( init(psengine,timeout,lowerBound,upperBound,activities,resources,precedenceOracle); doSolve(); } - + protected void doSolve() { for (;;) { @@ -78,29 +78,29 @@ protected void doSolve() bestSolution_.clear(); bestSolution_.addAll(precedences_); timeToBest_ = timer_.getElapsed(); - RCPSPUtil.dbgout("ExhaustiveSolver found new best makespan "+bestMakespan_+" "+getSolutionAsString()); - } + RCPSPUtil.dbgout("ExhaustiveSolver found new best makespan "+bestMakespan_+" "+getSolutionAsString()); + } // if upper and lower bound cross, we're done if (upperBound_ <= lowerBound_) { doSolveFinished("Bounds crossed"); break; - } + } if (decisionStack_.isEmpty()) { doSolveFinished("exhausted"); break; } - else + else doBacktrack("Backtracking after finding solution"); } else { if (curDP_.hasNext()) { executeDecision(curDP_); - if (psengine_.getViolation() > 0) + if (psengine_.getViolation() > 0) doBacktrack("Backtracking because of violation"); - else if (getMakespan() > upperBound_) + else if (getMakespan() > upperBound_) doBacktrack("Backtracking because of upper bound "+getMakespan()+" vs. "+upperBound_); } else if (decisionStack_.isEmpty()) { @@ -111,9 +111,9 @@ else if (decisionStack_.isEmpty()) { doBacktrack("Backtracking because decision point exhausted choices"); } } - } + } } - + protected void doSolveFinished(String msg) { timer_.stop(); @@ -124,7 +124,7 @@ protected void doSolveFinished(String msg) restoreBestSolution(); resetState(); } - + public void init( PSEngine psengine, long timeout, @@ -135,7 +135,7 @@ public void init( List precedenceOracle) { timer_ = new SimpleTimer(); - timer_.start(); + timer_.start(); psengine_ = psengine; timeout_ = timeout; @@ -143,44 +143,44 @@ public void init( resources_ = resources; lowerBound_ = lowerBound; upperBound_ = upperBound; - + precedenceOracle_ = new TreeSet(); for (Precedence p : precedenceOracle) precedenceOracle_.add(p.toString()); - + resetSolution(); resetState(); } - + void resetState() { - curDP_ = null; + curDP_ = null; } - + int lastIdx_ = 0; - + protected DecisionPoint getNextDecisionPoint() { double lowestLevel = Double.MAX_VALUE; Resource maxViolatedResource = null; int maxViolatedTime = Integer.MIN_VALUE; - + int start = lastIdx_; for (int i=lastIdx_;;) { Resource r = resources_.get(i); ResourceViolationInfo rvi = r.getMaxViolation(); - + if ((rvi.level < lowestLevel) && (rvi.level < 0)) { lowestLevel = rvi.level; maxViolatedResource = r; maxViolatedTime = rvi.time; } - + i = (i+1) % resources_.size(); if (i == start) break; - } - + } + if (maxViolatedResource == null) { //RCPSPUtil.dbgout("No violations found!"); return null; @@ -188,27 +188,27 @@ protected DecisionPoint getNextDecisionPoint() else return new DecisionPoint(maxViolatedResource,maxViolatedTime); } - + protected void executeDecision(DecisionPoint dp) { decisionStack_.add(dp); - dp.execute(); + dp.execute(); curDP_ = null; } - + protected void doBacktrack(String reason) { curDP_ = decisionStack_.remove(decisionStack_.size()-1); - curDP_.undo(); + curDP_.undo(); //RCPSPUtil.dbgout(reason+" new stack size:"+decisionStack_.size()); } - + protected class DecisionPoint { TreeSet choices_; SortedSet executedChoices_; Precedence lastExecutedChoice_; - + public DecisionPoint(Resource r, int t) { choices_ = new TreeSet(); @@ -216,55 +216,55 @@ public DecisionPoint(Resource r, int t) if (conflictSet.size() < 2) RCPSPUtil.dbgout("ERROR!!: conflictSet size is :"+conflictSet.size()); - + for (int i=0;i oracle = new Vector(); oracle.addAll(ifirSolver_.getBestSolution()); - ifirSolver_.undoSolve(); - + ifirSolver_.undoSolve(); + exhSolver_ = new ExhaustiveSolver(); exhSolver_.solve( psengine, @@ -63,7 +63,7 @@ public void solve(PSEngine psengine, ifirSolver_.getActivityMap(), ifirSolver_.getResources(), oracle - ); + ); timer_.stop(); if (exhSolver_.getBestMakespan() < Integer.MAX_VALUE) lastSolver_ = exhSolver_; diff --git a/examples/UBO/java/UBO/IFlatIRelaxSolver.java b/examples/UBO/java/UBO/IFlatIRelaxSolver.java index 2fc692cfb..45d9636e7 100644 --- a/examples/UBO/java/UBO/IFlatIRelaxSolver.java +++ b/examples/UBO/java/UBO/IFlatIRelaxSolver.java @@ -13,47 +13,47 @@ import psengine.util.SimpleTimer; /* - * This is a solver based on the Iterative flattening and relaxation algorithm. + * This is a solver based on the Iterative flattening and relaxation algorithm. * It has been enhanced to be able to deal with general min/max precedence constraints */ -public class IFlatIRelaxSolver - extends RCPSPSolverBase +public class IFlatIRelaxSolver + extends RCPSPSolverBase { int curIteration_ = 0; - int nbStable_ = 0; + int nbStable_ = 0; int maxStable_ = 10000; int makespanBound_; - + boolean usePSResources_; Set criticalPath_; Map noGoods_; boolean hasViolations_; - + public void solve(PSEngine psengine, long timeout, // in msecs - int bound, + int bound, boolean usePSResources) { init(psengine,timeout,bound,usePSResources); - + for (int i=0; true ; i++) { flatten(); updateSolution(i); updateCriticalPrecedences(); - + if ((nbStable_ > maxStable_) || (bestMakespan_ <= makespanBound_)) break; - + if (timer_.getElapsed() > timeout) { timedOut_ = true; break; } - + relax(); curIteration_++; - } + } restoreBestSolution(); timer_.stop(); @@ -62,7 +62,7 @@ public void solve(PSEngine psengine, } public boolean timedOut() { return timedOut_; } - + protected Resource makeResource(PSResource r,int capacity) { if (usePSResources_) @@ -70,23 +70,23 @@ protected Resource makeResource(PSResource r,int capacity) else return new RCPSPResource(psengine_,r,capacity); } - + protected void init(PSEngine psengine,long timeout,int bound, boolean usePSResources) { timer_ = new SimpleTimer(); timer_.start(); - + timeout_ = timeout; timedOut_ = false; timeToBest_=timeout; - + psengine_ = psengine; makespanBound_ = bound; usePSResources_ = usePSResources; - + List res = PSUtil.toResourceList(psengine.getObjectsByType("CapacityResource")); resources_ = new Vector(); - + for (PSResource r : res) { PSResourceProfile prof = r.getCapacity(); int t = prof.getTimes().get(0); @@ -94,7 +94,7 @@ protected void init(PSEngine psengine,long timeout,int bound, boolean usePSResou resources_.add(makeResource(r,capacity)); //RCPSPUtil.dbgout("capacity for resource "+r.getName()+" is "+capacity); } - + PSTokenList tokens = psengine.getTokens(); activities_ = new TreeMap(); for (int i=0;i(); noGoods_ = new HashMap(); - + curIteration_ = 0; nbStable_ = 0; - + resetSolution(); // Completely relax finish time PSVariable v = psengine_.getVariableByName("maxDuration"); - v.specifyValue(PSVarValue.getInstance(100000)); + v.specifyValue(PSVarValue.getInstance(100000)); } public void flatten() { hasViolations_ = true; boolean addedConstraint = true; - + while (hasViolations_) { hasViolations_ = false; addedConstraint = false; for (Resource r : resources_) { //RCPSPUtil.dbgout("Before flatten() step : "+r.toString()); - + ResourceViolationInfo rvi = r.getMaxViolation(); int t = rvi.time; - if (t >= 0) { + if (t >= 0) { hasViolations_ = true; - if (addPrecedenceConstraint(r,t)) + if (addPrecedenceConstraint(r,t)) addedConstraint = true; } - //RCPSPUtil.dbgout("After flatten() step : "+r.toString()); + //RCPSPUtil.dbgout("After flatten() step : "+r.toString()); } - + if (!addedConstraint) break; - + if (timer_.getElapsed() > timeout_) { timedOut_ = true; break; - } + } } - + //if (hasViolations_) - // RCPSPUtil.dbgout("WARNING:unable to remove all violations"); + // RCPSPUtil.dbgout("WARNING:unable to remove all violations"); //RCPSPUtil.dbgout("flatten() finished "+timer_.getElapsedString()); } - + public void relax() { - double probOfDeletion = 0.3; + double probOfDeletion = 0.3; int before = precedences_.size(); - + boolean removed = false; psengine_.setAutoPropagation(false); @@ -165,52 +165,52 @@ public void relax() List precs = new Vector(); precs.addAll(precedences_); for (Precedence p : precs) { - if (p.isCritical && (Math.random() < probOfDeletion)) { - removePrecedence(p); + if (p.isCritical && (Math.random() < probOfDeletion)) { + removePrecedence(p); removed = true; } - + if (timer_.getElapsed() > timeout_) { timedOut_ = true; break; - } + } } - + // make sure we remove at least one precedence if (!removed) { for (Precedence p : precs) { if (p.isCritical) { - removePrecedence(p); - break; + removePrecedence(p); + break; } } } - psengine_.setAutoPropagation(true); - + psengine_.setAutoPropagation(true); + //RCPSPUtil.dbgout("Removed "+(before-precedences_.size())+" out of "+before+" precedences"); //RCPSPUtil.dbgout("after relax. makespan (current,best)=("+getMakespan()+","+bestMakespan_+")"); //RCPSPUtil.dbgout("relax() finished "+timer_.getElapsedString()); } - + /* * Try to fix capacity violation on resource r at time t by adding a precedence constraint */ protected boolean addPrecedenceConstraint(Resource r,int t) - { + { List conflictSet = r.getConflictSet(t); - + if (conflictSet.size() < 2) { RCPSPUtil.dbgout(r.getName()+": conflict set has less than 2 elements, bailing out without adding precedence constraint"); return false; } - + TreeSet candidates = new TreeSet(); - + // look for the pair of tokens with max(succ.LatestStart-pred.EarliestFinish) for (int i=0;i 0) { - removePrecedence(p); - addNoGood(p.pred,p.succ); // this can happen because of the max distance constraints, add a no-good - } + removePrecedence(p); + addNoGood(p.pred,p.succ); // this can happen because of the max distance constraints, add a no-good + } else return true; } - + //RCPSPUtil.dbgout("WARNING!: for "+r.getName()+" could not find activity pair with positive slack, bailing out without adding precedence constraint"); return false; } - + String getNoGoodKey(PSToken pred,PSToken succ) { int actPred = RCPSPUtil.getActivity(pred); int actSucc = RCPSPUtil.getActivity(succ); - return actPred + "<" + actSucc; + return actPred + "<" + actSucc; } - + int tabuTenure_ = 1; - + void addNoGood(PSToken pred,PSToken succ) { String key = getNoGoodKey(pred,succ); - noGoods_.put(key,curIteration_+tabuTenure_); + noGoods_.put(key,curIteration_+tabuTenure_); //RCPSPUtil.dbgout(curIteration_+" added noGood:{"+key+"}"); } - + boolean isNoGood(PSToken pred,PSToken succ) { String key = getNoGoodKey(pred,succ); Integer iteration = noGoods_.get(key); - + if (iteration == null) return false; - + return (iteration.intValue() > curIteration_); } - + protected void addPrecedence(Precedence p) { //RCPSPUtil.dbgout("adding {"+RCPSPUtil.getActivity(p.pred)+"<"+RCPSPUtil.getActivity(p.succ)+"} because of "+p.res.getName()); @@ -275,15 +275,15 @@ protected void removePrecedence(Precedence p) //RCPSPUtil.dbgout("removing {"+RCPSPUtil.getActivity(p.pred)+"<"+RCPSPUtil.getActivity(p.succ)+"} because of "+p.res.getName()); p.res.removePrecedence(p.pred,p.succ); precedences_.remove(p); - //RCPSPUtil.dbgout("removed {"+RCPSPUtil.getActivity(p.pred)+"<"+RCPSPUtil.getActivity(p.succ)+"} because of "+p.res.getName()); + //RCPSPUtil.dbgout("removed {"+RCPSPUtil.getActivity(p.pred)+"<"+RCPSPUtil.getActivity(p.succ)+"} because of "+p.res.getName()); } - + protected void updateSolution(int iteration) - { + { int newMakespan = getMakespan(); String violationMsg = (hasViolations_ ? " with violations" : ""); //RCPSPUtil.dbgout("Iteration "+iteration+": found makespan "+newMakespan+violationMsg); - + if (newMakespan < bestMakespan_ && !hasViolations_) { bestMakespan_ = newMakespan; bestSolution_.clear(); @@ -296,36 +296,36 @@ protected void updateSolution(int iteration) nbStable_++; } } - - public SortedMap getActivityMap() { return activities_; } + + public SortedMap getActivityMap() { return activities_; } /* (non-Javadoc) * @see UBO.RCPSPSolver#getActivities() */ - + protected void updateCriticalPrecedences() { // TODO: this only works if we're working with a solution that doesn't have any temporal violations /* int savedUb = RCPSPUtil.getUb(getProjectFinish()); - + // TODO: mark activities on the critical path - for (Precedence p : precs) { + for (Precedence p : precs) { if (criticalPath_.contains(pred.getKey) || criticalPath_.contains(pred.getKey)) p.isCritical = true; else p.isCritical = false; - } - */ + } + */ } - + public String printResources() { StringBuffer buf = new StringBuffer(); - + for (Resource r : resources_) { buf.append(r.toString()).append("\n"); } - - return buf.toString(); - } + + return buf.toString(); + } } diff --git a/examples/UBO/java/UBO/Main.java b/examples/UBO/java/UBO/Main.java index 4fa9fe9b4..facc56e64 100644 --- a/examples/UBO/java/UBO/Main.java +++ b/examples/UBO/java/UBO/Main.java @@ -13,7 +13,7 @@ class Main { protected static PSEngine psEngine_; - + public static void main(String args[]) { if ((args.length >= 4) && !(args[3].equals(""))) { @@ -21,13 +21,13 @@ public static void main(String args[]) } else { String debugMode = args[0]; - PSUtil.loadLibraries(debugMode); + PSUtil.loadLibraries(debugMode); psEngine_ = PSEngine.makeInstance(); psEngine_.start(); Runtime.getRuntime().addShutdownHook(new ShutdownHook()); loadCustomCode(debugMode); - + if((args.length >= 3) && args[2].equals("nogui")) { Interpreter bshInterpreter_ = new bsh.Interpreter(); try { @@ -36,7 +36,7 @@ public static void main(String args[]) } catch (Exception e) { throw new RuntimeException(e); - } + } } else { PSDesktop d = PSDesktop.makeInstance(psEngine_,args); @@ -44,50 +44,50 @@ public static void main(String args[]) } } } - + protected static void loadCustomCode(String debugMode) { //Load module with any custom code if it exists: String libName = "UBO_" + debugMode; - String fullLibName = LibraryLoader.getResolvedName(libName); + String fullLibName = LibraryLoader.getResolvedName(libName); if(fullLibName == null) { // Run 'make' to compile the library if you need it: - System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); + System.out.println("INFO: Custom library " + libName + " wasn't found and won't be loaded."); } else { // WARNING: Shared library loaded twice (see ticket #164) System.load(fullLibName); psEngine_.loadModule(fullLibName); - } + } } - - - static class ShutdownHook extends Thread + + + static class ShutdownHook extends Thread { public ShutdownHook() { super("ShutdownHook"); } - - public void run() + + public void run() { psEngine_.shutdown(); } - } - - + } + + public static void runBatchTest(String args[]) { try { String debugMode = args[0]; String test = args[3]; Integer bound = new Integer(args[4]); - long timeoutMsecs = (new Integer(args[5])).intValue() * 1000; + long timeoutMsecs = (new Integer(args[5])).intValue() * 1000; String solver = args[6]; System.out.println("Running batch test: "+debugMode+" "+test+" "+bound+" "+timeoutMsecs+" "+solver); - LibraryLoader.loadLibrary("System_"+debugMode); + LibraryLoader.loadLibrary("System_"+debugMode); PSEngine engine = PSEngine.makeInstance(); engine.start(); String nddlModel = "UBO-gen-initial-state.nddl"; @@ -102,21 +102,21 @@ else if ("Hybrid".equals(solver)) else throw new RuntimeException("Unknown solver:"+solver); - //engine.shutdown(); TODO: this is causing problems + //engine.shutdown(); TODO: this is causing problems } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException(e); } - } - + } + public static void runBuiltInSolver(PSEngine engine,String solverName, String test,Integer bound, long timeoutMsecs) { PSVariable v = engine.getVariableByName("maxDuration"); v.specifyValue(PSVarValue.getInstance(bound)); PSSolver solver = engine.createSolver("PlannerConfig.xml"/*config*/); - solver.configure(0/*horizonStart*/,1000/*horizonEnd*/); - + solver.configure(0/*horizonStart*/,1000/*horizonEnd*/); + SimpleTimer timer = new SimpleTimer(); timer.start(); boolean timedOut = false; @@ -128,7 +128,7 @@ public static void runBuiltInSolver(PSEngine engine,String solverName, String te } } timer.stop(); - + // Save results // test-name bound best-makespan time-in-msecs solution stepCount int makespan = ((timedOut || solver.isExhausted()) ? 0 : bound); // TODO: this could be lower, ground solution and find out @@ -141,17 +141,17 @@ public static void runBuiltInSolver(PSEngine engine,String solverName, String te //.append(s.getSolutionAsString()) // TODO: extract solution .append(solver.getStepCount()).append(separator) .append("\n"); - - writeToFile("Solver-"+solverName+"-"+timeoutMsecs+".txt",buf.toString()); + + writeToFile("Solver-"+solverName+"-"+timeoutMsecs+".txt",buf.toString()); } public static void runRCPSPSolver(PSEngine engine,RCPSPSolver s, String test,Integer bound, long timeoutMsecs) - { + { // TODO: since this is randomized, run several times an get avg boolean usePSResources = false; // TODO: eventually switch to true s.solve(engine,timeoutMsecs,bound,usePSResources); //RCPSPUtil.ground(s.getActivities()); - + // Save results // test-name bound best-makespan time-in-msecs solution int makespan = (s.getBestMakespan() != Integer.MAX_VALUE ? s.getBestMakespan() : 0); @@ -164,20 +164,20 @@ public static void runRCPSPSolver(PSEngine engine,RCPSPSolver s, String test,Int .append(s.getTimeToBest()).append(separator) .append(s.getSolutionAsString()) .append("\n"); - + String filename = "Solver-"+s.getName()+"-"+(s.getActivities().size()-2)+".txt"; writeToFile(filename,buf.toString()); - } - + } + protected static void writeToFile(String filename,String str) { try { BufferedWriter out = new BufferedWriter(new FileWriter(filename,true/*append*/)); out.write(str); out.close(); - } + } catch (Exception e) { throw new RuntimeException(e); - } + } } } diff --git a/examples/UBO/java/UBO/PSResourceWrapper.java b/examples/UBO/java/UBO/PSResourceWrapper.java index 2dd64344b..1a4e4cd11 100644 --- a/examples/UBO/java/UBO/PSResourceWrapper.java +++ b/examples/UBO/java/UBO/PSResourceWrapper.java @@ -8,13 +8,13 @@ /* * This is a thin wrapper around PSResource */ -public class PSResourceWrapper extends ResourceBase +public class PSResourceWrapper extends ResourceBase { public PSResourceWrapper(PSEngine pse,PSResource r, int capacity) { super(pse,r,capacity); } - + public List getConflictSet(int t) { List retval = new Vector(); @@ -24,15 +24,15 @@ public List getConflictSet(int t) PSToken tok = psengine_.getTokenByKey(tokKeys.get(i)); retval.add(tok); } - + return retval; } - + public ResourceViolationInfo getMaxViolation() { int t = -1; double lowestLevel = Double.MAX_VALUE; - + PSResourceProfile prof = res_.getVDLevels(); PSTimePointList times = prof.getTimes(); for (int i=0; i=0) RCPSPUtil.dbgout("MaxViolation for "+res_.getEntityName()+" "+lowestLevel+" at time "+t); - - return new ResourceViolationInfo(t,lowestLevel); - } + + return new ResourceViolationInfo(t,lowestLevel); + } } diff --git a/examples/UBO/java/UBO/PlanHistoryEntry.java b/examples/UBO/java/UBO/PlanHistoryEntry.java index 34e1d652d..8fab6db55 100644 --- a/examples/UBO/java/UBO/PlanHistoryEntry.java +++ b/examples/UBO/java/UBO/PlanHistoryEntry.java @@ -6,7 +6,7 @@ public class PlanHistoryEntry Long remainingTreeSize_; String currentTree_; String currentPlan_; - + public PlanHistoryEntry( Integer step, Long remainingTreeSize, @@ -18,19 +18,19 @@ public PlanHistoryEntry( currentTree_ = currentTree; currentPlan_ = currentPlan; } - + public Integer getStepNumber() { return step_; } public Long getRemainingTreeSize() { return remainingTreeSize_; } public String getCurrentTree() { return currentTree_; } - public String getCurrentPlan() { return currentPlan_; } - + public String getCurrentPlan() { return currentPlan_; } + public String toString() { StringBuffer buf = new StringBuffer(); buf.append(step_).append(": ") .append("(").append(remainingTreeSize_).append(")") .append(currentTree_) - .append(currentPlan_); + .append(currentPlan_); return buf.toString(); } } diff --git a/examples/UBO/java/UBO/Precedence.java b/examples/UBO/java/UBO/Precedence.java index 647ec0574..2e1769fd3 100644 --- a/examples/UBO/java/UBO/Precedence.java +++ b/examples/UBO/java/UBO/Precedence.java @@ -17,28 +17,28 @@ public Precedence(PSResource r,PSToken p,PSToken s) this(r,p,s,0); int succStart = RCPSPUtil.getUb(succ.getStart()); int predFinish = RCPSPUtil.getLb(pred.getEnd()); - buffer = succStart-predFinish; + buffer = succStart-predFinish; } public Precedence(PSResource r,PSToken p,PSToken s, int b) { res = r; pred = p; - succ = s; + succ = s; isCritical = true; buffer = b; - } + } public int compareTo(Object o) { Precedence rhs = (Precedence)o; return rhs.buffer - buffer; } - + public String toString() { StringBuffer buf = new StringBuffer(); buf.append(RCPSPUtil.getActivity(pred)).append("<").append(RCPSPUtil.getActivity(succ)); return buf.toString(); } -} +} diff --git a/examples/UBO/java/UBO/RCPSPResource.java b/examples/UBO/java/UBO/RCPSPResource.java index a76ac443e..c328fc5e9 100644 --- a/examples/UBO/java/UBO/RCPSPResource.java +++ b/examples/UBO/java/UBO/RCPSPResource.java @@ -9,13 +9,13 @@ /* * This is a version of Resource that performs much more computation outside EUROPA than PSResourceWrapper */ -public class RCPSPResource extends ResourceBase -{ +public class RCPSPResource extends ResourceBase +{ public RCPSPResource(PSEngine pse,PSResource r, int capacity) { super(pse,r,capacity); } - + public List getConflictSet(int t) { List conflictSet = new Vector(); @@ -23,7 +23,7 @@ public List getConflictSet(int t) PSTokenList toks = res_.getTokens(); for (int i=0;i getConflictSet(int t) // Don't try to order tokens that can't be ordered int predEndLb = RCPSPUtil.getLb(pred.getEnd()); int succStartUb = RCPSPUtil.getUb(pred.getStart()); - + if ((pred != succ) && (predEndLb <= succStartUb)) { retval.add(pred); retval.add(succ); } } } - + return retval; } - + public ResourceViolationInfo getMaxViolation() { int lowestTime = -1; double lowestLevel = Double.MAX_VALUE; - + ResourceProfile prof = getLevels(); Iterator times = prof.getTimes().iterator(); while (times.hasNext()) { @@ -60,10 +60,10 @@ public ResourceViolationInfo getMaxViolation() lowestTime = t; } } - + //if (lowestTime>=0) // RCPSPUtil.dbgout("MaxViolation for "+res_.getName()+" "+lowestLevel+" at time "+lowestTime); - - return new ResourceViolationInfo(lowestTime,lowestLevel); + + return new ResourceViolationInfo(lowestTime,lowestLevel); } } diff --git a/examples/UBO/java/UBO/RCPSPSolver.java b/examples/UBO/java/UBO/RCPSPSolver.java index 1a94a2589..f1c426307 100644 --- a/examples/UBO/java/UBO/RCPSPSolver.java +++ b/examples/UBO/java/UBO/RCPSPSolver.java @@ -5,13 +5,13 @@ import psengine.PSEngine; import psengine.PSToken; -public interface RCPSPSolver +public interface RCPSPSolver { public String getName(); - - public void solve(PSEngine psengine, + + public void solve(PSEngine psengine, long timeout, // in msecs - int bound, + int bound, boolean usePSResources); public long getElapsedMsecs(); @@ -28,4 +28,4 @@ public void solve(PSEngine psengine, public String getSolutionAsString(); -} \ No newline at end of file +} diff --git a/examples/UBO/java/UBO/RCPSPSolverBase.java b/examples/UBO/java/UBO/RCPSPSolverBase.java index d484bbd16..46b3a77b4 100644 --- a/examples/UBO/java/UBO/RCPSPSolverBase.java +++ b/examples/UBO/java/UBO/RCPSPSolverBase.java @@ -13,8 +13,8 @@ import psengine.PSVariable; import psengine.util.SimpleTimer; -public abstract class RCPSPSolverBase - implements RCPSPSolver +public abstract class RCPSPSolverBase + implements RCPSPSolver { protected SimpleTimer timer_; protected boolean timedOut_; @@ -23,15 +23,15 @@ public abstract class RCPSPSolverBase protected int bestMakespan_; protected PSEngine psengine_; - protected List resources_; + protected List resources_; protected SortedMap activities_; protected SortedSet precedences_; - - protected SortedSet bestSolution_; - + + protected SortedSet bestSolution_; + public String getName() { return getClass().getSimpleName(); } - - public Collection getActivities() { return activities_.values(); } + + public Collection getActivities() { return activities_.values(); } public List getResources() { return resources_; } public SortedSet getPrecedences() { return precedences_; } @@ -39,51 +39,51 @@ public abstract class RCPSPSolverBase public int getBestMakespan() { return bestMakespan_; } public long getTimeToBest() { return timeToBest_; } public SortedSet getBestSolution() { return bestSolution_; } - + public void undoSolve() { psengine_.setAutoPropagation(false); for (Precedence p : bestSolution_) p.res.removePrecedence(p.pred,p.succ); - - psengine_.setAutoPropagation(true); + + psengine_.setAutoPropagation(true); } - + public void restoreBestSolution() { psengine_.setAutoPropagation(false); - + for (Precedence p : precedences_) p.res.removePrecedence(p.pred,p.succ); precedences_.clear(); - + for (Precedence p : bestSolution_) - p.res.addPrecedence(p.pred,p.succ); + p.res.addPrecedence(p.pred,p.succ); - psengine_.setAutoPropagation(true); + psengine_.setAutoPropagation(true); } - + public String getSolutionAsString() { StringBuffer buf = new StringBuffer(); - - for (Precedence p : bestSolution_) + + for (Precedence p : bestSolution_) buf.append("{").append(RCPSPUtil.getActivity(p.pred)).append("<").append(RCPSPUtil.getActivity(p.succ)).append("}"); - + return buf.toString(); - } - + } + public int getMakespan() { return RCPSPUtil.getLb(getProjectFinish()); } - + public PSVariable getProjectFinish() { return activities_.get(activities_.lastKey()).getStart(); - } - + } + protected void addPrecedence(Precedence p) { //RCPSPUtil.dbgout("adding {"+RCPSPUtil.getActivity(p.pred)+"<"+RCPSPUtil.getActivity(p.succ)+"} because of "+p.res.getName()); @@ -97,42 +97,42 @@ protected void removePrecedence(Precedence p) //RCPSPUtil.dbgout("removing {"+RCPSPUtil.getActivity(p.pred)+"<"+RCPSPUtil.getActivity(p.succ)+"} because of "+p.res.getName()); p.res.removePrecedence(p.pred,p.succ); precedences_.remove(p); - //RCPSPUtil.dbgout("removed {"+RCPSPUtil.getActivity(p.pred)+"<"+RCPSPUtil.getActivity(p.succ)+"} because of "+p.res.getName()); - } + //RCPSPUtil.dbgout("removed {"+RCPSPUtil.getActivity(p.pred)+"<"+RCPSPUtil.getActivity(p.succ)+"} because of "+p.res.getName()); + } // TODO: do this faster with a key boolean isPrecedence(PSToken pred,PSToken succ) { int actPred = RCPSPUtil.getActivity(pred); int actSucc = RCPSPUtil.getActivity(succ); - + for (Precedence p : precedences_) { - if ((RCPSPUtil.getActivity(p.pred)==actPred) && (RCPSPUtil.getActivity(p.succ)==actSucc)) - return true; + if ((RCPSPUtil.getActivity(p.pred)==actPred) && (RCPSPUtil.getActivity(p.succ)==actSucc)) + return true; } - + return false; - } + } + - protected void resetSolution() { bestMakespan_ = Integer.MAX_VALUE; - bestSolution_ = new TreeSet(new PrecedenceComparator()); + bestSolution_ = new TreeSet(new PrecedenceComparator()); precedences_ = new TreeSet(new PrecedenceComparator()); } - + static class PrecedenceComparator implements Comparator { - public int compare(Precedence o1, Precedence o2) + public int compare(Precedence o1, Precedence o2) { int diff = RCPSPUtil.getActivity(o1.pred) - RCPSPUtil.getActivity(o2.pred); - if (diff != 0) + if (diff != 0) return diff; - else + else return RCPSPUtil.getActivity(o1.succ) - RCPSPUtil.getActivity(o2.succ); } - } + } } diff --git a/examples/UBO/java/UBO/RCPSPUtil.java b/examples/UBO/java/UBO/RCPSPUtil.java index 788ed50fc..9d51a21b1 100644 --- a/examples/UBO/java/UBO/RCPSPUtil.java +++ b/examples/UBO/java/UBO/RCPSPUtil.java @@ -6,63 +6,63 @@ import psengine.PSVarValue; import psengine.PSVariable; -public class RCPSPUtil +public class RCPSPUtil { public static int getActivity(PSToken tok) { return tok.getMaster().getParameter("m_identifier").getSingletonValue().asInt(); } - + public static int getLb(PSVariable v) { if (v.isSingleton()) return (new Double(valueToString(v.getSingletonValue()))).intValue(); else if (v.isInterval()) return (int)v.getLowerBound(); - + throw new RuntimeException("Can only get lb for singleton or interval vars"); } - + public static int getUb(PSVariable v) { if (v.isSingleton()) return (new Double(valueToString(v.getSingletonValue()))).intValue(); else if (v.isInterval()) return (int)v.getUpperBound(); - + throw new RuntimeException("Can only get ub for singleton or interval vars"); } - + public static boolean overlaps(PSToken tok, int t) { int lb = getLb(tok.getStart()); int ub = getLb(tok.getEnd()); - + return ((lb <= t) && (t <= ub)); - } + } public static String valueToString(PSVarValue v) { String type = v.getType().toString(); - + if ("STRING".equals(type)) return v.asString(); if ("INTEGER".equals(type)) - return new Integer(v.asInt()).toString(); + return new Integer(v.asInt()).toString(); if ("DOUBLE".equals(type)) return new Double(v.asDouble()).toString(); if ("BOOLEAN".equals(type)) return new Boolean(v.asBoolean()).toString(); if ("OBJECT".equals(type)) return v.asObject().getEntityName(); - + return "ERROR!!! UNKNOWN TYPE :" + type; } public static String varValueToString(PSVariable var) - { - if (var.isSingleton()) - return valueToString(var.getSingletonValue()); + { + if (var.isSingleton()) + return valueToString(var.getSingletonValue()); else if (var.isInterval()) { StringBuffer buf = new StringBuffer(); buf.append("[").append(var.getLowerBound()).append(",") @@ -81,9 +81,9 @@ else if (var.isEnumerated()) { buf.append("]"); return buf.toString(); } - + throw new RuntimeException("Unexpected ERROR: variable "+var.getEntityName()+" is not one of {Singleton, Interval, Enumeration}"); - } + } public static void ground(Collection tokens) { @@ -92,12 +92,12 @@ public static void ground(Collection tokens) ground(t.getEnd()); } } - + public static void ground(PSVariable v) { int value = RCPSPUtil.getLb(v); v.specifyValue(PSVarValue.getInstance(value)); - } + } public static void undoGround(Collection tokens) { @@ -110,11 +110,11 @@ public static void undoGround(PSVariable v) { int value = RCPSPUtil.getLb(v); v.reset(); - } + } + - public static void dbgout(String msg) { System.out.println(msg); - } + } } diff --git a/examples/UBO/java/UBO/ResourceBase.java b/examples/UBO/java/UBO/ResourceBase.java index 144381d23..79ac71eaa 100644 --- a/examples/UBO/java/UBO/ResourceBase.java +++ b/examples/UBO/java/UBO/ResourceBase.java @@ -2,32 +2,32 @@ import psengine.*; -public abstract class ResourceBase implements Resource +public abstract class ResourceBase implements Resource { protected PSEngine psengine_; protected PSResource res_; protected int capacity_; - + public ResourceBase(PSEngine pse,PSResource r, int capacity) { psengine_ = pse; capacity_ = capacity; res_ = r; } - + public int getCapacity() { return capacity_; } public PSResource getPSResource() { return res_; } public String getName() { return res_.getEntityName(); } - + public ResourceProfile getLevels() { return new ResourceProfile(this); } - + public String toString() { StringBuffer buf = new StringBuffer(); buf.append(res_.getEntityName()).append(" ").append(getLevels().toString()); return buf.toString(); - } + } } diff --git a/examples/UBO/java/UBO/ResourceProfile.java b/examples/UBO/java/UBO/ResourceProfile.java index 5f0e5f84d..8c0bb7609 100644 --- a/examples/UBO/java/UBO/ResourceProfile.java +++ b/examples/UBO/java/UBO/ResourceProfile.java @@ -8,40 +8,40 @@ import psengine.*; -public class ResourceProfile -{ +public class ResourceProfile +{ protected Resource res_; protected SortedMap levels_; - + public ResourceProfile(Resource r) { res_ = r; init(); } - + protected void init() { levels_ = new TreeMap(); levels_.put(0,res_.getCapacity()); - + PSTokenList acts = res_.getPSResource().getTokens(); for (int i=0;i> it = levels_.entrySet().iterator(); + if (levelAtStart == null) { + Iterator> it = levels_.entrySet().iterator(); while(it.hasNext()) { Entry entry = it.next(); if (entry.getKey() < start) @@ -51,27 +51,27 @@ protected void update(int start,int end,int qty) } levels_.put(start, levelAtStart); } - + Integer lastValue=levelAtStart; SortedMap submap = levels_.subMap(start, end); // this doesn't include end - Iterator> it = submap.entrySet().iterator(); + Iterator> it = submap.entrySet().iterator(); while(it.hasNext()) { Entry entry = it.next(); lastValue = entry.getValue()-qty; - entry.setValue(lastValue); + entry.setValue(lastValue); } - + Integer levelAtEnd=levels_.get(end); if (levelAtEnd == null) levels_.put(end, lastValue+qty); - - } - + + } + public Set getTimes() { return levels_.keySet(); } - + // TODO: make this more sophisticated public Integer getLevel(Integer time) { return levels_.get(time); } - + public String toString() { StringBuffer buf = new StringBuffer(); @@ -81,7 +81,7 @@ public String toString() Integer t = times.next(); buf.append("{").append(t).append("=").append(getLevel(t)).append("}"); } - + return buf.toString(); } } diff --git a/examples/UBO/java/UBO/ResourceViolationInfo.java b/examples/UBO/java/UBO/ResourceViolationInfo.java index 7cfe969db..7a4417f5f 100644 --- a/examples/UBO/java/UBO/ResourceViolationInfo.java +++ b/examples/UBO/java/UBO/ResourceViolationInfo.java @@ -1,10 +1,10 @@ package UBO; -public class ResourceViolationInfo +public class ResourceViolationInfo { public int time; public double level; - + public ResourceViolationInfo(int t,double l) { time = t; diff --git a/examples/UBO/java/UBO/SolDistExhaustiveSolver.java b/examples/UBO/java/UBO/SolDistExhaustiveSolver.java index f52bea868..77e1b0db7 100644 --- a/examples/UBO/java/UBO/SolDistExhaustiveSolver.java +++ b/examples/UBO/java/UBO/SolDistExhaustiveSolver.java @@ -12,36 +12,36 @@ /* * this is a different version of the Exhaustive solver that didn't turn out to be an improvement - * instead of starting from scratch, it removes 1, then 2, then 3 ... precedences from the incoming oracle and then + * instead of starting from scratch, it removes 1, then 2, then 3 ... precedences from the incoming oracle and then * performs and exhaustive search. * Leaving the code around for now, in case this idea can be reused in some form later. * For now it looks like it'll be much better to improve the Exhaustive solver by using ideas from existing B&B solvers */ public class SolDistExhaustiveSolver - extends RCPSPSolverBase + extends RCPSPSolverBase { List decisionStack_ = new Vector(); int lowerBound_; int upperBound_; SortedSet precedenceOracle_; DecisionPoint curDP_; - + public SolDistExhaustiveSolver() - { + { } - + public void solve( - PSEngine psengine, - long timeout, + PSEngine psengine, + long timeout, int bound, - boolean usePSResources) + boolean usePSResources) { // TODO: get this to work solve(psengine,timeout,bound,Integer.MAX_VALUE,null,null,null); - } + } Precedence noGood_ = null; - + public void solve( PSEngine psengine, long timeout, @@ -57,20 +57,20 @@ public void solve( if (precedenceOracle.size() > 0) { for (int i=0;i exclusions = it.next(); + List exclusions = it.next(); removePrecedences(exclusions); doSolve(); if (upperBound_ <= lowerBound_ || timedOut_) { solveFinished(precedenceOracle); - return; + return; } - + undoSolve(); - addPrecedences(exclusions); + addPrecedences(exclusions); } } } @@ -80,13 +80,13 @@ public void solve( solveFinished(precedenceOracle); } - + protected void solveFinished(List precedenceOracle) { bestSolution_.addAll(precedenceOracle); - timer_.stop(); + timer_.stop(); } - + protected void doSolve() { for (;;) { @@ -110,29 +110,29 @@ protected void doSolve() bestSolution_.clear(); bestSolution_.addAll(precedences_); timeToBest_ = timer_.getElapsed(); - RCPSPUtil.dbgout("ExhaustiveSolver found new best makespan "+bestMakespan_+" "+getSolutionAsString()); - } + RCPSPUtil.dbgout("ExhaustiveSolver found new best makespan "+bestMakespan_+" "+getSolutionAsString()); + } // if upper and lower bound cross, we're done if (upperBound_ <= lowerBound_) { doSolveFinished("Bounds crossed"); break; - } + } if (decisionStack_.isEmpty()) { doSolveFinished("exhausted"); break; } - else + else doBacktrack("Backtracking after finding solution"); } else { if (curDP_.hasNext()) { executeDecision(curDP_); - if (psengine_.getViolation() > 0) + if (psengine_.getViolation() > 0) doBacktrack("Backtracking because of violation"); - else if (getMakespan() > upperBound_) + else if (getMakespan() > upperBound_) doBacktrack("Backtracking because of upper bound "+getMakespan()+" vs. "+upperBound_); } else if (decisionStack_.isEmpty()) { @@ -143,9 +143,9 @@ else if (decisionStack_.isEmpty()) { doBacktrack("Backtracking because decision point exhausted choices"); } } - } + } } - + protected void doSolveFinished(String msg) { // TODO: timer_.stop(); @@ -156,7 +156,7 @@ protected void doSolveFinished(String msg) restoreBestSolution(); resetState(); } - + public void init( PSEngine psengine, long timeout, @@ -167,7 +167,7 @@ public void init( List precedenceOracle) { timer_ = new SimpleTimer(); - timer_.start(); + timer_.start(); psengine_ = psengine; timeout_ = timeout; @@ -175,44 +175,44 @@ public void init( resources_ = resources; lowerBound_ = lowerBound; upperBound_ = upperBound; - + precedenceOracle_ = new TreeSet(); for (Precedence p : precedenceOracle) precedenceOracle_.add(p.toString()); - + resetSolution(); resetState(); } - + void resetState() { - curDP_ = null; + curDP_ = null; } - + int lastIdx_ = 0; - + protected DecisionPoint getNextDecisionPoint() { double lowestLevel = Double.MAX_VALUE; Resource maxViolatedResource = null; int maxViolatedTime = Integer.MIN_VALUE; - + int start = lastIdx_; for (int i=lastIdx_;;) { Resource r = resources_.get(i); ResourceViolationInfo rvi = r.getMaxViolation(); - + if ((rvi.level < lowestLevel) && (rvi.level < 0)) { lowestLevel = rvi.level; maxViolatedResource = r; maxViolatedTime = rvi.time; } - + i = (i+1) % resources_.size(); if (i == start) break; - } - + } + if (maxViolatedResource == null) { //RCPSPUtil.dbgout("No violations found!"); return null; @@ -220,38 +220,38 @@ protected DecisionPoint getNextDecisionPoint() else return new DecisionPoint(maxViolatedResource,maxViolatedTime); } - + protected void executeDecision(DecisionPoint dp) { decisionStack_.add(dp); - dp.execute(); + dp.execute(); curDP_ = null; } - + protected void doBacktrack(String reason) { curDP_ = decisionStack_.remove(decisionStack_.size()-1); - curDP_.undo(); + curDP_.undo(); //RCPSPUtil.dbgout(reason+" new stack size:"+decisionStack_.size()); } - + boolean isNoGood(PSToken pred,PSToken succ) { return false; - /* + /* if (noGood_ == null) return false; - + return ((noGood_.pred.getKey()==pred.getKey()) && (noGood_.succ.getKey() == succ.getKey())); */ } - + protected class DecisionPoint { TreeSet choices_; SortedSet executedChoices_; Precedence lastExecutedChoice_; - + public DecisionPoint(Resource r, int t) { choices_ = new TreeSet(); @@ -259,78 +259,78 @@ public DecisionPoint(Resource r, int t) if (conflictSet.size() < 2) RCPSPUtil.dbgout("ERROR!!: conflictSet size is :"+conflictSet.size()); - + for (int i=0;i l) { psengine_.setAutoPropagation(false); - + for (Precedence p : l) p.res.addPrecedence(p.pred,p.succ); - - psengine_.setAutoPropagation(true); + + psengine_.setAutoPropagation(true); } - + void removePrecedences(List l) { psengine_.setAutoPropagation(false); - + for (Precedence p : l) p.res.removePrecedence(p.pred,p.succ); - - psengine_.setAutoPropagation(true); + + psengine_.setAutoPropagation(true); } - + class OracleIterator { int setSize_; @@ -338,7 +338,7 @@ class OracleIterator List counter_; int counterRow_; int max_; - + public OracleIterator(List source,int setSize) { setSize_ = setSize; @@ -346,54 +346,54 @@ public OracleIterator(List source,int setSize) counter_ = new Vector(); for (int i=0;i= 0; + return counterRow_ >= 0; } - + void incCounter() { int newValue = counter_.get(counterRow_)+1; while ((newValue + (counter_.size()-counterRow_) > max_) && counterRow_>=0) { counterRow_--; if (counterRow_ >= 0) - newValue = counter_.get(counterRow_)+1; + newValue = counter_.get(counterRow_)+1; } - + if (counterRow_ >=0) { for (int i=0;(counterRow_+i) next() { List retval = new Vector(); - + for (Integer i : counter_) retval.add(source_.get(i)); - + incCounter(); //printExcluded(retval); - + return retval; } - + void printExcluded(List retval) { StringBuffer buf = new StringBuffer(); buf.append("Excluded:"); for (Precedence p: retval) buf.append(p.toString()).append(","); - RCPSPUtil.dbgout(buf.toString()); + RCPSPUtil.dbgout(buf.toString()); } } - + } diff --git a/examples/UBO/java/UBO/UBOSolverListener.java b/examples/UBO/java/UBO/UBOSolverListener.java index 40f0d1233..9c505dde7 100644 --- a/examples/UBO/java/UBO/UBOSolverListener.java +++ b/examples/UBO/java/UBO/UBOSolverListener.java @@ -16,7 +16,7 @@ public class UBOSolverListener Vector planHistory_; Vector treeSize_; Vector currentTree_; - + public UBOSolverListener() { lastDepth_ = 0; @@ -26,16 +26,16 @@ public UBOSolverListener() treeSize_ = new Vector(); currentTree_ = new Vector(); } - + PSEngine getPSEngine() { - return PSDesktop.getInstance().getPSEngine(); + return PSDesktop.getInstance().getPSEngine(); // return PSDesktop.desktop.getPSEngine(); } - + public Vector getDecisionHistory() { return decisionHistory_; } public Vector getPlanHistory() { return planHistory_; } - + protected PlanHistoryEntry makePlanHistoryEntry(PSSolver s) { // Compute remaining nodes to explore @@ -43,25 +43,25 @@ protected PlanHistoryEntry makePlanHistoryEntry(PSSolver s) for (Integer i : treeSize_) { if (i != null) size *= i; - } - + } + PlanHistoryEntry entry = new PlanHistoryEntry(s.getStepCount(),size,currentTree_.toString(),plan_.toString()); return entry; } - + protected void decreasePlanSize(int delta) { int newSize = Math.max(0,plan_.size()-delta); - + plan_.setSize(newSize); treeSize_.setSize(newSize); currentTree_.setSize(newSize); } - + public void stepCompleted(PSSolver s) { - String lastDecision = s.getLastExecutedDecision(); + String lastDecision = s.getLastExecutedDecision(); if (lastDecision.startsWith("INSTANT") && (lastDepth_ <= s.getDepth())) { Pattern p = Pattern.compile("token=[0-9]+"); Matcher m = p.matcher(lastDecision); @@ -70,7 +70,7 @@ public void stepCompleted(PSSolver s) m.find(); Integer succId = new Integer(lastDecision.substring(m.start()+6,m.end())); String tokenDecision = " tokens:{" + predId + "} < {" + succId +"}"; - + PSObject resource = getPSEngine().getTokenByKey(predId).getOwner(); PSToken pred = getPSEngine().getTokenByKey(predId).getMaster(); PSToken succ = getPSEngine().getTokenByKey(succId).getMaster(); @@ -91,29 +91,29 @@ public void stepCompleted(PSSolver s) String decision = decisionBuf.toString(); String decisionMsg = s.getStepCount() + ": "+ decision + " because of " + resource.getEntityName() + tokenDecision; decisionHistory_.add(decisionMsg); - //System.out.println(decisionMsg); + //System.out.println(decisionMsg); plan_.add(decision); treeSize_.add((remaining > 0) ? remaining : new Integer(1)); currentTree_.add("("+choiceIdx+","+choiceCnt+")"); PlanHistoryEntry entry = makePlanHistoryEntry(s); - planHistory_.add(entry); - //System.out.println(entry); - } - + planHistory_.add(entry); + //System.out.println(entry); + } + if (lastDepth_ >= s.getDepth()) { String btMsg = s.getStepCount() + ": Backtracked! from "+plan_.size()+" to "+s.getDepth(); decisionHistory_.add(btMsg); - //System.out.println(btMsg); + //System.out.println(btMsg); decreasePlanSize(lastDepth_ - s.getDepth()); PlanHistoryEntry entry = makePlanHistoryEntry(s); - planHistory_.add(entry); - //System.out.println(entry); + planHistory_.add(entry); + //System.out.println(entry); } - lastDepth_ = s.getDepth(); + lastDepth_ = s.getDepth(); //System.out.println(s.getStepCount()+" set last depth to:"+lastDepth_); } -} +} diff --git a/src/Java/CMakeLists.txt b/src/Java/CMakeLists.txt index 725a14d04..411fcbbb5 100644 --- a/src/Java/CMakeLists.txt +++ b/src/Java/CMakeLists.txt @@ -1 +1,2 @@ -add_subdirectory(PSEngine) \ No newline at end of file +add_subdirectory(PSEngine) +add_subdirectory(JavaUI) \ No newline at end of file diff --git a/src/Java/JavaUI/CMakeLists.txt b/src/Java/JavaUI/CMakeLists.txt new file mode 100644 index 000000000..52f8f6ee0 --- /dev/null +++ b/src/Java/JavaUI/CMakeLists.txt @@ -0,0 +1,137 @@ +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp) + +set(jarclasses "") +set(libjars lib/bsh-2.0b4.jar + lib/jcommon-1.0.16.jar + lib/jfreechart-1.0.13.jar + lib/egantt/egantt-core.jar + lib/egantt/egantt-ext.jar + lib/egantt/egantt-resources.jar) + +foreach(jar ${libjars}) + set(classes "") + get_filename_component(jarname ${jar} NAME) + unjar(${jarname}_unjarred ${CMAKE_CURRENT_SOURCE_DIR}/${jar} temp contents) + # message(STATUS ${classes}) + list(APPEND jarcontents ${contents}) + set(CMAKE_JAVA_INCLUDE_PATH "${CMAKE_JAVA_INCLUDE_PATH}:${jar}") +endforeach(jar) + set(CMAKE_JAVA_INCLUDE_PATH "${CMAKE_JAVA_INCLUDE_PATH}:lib/PSEngine.jar") +add_jar(PSUISwing + # INCLUDE_JARS + # ${libjars} + # ${CMAKE_CURRENT_BINARY_DIR}/../PSEngine/PSEngine.jar + SOURCES + #${jarclasses} + source/org/ops/ui/beanshell/swing/BeanShellView.java + source/org/ops/ui/editor/model/OutlineNode.java + source/org/ops/ui/editor/model/OutlineNodeType.java + source/org/ops/ui/editor/swing/anml/AnmlInterpreter.java + source/org/ops/ui/editor/swing/anml/AnmlTokenMarker.java + source/org/ops/ui/editor/swing/ash/AshConsole.java + source/org/ops/ui/editor/swing/ash/AshInterpreter.java + source/org/ops/ui/editor/swing/ash/AshTokenMarker.java + source/org/ops/ui/editor/swing/ash/ConsoleDefaults.java + source/org/ops/ui/editor/swing/ash/ConsolePainter.java + source/org/ops/ui/editor/swing/ash/DefaultInputHandler.java + source/org/ops/ui/editor/swing/ash/DocumentOutputStream.java + source/org/ops/ui/editor/swing/ash/DocumentWriter.java + source/org/ops/ui/editor/swing/ash/InputHandler.java + source/org/ops/ui/editor/swing/ash/KeywordMap.java + source/org/ops/ui/editor/swing/ash/SyntaxDocument.java + source/org/ops/ui/editor/swing/ash/SyntaxStyle.java + source/org/ops/ui/editor/swing/ash/SyntaxUtilities.java + source/org/ops/ui/editor/swing/ash/TextUtilities.java + source/org/ops/ui/editor/swing/ash/Token.java + source/org/ops/ui/editor/swing/ash/TokenMarker.java + source/org/ops/ui/editor/swing/nddl/NddlAshInterpreter.java + source/org/ops/ui/editor/swing/nddl/NddlTokenMarker.java + source/org/ops/ui/filemanager/model/AstNode.java + source/org/ops/ui/filemanager/model/AstNodeTypes.java + source/org/ops/ui/filemanager/model/ErrorRecord.java + source/org/ops/ui/filemanager/model/FileModel.java + source/org/ops/ui/gantt/model/EuropaGanttActivity.java + source/org/ops/ui/gantt/model/EuropaGanttModel.java + source/org/ops/ui/gantt/model/EuropaGanttResource.java + source/org/ops/ui/gantt/model/IGanttActivity.java + source/org/ops/ui/gantt/model/IGanttModel.java + source/org/ops/ui/gantt/model/IGanttResource.java + source/org/ops/ui/gantt/model/PSGanttActivity.java + source/org/ops/ui/gantt/model/PSGanttActivityImpl.java + source/org/ops/ui/gantt/model/PSGanttModel.java + source/org/ops/ui/gantt/model/PSGanttPSEModel.java + source/org/ops/ui/gantt/swing/GanttView.java + source/org/ops/ui/gantt/swing/LinePanel.java + source/org/ops/ui/gantt/swing/PSEGantt.java + source/org/ops/ui/gantt/swing/PSGantt.java + source/org/ops/ui/gantt/swing/PSGanttColorProvider.java + source/org/ops/ui/gantt/swing/ResourcePanel.java + source/org/ops/ui/gantt/swing/TimelinePanel.java + source/org/ops/ui/gantt/swing/TokenColor.java + source/org/ops/ui/gantt/swing/TokenWidget.java + source/org/ops/ui/main/swing/EuropaInternalFrame.java + source/org/ops/ui/main/swing/FileNameExtensionFilter.java + source/org/ops/ui/main/swing/PSComponent.java + source/org/ops/ui/main/swing/PSComponentBase.java + source/org/ops/ui/main/swing/PSDesktop.java + source/org/ops/ui/main/swing/PSMouseListener.java + source/org/ops/ui/mouse/swing/ActionDetailsPanel.java + source/org/ops/ui/mouse/swing/ActionViolationsPanel.java + source/org/ops/ui/mouse/swing/MouseListenerPanel.java + source/org/ops/ui/rchart/model/PSResourceChartModel.java + source/org/ops/ui/rchart/model/PSResourceChartPSEModel.java + source/org/ops/ui/rchart/swing/PSJFreeResourceChart.java + source/org/ops/ui/rchart/swing/PSResourceChart.java + source/org/ops/ui/schemabrowser/model/SchemaModel.java + source/org/ops/ui/schemabrowser/model/SchemaModelImpl.java + source/org/ops/ui/schemabrowser/model/SchemaNode.java + source/org/ops/ui/schemabrowser/model/SchemaSolverModel.java + source/org/ops/ui/schemabrowser/swing/SchemaNodeCellRenderer.java + source/org/ops/ui/schemabrowser/swing/SchemaTreeModel.java + source/org/ops/ui/schemabrowser/swing/SchemaView.java + source/org/ops/ui/solver/model/SolverAdapter.java + source/org/ops/ui/solver/model/SolverListener.java + source/org/ops/ui/solver/model/SolverModel.java + source/org/ops/ui/solver/model/StepStatisticsRecord.java + source/org/ops/ui/solver/model/TimeFormatHelper.java + source/org/ops/ui/solver/swing/ConsoleView.java + source/org/ops/ui/solver/swing/OpenDecisionsPanel.java + source/org/ops/ui/solver/swing/OpenDecisionsView.java + source/org/ops/ui/solver/swing/PSSolverDialog.java + source/org/ops/ui/solver/swing/PSSolverDialogListener.java + source/org/ops/ui/solver/swing/PSSolverView.java + source/org/ops/ui/solver/swing/SolverChartPanel.java + source/org/ops/ui/utils/swing/Util.java + source/org/ops/ui/utils/Utilities.java + MANIFEST + ${CMAKE_CURRENT_SOURCE_DIR}/META-INF/MANIFEST.SWING + ) +foreach(f ${libjars}) + get_filename_component(jarname ${f} NAME) + add_dependencies(PSUISwing ${jarname}_unjarred) +endforeach(f) +# foreach(f ${jarclasses}) +# add_dependencies(PSUISwing ${CMAKE_CURRENT_BINARY_DIR}/temp/${f}) +# endforeach(f) +# add_dependencies(PSUISwing ${jarclasses}) + +file(REMOVE PSEngineAdditionalClasses) +foreach(f ${jarcontents}) + file(APPEND PSEngineAdditionalClasses "${f}\n") +endforeach(f) + +add_custom_command(TARGET PSUISwing + POST_BUILD #? + COMMAND + ${Java_JAR_EXECUTABLE} -uf PSUISwing.jar -C ${CMAKE_CURRENT_BINARY_DIR}/temp . + #WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp +) + + +install_jar(PSUISwing ${EUROPA_ROOT}/dist/europa) \ No newline at end of file diff --git a/src/Java/JavaUI/source/org/ops/ui/beanshell/swing/BeanShellView.java b/src/Java/JavaUI/source/org/ops/ui/beanshell/swing/BeanShellView.java index 4ef51f4f9..29daa8c6c 100644 --- a/src/Java/JavaUI/source/org/ops/ui/beanshell/swing/BeanShellView.java +++ b/src/Java/JavaUI/source/org/ops/ui/beanshell/swing/BeanShellView.java @@ -23,8 +23,8 @@ public BeanShellView(SolverModel solverModel, PSDesktop psDesktop) { console = new JConsole(); this.setContentPane(console); - this.interpreter = new Interpreter(console); - + this.interpreter = new Interpreter(console); + // Register variables try { interpreter.set("desktop", psDesktop); diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/model/OutlineNode.java b/src/Java/JavaUI/source/org/ops/ui/editor/model/OutlineNode.java index 8fadaa229..7e675d32e 100644 --- a/src/Java/JavaUI/source/org/ops/ui/editor/model/OutlineNode.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/model/OutlineNode.java @@ -8,7 +8,7 @@ /** * Outline node. Outline tree is computed from AST tree. This class also * contains a bunch of static methods for the actual AST to Outline conversion. - * + * * @author Tatiana Kichkaylo */ public class OutlineNode { diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/AshConsole.java b/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/AshConsole.java index 573f49d9c..4eb1fde87 100644 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/AshConsole.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/AshConsole.java @@ -1636,7 +1636,7 @@ public Dimension minimumLayoutSize(Container parent) { dim.height = insets.top + insets.bottom; Dimension centerPref = center.getMinimumSize(); - dim.width += centerPref.width; + dim.width += centerPref.width; dim.height += centerPref.height; Dimension rightPref = right.getMinimumSize(); dim.width += rightPref.width; @@ -1750,7 +1750,7 @@ public void insertUpdate(DocumentEvent evt) { int newStart; int newEnd; - if(selectionStart > offset || (selectionStart + if(selectionStart > offset || (selectionStart == selectionEnd && selectionStart == offset)) newStart = selectionStart + length; else @@ -1885,7 +1885,7 @@ public void mousePressed(MouseEvent evt) { } } - private void doSingleClick(MouseEvent evt, int line, + private void doSingleClick(MouseEvent evt, int line, int offset, int dot) { if((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) { rectSelect = (evt.getModifiers() & InputEvent.CTRL_MASK) != 0; diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/ConsolePainter.java b/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/ConsolePainter.java index 06c3cd36e..6e3e0b058 100644 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/ConsolePainter.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/ConsolePainter.java @@ -568,7 +568,7 @@ protected void paintBracketHighlight(Graphics gfx, int line, int y) { protected void paintCaret(Graphics gfx, int line, int y) { if(console.isCaretVisible()) { - int offset = console.getCaretPosition() + int offset = console.getCaretPosition() - console.getLineStartOffset(line); int caretX = console._offsetToX(line,offset); int caretWidth = ((blockCaret || console.isOverwriteEnabled()) ? fm.charWidth('w') : 1); diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/Token.java b/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/Token.java index 9863f9020..827fbc09b 100644 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/Token.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/Token.java @@ -51,7 +51,7 @@ public class Token { /** * Literal 3 token id. This can be used to mark a numeric - * literal + * literal */ public static final byte LITERAL3 = 5; diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/TokenMarker.java b/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/TokenMarker.java index dc84509e7..2351f44b3 100644 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/TokenMarker.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swing/ash/TokenMarker.java @@ -109,7 +109,7 @@ public Token markTokens(Segment line, int lineIndex) { * add syntax tokens to the token list. Then, it should return * the initial token type for the next line.

* - * For example if the current line contains the start of a + * For example if the current line contains the start of a * multiline comment that doesn't end on that line, this method * should return the comment token type so that it continues on * the next line. @@ -141,7 +141,7 @@ public boolean supportsMultilineTokens() { * the document. This inserts a gap in the lineInfo * array. * @param index The first line number - * @param lines The number of lines + * @param lines The number of lines */ public void insertLines(int index, int lines) { if(lines <= 0) diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swing/nddl/NddlAshInterpreter.java b/src/Java/JavaUI/source/org/ops/ui/editor/swing/nddl/NddlAshInterpreter.java index 28fc5b13d..fd7bc95ee 100644 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swing/nddl/NddlAshInterpreter.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swing/nddl/NddlAshInterpreter.java @@ -10,31 +10,31 @@ //import psengine.NddlInterpreter; import psengine.PSEngine; -public class NddlAshInterpreter extends AshInterpreter +public class NddlAshInterpreter extends AshInterpreter { PrintStream consoleErr_ = System.err; //NddlInterpreter interpreter_ = null; - public NddlAshInterpreter(PSEngine pse) + public NddlAshInterpreter(PSEngine pse) { super("Nddl"); //interpreter_ = pse.getNddlInterpreter(); } - public void setConsole(AshConsole console) + public void setConsole(AshConsole console) { consoleErr_ = new PrintStream(new BufferedOutputStream(new DocumentOutputStream(console.getDocument(), "!!")), true); //interpreter_.setErrorStream(consoleErr_); } - public void source(String filename) + public void source(String filename) { - //interpreter_.source(filename); + //interpreter_.source(filename); } - public boolean eval(String toEval) + public boolean eval(String toEval) { return false; - //return interpreter_.eval(toEval); + //return interpreter_.eval(toEval); } } diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlEditor.java b/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlEditor.java index 62bb1db46..254d1373b 100755 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlEditor.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlEditor.java @@ -9,7 +9,7 @@ /** * NDDL editor with syntax highlighting. - * + * * @author Tatiana */ public class NddlEditor extends TextEditor { @@ -29,7 +29,7 @@ public NddlEditor() { /** * Create the part control. - * + * * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ @Override @@ -45,7 +45,7 @@ public void dispose() { /** * Used by platform to get the OutlinePage and ProjectionSupport adapter. - * + * * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ @SuppressWarnings("unchecked") @@ -60,7 +60,7 @@ public Object getAdapter(Class required) { } return super.getAdapter(required); } - + public NddlContentProvider getNddlContentProvider() { return provider; } diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlScanner.java b/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlScanner.java index 5a196f1c3..8f20a0129 100755 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlScanner.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlScanner.java @@ -95,7 +95,7 @@ private static final class CharacterRule implements IRule { /** * Creates a new operator rule. - * + * * @param token * Token to use for this rule */ diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlToggleCommentHandler.java b/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlToggleCommentHandler.java index 2a23fa627..8b6ea3652 100644 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlToggleCommentHandler.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swt/NddlToggleCommentHandler.java @@ -16,7 +16,7 @@ /** * Trigger comment // for the current selection of the currently active editor. - * + * * @author Tatiana, Tristan */ public class NddlToggleCommentHandler extends AbstractHandler { diff --git a/src/Java/JavaUI/source/org/ops/ui/editor/swt/NonRuleBasedDamagerRepairer.java b/src/Java/JavaUI/source/org/ops/ui/editor/swt/NonRuleBasedDamagerRepairer.java index 6b770e7b0..537aef1f5 100755 --- a/src/Java/JavaUI/source/org/ops/ui/editor/swt/NonRuleBasedDamagerRepairer.java +++ b/src/Java/JavaUI/source/org/ops/ui/editor/swt/NonRuleBasedDamagerRepairer.java @@ -19,7 +19,7 @@ public class NonRuleBasedDamagerRepairer implements IPresentationDamager, /** The document this object works on */ protected IDocument fDocument; - + /** * The default text attribute if non is returned as data by the current * token @@ -43,7 +43,7 @@ public void setDocument(IDocument document) { * Returns the end offset of the line that contains the specified offset or * if the offset is inside a line delimiter, the end offset of the next * line. - * + * * @param offset * the offset whose line end offset must be computed * @return the line end offset for the given offset @@ -112,7 +112,7 @@ public void createPresentation(TextPresentation presentation, /** * Adds style information to the given text presentation. - * + * * @param presentation * the text presentation to be extended * @param offset @@ -128,4 +128,4 @@ protected void addRange(TextPresentation presentation, int offset, presentation.addStyleRange(new StyleRange(offset, length, attr .getForeground(), attr.getBackground(), attr.getStyle())); } -} \ No newline at end of file +} diff --git a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/AstNode.java b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/AstNode.java index 4f13dbae4..a6b4f0544 100644 --- a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/AstNode.java +++ b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/AstNode.java @@ -5,7 +5,7 @@ /** * Java version of Antlr3 AST node as passed through verbose string - * + * * @author Tatiana Kichkaylo */ public class AstNode { @@ -27,7 +27,7 @@ public class AstNode { /** * Read from the string/offset. Expect to see * "text":token-type:"file":line:offset-in-line or "text":token-type - * + * * @return offset past this node */ public int readNodeFrom(String astString, int offset) { diff --git a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/AstNodeTypes.java b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/AstNodeTypes.java index d23eb6b87..5c3fcd121 100644 --- a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/AstNodeTypes.java +++ b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/AstNodeTypes.java @@ -1,7 +1,7 @@ package org.ops.ui.filemanager.model; /** - * Type constants. The numbers in this file should match those in + * Type constants. The numbers in this file should match those in * /Europa/src/PLASMA/NDDL/base/NDDL3.tokens */ public interface AstNodeTypes { @@ -20,6 +20,6 @@ public interface AstNodeTypes { public static final int FACT_KEYWORD = 59; // instantiation of predicate public static final int PREDICATE_INSTANCE = 9; - public static final int CONSTRAINT_INSTANCE = 4; + public static final int CONSTRAINT_INSTANCE = 4; public static final int ENUM_KEYWORD = 32; } diff --git a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/ErrorRecord.java b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/ErrorRecord.java index 33ca651a9..12e09de29 100644 --- a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/ErrorRecord.java +++ b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/ErrorRecord.java @@ -3,7 +3,7 @@ /** * Record for representing error messages accompanying AST. All fields are read * only. - * + * * @author Tatiana Kichkaylo */ public class ErrorRecord { diff --git a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/FileModel.java b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/FileModel.java index 96716f1ee..b69fd806e 100644 --- a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/FileModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/FileModel.java @@ -9,7 +9,7 @@ * File model gets AST from a file. To do so, it creates a brand new copy of * engine, and deletes it when it is done. Loading of models into an engine for * running is done in SolverModel. - * + * * @author Tatiana Kichkaylo */ public class FileModel { diff --git a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/unittesting/FileModelTest.java b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/unittesting/FileModelTest.java index 164abc59e..c1af1a7a0 100644 --- a/src/Java/JavaUI/source/org/ops/ui/filemanager/model/unittesting/FileModelTest.java +++ b/src/Java/JavaUI/source/org/ops/ui/filemanager/model/unittesting/FileModelTest.java @@ -19,10 +19,10 @@ * Often changes to the NDDL grammar cause these constants to shift, in which * case AstNodeTypes.java needs to be updated. For now this update is manual, * which is bad. - * + * * At the very least we need some unittests to verify that constants still * match. - * + * * @author Tatiana Kichkaylo */ public class FileModelTest extends TestCase { diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/EuropaGanttActivity.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/EuropaGanttActivity.java index 86d276075..baf4dea94 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/EuropaGanttActivity.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/EuropaGanttActivity.java @@ -37,7 +37,7 @@ public boolean hasViolation() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttActivity#getStartMin() */ @Override @@ -47,7 +47,7 @@ public int getStartMin() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttActivity#getStartMax() */ @Override @@ -57,7 +57,7 @@ public int getStartMax() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttActivity#getEndMin() */ @Override @@ -67,7 +67,7 @@ public int getEndMin() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttActivity#getEndMax() */ @Override @@ -77,7 +77,7 @@ public int getEndMax() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttActivity#getDurMin() */ @Override @@ -87,7 +87,7 @@ public int getDurMin() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttActivity#getDurMax() */ @Override @@ -101,7 +101,7 @@ public int getKey() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttActivity#getText() */ @Override diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/EuropaGanttResource.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/EuropaGanttResource.java index 4e43a1ccf..ab2b336e4 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/EuropaGanttResource.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/EuropaGanttResource.java @@ -6,7 +6,7 @@ /** * Implementation of IGanttResource around Europa PSResource - * + * * @author tatiana */ public class EuropaGanttResource implements IGanttResource { @@ -52,7 +52,7 @@ public String toString() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttResource#getName() */ @Override @@ -62,7 +62,7 @@ public String getName() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttResource#getActualMin() */ @Override @@ -72,7 +72,7 @@ public double getActualMin() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttResource#getActualMax() */ @Override @@ -82,7 +82,7 @@ public double getActualMax() { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttResource#getLow(int) */ @Override @@ -92,7 +92,7 @@ public double getLow(int time) { /* * (non-Javadoc) - * + * * @see org.ops.ui.gantt.model.IGanttResource#getHigh(int) */ @Override diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttActivity.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttActivity.java index 500dfd41f..b777811a6 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttActivity.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttActivity.java @@ -2,7 +2,7 @@ /** * Interface for the data structure representing an activity in Gantt chart - * + * * @author Tatiana */ public interface IGanttActivity { @@ -32,4 +32,4 @@ public interface IGanttActivity { * underlying data */ public Object getData(); -} \ No newline at end of file +} diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttModel.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttModel.java index 9daaa5178..78b376d89 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttModel.java @@ -3,11 +3,11 @@ import java.util.List; /** Generic model providing access to activities and resource profiles. - * + * * @author Tatiana */ public interface IGanttModel { - + public int getResourceCount(); public List getActivities(int resource); @@ -20,4 +20,4 @@ public interface IGanttModel { public String getResourceName(int index); -} \ No newline at end of file +} diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttResource.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttResource.java index 231df30ee..51eeefcb9 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttResource.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/IGanttResource.java @@ -2,7 +2,7 @@ /** * Interface for a resource profile to be used with Gantt chart. - * + * * @author tatiana */ public interface IGanttResource { @@ -21,4 +21,4 @@ public interface IGanttResource { /** @return the upper bound value for the given time step */ public double getHigh(int time); -} \ No newline at end of file +} diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttActivity.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttActivity.java index cdd8afeb2..9ba85a8e3 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttActivity.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttActivity.java @@ -2,7 +2,7 @@ import java.util.Calendar; -public interface PSGanttActivity +public interface PSGanttActivity { public Object getKey(); public Calendar getStart(); diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttActivityImpl.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttActivityImpl.java index 14f4a55cd..a7dbdacb4 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttActivityImpl.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttActivityImpl.java @@ -2,16 +2,16 @@ import java.util.Calendar; -public class PSGanttActivityImpl - implements PSGanttActivity +public class PSGanttActivityImpl + implements PSGanttActivity { protected Object key_; protected Calendar start_; protected Calendar finish_; protected double violation_; - - public PSGanttActivityImpl(Object key, - Calendar start, + + public PSGanttActivityImpl(Object key, + Calendar start, Calendar finish, double violation) { @@ -24,5 +24,5 @@ public PSGanttActivityImpl(Object key, public Calendar getFinish() { return finish_; } public Object getKey() { return key_; } public Calendar getStart() { return start_; } - public double getViolation() { return violation_; } + public double getViolation() { return violation_; } } diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttModel.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttModel.java index d39f430d8..585bd9342 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttModel.java @@ -3,13 +3,13 @@ import java.util.Calendar; import java.util.Iterator; -public interface PSGanttModel +public interface PSGanttModel { public String[] getResourceColumnNames(); public String getResourceColumn(int resource, int column); - + public int getResourceCount(); public Iterator getActivities(int resource); public void setActivityStart(Object key, Calendar start); - public void setActivityFinish(Object key, Calendar finish); + public void setActivityFinish(Object key, Calendar finish); } diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttPSEModel.java b/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttPSEModel.java index 1b6637f26..aea997b81 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttPSEModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/model/PSGanttPSEModel.java @@ -15,39 +15,39 @@ import psengine.PSTokenList; import psengine.PSObjectList; -public class PSGanttPSEModel - implements PSGanttModel +public class PSGanttPSEModel + implements PSGanttModel { Calendar startHorizon_; String objectsType_; PSObjectList resources_; int timeUnit_; - + public PSGanttPSEModel(PSEngine pse, Calendar startHorizon, String objectsType) { - this(pse,startHorizon,objectsType,Calendar.MINUTE); + this(pse,startHorizon,objectsType,Calendar.MINUTE); } - + public PSGanttPSEModel(PSEngine pse, Calendar startHorizon, String objectsType, int timeUnit) { startHorizon_ = startHorizon; objectsType_ = objectsType; resources_ = pse.getObjectsByType(objectsType_); timeUnit_=timeUnit; - + } - public Iterator getActivities(int resource) + public Iterator getActivities(int resource) { assert (resource >=0 && resource < getResourceCount()); - + // TODO: cache activities? List acts = new ArrayList(); - + PSTokenList tokens = resources_.get(resource).getTokens(); for (int i=0;i getActivities(int resource) { start = 0; } - + acts.add(new PSGanttActivityImpl(token.getEntityKey(), instantToCalendar(start), instantToCalendar(end), @@ -64,10 +64,10 @@ public Iterator getActivities(int resource) ) ); } - + return acts.iterator(); } - + protected Calendar instantToCalendar(double i) { Calendar retval = (Calendar)startHorizon_.clone(); @@ -76,32 +76,32 @@ protected Calendar instantToCalendar(double i) return retval; } - public String getResourceColumn(int resource, int column) + public String getResourceColumn(int resource, int column) { if (column == 0 && resource < getResourceCount()) return resources_.get(resource).getEntityName(); - + return ""; } static String resourceColumnNames_[] = { "Name" }; - public String[] getResourceColumnNames() + public String[] getResourceColumnNames() { return resourceColumnNames_; } - public int getResourceCount() + public int getResourceCount() { return resources_.size(); } - public void setActivityStart(Object key, Calendar start) + public void setActivityStart(Object key, Calendar start) { // TODO Auto-generated method stub notifyChange(key,"StartChanged",start); } - public void setActivityFinish(Object key, Calendar finish) + public void setActivityFinish(Object key, Calendar finish) { // TODO Auto-generated method stub notifyChange(key,"FinishChanged",finish); @@ -111,16 +111,16 @@ public void setActivityFinish(Object key, Calendar finish) protected void notifyChange(Object key, String type, Object value) { Object newValue=value; - + if (value instanceof Calendar) { SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss", new Locale("en","US")); newValue = formatter.format(((Calendar)value).getTime()); } - + System.out.println(++notificationCnt_ + " - Object changed - {"+ "id:"+key+" "+ "type:"+type+" "+ "newValue:"+newValue+ "}" - ); + ); } } diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/GanttView.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/GanttView.java index 1e8f62944..64104d321 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/GanttView.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/GanttView.java @@ -50,7 +50,7 @@ public class GanttView extends EuropaInternalFrame { /** Make this thing configurable? Issue 117 */ private boolean skipEmptyObjects = false; - + /** Odd and even background colors */ protected static final Color oddBg = new Color(250, 255, 250), evenBg = new Color(250, 250, 150), boldGrid = Color.gray, @@ -133,7 +133,7 @@ protected void updateView() { LinePanel line; if (r != null) { // Can resource timeline also have tokens? - line = new ResourcePanel(r); + line = new ResourcePanel(r); // . TODO } else { TimelinePanel tline = new TimelinePanel(model.getResourceName(i)); @@ -154,7 +154,7 @@ protected void updateView() { tokenPanel.add(line); labelPanel.add(line.getLabel()); } - + Point p = new Point(0,0); timeHeader.setViewPosition(p); labelVPort.setViewPosition(p); diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/LinePanel.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/LinePanel.java index 37030d41e..95c77828a 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/LinePanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/LinePanel.java @@ -7,7 +7,7 @@ /** * Parent class for TimelinePanel and ResourcePanel. - * + * * @author Tatiana Kichkaylo */ public abstract class LinePanel extends JPanel { diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSEGantt.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSEGantt.java index e26841a1c..367f06632 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSEGantt.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSEGantt.java @@ -50,43 +50,43 @@ /* * PSGantt implementation that uses egantt */ -public class PSEGantt +public class PSEGantt extends PSGantt implements MouseMotionListener, DrawingPartListener { /** - * + * */ private static final long serialVersionUID = -7727371579397987014L; - + GanttTable gantt_; Map actEntries_; JButton refreshBtn_; Calendar start_; Calendar end_; PSGanttColorProvider colorProvider_; - + public PSEGantt(PSGanttModel model, - Calendar start, + Calendar start, Calendar end) { super(model); start_ = start; end_ = end; colorProvider_ = new DefaultColorProvider(); - + makeGantt(); - + refreshBtn_ = new JButton("Refresh"); setLayout(new BorderLayout()); //add(BorderLayout.NORTH,refreshBtn_); add(BorderLayout.CENTER,gantt_); - add(new GanttToolBar(gantt_.getViewManager(GanttTable.TIME_AXIS)), BorderLayout.SOUTH); + add(new GanttToolBar(gantt_.getViewManager(GanttTable.TIME_AXIS)), BorderLayout.SOUTH); } - + public PSGanttColorProvider getColorProvider() { return colorProvider_; } public void setColorProvider(PSGanttColorProvider cp) { colorProvider_ = cp; } - + protected void makeGantt() { gantt_ = new GanttTable(makeTableModel(model_)); @@ -94,11 +94,11 @@ protected void makeGantt() //System.out.println("model rows:"+model.getTableModel().getRowCount()); TableColumnModel columnModel = gantt_.getColumnModel(1); TableColumn column = columnModel.getColumn(0); - + // Enable drag and drop TableCellEditor editor = gantt_.getDefaultEditor(1, AbstractDrawingState.class); column.setCellEditor(editor); - + gantt_.getDrawingContext().put( ContextConstants.EDITING_AXIS, ContextResources.OTHER_PROPERTY, @@ -106,12 +106,12 @@ protected void makeGantt() gantt_.getDrawingContext().put( ContextConstants.EDITING_MODE, - ContextResources.OTHER_PROPERTY, - EditorDrawingModule.MOVE_RESIZE_EDITOR); + ContextResources.OTHER_PROPERTY, + EditorDrawingModule.MOVE_RESIZE_EDITOR); // Display timeline at the top column.setHeaderValue(GanttEntryHelper.createCalendar()); - gantt_.setTimeRange(start_.getTime(),end_.getTime()); + gantt_.setTimeRange(start_.getTime(),end_.getTime()); gantt_.addMouseMotionListener(this); /* TODO: Disable row selection? @@ -119,16 +119,16 @@ protected void makeGantt() activityTable.setRowSelectionAllowed(false); activityTable.setColumnSelectionAllowed(false); activityTable.setCellSelectionEnabled(false); - */ + */ } - + public void refresh() { remove(gantt_); makeGantt(); - add(BorderLayout.CENTER,gantt_); + add(BorderLayout.CENTER,gantt_); } - + protected TableModel makeTableModel(PSGanttModel model) { String[][] columnNames = { @@ -147,14 +147,14 @@ protected TableModel makeTableModel(PSGanttModel model) while (resActivities.hasNext()) { PSGanttActivity act = resActivities.next(); String context = mapColor(colorProvider_.getColor(act)); - + MutableDrawingPart entry = GanttDrawingPartHelper.createActivityEntry( - act.getKey(), + act.getKey(), act.getStart().getTime(), - act.getFinish().getTime(), - context, + act.getFinish().getTime(), + context, actList - ); + ); actEntries_.put(act.getKey(), entry); //System.out.println("ID:"+key+" Start:"+start.getTime()+" Finish:"+finish.getTime()); } @@ -166,31 +166,31 @@ protected TableModel makeTableModel(PSGanttModel model) data[i][1] = activities; } - return JTableHelper.createTableModel(data, columnNames); + return JTableHelper.createTableModel(data, columnNames); } - + // DrawingPartListener methods - public void stateChanged(DrawingPartEvent event) + public void stateChanged(DrawingPartEvent event) { String colors[] = { GradientColorModule.GREEN_GRADIENT_CONTEXT, - GradientColorModule.RED_GRADIENT_CONTEXT, + GradientColorModule.RED_GRADIENT_CONTEXT, }; - + Object key = event.getSource(); MutableDrawingPart entry = actEntries_.get(key); - //LongInterval li = (LongInterval)entry.getInterval()[0]; + //LongInterval li = (LongInterval)entry.getInterval()[0]; //int idx = (int)(Math.round(Math.random())); //System.out.println("range:"+li.getRangeValue()+" idx:"+idx); //entry.setContext(key, colors[idx]); - + List changes = (List)(event.changes().next()); - + int changeType = ((Integer)changes.get(0)).intValue(); Long newValue = (Long)changes.get(1); Calendar calValue = new GregorianCalendar(); calValue.setTime(new java.util.Date(newValue.longValue())); - + switch (changeType) { case MutableIntervalListener.START_CHANGED : model_.setActivityStart(key,calValue); @@ -201,17 +201,17 @@ public void stateChanged(DrawingPartEvent event) default: System.err.println("ERROR:Unknow MutableIntervalListener change:"+changeType); } - } - - // MouseMotionListenerMethods - public void mouseDragged(MouseEvent e) + } + + // MouseMotionListenerMethods + public void mouseDragged(MouseEvent e) { if (e.isPopupTrigger()) return; } - public void mouseMoved(MouseEvent e) - { + public void mouseMoved(MouseEvent e) + { if (e.isPopupTrigger()) return; @@ -222,49 +222,49 @@ public void mouseMoved(MouseEvent e) DrawingState state = getDrawingState((JTable) e.getComponent(), e.getPoint()); if (state == null) return; - + MouseEvent evt = getTranslatedMouseEvent(e, cellRect); MutableInterval interval = (MutableInterval) getInterval( evt.getPoint(), - 3, - state, + 3, + state, GanttTable.TIME_AXIS); - + Object key = (interval == null ? null : interval.getKey()); notifyMouseMoved(key); } public MutableInterval getInterval( - Point point, - int buffer, - DrawingState drawing, - Object axisKey) + Point point, + int buffer, + DrawingState drawing, + Object axisKey) { Object key = drawing.getValueAt(point, buffer, buffer); return (MutableInterval) getInterval(key, drawing, axisKey); } - - protected AxisInterval getInterval(Object key, DrawingState drawing, Object axisKey) + + protected AxisInterval getInterval(Object key, DrawingState drawing, Object axisKey) { for (Iterator iter = drawing.parts(); iter.hasNext();) { DrawingPart part = (DrawingPart) iter.next(); if (part.isSummaryPart()) continue; - + AxisInterval[] interval = part.getInterval(key, new AxisInterval[] {}); int index = part.keys().indexOf(axisKey); if (index < 0) continue; - + if (interval != null && index < interval.length && interval[index] != null) return interval[index]; } return null; } - protected Rectangle getCellRect(JTable table, Point location) + protected Rectangle getCellRect(JTable table, Point location) { int row = table.rowAtPoint(location); int column = table.columnAtPoint(location); @@ -273,55 +273,55 @@ protected Rectangle getCellRect(JTable table, Point location) return null; return table.getCellRect(row, column, true); - } - - protected MouseEvent getTranslatedMouseEvent(MouseEvent evt, Rectangle cellRect) - { + } + + protected MouseEvent getTranslatedMouseEvent(MouseEvent evt, Rectangle cellRect) + { Point location = new Point(evt.getPoint()); location.translate(-cellRect.x, -cellRect.y); - - - Component component = SwingUtilities.getAncestorOfClass(GanttTable.class, evt.getComponent()) != null + + + Component component = SwingUtilities.getAncestorOfClass(GanttTable.class, evt.getComponent()) != null ? SwingUtilities.getAncestorOfClass(GanttTable.class, evt.getComponent()) : evt.getComponent(); - return location != null ? + return location != null ? new MouseEvent(component, evt.getID(), evt.getWhen(), evt.getModifiers(), location.x, location.y, evt.getClickCount(), evt.isPopupTrigger(), evt.getButton()) : null; - } - - protected DrawingState getDrawingState(JTable table, Point location) + } + + protected DrawingState getDrawingState(JTable table, Point location) { int row = table.rowAtPoint(location); int column = table.columnAtPoint(location); - + if (row < 0 || column < 0) return null; - + Object value = table.getValueAt(row, column); return value instanceof DrawingState ? (DrawingState) value : null; - } - + } + protected static class DefaultColorProvider implements PSGanttColorProvider { - public Color getColor(PSGanttActivity activity) + public Color getColor(PSGanttActivity activity) { return (activity.getViolation() == 0 ? Color.GREEN : Color.RED); } } - + static Map colorMap_; - + static String mapColor(Color c) { String retval = colorMap_.get(c); - + if (retval == null) retval = GradientColorModule.WHITE_GRADIENT_CONTEXT; - + return retval; } - - static + + static { colorMap_ = new HashMap(); colorMap_.put(Color.BLACK, GradientColorModule.BLACK_GRADIENT_CONTEXT); diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSGantt.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSGantt.java index e0e098fa6..6e94e9d58 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSGantt.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSGantt.java @@ -3,13 +3,13 @@ import org.ops.ui.main.swing.PSComponentBase; import org.ops.ui.gantt.model.PSGanttModel; -public abstract class PSGantt +public abstract class PSGantt extends PSComponentBase { private static final long serialVersionUID = 1L; - + protected PSGanttModel model_; - + public PSGantt(PSGanttModel model) { model_ = model; diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSGanttColorProvider.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSGanttColorProvider.java index 68787403b..ad9a3b51b 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSGanttColorProvider.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/PSGanttColorProvider.java @@ -3,7 +3,7 @@ import java.awt.Color; import org.ops.ui.gantt.model.PSGanttActivity; -public interface PSGanttColorProvider +public interface PSGanttColorProvider { public Color getColor(PSGanttActivity activity); } diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/ResourcePanel.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/ResourcePanel.java index 09de2c3b4..f1cc6ca79 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/ResourcePanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/ResourcePanel.java @@ -9,7 +9,7 @@ /** * Single resource profile panel, includes upper and lower lines. - * + * * @author Tatiana Kichkaylo */ public class ResourcePanel extends LinePanel { diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/TimelinePanel.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/TimelinePanel.java index 2d7d541ee..ed32da85f 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swing/TimelinePanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swing/TimelinePanel.java @@ -5,7 +5,7 @@ /** * Single resource time line, may include multiple rows of tokens. Rows are * ordered by the earliest token start, ties are broken by the order of arrival. - * + * * @author Tatiana Kichkaylo */ public class TimelinePanel extends LinePanel { @@ -53,7 +53,7 @@ public void addToken(TokenWidget token) { if (index >= lines.size()) { line = new ArrayList(); - + // Insert so that the earliest token starts are sorted int mine = token.getActivity().getStartMin(); for (index=0; index 0 ? token.getViolationExpl() : "--"); parameterViewer.setInput(token); } } - + private void clear() { token = null; refresh(); } - + // Ie no token selected protected void hideViewContents() { noData.heightHint = -1; yesData.heightHint = 0; - + noData.exclude = false; yesData.exclude = true; - + noLabel.setVisible(true); yesComposite.setVisible(false); redraw(); } - + // Ie a token is selected protected void showViewContents() { noData.heightHint = 0; yesData.heightHint = -1; - + noData.exclude = true; yesData.exclude = false; @@ -219,16 +219,16 @@ protected void showViewContents() { yesComposite.setVisible(true); redraw(); } - + private void redraw() { parent.layout(true, true); yesComposite.layout(true, true); - + noLabel.redraw(); yesComposite.redraw(); } - + //********************************************************************* // SolverListener Interface // @@ -252,7 +252,7 @@ private void redraw() { @Override public void afterStepping() { clear(); } - + //********************************************************************* // SolverModelView Interface // @@ -265,7 +265,7 @@ public void setModel() { super.setModel(); clear(); } - + //********************************************************************* // ISelectionListener Interface //********************************************************************* diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/GanttView.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/GanttView.java index 8711fc2aa..a0637f44c 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/GanttView.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/GanttView.java @@ -11,7 +11,7 @@ /** * Gantt chart view - SWT version for the Eclipse plugin - * + * * @author Tatiana Kichkaylo, Tristan Smith */ public class GanttView extends GenericGanttView implements SolverListener, diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/GenericGanttView.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/GenericGanttView.java index 3eacd0f0d..e68113434 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/GenericGanttView.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/GenericGanttView.java @@ -36,7 +36,7 @@ /** * Gantt chart view - SWT version for the Eclipse plugin - * + * * @author Tatiana Kichkaylo, Tristan Smith */ public abstract class GenericGanttView extends ViewPart implements ISelectionProvider { @@ -58,7 +58,7 @@ public abstract class GenericGanttView extends ViewPart implements ISelectionPro /** Odd and even background colors */ protected static Color oddBg, evenBg, smallGrid, boldGrid = ColorConstants.gray; - + /** Make this thing configurable? Issue 117 */ private boolean skipEmptyObjects = false; @@ -70,7 +70,7 @@ public abstract class GenericGanttView extends ViewPart implements ISelectionPro @Override public void createPartControl(final Composite parent) { initializeColors(); - + final Sash sash = new Sash(parent, SWT.VERTICAL); labelCanvas = new FigureCanvas(parent, SWT.H_SCROLL); @@ -193,18 +193,18 @@ public void setBounds(org.eclipse.draw2d.geometry.Rectangle rect) { // Register so we can report when user selects tokens: getSite().setSelectionProvider(this); } - + @Override public void setFocus() { } - + protected abstract IGanttModel getGanttModel(); private void doUpdate() { contents.removeAll(); lines.clear(); labelContents.removeAll(); - + IGanttModel gmodel = getGanttModel(); if (gmodel == null) { stepCount = 0; @@ -329,8 +329,8 @@ public void removeSelectionChangedListener( public void setSelection(ISelection selection) { for (ISelectionChangedListener listener : selectionChangedListeners ) { listener.selectionChanged(new SelectionChangedEvent( - this, selection/*getSelection()*/)); + this, selection/*getSelection()*/)); } } - + } diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ParameterTableContentProvider.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ParameterTableContentProvider.java index 75a3e9fb4..8bfa98b12 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ParameterTableContentProvider.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ParameterTableContentProvider.java @@ -8,11 +8,11 @@ import psengine.PSVariableList; /** - * Content provider for token parameters (ie variables), + * Content provider for token parameters (ie variables), * simply returns all variables as an array. - * + * * @author Tristan Smith - * + * */ public class ParameterTableContentProvider implements @@ -29,7 +29,7 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { @Override public Object[] getElements(Object inputElement) { PSToken token = (PSToken) inputElement; - + if(token == null) { return null; } diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ParameterTableLabelProvider.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ParameterTableLabelProvider.java index 3b05fca4d..de77bfc7a 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ParameterTableLabelProvider.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ParameterTableLabelProvider.java @@ -8,17 +8,17 @@ import psengine.PSVariable; /** - * Label provider for token parameters (ie variables), assumes you + * Label provider for token parameters (ie variables), assumes you * want the variable name in first column and user-friendly value * in second. - * + * * @author Tristan Smith - * + * */ public class ParameterTableLabelProvider extends ColumnLabelProvider { - + public void update(ViewerCell cell) { Object element = cell.getElement(); cell.setText(getColumnText(element, cell.getColumnIndex())); @@ -32,7 +32,7 @@ public void update(ViewerCell cell) { // @Override public String getColumnText(Object element, int index) { PSVariable variable = (PSVariable) element; - + if(variable == null) { return "--"; } diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ResourcePanel.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ResourcePanel.java index 1274bf896..ebb13c449 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ResourcePanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/ResourcePanel.java @@ -9,7 +9,7 @@ /** * Single resource profile panel, includes upper and lower lines. - * + * * @author Tatiana Kichkaylo */ public class ResourcePanel extends LinePanel { diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TimelinePanel.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TimelinePanel.java index f08fe6c06..3e9287a30 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TimelinePanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TimelinePanel.java @@ -7,7 +7,7 @@ /** * Single resource time line, may include multiple rows of tokens. Rows are * ordered by the earliest token start, ties are broken by the order of arrival. - * + * * @author Tatiana Kichkaylo */ public class TimelinePanel extends LinePanel { @@ -25,7 +25,7 @@ public class TimelinePanel extends LinePanel { * (6 + (showDurationLine ? 1 : 0)); private ArrayList> lines = new ArrayList>(); - + public TimelinePanel(String resourceName) { super(resourceName); this.setLayoutManager(null); diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TokenColor.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TokenColor.java index 15af5debf..6b0479bfc 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TokenColor.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TokenColor.java @@ -5,7 +5,7 @@ /** * Color structure for painting a token - * + * * @author Tatiana */ public class TokenColor { diff --git a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TokenSelection.java b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TokenSelection.java index 8d664f04f..565592a1e 100644 --- a/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TokenSelection.java +++ b/src/Java/JavaUI/source/org/ops/ui/gantt/swt/TokenSelection.java @@ -6,13 +6,13 @@ public class TokenSelection implements ISelection { private IGanttActivity token; - + TokenSelection(IGanttActivity activity) { this.token = activity; } - + public IGanttActivity getToken() { return token; } - + @Override public boolean isEmpty() { return token == null; diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swing/EuropaInternalFrame.java b/src/Java/JavaUI/source/org/ops/ui/main/swing/EuropaInternalFrame.java index a77ea3d1d..25b056f77 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swing/EuropaInternalFrame.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swing/EuropaInternalFrame.java @@ -13,7 +13,7 @@ /** * Base class for internal frames of Swing version of GUI. This class takes care * of various open/close behavior and supplies check box menu item - * + * * @author Tatiana Kichkaylo */ public class EuropaInternalFrame extends JInternalFrame { @@ -36,7 +36,7 @@ public void internalFrameClosing(InternalFrameEvent e) { } }); } - + /** Minimum/initial size. Made into a method for overriding */ public Dimension getFavoriteSize() { return new Dimension(100, 100); diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swing/FileNameExtensionFilter.java b/src/Java/JavaUI/source/org/ops/ui/main/swing/FileNameExtensionFilter.java index f2684b203..3e476f12e 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swing/FileNameExtensionFilter.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swing/FileNameExtensionFilter.java @@ -21,18 +21,18 @@ *

* The following example creates a {@code FileNameExtensionFilter} that will * show {@code jpg} files: - * + * *

  * FileFilter filter = new FileNameExtensionFilter("JPEG file", "jpg", "jpeg");
  * JFileChooser fileChooser = ...;
  * fileChooser.addChoosableFileFilter(filter);
  * 
- * + * * @see FileFilter * @see javax.swing.JFileChooser#setFileFilter * @see javax.swing.JFileChooser#addChoosableFileFilter * @see javax.swing.JFileChooser#getFileFilter - * + * * @version 1.1 02/02/06 * @since 1.6 */ @@ -51,7 +51,7 @@ public final class FileNameExtensionFilter extends FileFilter { * and file name extensions. The returned {@code FileNameExtensionFilter} * will accept all directories and any file with a file name extension * contained in {@code extensions}. - * + * * @param description * textual description for the filter, may be {@code null} * @param extensions @@ -83,7 +83,7 @@ public FileNameExtensionFilter(String description, String... extensions) { * Tests the specified file, returning true if the file is accepted, false * otherwise. True is returned if the extension matches one of the file name * extensions of this {@code FileFilter}, or the file is a directory. - * + * * @param f * the {@code File} to test * @return true if the file is to be accepted, false otherwise @@ -116,7 +116,7 @@ public boolean accept(File f) { /** * The description of this filter. For example: "JPG and GIF Images." - * + * * @return the description of this filter */ @Override @@ -126,7 +126,7 @@ public String getDescription() { /** * Returns the set of file name extensions files are tested against. - * + * * @return the set of file name extensions files are tested against */ public String[] getExtensions() { @@ -140,7 +140,7 @@ public String[] getExtensions() { * This method is intended to be used for debugging purposes, and the * content and format of the returned string may vary between * implementations. - * + * * @return a string representation of this {@code FileNameExtensionFilter} */ @Override diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swing/PSComponent.java b/src/Java/JavaUI/source/org/ops/ui/main/swing/PSComponent.java index 4ed5f2b98..ca888efd7 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swing/PSComponent.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swing/PSComponent.java @@ -1,6 +1,6 @@ package org.ops.ui.main.swing; -public interface PSComponent +public interface PSComponent { public void addMouseListener(PSMouseListener l); public void removeMouseListener(PSMouseListener l); diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swing/PSComponentBase.java b/src/Java/JavaUI/source/org/ops/ui/main/swing/PSComponentBase.java index b5c843bf7..a14b3a811 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swing/PSComponentBase.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swing/PSComponentBase.java @@ -4,32 +4,32 @@ import java.util.ArrayList; import javax.swing.JPanel; -public abstract class PSComponentBase - extends JPanel - implements PSComponent +public abstract class PSComponentBase + extends JPanel + implements PSComponent { private static final long serialVersionUID = 1L; - + List mouseListeners_; - + public PSComponentBase() { mouseListeners_ = new ArrayList(); } - public void addMouseListener(PSMouseListener l) + public void addMouseListener(PSMouseListener l) { mouseListeners_.add(l); } - public void removeMouseListener(PSMouseListener l) + public void removeMouseListener(PSMouseListener l) { mouseListeners_.remove(l); } - + protected void notifyMouseMoved(Object key) { if (key != null) System.out.println("MouseMovedOver{"+key+"}"); - + for (PSMouseListener l : mouseListeners_) { l.mouseMoved(key); } diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swing/PSDesktop.java b/src/Java/JavaUI/source/org/ops/ui/main/swing/PSDesktop.java index 792d045c9..5386f60eb 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swing/PSDesktop.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swing/PSDesktop.java @@ -53,15 +53,15 @@ public class PSDesktop // protected NddlAshInterpreter nddlInterpreter_; protected JConsole bshConsole_; protected Interpreter bshInterpreter_; - + protected static String debugMode_="g"; protected static String bshFile_=null; public static void main(String[] args) - { + { try { String debugMode = args[0]; - PSUtil.loadLibraries(debugMode); + PSUtil.loadLibraries(debugMode); PSEngine engine = PSEngine.makeInstance(); engine.start(); @@ -72,39 +72,39 @@ public static void main(String[] args) } catch (Exception e) { e.printStackTrace(); - Runtime.getRuntime().exit(-1); + Runtime.getRuntime().exit(-1); } } - - static class ShutdownHook extends Thread + + static class ShutdownHook extends Thread { public ShutdownHook() { super("ShutdownHook"); } - - public void run() + + public void run() { PSDesktop.getInstance().getPSEngine().shutdown(); } - } + } public String getLibsMode() { return debugMode_; } - + public static PSDesktop getInstance() { if (instance_ == null) instance_ = makeInstance(PSEngine.makeInstance(),new String[]{"g",null}); - + return instance_; } - + public static Map parseArgs(String args[]) { Map retval = new HashMap(); String debugMode = "g"; - String bshFile = null; - + String bshFile = null; + if (args.length > 0) debugMode = args[0]; if ((args.length > 1) && (args[1].length()>0)) @@ -112,41 +112,41 @@ public static Map parseArgs(String args[]) retval.put("debugMode", debugMode); retval.put("bshFile",bshFile); - + return retval; } - + public static PSDesktop makeInstance(PSEngine pse,String args[]) { - if (instance_ != null) + if (instance_ != null) throw new RuntimeException("PSDesktop is a singleton"); init(args); instance_ = new PSDesktop(pse); - + return instance_; } public static void init(String[] args) - { - init(parseArgs(args)); + { + init(parseArgs(args)); } - + public static void init(Map args) { debugMode_ = args.get("debugMode"); - bshFile_ = args.get("bshFile"); + bshFile_ = args.get("bshFile"); } - + protected PSDesktop(PSEngine pse) { assert (pse != null); psEngine_ = pse; // nddlInterpreter_ = new NddlAshInterpreter(psEngine_); bshConsole_ = new JConsole(); - bshInterpreter_ = new Interpreter(bshConsole_); + bshInterpreter_ = new Interpreter(bshConsole_); } - + public PSEngine getPSEngine() { return psEngine_; } public void runUI() @@ -236,7 +236,7 @@ public void addBshVariable(String name,Object obj) throw new RuntimeException(e); } } - + protected void registerBshVariables() { addBshVariable("desktop",this); @@ -247,10 +247,10 @@ public PSSolver makeSolver(String config,int horizonStart,int horizonEnd) { PSSolver solver = getPSEngine().createSolver(config); solver.configure(horizonStart,horizonEnd); - + return solver; } - + public PSSolverDialog makeSolverDialog(PSSolver solver) { try { @@ -259,7 +259,7 @@ public PSSolverDialog makeSolverDialog(PSSolver solver) PSSolverDialog d = new PSSolverDialog(this,solver); frame.getContentPane().add(new JScrollPane(d)); frame.setSize(675,375); - + return d; } catch (Exception e) @@ -284,7 +284,7 @@ public void showTokens(PSObject o) } public void showTokens(String title,PSTokenList l) - { + { List columnNames = new ArrayList(); List data = new ArrayList(); columnNames.add("Key"); @@ -308,12 +308,12 @@ public void showTokens(String title,PSTokenList l) } data.add(row); } - + JInternalFrame frame = makeNewFrame(title); JTable table = new JTable(new Util.MatrixTableModel(data,columnNames)); JScrollPane scrollpane = new JScrollPane(table); - frame.getContentPane().add(scrollpane); + frame.getContentPane().add(scrollpane); frame.setSize(frame.getSize()); // Force repaint } @@ -326,7 +326,7 @@ public JInternalFrame makeSchemaBrowserFrame() return frame; } - + public JInternalFrame makeViolationsFrame() { ActionViolationsPanel vp = new ActionViolationsPanel(getPSEngine()); @@ -347,7 +347,7 @@ public JInternalFrame makeDetailsFrame() frame.setSize(300,200); return frame; - } + } public PSResourceChart makeResourceChart(PSResource r,Calendar start) { @@ -361,7 +361,7 @@ public JInternalFrame makeResourcesFrame(String type,Calendar start) { JTabbedPane resourceTabs = new JTabbedPane(); List resources = PSUtil.toResourceList(getPSEngine().getObjectsByType(type)); - for (PSResource r : resources) + for (PSResource r : resources) resourceTabs.add(r.getEntityName(),makeResourceChart(r,start)); JInternalFrame frame = makeNewFrame("Resources"); @@ -370,7 +370,7 @@ public JInternalFrame makeResourcesFrame(String type,Calendar start) return frame; } - + public JInternalFrame makeResourceGanttFrame( String objectsType, Calendar start, @@ -378,7 +378,7 @@ public JInternalFrame makeResourceGanttFrame( { return makeResourceGanttFrame(objectsType,start,end,Calendar.MINUTE); } - + public JInternalFrame makeResourceGanttFrame( String objectsType, Calendar start, @@ -393,8 +393,8 @@ public JInternalFrame makeResourceGanttFrame( return frame; } - -/* + +/* // Creates a table on the results of a JoSQL query public void makeTableFrame(String title,List l,String josqlQry) { @@ -406,12 +406,12 @@ public void makeTableFrame(String title,List l,String josqlQry) model.parse(josqlQry); model.execute(l); - + //Query qry = new Query(); //qry.parse(josqlQry); //List data = qry.execute(l).getResults(); //TableModel model = Util.makeTableModel(data, new String[]{"toString"}); - + JTable table = new JTable(model); JScrollPane scrollpane = new JScrollPane(table); @@ -422,14 +422,14 @@ public void makeTableFrame(String title,List l,String josqlQry) throw new RuntimeException(e); } } - + public void makeNddlConsole() { JInternalFrame nddlInterpFrame = makeNewFrame("Nddl Console"); AshConsole console = new AshConsole(nddlInterpreter_); nddlInterpreter_.setConsole(console); console.setTokenMarker(new NddlTokenMarker()); - nddlInterpFrame.setContentPane(console); + nddlInterpFrame.setContentPane(console); } public void makeAnmlConsole() @@ -440,7 +440,7 @@ public void makeAnmlConsole() anmlInterpreter.setConsole(console); console.setTokenMarker(new AnmlTokenMarker()); anmlInterpFrame.setContentPane(console); - } + } */ } diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swing/PSMouseListener.java b/src/Java/JavaUI/source/org/ops/ui/main/swing/PSMouseListener.java index d14e99a7a..154feca1d 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swing/PSMouseListener.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swing/PSMouseListener.java @@ -1,6 +1,6 @@ package org.ops.ui.main.swing; -public interface PSMouseListener +public interface PSMouseListener { public void mouseMoved(Object key); } diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlConfigurationFields.java b/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlConfigurationFields.java index 5d2d3b734..f26bc4ebe 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlConfigurationFields.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlConfigurationFields.java @@ -2,7 +2,7 @@ /** * Attribute names in a launch configuration for NDDL models - * + * * @author Tatiana Kichkaylo */ public interface NddlConfigurationFields { diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlLaunchShortcut.java b/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlLaunchShortcut.java index 6be867342..b5e6abb22 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlLaunchShortcut.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlLaunchShortcut.java @@ -17,7 +17,7 @@ /** * Launch shortcut to appear in "Run as" menus - * + * * @author Tatiana Kichkaylo */ public class NddlLaunchShortcut implements ILaunchShortcut, diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlModelTab.java b/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlModelTab.java index 7d96297b9..c083b2314 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlModelTab.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlModelTab.java @@ -80,11 +80,11 @@ public void widgetSelected(SelectionEvent evt) { fHorizonEnd = createSingleText(comp, 2); fHorizonEnd.addModifyListener(this); } - + public void modifyText(ModifyEvent e) { this.updateLaunchConfigurationDialog(); } - + private Text createSingleText(Composite parent, int hspan) { Text t = new Text(parent, SWT.SINGLE | SWT.BORDER); t.setFont(parent.getFont()); diff --git a/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlRunPerspective.java b/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlRunPerspective.java index 2c832e814..7dcc2c988 100644 --- a/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlRunPerspective.java +++ b/src/Java/JavaUI/source/org/ops/ui/main/swt/NddlRunPerspective.java @@ -55,7 +55,7 @@ private void addViews() { IPageLayout.RIGHT, 0.3f, factory.getEditorArea()); bottomRight.addView(DetailsView.VIEW_ID); bottomRight.addView(IPageLayout.ID_RES_NAV); - + // Little buttons at the bottom. Left from the template factory.addFastView("org.eclipse.team.ccvs.ui.RepositoriesView", 0.50f); // NON-NLS-1 factory.addFastView("org.eclipse.team.sync.views.SynchronizeView", diff --git a/src/Java/JavaUI/source/org/ops/ui/mouse/swing/ActionDetailsPanel.java b/src/Java/JavaUI/source/org/ops/ui/mouse/swing/ActionDetailsPanel.java index 1a56107de..0947c260e 100644 --- a/src/Java/JavaUI/source/org/ops/ui/mouse/swing/ActionDetailsPanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/mouse/swing/ActionDetailsPanel.java @@ -6,32 +6,32 @@ import psengine.PSVariable; import psengine.PSVariableList; -public class ActionDetailsPanel - extends MouseListenerPanel +public class ActionDetailsPanel + extends MouseListenerPanel { private static final long serialVersionUID = 7779941401503562818L; protected PSEngine psengine_ = null; - + public ActionDetailsPanel(PSEngine pse) { psengine_ = pse; } - + @Override - public void mouseMoved(Object key) + public void mouseMoved(Object key) { - if (key == null) + if (key == null) text_.setText(""); - else + else text_.setText(getDetails((Integer)key)); } - + protected String getDetails(Integer key) { return tokenDetails(psengine_.getTokenByKey(key)); } - + protected String tokenDetails(PSToken t) { StringBuffer buf = new StringBuffer(); @@ -40,7 +40,7 @@ protected String tokenDetails(PSToken t) .append("Name : ").append(t.getEntityName()).append("\n") .append("isFact : ").append(t.isFact()).append("\n") ; - + if (t.getParameters().size() > 0) { buf.append("Parameters:").append("\n"); PSVariableList parameters = t.getParameters(); @@ -49,7 +49,7 @@ protected String tokenDetails(PSToken t) buf.append(p.getEntityName()).append(" : ").append(p.toString()).append("\n"); } } - + return buf.toString(); - } + } } diff --git a/src/Java/JavaUI/source/org/ops/ui/mouse/swing/ActionViolationsPanel.java b/src/Java/JavaUI/source/org/ops/ui/mouse/swing/ActionViolationsPanel.java index 744d444e9..af861a2a0 100644 --- a/src/Java/JavaUI/source/org/ops/ui/mouse/swing/ActionViolationsPanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/mouse/swing/ActionViolationsPanel.java @@ -3,34 +3,34 @@ import psengine.PSEngine; import psengine.PSToken; -public class ActionViolationsPanel - extends MouseListenerPanel +public class ActionViolationsPanel + extends MouseListenerPanel { private static final long serialVersionUID = 7462693069863073725L; protected PSEngine psengine_ = null; - + public ActionViolationsPanel(PSEngine pse) { psengine_ = pse; } - + @Override - public void mouseMoved(Object key) + public void mouseMoved(Object key) { - if (key == null) + if (key == null) text_.setText(""); - else + else text_.setText(getViolations((Integer)key)); } - + protected String getViolations(Integer key) { return tokenViolations(psengine_.getTokenByKey(key)); } - + protected String tokenViolations(PSToken t) { return t.getViolationExpl(); - } + } } diff --git a/src/Java/JavaUI/source/org/ops/ui/mouse/swing/MouseListenerPanel.java b/src/Java/JavaUI/source/org/ops/ui/mouse/swing/MouseListenerPanel.java index 9f0911f16..4fc5b8175 100644 --- a/src/Java/JavaUI/source/org/ops/ui/mouse/swing/MouseListenerPanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/mouse/swing/MouseListenerPanel.java @@ -6,17 +6,17 @@ public abstract class MouseListenerPanel extends JPanel - implements PSMouseListener + implements PSMouseListener { private static final long serialVersionUID = 1L; - + protected JTextArea text_; - + public MouseListenerPanel() { text_ = new JTextArea(""); - add(text_); + add(text_); } - + public abstract void mouseMoved(Object key); } diff --git a/src/Java/JavaUI/source/org/ops/ui/rchart/model/PSResourceChartModel.java b/src/Java/JavaUI/source/org/ops/ui/rchart/model/PSResourceChartModel.java index 25d7b8a5d..a7a7d84e8 100644 --- a/src/Java/JavaUI/source/org/ops/ui/rchart/model/PSResourceChartModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/rchart/model/PSResourceChartModel.java @@ -5,7 +5,7 @@ import psengine.PSResourceProfile; -public interface PSResourceChartModel +public interface PSResourceChartModel { public PSResourceProfile getCapacity(); public PSResourceProfile getUsage(); diff --git a/src/Java/JavaUI/source/org/ops/ui/rchart/model/PSResourceChartPSEModel.java b/src/Java/JavaUI/source/org/ops/ui/rchart/model/PSResourceChartPSEModel.java index 598c1d00d..ee12d09af 100644 --- a/src/Java/JavaUI/source/org/ops/ui/rchart/model/PSResourceChartPSEModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/rchart/model/PSResourceChartPSEModel.java @@ -3,37 +3,37 @@ import psengine.PSResource; import psengine.PSResourceProfile; -public class PSResourceChartPSEModel - implements PSResourceChartModel +public class PSResourceChartPSEModel + implements PSResourceChartModel { protected PSResource resource_; - + public PSResourceChartPSEModel(PSResource resource) { resource_ = resource; } - public PSResourceProfile getCapacity() + public PSResourceProfile getCapacity() { return resource_.getCapacity(); } - public PSResourceProfile getUsage() + public PSResourceProfile getUsage() { return resource_.getUsage(); - } + } - public PSResourceProfile getLimit() + public PSResourceProfile getLimit() { return resource_.getLimits(); } - public PSResourceProfile getFDLevel() + public PSResourceProfile getFDLevel() { return resource_.getFDLevels(); } - - public PSResourceProfile getVDLevel() + + public PSResourceProfile getVDLevel() { return resource_.getVDLevels(); } diff --git a/src/Java/JavaUI/source/org/ops/ui/rchart/swing/PSJFreeResourceChart.java b/src/Java/JavaUI/source/org/ops/ui/rchart/swing/PSJFreeResourceChart.java index 1ed118bb7..3d37fdb5e 100644 --- a/src/Java/JavaUI/source/org/ops/ui/rchart/swing/PSJFreeResourceChart.java +++ b/src/Java/JavaUI/source/org/ops/ui/rchart/swing/PSJFreeResourceChart.java @@ -27,31 +27,31 @@ import psengine.PSTimePointList; import org.ops.ui.rchart.model.PSResourceChartModel; -public class PSJFreeResourceChart - extends PSResourceChart +public class PSJFreeResourceChart + extends PSResourceChart { /** - * + * */ private static final long serialVersionUID = 9008639833839752404L; - + JFreeChart chart_; Calendar start_; - + public PSJFreeResourceChart(String resourceName, PSResourceChartModel model, Calendar start) { super(model,resourceName); - + start_ = start; chart_ = createChart(); JPanel chartPanel = makeResourcePanel(chart_); setLayout(new BorderLayout()); add(new JScrollPane(chartPanel)); } - - protected JFreeChart createChart() + + protected JFreeChart createChart() { XYDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createTimeSeriesChart( @@ -73,42 +73,42 @@ protected JFreeChart createChart() plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); - + XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } - + DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yy")); - + return chart; - } - + } + protected JPanel makeResourcePanel(JFreeChart chart) { ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(500, 270)); chartPanel.setMouseZoomable(true, false); - + return chartPanel; - } + } - protected XYDataset createDataset() - { + protected XYDataset createDataset() + { TimeSeriesCollection dataset = new TimeSeriesCollection(); int seriesCnt = 5; TimeSeries ts[] = new TimeSeries[seriesCnt]; - + ts[0] = resourceProfileToTimeSeries("FD Level Lower Bound", model_.getFDLevel(),false); ts[1] = resourceProfileToTimeSeries("FD Level Upper Bound", model_.getFDLevel(),true); ts[2] = resourceProfileToTimeSeries("Limit Lower Bound", model_.getLimit(),false); ts[3] = resourceProfileToTimeSeries("Limit Upper Bound", model_.getLimit(),true); ts[4] = resourceProfileToTimeSeries("Capacity", model_.getCapacity(),true); - + RegularTimePeriod maxX = new Minute(((Calendar)start_.clone()).getTime()); for (int i=0;i= einfinity) continue; - + // Display a step function if ((lastTime >=0) && (lastValue != value) && (i-lastTime > 1)) { time.add(Calendar.MINUTE, -1); @@ -176,11 +176,11 @@ protected TimeSeries resourceProfileToTimeSeries(String name,PSResourceProfile r ts.addOrUpdate(t1,lastValue); } - ts.addOrUpdate(t,value); + ts.addOrUpdate(t,value); lastTime = i; lastValue = value; } - - return ts; + + return ts; } } diff --git a/src/Java/JavaUI/source/org/ops/ui/rchart/swing/PSResourceChart.java b/src/Java/JavaUI/source/org/ops/ui/rchart/swing/PSResourceChart.java index 174424a99..bd0ef66b6 100644 --- a/src/Java/JavaUI/source/org/ops/ui/rchart/swing/PSResourceChart.java +++ b/src/Java/JavaUI/source/org/ops/ui/rchart/swing/PSResourceChart.java @@ -5,12 +5,12 @@ // TODO: do we really need a specialized ResourceChart, or just a generic time series chart will suffice? -public abstract class PSResourceChart +public abstract class PSResourceChart extends PSComponentBase { protected PSResourceChartModel model_; protected String resourceName_; - + public PSResourceChart(PSResourceChartModel model, String resourceName) { model_ = model; diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaModel.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaModel.java index 5f68065b5..264f25041 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaModel.java @@ -1,7 +1,7 @@ package org.ops.ui.schemabrowser.model; -public interface SchemaModel +public interface SchemaModel { public boolean isInitialized(); public SchemaNode getObjectTypesNode(); -} \ No newline at end of file +} diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaModelImpl.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaModelImpl.java index e10d7cc13..121aab177 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaModelImpl.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaModelImpl.java @@ -19,79 +19,79 @@ /** * Accessor class for EUROPA schema. Uses PSEngine to get actual data - * + * */ -public class SchemaModelImpl implements SchemaModel +public class SchemaModelImpl implements SchemaModel { /** Solver model pointing to loaded files and PSEngine to do all the work */ protected PSEngine engine_; - - public SchemaModelImpl(PSEngine e) + + public SchemaModelImpl(PSEngine e) { engine_ = e; } /** Make a node for object types */ - public SchemaNode getObjectTypesNode() + public SchemaNode getObjectTypesNode() { if (!isInitialized()) return null; SchemaNode rootNode = new SchemaNode(Type.CATEGORY, "Object types"); PSObjectTypeList types = engine_.getPSSchema().getAllPSObjectTypes(); - for (int i = 0; i < types.size(); i++) + for (int i = 0; i < types.size(); i++) rootNode.add(makeObjectTypeNode(types.get(i))); return rootNode; } - + protected SchemaNode makeObjectTypeNode(PSObjectType type) { SchemaNode typeNode = new SchemaNode( - Type.OBJECT_TYPE, - type.getNameString(), + Type.OBJECT_TYPE, + type.getNameString(), type.getParentName()); - + PSStringList members = type.getMemberNames(); - for (int j = 0; j < members.size(); j++) + for (int j = 0; j < members.size(); j++) typeNode.add(makeObjectMemberNode(type,members.get(j))); PSTokenTypeList preds = type.getPredicates(); - for (int j = 0; j < preds.size(); j++) + for (int j = 0; j < preds.size(); j++) typeNode.add(makeTokenTypeNode(preds.get(j))); - + return typeNode; } - + protected SchemaNode makeObjectMemberNode(PSObjectType type,String memberName) { - PSDataType mtype = type.getMemberTypeRef(memberName); + PSDataType mtype = type.getMemberTypeRef(memberName); return new SchemaNode( - Type.OBJECT_TYPE_MEMBER, + Type.OBJECT_TYPE_MEMBER, memberName, mtype); } - + protected SchemaNode makeTokenTypeNode(PSTokenType ttype) { SchemaNode pnode = new SchemaNode( - Type.TOKEN_TYPE, + Type.TOKEN_TYPE, ttype.getName()); - + PSStringList argNames = ttype.getParameterNames(); for (int k = 0; k < argNames.size(); k++) { PSDataType atype = ttype.getParameterType(k); pnode.add(new SchemaNode( Type.TOKEN_TYPE_PARAMETER, - argNames.get(k), + argNames.get(k), atype)); } return pnode; } - - public boolean isInitialized() + + public boolean isInitialized() { return engine_ != null; } diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaNode.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaNode.java index f2b33ef59..4d8fa15d9 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaNode.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaNode.java @@ -7,10 +7,10 @@ /** * Node of the schema tree. - * + * * @author Tatiana Kichkaylo */ -public class SchemaNode +public class SchemaNode { /** Seed for conversion to array */ private final static SchemaNode[] seedArray = {}; @@ -123,22 +123,22 @@ public void clear() { children.clear(); } - public void setFileLocation(FileLocation fl) + public void setFileLocation(FileLocation fl) { this.fileLocation = fl; } - public FileLocation getFileLocation() + public FileLocation getFileLocation() { return fileLocation; } - + public static class FileLocation { public String filename; public int startLine; public int endLine; - + public FileLocation(String fn, int sl, int el) { filename = fn; diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaSolverModel.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaSolverModel.java index 41f11476d..ec9918f4d 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaSolverModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/model/SchemaSolverModel.java @@ -11,26 +11,26 @@ /** * Accessor class for EUROPA schema. Uses PSEngine to get actual data - * + * * TODO JRB: this class shouldn't be needed, the PSSchema API should be extended to provide file location info * which is the only thing this class adds - * + * */ -public class SchemaSolverModel extends SchemaModelImpl +public class SchemaSolverModel extends SchemaModelImpl { /** Solver model pointing to loaded files and PSEngine to do all the work */ protected SolverModel model; protected HashMap astMap = null; - - public SchemaSolverModel(SolverModel model) + + public SchemaSolverModel(SolverModel model) { super(model != null ? model.getEngine() : null); this.model = model; } /** Make a node for object types */ - public SchemaNode getObjectTypesNode() + public SchemaNode getObjectTypesNode() { if (!isInitialized()) return null; @@ -42,22 +42,22 @@ public SchemaNode getObjectTypesNode() return super.getObjectTypesNode(); } - + protected SchemaNode makeObjectTypeNode(PSObjectType type) { SchemaNode typeNode = super.makeObjectTypeNode(type); - + AstNode ast = astMap.get(typeNode.getName()); if (ast != null) typeNode.setFileLocation(new SchemaNode.FileLocation( ast.getFileName(), ast.getLine(), ast.getEndLine())); - + return typeNode; } - - private void collectClasses(AstNode ast, HashMap map) + + private void collectClasses(AstNode ast, HashMap map) { if (ast.getType() == AstNodeTypes.CLASS_DEF) { map.put(ast.getChildren().get(0).getText(), ast); @@ -67,7 +67,7 @@ private void collectClasses(AstNode ast, HashMap map) } } - public boolean isInitialized() + public boolean isInitialized() { return super.isInitialized() && (model != null) && !model.isTerminated(); } diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swing/SchemaTreeModel.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swing/SchemaTreeModel.java index cb4455571..b374759c8 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swing/SchemaTreeModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swing/SchemaTreeModel.java @@ -12,7 +12,7 @@ /** * Convert schema nodes into Swing tree model - * + * * @author Tatiana Kichkaylo */ public class SchemaTreeModel implements TreeModel { diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swing/SchemaView.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swing/SchemaView.java index 4efb9fdd4..b3feb4b96 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swing/SchemaView.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swing/SchemaView.java @@ -12,10 +12,10 @@ public class SchemaView extends JPanel { /** - * + * */ private static final long serialVersionUID = 1L; - + private JTree tree; private SchemaTreeModel treeModel; @@ -24,7 +24,7 @@ public SchemaView(SchemaModel model) { this.treeModel = new SchemaTreeModel(model); setLayout(new BorderLayout()); - + // Widgets this.tree = new JTree(treeModel); this.add(new JScrollPane(tree)); diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaContentProvider.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaContentProvider.java index d2cb41fd0..cf7b8f60f 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaContentProvider.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaContentProvider.java @@ -7,7 +7,7 @@ /** * Wrapping SchemaSource as a SWT content provider - * + * * @author Tatiana Kichkaylo */ public class SchemaContentProvider implements ITreeContentProvider { @@ -26,7 +26,7 @@ public SchemaContentProvider(SchemaModel model) { public void setModel(SchemaModel model) { this.model = model; } - + public void dispose() { } diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaLabelProvider.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaLabelProvider.java index fe43ba6c5..23c8aba02 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaLabelProvider.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaLabelProvider.java @@ -13,7 +13,7 @@ /** * Label and icon provider for the SWT version of schema browser - * + * * @author Tatiana Kichkaylo */ public class SchemaLabelProvider extends LabelProvider implements diff --git a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaView.java b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaView.java index 97272c7e0..55b81ff73 100644 --- a/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaView.java +++ b/src/Java/JavaUI/source/org/ops/ui/schemabrowser/swt/SchemaView.java @@ -22,7 +22,7 @@ /** * Europa schema browser - SWT version - * + * * @author Tatiana Kichkaylo */ public class SchemaView extends SolverModelViewImpl { diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverAdapter.java b/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverAdapter.java index 0f469521e..7cfbbaaf3 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverAdapter.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverAdapter.java @@ -3,7 +3,7 @@ /** * Convenience class: empty implementation of SolverListener. The class is made * abstract to force clients to provide at least some methods. - * + * * @author Tatiana Kichkaylo */ public abstract class SolverAdapter implements SolverListener { diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverListener.java b/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverListener.java index 36086c556..790de256f 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverListener.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverListener.java @@ -2,22 +2,22 @@ /** * Listener to Solver Model - * + * * @author Tatiana Kichkaylo */ public interface SolverListener { /** Solver started/restarted */ public void solverStarted(); - + /** Solver stopped */ public void solverStopped(); - + /** Called before the solver starts running */ public void beforeStepping(); /** * Called each time new statistics are available, even mid-run - * + * * @param time * stepping time in ms */ diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverModel.java b/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverModel.java index 618a9d266..e9a0fcf68 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverModel.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/model/SolverModel.java @@ -11,8 +11,8 @@ /** * Solver model corresponds to a single engine, or "run". Each launch of an NDDL - * model creates a separate solver model. - * + * model creates a separate solver model. + * * @author tatiana */ @@ -25,10 +25,10 @@ public class SolverModel { /** Property name in the engine config: list of search paths for includes */ private final String INCLUDE_PATH = "nddl.includePath"; - + protected Logger log = Logger.getLogger(getClass().getName()); private PSEngine engine = null; - private PSSolver solver = null; + private PSSolver solver = null; private ArrayList listeners = new ArrayList(); private ArrayList stepStatistics = new ArrayList(); @@ -40,7 +40,7 @@ public class SolverModel { private int horizonStart, horizonEnd; /** Planner configuration file */ private File plannerConfig = null; - + public void configure(File modelFile, File plannerConfigFile, int horizonStart, int horizonEnd) { this.modelFile = modelFile; @@ -69,11 +69,11 @@ public void loadNddlFile(File file) { this.engine.getConfig().setProperty(INCLUDE_PATH, oldPath); } } - + public File getModelFile() { return this.modelFile; } - + public File getPlannerConfig() { return this.plannerConfig; } @@ -113,7 +113,7 @@ public void removeSolverListener(SolverListener lnr) { /** * Make one step (assuming we can) - * + * * @return time in ms */ public long stepOnce() { @@ -163,7 +163,7 @@ public StepStatisticsRecord getStepStatistics(int step) { public boolean isTerminated() { return solver == null; } - + /** Start and configure engine. Assume it is not already running */ public synchronized void start() { if (engine != null) diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/model/StepStatisticsRecord.java b/src/Java/JavaUI/source/org/ops/ui/solver/model/StepStatisticsRecord.java index 09f433b64..54484a1a1 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/model/StepStatisticsRecord.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/model/StepStatisticsRecord.java @@ -7,7 +7,7 @@ /** * A single record containing various aspects of step statistics - * + * * @author Tatiana Kichkaylo */ public class StepStatisticsRecord { @@ -29,7 +29,7 @@ public static StepStatisticsRecord getEmpty() { /** * Create a record for the current state of the solver. - * + * * @param solver * the solver to read data from * @param timeMs diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/model/TimeFormatHelper.java b/src/Java/JavaUI/source/org/ops/ui/solver/model/TimeFormatHelper.java index 15c8919f2..ec91c499f 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/model/TimeFormatHelper.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/model/TimeFormatHelper.java @@ -3,7 +3,7 @@ import java.text.NumberFormat; public abstract class TimeFormatHelper { - + private TimeFormatHelper() {} private final static NumberFormat decimal3 = NumberFormat diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/swing/ConsoleView.java b/src/Java/JavaUI/source/org/ops/ui/solver/swing/ConsoleView.java index e0245f64b..396ee0f5d 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/swing/ConsoleView.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/swing/ConsoleView.java @@ -8,7 +8,7 @@ /** * A read-only view to capture engine's error output. Used by PSSolverDialog. - * + * * @author Tatiana */ public class ConsoleView extends EuropaInternalFrame { diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/swing/OpenDecisionsPanel.java b/src/Java/JavaUI/source/org/ops/ui/solver/swing/OpenDecisionsPanel.java index ac074fa08..8d57b4aa8 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/swing/OpenDecisionsPanel.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/swing/OpenDecisionsPanel.java @@ -22,8 +22,8 @@ import org.ops.ui.utils.swing.Util; -public class OpenDecisionsPanel - extends JPanel +public class OpenDecisionsPanel + extends JPanel implements ActionListener { private static final long serialVersionUID = 2128067653391774807L; @@ -43,25 +43,25 @@ public class OpenDecisionsPanel // so need to keep track explicitly protected List snList_; // StepNumbers protected List ledList_; // LastExecutedDecisions - + public OpenDecisionsPanel() { odList_ = new Vector>(); snList_ = new Vector(); ledList_ = new Vector(); - + currentIdx_ = -1; - + labelTotal_ = new JLabel(makeLabelTotal(),SwingConstants.CENTER); labelCurrent_ = new JLabel(makeLabelCurrent(),SwingConstants.CENTER); JPanel btnPanel = new JPanel(new FlowLayout()); - + btnPrev_ = new JButton("<<"); btnPrev_.addActionListener(this);btnPrev_.setActionCommand("prev"); btnNext_ = new JButton(">>"); btnNext_.addActionListener(this);btnNext_.setActionCommand("next"); checkButtons(); JButton btn; btn = new JButton("Go To Step"); btn.addActionListener(this);btn.setActionCommand("goto"); - + gotoIdx_ = new JTextField(6); btnPanel.add(btnPrev_); btnPanel.add(btnNext_); @@ -70,53 +70,53 @@ public OpenDecisionsPanel() lastExecutedDecision_ = new JTextArea(5,10); lastExecutedDecision_.setLineWrap(true); - + JPanel topPanel = new JPanel(new BorderLayout()); JPanel p = new JPanel(new GridLayout(3,1)); p.add(labelTotal_); p.add(btnPanel); p.add(new JLabel("Last Executed Decision",SwingConstants.CENTER)); - + ledTable_ = new JTable(); ledTable_.setTableHeader(null); ledTable_.setPreferredScrollableViewportSize(new Dimension(500, 70)); - + JTabbedPane tp = new JTabbedPane(); tp.addTab("As Table", new JScrollPane(ledTable_)); tp.addTab("As Text", new JScrollPane(lastExecutedDecision_)); topPanel.add(BorderLayout.NORTH,p); - topPanel.add(BorderLayout.CENTER,tp); + topPanel.add(BorderLayout.CENTER,tp); odTable_ = new JTable(Util.makeTableModel(odList_,new String[]{"toString"})); odTable_.setTableHeader(null); odTable_.setPreferredScrollableViewportSize(new Dimension(500, 70)); - + setLayout(new BorderLayout()); add(BorderLayout.NORTH, topPanel); - + JPanel odPanel = new JPanel(new BorderLayout()); odPanel.add(BorderLayout.NORTH,labelCurrent_); - odPanel.add(BorderLayout.CENTER, new JScrollPane(odTable_)); - add(BorderLayout.CENTER, odPanel); + odPanel.add(BorderLayout.CENTER, new JScrollPane(odTable_)); + add(BorderLayout.CENTER, odPanel); } - + protected String makeLabelTotal() { String retval = "Open Decisions for "+odList_.size()+" steps are available"; - + return retval; } protected String makeLabelCurrent() { String retval=""; - + if (currentIdx_ >= 0) retval = "Currently looking at "+ odList_.get(currentIdx_).size() +" Open Decisions for step "+snList_.get(currentIdx_); - + return retval; } - + protected void checkButtons() { btnPrev_.setEnabled(currentIdx_ > 0); @@ -126,9 +126,9 @@ protected void checkButtons() protected void updateTable() { // TODO: put in Swing thread? - odTable_.setModel(Util.makeTableModel(odList_.get(currentIdx_),new String[]{"toString"})); + odTable_.setModel(Util.makeTableModel(odList_.get(currentIdx_),new String[]{"toString"})); } - + protected void updateStatus() { checkButtons(); @@ -137,37 +137,37 @@ protected void updateStatus() String led = ledList_.get(currentIdx_); lastExecutedDecision_.setText(led); lastExecutedDecision_.setCaretPosition(0); - + List details = new Vector(); StringTokenizer tok = new StringTokenizer(led,":"); - while (tok.hasMoreTokens()) + while (tok.hasMoreTokens()) details.add(tok.nextToken()); // TODO: put in Swing thread? - ledTable_.setModel(Util.makeTableModel(details,new String[]{"toString"})); + ledTable_.setModel(Util.makeTableModel(details,new String[]{"toString"})); } - + protected void showNext() { currentIdx_++; updateStatus(); } - + protected void showPrev() { currentIdx_--; updateStatus(); } - + protected void beep() { - java.awt.Toolkit.getDefaultToolkit().beep(); + java.awt.Toolkit.getDefaultToolkit().beep(); } - + protected void gotoStep() { int step; - + try { step = new Integer(gotoIdx_.getText()); } @@ -176,46 +176,46 @@ protected void gotoStep() beep(); return; } - + for (int i=0;i < snList_.size();i++) { if (snList_.get(i)==step) { currentIdx_=i; updateStatus(); } } - + // TODO: display error message beep(); } - + public void addEntry(int stepNumber,List od,String lastExecutedDecision) { snList_.add(stepNumber); odList_.add(od); ledList_.add(lastExecutedDecision); - + if (snList_.size() == 1) showNext(); - + checkButtons(); labelTotal_.setText(makeLabelTotal()); } - - public void actionPerformed(ActionEvent e) + + public void actionPerformed(ActionEvent e) { if ("next".equals(e.getActionCommand())) { showNext(); return; - } + } if ("prev".equals(e.getActionCommand())) { showPrev(); return; - } + } if ("goto".equals(e.getActionCommand())) { gotoStep(); return; - } - } + } + } } diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/swing/OpenDecisionsView.java b/src/Java/JavaUI/source/org/ops/ui/solver/swing/OpenDecisionsView.java index ff4d49a48..eeff9deea 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/swing/OpenDecisionsView.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/swing/OpenDecisionsView.java @@ -28,7 +28,7 @@ /** * Panel for open decisions. This panel listens to SolverModel and gets all data * from it. - * + * * @author Tatiana Kichkaylo */ public class OpenDecisionsView extends EuropaInternalFrame { diff --git a/src/Java/JavaUI/source/org/ops/ui/solver/swing/PSSolverDialog.java b/src/Java/JavaUI/source/org/ops/ui/solver/swing/PSSolverDialog.java index 9a84f9660..23bbf50fb 100644 --- a/src/Java/JavaUI/source/org/ops/ui/solver/swing/PSSolverDialog.java +++ b/src/Java/JavaUI/source/org/ops/ui/solver/swing/PSSolverDialog.java @@ -40,19 +40,19 @@ import psengine.PSSolver; import psengine.PSStringList; -public class PSSolverDialog +public class PSSolverDialog extends JPanel implements ActionListener { private static final long serialVersionUID = -7130640151223933584L; - + protected JTextField horizonStart_ = new JTextField("0"); protected JTextField horizonEnd_ = new JTextField("5760"); protected JTextField maxSteps_ = new JTextField("2000"); protected JTextField maxDepth_ = new JTextField("100000"); protected JTextField configFile_ = new JTextField("../Crew1/PlannerConfig.xml"); protected JTextField incSteps_ = new JTextField("500",8); - + protected JButton btnConfigure_= new JButton("Configure"); protected JButton btnStep_= new JButton("Go"); protected JButton btnSolve_ = new JButton("Solve"); @@ -60,30 +60,30 @@ public class PSSolverDialog protected JLabel lblRunTime_ = new JLabel(format(startTime_)); protected JLabel lblStepCnt_ = new JLabel("0"); protected JLabel lblMaxStepCnt_ = new JLabel("0"); - + protected XYSeries solverDepthSeries_; protected XYSeries stepTimeSeries_; protected XYSeries stepAvgTimeSeries_; protected double totalTime_; protected XYSeries decisionCntSeries_; protected JPanel chartsPanel_; - + protected OpenDecisionsPanel openDecisions_; - + protected JSplitPane topSplitPane_; - + protected PSDesktop desktop_; protected PSSolver solver_; protected Integer maxStepsValue_=100; protected Integer maxDepthValue_=100; - + protected List listeners_ = new Vector(); - + public PSSolverDialog(PSDesktop desktop,PSSolver solver) { desktop_ = desktop; solver_ = solver; - + if (solver != null) { horizonStart_ = new JTextField(new Integer(solver_.getHorizonStart()).toString(),15); horizonEnd_ = new JTextField(new Integer(solver_.getHorizonEnd()).toString(),15); @@ -92,18 +92,18 @@ public PSSolverDialog(PSDesktop desktop,PSSolver solver) configFile_ = new JTextField(solver_.getConfigFilename()); incSteps_ = new JTextField(maxStepsValue_.toString(),8); } - + totalTime_ = 0; - + JPanel solverPanel = new JPanel(new BorderLayout()); JTabbedPane tp = new JTabbedPane(); tp.add("Run",makeRunPanel()); tp.add("Configure",makeConfigPanel()); solverPanel.add(tp); - - openDecisions_ = new OpenDecisionsPanel(); - setLayout(new BorderLayout()); + openDecisions_ = new OpenDecisionsPanel(); + + setLayout(new BorderLayout()); add(solverPanel); JInternalFrame frame = desktop_.makeNewFrame("Solver Open Decisions"); @@ -111,10 +111,10 @@ public PSSolverDialog(PSDesktop desktop,PSSolver solver) frame.setSize(400,400); frame.setLocation(700,20); } - + public void addListener(PSSolverDialogListener l) { listeners_.add(l); } public void removeListener(PSSolverDialogListener l) { listeners_.remove(l); } - + protected JPanel makeConfigPanel() { JPanel p = new JPanel(new FlowLayout()); @@ -129,24 +129,24 @@ protected JPanel makeConfigPanel() btnConfigure_.addActionListener(this);btnConfigure_.setActionCommand("configure"); - JPanel buttonPanel = new JPanel(new FlowLayout()); - buttonPanel.add(btnConfigure_); - + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(btnConfigure_); + JPanel p1 = new JPanel(new BorderLayout()); p1.add(BorderLayout.CENTER,configPanel); p1.add(BorderLayout.SOUTH,buttonPanel); p.add(p1); - + return p; } - + protected JPanel makeRunPanel() { JPanel p = new JPanel(new BorderLayout()); - + chartsPanel_ = new JPanel(new GridLayout(1,3)); - + stepTimeSeries_ = new XYSeries("Time (secs) per Step"); stepAvgTimeSeries_ = new XYSeries("Avg Time (secs) per Step"); chartsPanel_.add(makeChartPanel( @@ -156,7 +156,7 @@ protected JPanel makeRunPanel() new XYSeries[]{stepTimeSeries_,stepAvgTimeSeries_}, false // Create legend )); - + decisionCntSeries_ = new XYSeries("Open Decision Cnt"); chartsPanel_.add(makeChartPanel( "Open Decision Count", // title @@ -164,7 +164,7 @@ protected JPanel makeRunPanel() "Open Decision Count", // y-axis label new XYSeries[]{decisionCntSeries_}, false // Create legend - )); + )); solverDepthSeries_ = new XYSeries("Decisions in Plan"); chartsPanel_.add(makeChartPanel( @@ -173,7 +173,7 @@ protected JPanel makeRunPanel() "Decisions in Plan", // y-axis label new XYSeries[]{solverDepthSeries_}, false // Create legend - )); + )); btnStep_.addActionListener(this);btnStep_.setActionCommand("step"); btnSolve_.addActionListener(this);btnSolve_.setActionCommand("solve"); @@ -181,14 +181,14 @@ protected JPanel makeRunPanel() boolean enabled = solver_ != null; btnStep_.setEnabled(enabled); btnSolve_.setEnabled(enabled); - + JPanel buttonPanel = new JPanel(new GridLayout(1,4)); /* lblMaxStepCnt_.setText(solver_.getMaxSteps().toString()); buttonPanel.add(new JLabel("Max Step Count : ")); buttonPanel.add(lblMaxStepCnt_); */ - + buttonPanel.add(new JLabel("Run for")); buttonPanel.add(incSteps_); buttonPanel.add(new JLabel("steps")); @@ -200,12 +200,12 @@ protected JPanel makeRunPanel() JPanel totalsPanel = new JPanel(new GridLayout(1,4)); lblStepCnt_.setText(Integer.toString(solver_.getStepCount())); totalsPanel.add(new JLabel("Step Count : ")); - totalsPanel.add(lblStepCnt_); + totalsPanel.add(lblStepCnt_); totalsPanel.add(new JLabel("Run Time :")); totalsPanel.add(lblRunTime_); JPanel p2 = new JPanel(new FlowLayout()); p2.add(totalsPanel); - + JPanel p3 = new JPanel(new FlowLayout()); p3.add(chartsPanel_); p.add(BorderLayout.NORTH,p1); @@ -224,12 +224,12 @@ protected JPanel makeChartPanel( XYSeriesCollection dataset = new XYSeriesCollection(); for (XYSeries s : series) dataset.addSeries(s); - + JFreeChart chart = createChart(title,xAxisLabel,yAxisLabel,dataset,createLegend); return makeChartPanel(chart); } - + protected JPanel makeChartPanel(JFreeChart chart) { JPanel p = new JPanel(new BorderLayout()); @@ -237,37 +237,37 @@ protected JPanel makeChartPanel(JFreeChart chart) ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(200, 150)); chartPanel.setMouseZoomable(true, false); - + Border border = BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(1, 1, 1, 1), BorderFactory.createEtchedBorder() ); chartPanel.setBorder(border); - + p.add(new JScrollPane(chartPanel)); return p; } - + protected JFreeChart createChart( String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, - boolean createLegend) + boolean createLegend) { JFreeChart chart = ChartFactory.createXYLineChart( title, xAxisLabel, yAxisLabel, - dataset, + dataset, PlotOrientation.VERTICAL, createLegend, // create legend? true, // generate tooltips? false // generate URLs? ); - + chart.setBackgroundPaint(Color.white); - + XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); @@ -275,17 +275,17 @@ protected JFreeChart createChart( plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); - + XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } - + return chart; - } - + } + public void configureSolver() { int horizonStart = getInteger(horizonStart_.getText()); @@ -294,36 +294,36 @@ public void configureSolver() solver_ = desktop_.getPSEngine().createSolver(config); solver_.configure(horizonStart,horizonEnd); } - + protected int getInteger(String text) { return new Integer(text.trim()); } - + public void stepSolver() { try { startTime_ = System.currentTimeMillis(); setButtons(false); - + int maxIter = getInteger(incSteps_.getText()); int stepCnt = solver_.getStepCount(); int max = stepCnt+maxIter; - - for (int i=1; solver_.hasFlaws() + + for (int i=1; solver_.hasFlaws() && !solver_.isExhausted() && !solver_.isTimedOut() - && stepCnt SWIGList(Object list) { try { List retval = new Vector(); - + Method m = list.getClass().getMethod("size", (Class[])null); int size = (Integer)m.invoke(list,(Object[])null); m = list.getClass().getMethod("get", new Class[]{int.class}); @@ -64,7 +64,7 @@ public static List SWIGList(Object list) args[0] = i; retval.add(m.invoke(list, args)); } - + return retval; } catch (Exception e) { diff --git a/src/Java/JavaUI/source/org/ops/ui/utils/swing/Util.java b/src/Java/JavaUI/source/org/ops/ui/utils/swing/Util.java index ca0917bc1..0254bfc6c 100644 --- a/src/Java/JavaUI/source/org/ops/ui/utils/swing/Util.java +++ b/src/Java/JavaUI/source/org/ops/ui/utils/swing/Util.java @@ -9,19 +9,19 @@ import javax.swing.table.TableModel; import javax.swing.table.AbstractTableModel; -public class Util +public class Util { public static JTable makeTable(List l,String fields[]) { JTable table = new JTable(Util.makeTableModel(l,fields)); return table; } - - public static TableModel makeTableModel(List l, String fields[]) + + public static TableModel makeTableModel(List l, String fields[]) { - return new ListTableModel(l,fields); + return new ListTableModel(l,fields); } - + protected static class ListTableModel extends AbstractTableModel { @@ -30,16 +30,16 @@ protected static class ListTableModel protected List data_; protected List columnNames_; protected List columnMethods_; - + public ListTableModel(List l,String fields[]) { data_ = new Vector(); columnNames_ = new Vector(); columnMethods_ = new Vector(); - if (l == null) + if (l == null) return; - + data_ = l; if (fields != null) { columnNames_ = Arrays.asList(fields); @@ -54,9 +54,9 @@ protected void mapFields(String fields[]) { if (data_.size() == 0) return; - + Class c = data_.get(0).getClass(); - + int i=0; try { for (String s : fields) { @@ -74,16 +74,16 @@ protected void mapFields(String fields[]) protected void mapFields() { columnNames_ = new Vector(); - + if (data_.size() == 0) return; - Class c = data_.get(0).getClass(); - + Class c = data_.get(0).getClass(); + try { - for (Method m : c.getMethods()) { + for (Method m : c.getMethods()) { Class paramTypes[] = m.getParameterTypes(); - if (m.getName().startsWith("get") && + if (m.getName().startsWith("get") && (paramTypes==null || paramTypes.length==0)) { columnMethods_.add(m); columnNames_.add(m.getName().substring(3)); @@ -95,47 +95,47 @@ protected void mapFields() System.err.println("Error mapping field : "+e.getMessage()); } } - + public int getColumnCount() { return columnNames_.size(); } public String getColumnName(int columnIndex) { return columnNames_.get(columnIndex); } - + public int getRowCount() { return data_.size(); } - public Object getValueAt(int rowIndex, int columnIndex) + public Object getValueAt(int rowIndex, int columnIndex) { try { Object o = data_.get(rowIndex); Method m = columnMethods_.get(columnIndex); - + return m.invoke(o, (Object[])null); } catch (Exception e) { - return e.getMessage(); + return e.getMessage(); } } } - + static public class MatrixTableModel extends AbstractTableModel { private static final long serialVersionUID = -8922640086581386437L; - + protected List data_; protected List columnNames_; - + public MatrixTableModel(List data,List columnNames) { data_ = data; columnNames_ = columnNames; } - public int getColumnCount() { return columnNames_.size(); } - public String getColumnName(int columnIndex) { return columnNames_.get(columnIndex).toString(); } + public int getColumnCount() { return columnNames_.size(); } + public String getColumnName(int columnIndex) { return columnNames_.get(columnIndex).toString(); } public int getRowCount() { return data_.size(); } @SuppressWarnings("unchecked") - public Object getValueAt(int rowIndex, int columnIndex) + public Object getValueAt(int rowIndex, int columnIndex) { // MD: Need to check for INDEX-OUT-OF-BOUND error if(rowIndex < data_.size()) { @@ -145,6 +145,6 @@ public Object getValueAt(int rowIndex, int columnIndex) return null; } else return null; - } + } } } diff --git a/src/Java/PSEngine/CMakeLists.txt b/src/Java/PSEngine/CMakeLists.txt index d6beb2480..178d8fb1b 100644 --- a/src/Java/PSEngine/CMakeLists.txt +++ b/src/Java/PSEngine/CMakeLists.txt @@ -1,5 +1,57 @@ find_package(Java REQUIRED) -include(UseJava) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) -# add_jar(PSEngine -# SOURCES src/psengine/PSUtil.java src/psengine/util/LibraryLoader.java src/psengine/util/SimpleTimer.java \ No newline at end of file +#set(CMAKE_JAVA_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}) +#list(APPEND CMAKE_JAVA_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/PSEngineGenerated.jar) +add_jar(PSEngineJar + SOURCES + src/psengine/PSUtil.java + src/psengine/util/LibraryLoader.java + src/psengine/util/SimpleTimer.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/EngineConfig.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSConstraint.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSConstraintEngineListener.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSConstraintList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSDataType.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSDataTypeList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSEngine.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSEngineInterface.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSEngineInterfaceJNI.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSEntity.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSException.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSIntList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSLanguageException.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSLanguageExceptionList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSObject.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSObjectList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSObjectType.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSObjectTypeList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSPlanDatabaseClient.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSPlanDatabaseListener.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSResource.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSResourceProfile.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSSchema.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSSolver.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSStringList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSTimePointList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSToken.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSTokenList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSTokenState.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSTokenType.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSTokenTypeList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSValueList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSVarType.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSVarValue.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSVariable.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/PSVariableList.java + ${CMAKE_BINARY_DIR}/src/PLASMA/System/psengine/StringErrorStream.java + # INCLUDE_JARS + # PSEngineGenerated.jar + OUTPUT_NAME + PSEngine) + +add_dependencies(PSEngineJar PSEngineGenerated) +install_jar(PSEngineJar ${EUROPA_ROOT}/dist/europa) \ No newline at end of file diff --git a/src/Java/PSEngine/src/psengine/PSUtil.java b/src/Java/PSEngine/src/psengine/PSUtil.java index 7b7a0646e..500ee5a17 100644 --- a/src/Java/PSEngine/src/psengine/PSUtil.java +++ b/src/Java/PSEngine/src/psengine/PSUtil.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Vector; import psengine.util.LibraryLoader; +import psengine.PSObjectList; public class PSUtil { @@ -14,7 +15,7 @@ public static List toJavaList(Object psList) { try { List retval = new Vector(); - + Method m = psList.getClass().getMethod("size", (Class[])null); int size = (Integer)m.invoke(psList,(Object[])null); m = psList.getClass().getMethod("get", new Class[]{int.class}); @@ -23,33 +24,33 @@ public static List toJavaList(Object psList) args[0] = i; retval.add(m.invoke(psList, args)); } - + return retval; } catch (Exception e) { throw new RuntimeException(e); } - } - + } + // TODO: unify this one with the toJavaList by using generics public static List toResourceList(PSObjectList psList) { List retval = new Vector(); - - for (int i=0; iremoveLanguageInterpreter("anml"); - if (old) - delete old; + delete old; } } diff --git a/src/PLASMA/ANML/ModuleAnml.hh b/src/PLASMA/ANML/ModuleAnml.hh index e38361c2d..d54de6372 100644 --- a/src/PLASMA/ANML/ModuleAnml.hh +++ b/src/PLASMA/ANML/ModuleAnml.hh @@ -1,6 +1,6 @@ -#ifndef _H_ModuleAnml -#define _H_ModuleAnml +#ifndef H_ModuleAnml +#define H_ModuleAnml #include "Module.hh" @@ -29,4 +29,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_ModuleAnml */ +#endif /* #ifndef H_ModuleAnml */ diff --git a/src/PLASMA/ANML/base/ANMLTranslator.cc b/src/PLASMA/ANML/base/ANMLTranslator.cc index aca1f1ed9..74ea695b9 100644 --- a/src/PLASMA/ANML/base/ANMLTranslator.cc +++ b/src/PLASMA/ANML/base/ANMLTranslator.cc @@ -483,10 +483,11 @@ namespace ANML } Range::Range(const std::string& name,const Type& dataType,const std::string& lb,const std::string& ub) - : Type(name!="" ? name : autoIdentifier("Range")) - , m_dataType(dataType) - , m_lb(lb) - , m_ub(ub) + : Type(name!="" ? name : autoIdentifier("Range")), + m_isResourceType(false), + m_dataType(dataType), + m_lb(lb), + m_ub(ub) { // TODO: convert lb,ub to typed values } @@ -687,15 +688,18 @@ namespace ANML } Variable::Variable(const Type& dataType, const std::string& name) - : m_name(name) - , m_dataType(dataType) + : m_name(name), + m_objType(NULL), + m_dataType(dataType) + { } Variable::Variable(const Type& dataType, const std::string& name, const std::vector& args) - : m_name(name) - , m_dataType(dataType) - , m_args(args) + : m_name(name), + m_objType(NULL), + m_dataType(dataType), + m_args(args) { } @@ -1126,15 +1130,14 @@ namespace ANML } Proposition::Proposition(TemporalQualifier* tq,Fluent* f) - : m_temporalQualifier(tq) + : m_context(), m_temporalQualifier(tq), m_fluents(), m_parentAction(NULL) { m_fluents.push_back(f); commonInit(); } Proposition::Proposition(TemporalQualifier* tq,const std::vector& fluents) - : m_temporalQualifier(tq) - , m_fluents(fluents) + : m_context(), m_temporalQualifier(tq), m_fluents(fluents), m_parentAction(NULL) { commonInit(); } diff --git a/src/PLASMA/ANML/base/ANMLTranslator.hh b/src/PLASMA/ANML/base/ANMLTranslator.hh index 51344d13f..db2c05ea3 100644 --- a/src/PLASMA/ANML/base/ANMLTranslator.hh +++ b/src/PLASMA/ANML/base/ANMLTranslator.hh @@ -542,13 +542,13 @@ class Change : public ANMLElement class PropositionComponent { - public: - PropositionComponent() {} - - void setProposition(Proposition* p) { m_parentProp = p; } + public: + PropositionComponent() : m_parentProp(NULL) {} - protected: - Proposition* m_parentProp; + void setProposition(Proposition* p) { m_parentProp = p; } + + protected: + Proposition* m_parentProp; }; class TemporalQualifier : public PropositionComponent diff --git a/src/PLASMA/ANML/component/AnmlInterpreter.cc b/src/PLASMA/ANML/component/AnmlInterpreter.cc index 234b74234..647386317 100644 --- a/src/PLASMA/ANML/component/AnmlInterpreter.cc +++ b/src/PLASMA/ANML/component/AnmlInterpreter.cc @@ -14,7 +14,7 @@ namespace EUROPA { -AnmlInterpreter::AnmlInterpreter(EngineId& engine) +AnmlInterpreter::AnmlInterpreter(EngineId engine) : m_engine(engine) { } diff --git a/src/PLASMA/ANML/component/AnmlInterpreter.hh b/src/PLASMA/ANML/component/AnmlInterpreter.hh index 03328cb20..bde7cdc2e 100644 --- a/src/PLASMA/ANML/component/AnmlInterpreter.hh +++ b/src/PLASMA/ANML/component/AnmlInterpreter.hh @@ -15,7 +15,7 @@ namespace EUROPA { class AnmlInterpreter : public LanguageInterpreter { public: - AnmlInterpreter(EngineId& engine); + AnmlInterpreter(EngineId engine); virtual ~AnmlInterpreter(); virtual std::string interpret(std::istream& input, const std::string& source); diff --git a/src/PLASMA/ANML/component/AnmlTestEngine.cc b/src/PLASMA/ANML/component/AnmlTestEngine.cc index 0ed81924c..1f012f6b6 100644 --- a/src/PLASMA/ANML/component/AnmlTestEngine.cc +++ b/src/PLASMA/ANML/component/AnmlTestEngine.cc @@ -15,5 +15,5 @@ AnmlTestEngine::~AnmlTestEngine() void AnmlTestEngine::createModules() { NddlTestEngine::createModules(); - addModule((new ModuleAnml())->getId()); + addModule((new EUROPA::ModuleAnml())->getId()); } diff --git a/src/PLASMA/ANML/component/AnmlTestEngine.hh b/src/PLASMA/ANML/component/AnmlTestEngine.hh index 89ba7b54a..19a35af7c 100644 --- a/src/PLASMA/ANML/component/AnmlTestEngine.hh +++ b/src/PLASMA/ANML/component/AnmlTestEngine.hh @@ -1,10 +1,8 @@ -#ifndef _H_ANML_TEST_ENGINE_ -#define _H_ANML_TEST_ENGINE_ +#ifndef H_ANML_TEST_ENGINE_ +#define H_ANML_TEST_ENGINE_ #include "NddlTestEngine.hh" -using namespace EUROPA; - class AnmlTestEngine : public NddlTestEngine { public: @@ -15,4 +13,4 @@ class AnmlTestEngine : public NddlTestEngine virtual void createModules(); }; -#endif // _H_ANML_TEST_ENGINE_ +#endif // H_ANML_TEST_ENGINE_ diff --git a/src/PLASMA/ANML/test/module-tests.cc b/src/PLASMA/ANML/test/module-tests.cc index f792eb4c0..6e8a92193 100644 --- a/src/PLASMA/ANML/test/module-tests.cc +++ b/src/PLASMA/ANML/test/module-tests.cc @@ -1,5 +1,5 @@ #include "anml-test-module.hh" -int main(int argc, const char** argv) { +int main(int , const char** ) { return 0; } diff --git a/src/PLASMA/CMakeLists.txt b/src/PLASMA/CMakeLists.txt index d465632c9..0ce1ecfbb 100644 --- a/src/PLASMA/CMakeLists.txt +++ b/src/PLASMA/CMakeLists.txt @@ -5,12 +5,46 @@ set(GCC_DEBUG_FLAGS "-ggdb3") set(CMAKE_LIBRARY_PATH "/opt/lib:/opt/local/lib:${CMAKE_LIBRARY_PATH}") if(OPTIMIZE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_OPTIMIZATION_FLAGS}") - set(EUROPA_SUFFIX "_o") + add_definitions(-DEUROPA_FAST=1) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_DEBUG_FLAGS}") - set(EUROPA_SUFFIX "_g") endif(OPTIMIZE) +if(COVERAGE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} g -O0 -Wall -W -fprofile-arcs -ftest-coverage") + + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") + link_libraries(gcov) +endif(COVERAGE) + +if(SIXTYFOUR) + message(STATUS "Configuring for 64-bit build") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64") + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m64") + add_definitions(-DEUROPA_64_BIT_PLATFORM) +else() + message(STATUS "Configuring for 32-bit build") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32") + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m32") +endif(SIXTYFOUR) + +if(BOOST_INCLUDE_PATH) + include_directories(${BOOST_INCLUDE_PATH}) +else() + find_package(Boost) + if(Boost_FOUND) + include_directories(${Boost_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "Failed to find boost libraries") + endif() +else() + message(FATAL_ERROR "Failed to find boost libraries") +endif() + add_subdirectory(TinyXml) add_subdirectory(Utils) add_subdirectory(ConstraintEngine) diff --git a/src/PLASMA/ConstraintEngine/CMakeLists.txt b/src/PLASMA/ConstraintEngine/CMakeLists.txt index 65821d7c3..64c95da3f 100644 --- a/src/PLASMA/ConstraintEngine/CMakeLists.txt +++ b/src/PLASMA/ConstraintEngine/CMakeLists.txt @@ -1,8 +1,9 @@ include(EuropaModule) +#set(internal_dependencies Utils TinyXml) set(internal_dependencies Utils TinyXml) set(root_sources ModuleConstraintEngine.cc) -set(base_sources CESchema.cc DataType.cc CFunction.cc Domain.cc ConstrainedVariable.cc DomainListener.cc Constraint.cc PSConstraintEngineListener.cc ConstraintEngine.cc PSVarValue.cc ConstraintEngineListener.cc Propagator.cc ConstraintType.cc VariableChangeListener.cc) -set(component_sources Constraints.cc EquivalenceClassCollection.cc DataTypes.cc Propagators.cc Domains.cc) +set(base_sources CESchema.cc DataType.cc CFunction.cc Domain.cc ConstrainedVariable.cc DomainListener.cc Constraint.cc PSConstraintEngineListener.cc ConstraintEngine.cc PSVarValue.cc ConstraintEngineListener.cc Propagator.cc ConstraintType.cc VariableChangeListener.cc ConstraintTypeChecking.cc) +set(component_sources Constraints.cc EquivalenceClassCollection.cc DataTypes.cc Propagators.cc Domains.cc CFunctions.cc) #set(test_sources ConstraintTesting.cc ce-test-module.cc module-tests.cc DomainTest.cc domain-tests.cc) set(test_sources ConstraintTesting.cc ce-test-module.cc module-tests.cc domain-tests.cc) @@ -10,5 +11,10 @@ common_module_prepends("${base_sources}" "${component_sources}" "${test_sources} declare_module(ConstraintEngine "${root_sources}" "${base_sources}" "${component_sources}" "${test_sources}" "${internal_dependencies}" "") -set(test_inputs test/CLibTestCases test/CLibTestCases.xml test/NewTestCases test/NewTestCases.xml) -file(COPY ${test_inputs} DESTINATION .) +set(test_inputs CLibTestCases CLibTestCases.xml NewTestCases NewTestCases.xml violations-allowed.xml violations-missing.xml violations-unallowed.xml) +foreach(file ${test_inputs}) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test/${file} ${CMAKE_CURRENT_BINARY_DIR}/${file}) + add_custom_target(${file} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${file}) + add_dependencies(${ConstraintEngine_TEST} ${file}) +endforeach(file) diff --git a/src/PLASMA/ConstraintEngine/ConstraintEngineDefs.hh b/src/PLASMA/ConstraintEngine/ConstraintEngineDefs.hh index 24dfdf0ee..bc4ea4d7f 100644 --- a/src/PLASMA/ConstraintEngine/ConstraintEngineDefs.hh +++ b/src/PLASMA/ConstraintEngine/ConstraintEngineDefs.hh @@ -1,5 +1,5 @@ -#ifndef _H_ConstraintEngineDefs -#define _H_ConstraintEngineDefs +#ifndef H_ConstraintEngineDefs +#define H_ConstraintEngineDefs /** * Just provide forward declarations of classes and certain global declarations related to error handling. @@ -13,55 +13,63 @@ #include namespace EUROPA { - class DataType; - typedef Id DataTypeId; - - class Domain; - class IntervalDomain; - class IntervalIntDomain; - class BoolDomain; - class EnumeratedDomain; - - class DomainListener; - typedef Id DomainListenerId; - - class ConstrainedVariable; - typedef Id ConstrainedVariableId; - typedef std::set > ConstrainedVariableSet; - - class ConstrainedVariableListener; - typedef Id ConstrainedVariableListenerId; - class VariableChangeListener; - typedef Id VariableChangeListenerId; - - class Constraint; - typedef Id ConstraintId; - typedef std::set > ConstraintSet; - class Propagator; - typedef Id PropagatorId; - class ConstraintEngine; - typedef Id ConstraintEngineId; - class ConstraintEngineListener; - typedef Id ConstraintEngineListenerId; - typedef std::pair ConstraintEntry; - typedef std::list ConstraintList; - - class PostPropagationCallback; - typedef Id PostPropagationCallbackId; - - /** - * @brief Helper method to cast singleton values - */ - template - Id id(const ConstrainedVariableId& var); - - class StringDomain; - typedef StringDomain LabelSet; - - /** Constants **/ - DECLARE_GLOBAL_CONST(char*, g_noVarName); - #define NO_VAR_NAME (g_noVarName()) +class DataType; +typedef Id DataTypeId; + +class Domain; +class IntervalDomain; +class IntervalIntDomain; +class BoolDomain; +class EnumeratedDomain; + +class DomainListener; +typedef Id DomainListenerId; + +class ConstrainedVariable; +typedef Id ConstrainedVariableId; +typedef std::set > ConstrainedVariableSet; + +class ConstrainedVariableListener; +typedef Id ConstrainedVariableListenerId; +class VariableChangeListener; +typedef Id VariableChangeListenerId; + +class Constraint; +typedef Id ConstraintId; +typedef std::set > ConstraintSet; +class CFunction; +typedef Id CFunctionId; +class ConstraintType; +typedef Id ConstraintTypeId; +class Propagator; +typedef Id PropagatorId; +class ConstraintEngine; +typedef Id ConstraintEngineId; +class ConstraintEngineListener; +typedef Id ConstraintEngineListenerId; +typedef std::pair ConstraintEntry; +typedef std::list ConstraintList; + +class CESchema; +typedef Id CESchemaId; + +class PostPropagationCallback; +typedef Id PostPropagationCallbackId; + +class PSVarValue; +/** + * @brief Helper method to cast singleton values + */ +template +Id id(const ConstrainedVariableId var); + +class StringDomain; +typedef StringDomain LabelSet; + +/** Constants **/ +DECLARE_GLOBAL_CONST(std::string, g_noVarName); +#define NO_VAR_NAME (g_noVarName()) } /* namespace EUROPA */ -#endif /* #ifndef _H_ConstraintEngineDefs */ +#endif /* #ifndef H_ConstraintEngineDefs */ diff --git a/src/PLASMA/ConstraintEngine/ModuleConstraintEngine.cc b/src/PLASMA/ConstraintEngine/ModuleConstraintEngine.cc index 87240e9f0..55c2edc31 100644 --- a/src/PLASMA/ConstraintEngine/ModuleConstraintEngine.cc +++ b/src/PLASMA/ConstraintEngine/ModuleConstraintEngine.cc @@ -4,6 +4,9 @@ #include "ConstraintType.hh" #include "Propagators.hh" #include "CFunctions.hh" +#include "CESchema.hh" + +#include namespace EUROPA { @@ -49,18 +52,20 @@ namespace EUROPA { ces->registerCFunction((new CeilFunction())->getId()); ConstraintEngine* ce = new ConstraintEngine(ces->getId()); - new DefaultPropagator(LabelStr("Default"), ce->getId()); + new DefaultPropagator(std::string("Default"), ce->getId()); + ce->setAllowViolations(engine->getConfig()->getProperty("ConstraintEngine.allowViolations") == "true"); + engine->addComponent("ConstraintEngine",ce); } - void ModuleConstraintEngine::uninitialize(EngineId engine) - { - ConstraintEngine* ce = (ConstraintEngine*)engine->removeComponent("ConstraintEngine"); - delete ce; +void ModuleConstraintEngine::uninitialize(EngineId engine) { + ConstraintEngine* ce = + boost::polymorphic_cast(engine->removeComponent("ConstraintEngine")); + delete ce; - CESchema* ces = (CESchema*)engine->removeComponent("CESchema"); - delete ces; - } + CESchema* ces = boost::polymorphic_cast(engine->removeComponent("CESchema")); + delete ces; +} /**************************************************************************************/ @@ -85,132 +90,72 @@ namespace EUROPA { { debugMsg("ModuleConstraintLibrary:initialize", "Initializing the constraint library"); - CESchema* ces = (CESchema*)engine->getComponent("CESchema"); + CESchema* ces = boost::polymorphic_cast(engine->getComponent("CESchema")); // Register constraint Factories REGISTER_CONSTRAINT_TYPE(ces,AbsoluteValueCT, "absVal", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,AddEqualCT, "AddEqual", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,AddEqualCT, "addeq", "Default"); REGISTER_CONSTRAINT_TYPE(ces,AddEqualCT, "addEq", "Default"); - REGISTER_CONSTRAINT(ces,AddMultEqualConstraint, "AddMultEqual", "Default"); - REGISTER_CONSTRAINT(ces,AddMultEqualConstraint, "addMulEq", "Default"); - REGISTER_CONSTRAINT(ces,AddMultEqualConstraint, "addmuleq", "Default"); - REGISTER_CONSTRAINT(ces,AllDiffConstraint, "adiff", "Default"); // all different - REGISTER_CONSTRAINT(ces,AllDiffConstraint, "fadiff", "Default"); // flexible all different - REGISTER_CONSTRAINT(ces,AllDiffConstraint, "fneq", "Default"); // flexible not equal - REGISTER_CONSTRAINT(ces,AllDiffConstraint, "AllDiff", "Default"); - REGISTER_CONSTRAINT(ces,CalcDistanceConstraint, "calcDistance", "Default"); - REGISTER_CONSTRAINT(ces,CardinalityConstraint, "card", "Default"); // cardinality not more than - REGISTER_CONSTRAINT(ces,CardinalityConstraint, "Cardinality", "Default"); - REGISTER_CONSTRAINT(ces,CondAllDiffConstraint, "CondAllDiff", "Default"); - REGISTER_CONSTRAINT(ces,CondAllSameConstraint, "CondAllSame", "Default"); - REGISTER_CONSTRAINT(ces,CondAllSameConstraint, "condEq", "Default"); - REGISTER_CONSTRAINT(ces,CondAllSameConstraint, "condeq", "Default"); - REGISTER_CONSTRAINT(ces,CondAllSameConstraint, "condasame", "Default"); - REGISTER_CONSTRAINT(ces,CondEqualSumConstraint, "CondEqualSum", "Default"); - REGISTER_CONSTRAINT(ces,CountNonZerosConstraint, "CountNonZeros", "Default"); - REGISTER_CONSTRAINT(ces,CountNonZerosConstraint, "cardeq", "Default"); // cardinality equals - REGISTER_CONSTRAINT(ces,CountZerosConstraint, "CountZeros", "Default"); - REGISTER_CONSTRAINT(ces,DistanceFromSquaresConstraint, "distanceSquares", "Default"); - - REGISTER_CONSTRAINT_TYPE(ces,EqualCT, "asame", "Default"); // all same + REGISTER_CONSTRAINT_TYPE(ces,MultEqualCT, "multEq", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,DivEqualCT, "divEq", "Default"); + REGISTER_CONSTRAINT_TYPE(ces, AllDiffCT, "allDiff", "Default"); + REGISTER_CONSTRAINT_TYPE(ces, CalcDistanceCT, "calcDistance", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,CondAllDiffCT, "condAllDiff", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,CondAllSameCT, "condEq", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,CountNonZeroesCT, "countNonZeroes", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,CountZeroesCT, "countZeroes", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,DistanceFromSquaresCT, "distanceSquares", "Default"); REGISTER_CONSTRAINT_TYPE(ces,EqualCT, "eq", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,EqualCT, "fasame", "Default"); // flexible all same - REGISTER_CONSTRAINT_TYPE(ces,EqualCT, "Equal", "Default"); - - REGISTER_CONSTRAINT(ces,EqualMaximumConstraint, "EqualMaximum", "Default"); - REGISTER_CONSTRAINT(ces,EqualMaximumConstraint, "fallmax", "Default"); // flexible all max - REGISTER_CONSTRAINT(ces,EqualMinimumConstraint, "fallmin", "Default"); // flexible all min - REGISTER_CONSTRAINT(ces,EqualMinimumConstraint, "EqualMinimum", "Default"); - REGISTER_CONSTRAINT(ces,EqualProductConstraint, "product", "Default"); - REGISTER_CONSTRAINT(ces,EqualProductConstraint, "EqualProduct", "Default"); - - REGISTER_CONSTRAINT(ces,EqualSumConstraint, "EqualSum", "Default"); - REGISTER_CONSTRAINT(ces,EqualSumConstraint, "sum", "Default"); - - REGISTER_CONSTRAINT(ces,GreaterThanSumConstraint, "GreaterThanSum", "Default"); - REGISTER_CONSTRAINT(ces,GreaterOrEqThanSumConstraint, "GreaterOrEqThanSum", "Default"); - REGISTER_CONSTRAINT(ces,LessOrEqThanSumConstraint, "leqsum", "Default"); - REGISTER_CONSTRAINT(ces,LessOrEqThanSumConstraint, "LessOrEqThanSum", "Default"); - + REGISTER_CONSTRAINT_TYPE(ces,EqualMaximumCT, "eqMaximum", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,EqualMinimumCT, "eqMinimum", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,EqualProductCT, "eqProduct", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,EqualSumCT, "eqSum", "Default"); REGISTER_CONSTRAINT_TYPE(ces,LessThanCT, "lt", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,LessThanCT, "lessThan", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,LessThanCT, "LessThan", "Default"); REGISTER_CONSTRAINT_TYPE(ces,LessThanEqualCT, "leq", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,LessThanEqualCT, "LessThanEqual", "Default"); - - REGISTER_CONSTRAINT(ces,LessThanSumConstraint, "LessThanSum", "Default"); - REGISTER_CONSTRAINT(ces,LockConstraint, "Lock", "Default"); - REGISTER_CONSTRAINT(ces,MemberImplyConstraint, "MemberImply", "Default"); - REGISTER_CONSTRAINT(ces,MemberImplyConstraint, "memberImply", "Default"); - REGISTER_CONSTRAINT(ces,MultEqualConstraint, "mulEq", "Default"); - REGISTER_CONSTRAINT(ces,MultEqualConstraint, "multEq", "Default"); - REGISTER_CONSTRAINT(ces,MultEqualConstraint, "MultEqual", "Default"); - // Minh: Added (06/06/2012) new entries for DivEqualConstraint - REGISTER_CONSTRAINT(ces,DivEqualConstraint, "divEq", "Default"); - // Minh: END - REGISTER_CONSTRAINT(ces,NegateConstraint, "neg", "Default"); - REGISTER_CONSTRAINT(ces,NotEqualConstraint, "neq", "Default"); - REGISTER_CONSTRAINT(ces,NotEqualConstraint, "NotEqual", "Default"); - REGISTER_CONSTRAINT(ces,OrConstraint, "Or", "Default"); - REGISTER_CONSTRAINT(ces,OrConstraint, "for", "Default"); // flexible or - REGISTER_CONSTRAINT(ces,OrConstraint, "or", "Default"); - REGISTER_CONSTRAINT(ces,SineFunction, "sin", "Default"); - REGISTER_CONSTRAINT(ces,SquareOfDifferenceConstraint, "diffSquare", "Default"); - REGISTER_CONSTRAINT(ces,SubsetOfConstraint, "SubsetOf", "Default"); - REGISTER_CONSTRAINT(ces,SubsetOfConstraint, "subsetOf", "Default"); - REGISTER_CONSTRAINT(ces,SubsetOfConstraint, "Singleton", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,LockCT, "lockCT", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,MemberImplyCT, "memberImply", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,MultEqualCT, "mulEq", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,DivEqualCT, "divEq", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,NegateCT, "neg", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,NotEqualCT, "neq", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,OrCT, "or", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,SineCT, "sin", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,SquareOfDifferenceCT, "diffSquare", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,SubsetOfCT, "subsetOf", "Default"); REGISTER_CONSTRAINT_TYPE(ces,TestAndCT, "testAnd", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,TestEQCT, "TestEqual", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,TestEQCT, "testEQ", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,TestLessThanCT, "TestLessThan", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,TestLessThanCT, "condlt", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,TestLEQCT, "condleq", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,TestLEQCT, "testLEQ", "Default"); - REGISTER_CONSTRAINT_TYPE(ces,TestNEQCT, "testNEQ", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,TestEQCT, "testEq", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,TestLessThanCT, "testLessThan", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,TestLEQCT, "testLeq", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,TestNEQCT, "testNeq", "Default"); REGISTER_CONSTRAINT_TYPE(ces,TestOrCT, "testOr", "Default"); REGISTER_CONSTRAINT_TYPE(ces,TestSingletonCT, "testSingleton", "Default"); REGISTER_CONSTRAINT_TYPE(ces,TestSpecifiedCT, "testSpecified", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,UnaryCT, "UNARY", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,WithinBoundsCT, "withinBounds", "Default"); - REGISTER_CONSTRAINT(ces,UnaryConstraint, "UNARY", "Default"); - - REGISTER_CONSTRAINT(ces,WithinBounds, "WithinBounds", "Default"); - REGISTER_CONSTRAINT(ces,WithinBounds, "withinBounds", "Default"); - - REGISTER_CONSTRAINT(ces,MaxConstraint, "maxf", "Default"); - REGISTER_CONSTRAINT(ces,MinConstraint, "minf", "Default"); - REGISTER_CONSTRAINT(ces,AbsConstraint, "abs", "Default"); - REGISTER_CONSTRAINT(ces,PowConstraint, "pow", "Default"); - REGISTER_CONSTRAINT(ces,SqrtConstraint, "sqrt", "Default"); - REGISTER_CONSTRAINT(ces,ModConstraint, "mod", "Default"); - REGISTER_CONSTRAINT(ces,FloorConstraint, "floor", "Default"); - REGISTER_CONSTRAINT(ces,CeilConstraint, "ceil", "Default"); - REGISTER_CONSTRAINT(ces,RandConstraint, "rand", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,MaxCT, "maxf", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,MinCT, "minf", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,AbsCT, "abs", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,PowCT, "pow", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,SqrtCT, "sqrt", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,ModCT, "mod", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,FloorCT, "floor", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,CeilCT, "ceil", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,RandCT, "rand", "Default"); + REGISTER_CONSTRAINT_TYPE(ces,EqUnionCT, "eqUnion", "Default"); - - - // Rotate scope right one (last var moves to front) to ... - // ... change addleq constraint to GreaterOrEqThan constraint: - REGISTER_ROTATED_CONSTRAINT(ces,"addleq", "Default", "GreaterOrEqThanSum", 1); - // ... change addlt constraint to GreaterThanSum constraint: - REGISTER_ROTATED_CONSTRAINT(ces,"addlt", "Default", "GreaterThanSum", 1); // ... change allmax and max constraint to EqualMaximum constraint: - REGISTER_ROTATED_CONSTRAINT(ces,"allmax", "Default", "EqualMaximum", 1); - REGISTER_ROTATED_CONSTRAINT(ces,"max", "Default", "EqualMaximum", 1); + REGISTER_ROTATED_CONSTRAINT(ces,"allMax", "Default", "eqMaximum", 1); + REGISTER_ROTATED_CONSTRAINT(ces,"max", "Default", "eqMaximum", 1); // ... change allmin and min constraint to EqualMinimum constraint: - REGISTER_ROTATED_CONSTRAINT(ces,"allmin", "Default", "EqualMinimum", 1); - REGISTER_ROTATED_CONSTRAINT(ces,"min", "Default", "EqualMinimum", 1); - - // But addeqcond is harder, requiring two "steps": - REGISTER_SWAP_TWO_VARS_CONSTRAINT(ces,"eqcondsum", "Default", "CondEqualSum", 0, 1); - REGISTER_ROTATED_CONSTRAINT(ces,"addeqcond", "Default", "eqcondsum", 2); + REGISTER_ROTATED_CONSTRAINT(ces,"allMin", "Default", "eqMinimum", 1); + REGISTER_ROTATED_CONSTRAINT(ces,"min", "Default", "eqMinimum", 1); } void ModuleConstraintLibrary::uninitialize(EngineId engine) { - CESchema* ces = (CESchema*)engine->getComponent("CESchema"); + CESchema* ces = boost::polymorphic_cast(engine->getComponent("CESchema")); // TODO: should be more selective and only remove the constraints we added above ces->purgeConstraintTypes(); } diff --git a/src/PLASMA/ConstraintEngine/ModuleConstraintEngine.hh b/src/PLASMA/ConstraintEngine/ModuleConstraintEngine.hh index 2aad6c38c..daf4035fd 100644 --- a/src/PLASMA/ConstraintEngine/ModuleConstraintEngine.hh +++ b/src/PLASMA/ConstraintEngine/ModuleConstraintEngine.hh @@ -1,6 +1,6 @@ -#ifndef _H_ModuleConstraintEngine -#define _H_ModuleConstraintEngine +#ifndef H_ModuleConstraintEngine +#define H_ModuleConstraintEngine #include "Module.hh" @@ -51,4 +51,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_ModuleConstraintEngine */ +#endif /* #ifndef H_ModuleConstraintEngine */ diff --git a/src/PLASMA/ConstraintEngine/base/CESchema.cc b/src/PLASMA/ConstraintEngine/base/CESchema.cc index ca084c356..576ffd2af 100644 --- a/src/PLASMA/ConstraintEngine/base/CESchema.cc +++ b/src/PLASMA/ConstraintEngine/base/CESchema.cc @@ -1,12 +1,11 @@ #include "CESchema.hh" #include "Debug.hh" +#include "ConstraintType.hh" +#include "CFunction.hh" namespace EUROPA { - CESchema::CESchema() - : m_id(this) - { - } +CESchema::CESchema() : m_id(this), m_dataTypes(), m_constraintTypes(), m_cfunctions() {} CESchema::~CESchema() { @@ -21,145 +20,141 @@ namespace EUROPA purgeDataTypes(); } - const CESchemaId& CESchema::getId() const + const CESchemaId CESchema::getId() const { return m_id; } - bool CESchema::isDataType(const char* typeName) const - { - return (m_dataTypes.find(LabelStr(typeName).getKey()) != m_dataTypes.end()); - } - - DataTypeId CESchema::getDataType(const char* typeName) - { - std::map::const_iterator it = m_dataTypes.find(LabelStr(typeName).getKey()); - condDebugMsg(it == m_dataTypes.end(), "europa:error", "no DataType found for type '" << std::string(typeName) << "'"); - check_error(it != m_dataTypes.end(), "no DataType found for type '" + std::string(typeName) + "'"); - - DataTypeId dt = it->second; - check_error(dt.isValid()); - return dt; - } - - void CESchema::registerDataType(const DataTypeId& dt) - { - check_error(dt.isValid()); +bool CESchema::isDataType(const std::string& typeName) const { + return (m_dataTypes.find(typeName) != m_dataTypes.end()); +} - if(m_dataTypes.find(dt->getName().getKey()) != m_dataTypes.end()){ - debugMsg("CESchema::registerDataType", "Over-writing prior registration for " << dt->getName().toString()); - DataTypeId oldFactory = m_dataTypes.find(dt->getName().getKey())->second; - m_dataTypes.erase(dt->getName().getKey()); - delete (DataType*) oldFactory; - } +DataTypeId CESchema::getDataType(const std::string& typeName) { + std::map::const_iterator it = m_dataTypes.find(typeName); + condDebugMsg(it == m_dataTypes.end(), + "europa:error", "no DataType found for type '" << typeName << "'"); + checkError(it != m_dataTypes.end(), + "no DataType found for type '" << typeName << "'"); - checkError(m_dataTypes.find(dt->getName().getKey()) == m_dataTypes.end(), "Already have '" + dt->getName().toString() + "' registered."); + DataTypeId dt = it->second; + check_error(dt.isValid()); + return dt; +} - m_dataTypes.insert(std::pair(dt->getName().getKey(), dt)); - debugMsg("CESchema::registerDataType", "Registered data type " << dt->getName().toString()); - } +void CESchema::registerDataType(const DataTypeId dt) { + check_error(dt.isValid()); - const Domain & CESchema::baseDomain(const char* typeName) - { - DataTypeId factory = getDataType(typeName); - check_error(factory.isValid(), "no DataType found for type '" + std::string(typeName) + "'"); - return factory->baseDomain(); - } - - void CESchema::purgeDataTypes() - { - std::map::iterator it = m_dataTypes.begin(); - while (it != m_dataTypes.end()) { - DataTypeId dt = (it++)->second; - debugMsg("DataType:purgeAll", - "Removing data type " << dt->getName().toString()); - delete (DataType *) dt; - } - m_dataTypes.clear(); + if(m_dataTypes.find(dt->getName()) != m_dataTypes.end()){ + debugMsg("CESchema::registerDataType", "Over-writing prior registration for " << dt->getName()); + DataTypeId oldFactory = m_dataTypes.find(dt->getName())->second; + m_dataTypes.erase(dt->getName()); + delete static_cast(oldFactory); } - void CESchema::registerConstraintType(const ConstraintTypeId& factory) { - const LabelStr& name = factory->getName(); - if(isConstraintType(name)){ - debugMsg("CESchema:registerConstraintType", "Over-riding prior registration for " << name.c_str()); - ConstraintTypeId oldFactory = getConstraintType(name); - std::map& factories = m_constraintTypes; - factories.erase(name.getKey()); - oldFactory.release(); - } - - check_error(!isConstraintType(name), "Constraint Type '" + name.toString() + "' should not be registered, and yet it is...."); - m_constraintTypes.insert(std::pair(name.getKey(),factory)); - debugMsg("CESchema:registerConstraintType", "Registered Constraint Type " << factory->getName().toString()); - } + checkError(m_dataTypes.find(dt->getName()) == m_dataTypes.end(), + "Already have '" + dt->getName() + "' registered."); - const ConstraintTypeId& CESchema::getConstraintType(const LabelStr& name) { - std::map< edouble, ConstraintTypeId >::const_iterator it = m_constraintTypes.find(name.getKey()); - condDebugMsg(it == m_constraintTypes.end(), "europa:error", "Factory for constraint '" << name.toString() << "' is not registered."); - check_error(it != m_constraintTypes.end(), "Factory for constraint '" + name.toString() + "' is not registered."); - return(it->second); - } + m_dataTypes.insert(std::make_pair(dt->getName(), dt)); + debugMsg("CESchema::registerDataType", "Registered data type " << dt->getName()); +} - bool CESchema::isConstraintType(const LabelStr& name, const bool& warn) { - std::map::const_iterator it = m_constraintTypes.find(name.getKey()); - if (it == m_constraintTypes.end()) { - if (warn) - std::cerr << "\nConstraint Type <" << name.toString() << "> has not been registered\n"; - return(false); - } - return(true); - } - - void CESchema::purgeConstraintTypes() - { - std::map::iterator it = m_constraintTypes.begin(); - while (it != m_constraintTypes.end()){ - ConstraintTypeId factory = it->second; - check_error(factory.isValid()); - debugMsg("CESchema:purgeAll", "Removing constraint type " << factory->getName().toString()); - m_constraintTypes.erase(it++); - factory.release(); - } - } - - void CESchema::registerCFunction(const CFunctionId& cf) - { - check_error(cf.isValid()); - - if(m_cfunctions.find(cf->getName().getKey()) != m_cfunctions.end()){ - debugMsg("CESchema::registerCFunction", "Over-writing prior registration for " << cf->getName().toString()); - CFunctionId old = m_cfunctions.find(cf->getName().getKey())->second; - m_cfunctions.erase(cf->getName().getKey()); - delete (CFunction*) old; - } - - checkError(m_cfunctions.find(cf->getName().getKey()) == m_cfunctions.end(), "Already have '" + cf->getName().toString() + "' registered."); - - m_cfunctions.insert(std::pair(cf->getName().getKey(), cf)); - debugMsg("CESchema::registerCFunction", "Registered CFunction " << cf->getName().toString()); - } - - CFunctionId CESchema::getCFunction(const LabelStr& name) - { - std::map::const_iterator it = m_cfunctions.find(name.getKey()); - - if (it != m_cfunctions.end()) - return it->second; - else - return CFunctionId::noId(); - } - - // TODO: write generic method to clean up maps instead - void CESchema::purgeCFunctions() - { - std::map::iterator it = m_cfunctions.begin(); - while (it != m_cfunctions.end()) { - CFunctionId cf = (it++)->second; - debugMsg("CESchema:purgeAll", - "Removing CFunction " << cf->getName().toString()); - delete (CFunction *) cf; - } - m_cfunctions.clear(); - } +const Domain & CESchema::baseDomain(const std::string& typeName) { + DataTypeId factory = getDataType(typeName); + check_error(factory.isValid(), "no DataType found for type '" + typeName + "'"); + return factory->baseDomain(); +} + +void CESchema::purgeDataTypes() { + std::map::iterator it = m_dataTypes.begin(); + while (it != m_dataTypes.end()) { + DataTypeId dt = (it++)->second; + debugMsg("DataType:purgeAll", + "Removing data type " << dt->getName()); + delete static_cast(dt); + } + m_dataTypes.clear(); +} + +void CESchema::registerConstraintType(const ConstraintTypeId factory) { + const std::string& name = factory->getName(); + if(isConstraintType(name)){ + debugMsg("CESchema:registerConstraintType", "Over-riding prior registration for " << name.c_str()); + ConstraintTypeId oldFactory = getConstraintType(name); + std::map& factories = m_constraintTypes; + factories.erase(name); + oldFactory.release(); + } + + check_error(!isConstraintType(name), "Constraint Type '" + name + "' should not be registered, and yet it is...."); + m_constraintTypes.insert(std::make_pair(name,factory)); + debugMsg("CESchema:registerConstraintType", "Registered Constraint Type " << factory->getName()); +} + +const ConstraintTypeId CESchema::getConstraintType(const std::string& name) { + std::map< std::string, ConstraintTypeId >::const_iterator it = m_constraintTypes.find(name); + condDebugMsg(it == m_constraintTypes.end(), + "europa:error", "Factory for constraint '" << name << "' is not registered."); + checkError(it != m_constraintTypes.end(), + "Factory for constraint '" << name << "' is not registered."); + return(it->second); +} + +bool CESchema::isConstraintType(const std::string& name, const bool& warn) { + std::map::const_iterator it = m_constraintTypes.find(name); + if (it == m_constraintTypes.end()) { + if (warn) + std::cerr << "\nConstraint Type <" << name << "> has not been registered\n"; + return(false); + } + return(true); +} + +void CESchema::purgeConstraintTypes() { + std::map::iterator it = m_constraintTypes.begin(); + while (it != m_constraintTypes.end()){ + ConstraintTypeId factory = it->second; + check_error(factory.isValid()); + debugMsg("CESchema:purgeAll", "Removing constraint type " << factory->getName()); + m_constraintTypes.erase(it++); + factory.release(); + } +} + +void CESchema::registerCFunction(const CFunctionId cf) { + check_error(cf.isValid()); + + if(m_cfunctions.find(cf->getName()) != m_cfunctions.end()){ + debugMsg("CESchema::registerCFunction", "Over-writing prior registration for " << cf->getName()); + CFunctionId old = m_cfunctions.find(cf->getName())->second; + m_cfunctions.erase(cf->getName()); + delete static_cast(old); + } + + checkError(m_cfunctions.find(cf->getName()) == m_cfunctions.end(), "Already have '" + cf->getName() + "' registered."); + + m_cfunctions.insert(std::make_pair(cf->getName(), cf)); + debugMsg("CESchema::registerCFunction", "Registered CFunction " << cf->getName()); +} + +CFunctionId CESchema::getCFunction(const std::string& name) { + std::map::const_iterator it = m_cfunctions.find(name); + + if (it != m_cfunctions.end()) + return it->second; + else + return CFunctionId::noId(); +} + +// TODO: write generic method to clean up maps instead +void CESchema::purgeCFunctions() { + std::map::iterator it = m_cfunctions.begin(); + while (it != m_cfunctions.end()) { + CFunctionId cf = (it++)->second; + debugMsg("CESchema:purgeAll", + "Removing CFunction " << cf->getName()); + delete static_cast(cf); + } + m_cfunctions.clear(); +} } // namespace EUROPA diff --git a/src/PLASMA/ConstraintEngine/base/CESchema.hh b/src/PLASMA/ConstraintEngine/base/CESchema.hh index a6edaffc0..637e99d01 100644 --- a/src/PLASMA/ConstraintEngine/base/CESchema.hh +++ b/src/PLASMA/ConstraintEngine/base/CESchema.hh @@ -1,14 +1,10 @@ -#ifndef _H_CESchema -#define _H_CESchema +#ifndef H_CESchema +#define H_CESchema -#include #include "ConstraintEngineDefs.hh" -#include "LabelStr.hh" #include "Engine.hh" -#include "Domain.hh" -#include "ConstraintType.hh" -#include "DataType.hh" -#include "CFunction.hh" + +#include /** * @file Class to manage all metadata for Constraint engine (variable data types, constraint types, etc). @@ -16,48 +12,48 @@ */ namespace EUROPA { - - class CESchema; - typedef Id CESchemaId; - - class CESchema : public EngineComponent - { - public: - CESchema(); - virtual ~CESchema(); - - const CESchemaId& getId() const; - - // Methods to Manage Data Types - void registerDataType(const DataTypeId& dt); - DataTypeId getDataType(const char* typeName); - bool isDataType(const char* typeName) const; - const Domain & baseDomain(const char* typeName); - void purgeDataTypes(); - - // Methods to Manage Constraint Factories - void registerConstraintType(const ConstraintTypeId& ct); - const ConstraintTypeId& getConstraintType(const LabelStr& name); - bool isConstraintType(const LabelStr& name, const bool& warn = false); - void purgeConstraintTypes(); - - // Methods to manage CFunctions - void registerCFunction(const CFunctionId& cf); - CFunctionId getCFunction(const LabelStr& name); - void purgeCFunctions(); - - /** - * @brief Delete all meta data stored. - */ - void purgeAll(); - - protected: - CESchemaId m_id; - std::map m_dataTypes; - std::map m_constraintTypes; - std::map m_cfunctions; - }; +class Domain; +class CESchema; +typedef Id CESchemaId; + +class CESchema : public EngineComponent +{ + public: + CESchema(); + virtual ~CESchema(); + + const CESchemaId getId() const; + + // Methods to Manage Data Types + void registerDataType(const DataTypeId dt); + DataTypeId getDataType(const std::string& typeName); + bool isDataType(const std::string& typeName) const; + const Domain & baseDomain(const std::string& typeName); + void purgeDataTypes(); + + // Methods to Manage Constraint Factories + void registerConstraintType(const ConstraintTypeId ct); + const ConstraintTypeId getConstraintType(const std::string& name); + bool isConstraintType(const std::string& name, const bool& warn = false); + void purgeConstraintTypes(); + + // Methods to manage CFunctions + void registerCFunction(const CFunctionId cf); + CFunctionId getCFunction(const std::string& name); + void purgeCFunctions(); + + /** + * @brief Delete all meta data stored. + */ + void purgeAll(); + + protected: + CESchemaId m_id; + std::map m_dataTypes; + std::map m_constraintTypes; + std::map m_cfunctions; +}; } // namespace EUROPA -#endif // _H_CESchema +#endif // H_CESchema diff --git a/src/PLASMA/ConstraintEngine/base/CFunction.cc b/src/PLASMA/ConstraintEngine/base/CFunction.cc index 3c3b12b77..b252df292 100644 --- a/src/PLASMA/ConstraintEngine/base/CFunction.cc +++ b/src/PLASMA/ConstraintEngine/base/CFunction.cc @@ -20,15 +20,16 @@ namespace EUROPA { m_id.remove(); } - const CFunctionId& CFunction::getId() const + const CFunctionId CFunction::getId() const { return m_id; } - const LabelStr& CFunction::getName() - { - return m_name; - } +const std::string& CFunction::getName() { + return m_name; +} +void CFunction::checkArgTypes(const std::vector&) {} } + diff --git a/src/PLASMA/ConstraintEngine/base/CFunction.hh b/src/PLASMA/ConstraintEngine/base/CFunction.hh index e0716e896..b30e59cac 100644 --- a/src/PLASMA/ConstraintEngine/base/CFunction.hh +++ b/src/PLASMA/ConstraintEngine/base/CFunction.hh @@ -8,35 +8,36 @@ #ifndef CFUNCTION_HH_ #define CFUNCTION_HH_ -#include "LabelStr.hh" -#include "DataType.hh" +#include "Id.hh" -namespace EUROPA { +#include +namespace EUROPA { +class DataType; +typedef Id DataTypeId; class CFunction; typedef Id CFunctionId; -class CFunction -{ +class CFunction { public: - CFunction(const char* name); - virtual ~CFunction(); - - const CFunctionId& getId() const; - - const LabelStr& getName(); - - // TODO: this API probably needs to be re-evaluated - // TODO: CFunction should know how to evaluate itself - virtual const char* getConstraint() = 0; - virtual const DataTypeId getReturnType() = 0; - virtual unsigned int getArgumentCount() = 0; - - virtual void checkArgTypes(const std::vector& argTypes) {} - -protected: - CFunctionId m_id; - LabelStr m_name; + CFunction(const char* name); + virtual ~CFunction(); + + const CFunctionId getId() const; + + const std::string& getName(); + + // TODO: this API probably needs to be re-evaluated + // TODO: CFunction should know how to evaluate itself + virtual const char* getConstraint() = 0; + virtual const DataTypeId getReturnType() = 0; + virtual unsigned int getArgumentCount() = 0; + + virtual void checkArgTypes(const std::vector& argTypes); + + protected: + CFunctionId m_id; + std::string m_name; }; } diff --git a/src/PLASMA/ConstraintEngine/base/ConstrainedVariable.cc b/src/PLASMA/ConstraintEngine/base/ConstrainedVariable.cc index c8af52e75..6e658f85e 100644 --- a/src/PLASMA/ConstraintEngine/base/ConstrainedVariable.cc +++ b/src/PLASMA/ConstraintEngine/base/ConstrainedVariable.cc @@ -6,47 +6,61 @@ #include "Debug.hh" #include "Error.hh" #include "VariableChangeListener.hh" +#include "DataType.hh" +#include "PSVarValue.hh" #include namespace EUROPA { - ConstrainedVariableListener::ConstrainedVariableListener(const ConstrainedVariableId& var) +ConstrainedVariableListener::ConstrainedVariableListener(const ConstrainedVariableId var) : m_id(this), m_var(var) { - var->notifyAdded(m_id); - } + var->notifyAdded(m_id); +} - const ConstrainedVariableListenerId& ConstrainedVariableListener::getId() const { - return(m_id); - } +const ConstrainedVariableListenerId ConstrainedVariableListener::getId() const { + return(m_id); +} - ConstrainedVariableListener::~ConstrainedVariableListener() { - m_var->notifyRemoved(m_id); - m_id.remove(); - } +void ConstrainedVariableListener::notifyDiscard() {} +void ConstrainedVariableListener::notifyConstraintAdded(const ConstraintId, + unsigned int) {} +void ConstrainedVariableListener::notifyConstraintRemoved(const ConstraintId, + unsigned int) {} - ConstrainedVariable::ConstrainedVariable(const ConstraintEngineId& constraintEngine, - const bool internal, - bool canBeSpecified, - const LabelStr& name, - const EntityId& parent, - int index) - : Entity(), m_id(this), m_lastRelaxed(0), m_constraintEngine(constraintEngine), m_name(name), - m_internal(internal), m_canBeSpecified(canBeSpecified), m_specifiedFlag(false), m_specifiedValue(0), - m_index(index), m_parent(parent), m_deactivationRefCount(0), m_deleted(false) { - check_error(m_constraintEngine.isValid()); - check_error(m_index >= NO_INDEX); - check_error(m_index == NO_INDEX || parent.isValid()); - m_constraintEngine->add(m_id); - m_listener = m_constraintEngine->allocateVariableListener(m_id, m_constraints); - } +ConstrainedVariableListener::~ConstrainedVariableListener() { + m_var->notifyRemoved(m_id); + m_id.remove(); +} + +const std::string& ConstrainedVariable::NO_NAME() { + static const std::string sl_noName(NO_VAR_NAME); + return(sl_noName); +} + +ConstrainedVariable::ConstrainedVariable(const ConstraintEngineId constraintEngine, + const bool internal, + bool _canBeSpecified, + const std::string& name, + const EntityId _parent, + unsigned long index) + : Entity(), m_id(this), m_listener(), m_propagatingConstraint(), m_lastRelaxed(0), + m_constraintEngine(constraintEngine), m_name(name), m_internal(internal), + m_canBeSpecified(_canBeSpecified), m_specifiedFlag(false), m_specifiedValue(0), + m_index(index), m_parent(_parent), m_deactivationRefCount(0), m_deleted(false), + m_listeners(), m_constraints() { + check_error(m_constraintEngine.isValid()); + check_error(m_index == NO_INDEX || _parent.isValid()); + m_constraintEngine->add(m_id); + m_listener = m_constraintEngine->allocateVariableListener(m_id, m_constraints); +} ConstrainedVariable::~ConstrainedVariable() { debugMsg("ConstrainedVariable:~ConstrainedVariable", - "NAME=" << getName().toString() << " KEY=" << getKey() << " ID=" << m_id); + "NAME=" << getName() << " KEY=" << getKey() << " ID=" << m_id); discard(false); - delete (DomainListener*) m_listener; + delete static_cast(m_listener); m_id.remove(); } @@ -110,7 +124,7 @@ namespace EUROPA { Entity::handleDiscard(); } - const ConstrainedVariableId& ConstrainedVariable::getId() const { + const ConstrainedVariableId ConstrainedVariable::getId() const { return(m_id); } @@ -120,9 +134,9 @@ namespace EUROPA { } - int ConstrainedVariable::getIndex() const { - return(m_index); - } +unsigned long ConstrainedVariable::getIndex() const { + return(m_index); +} void ConstrainedVariable::deactivate() { check_error(!Entity::isPurging()); @@ -183,43 +197,45 @@ namespace EUROPA { m_constraintEngine->propagate(); } - const EntityId& ConstrainedVariable::parent() const { + const EntityId ConstrainedVariable::parent() const { return m_parent; } - const ConstraintEngineId& ConstrainedVariable::getConstraintEngine() const { + const ConstraintEngineId ConstrainedVariable::getConstraintEngine() const { return m_constraintEngine; } - void ConstrainedVariable::addConstraint(const ConstraintId& constraint, int argIndex) { - check_error(!Entity::isPurging()); - check_error(constraint.isValid()); - debugMsg("ConstrainedVariable:addConstraint", "Adding " << constraint->toString() << " to " << toString()); - m_constraints.push_back(ConstraintEntry(constraint, argIndex)); +void ConstrainedVariable::addConstraint(const ConstraintId constraint, + unsigned int argIndex) { + check_error(!Entity::isPurging()); + check_error(constraint.isValid()); + debugMsg("ConstrainedVariable:addConstraint", "Adding " << constraint->toString() << " to " << toString()); + m_constraints.push_back(ConstraintEntry(constraint, argIndex)); - handleConstraintAdded(constraint); - for(std::set::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) - (*it)->notifyConstraintAdded(constraint, argIndex); + handleConstraintAdded(constraint); + for(std::set::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) + (*it)->notifyConstraintAdded(constraint, argIndex); - check_error(isConstrainedBy(constraint)); - } + check_error(isConstrainedBy(constraint)); +} - void ConstrainedVariable::removeConstraint(const ConstraintId& constraint, int argIndex) { - if(m_deleted) // Nothing to do - return; +void ConstrainedVariable::removeConstraint(const ConstraintId constraint, + unsigned int argIndex) { + if(m_deleted) // Nothing to do + return; - debugMsg("ConstrainedVariable:removeConstraint", "Unlinking " << constraint->toString()); + debugMsg("ConstrainedVariable:removeConstraint", "Unlinking " << constraint->toString()); - check_error(!Entity::isPurging()); - check_error(constraint.isValid()); - check_error(isConstrainedBy(constraint)); - check_error(!Entity::isPurging()); // Should not be getting this message - m_constraints.remove(ConstraintEntry(constraint, argIndex)); + check_error(!Entity::isPurging()); + check_error(constraint.isValid()); + check_error(isConstrainedBy(constraint)); + check_error(!Entity::isPurging()); // Should not be getting this message + m_constraints.remove(ConstraintEntry(constraint, argIndex)); - handleConstraintRemoved(constraint); - for(std::set::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) - (*it)->notifyConstraintRemoved(constraint, argIndex); - } + handleConstraintRemoved(constraint); + for(std::set::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) + (*it)->notifyConstraintRemoved(constraint, argIndex); +} bool ConstrainedVariable::isSpecified() const { return m_specifiedFlag; @@ -249,7 +265,7 @@ namespace EUROPA { return validate(); } - bool ConstrainedVariable::isConstrainedBy(const ConstraintId& constraint) { + bool ConstrainedVariable::isConstrainedBy(const ConstraintId constraint) { ConstraintList::const_iterator it = m_constraints.begin(); for ( ; it != m_constraints.end(); ++it) if (it->first == constraint) @@ -257,14 +273,14 @@ namespace EUROPA { return(false); } - void ConstrainedVariable::updateLastRelaxed(int cycleCount) { + void ConstrainedVariable::updateLastRelaxed(unsigned int cycleCount) { check_error(!Entity::isPurging()); check_error(m_lastRelaxed < cycleCount); m_lastRelaxed = cycleCount; - debugMsg("ConstrainedVariable:updateLastRelaxed",getName().toString() << " lastRelaxed updated to " << m_lastRelaxed); + debugMsg("ConstrainedVariable:updateLastRelaxed",getName() << " lastRelaxed updated to " << m_lastRelaxed); } - int ConstrainedVariable::lastRelaxed() const { + unsigned int ConstrainedVariable::lastRelaxed() const { return(m_lastRelaxed); } @@ -282,11 +298,11 @@ namespace EUROPA { results.insert(it->first); } - unsigned int ConstrainedVariable::constraintCount() const{ + unsigned long ConstrainedVariable::constraintCount() const{ return m_constraints.size(); } - const ConstraintId& ConstrainedVariable::getFirstConstraint() const { + const ConstraintId ConstrainedVariable::getFirstConstraint() const { check_error(!Entity::isPurging()); if (m_constraints.empty()) return(ConstraintId::noId()); @@ -309,13 +325,17 @@ namespace EUROPA { return(m_canBeSpecified); } +void ConstrainedVariable::handleBase(const Domain&) {} +void ConstrainedVariable::handleSpecified(edouble) {} + + bool ConstrainedVariable::isClosed() const { return(baseDomain().isClosed()); } - const LabelStr& ConstrainedVariable::getName() const { - return(m_name); - } +const std::string& ConstrainedVariable::getName() const { + return(m_name); +} void ConstrainedVariable::specify(edouble singletonValue) { debugMsg("ConstrainedVariable:specify", "specifying value:" << toString()); @@ -381,6 +401,8 @@ namespace EUROPA { if(getCurrentDomain().isEmpty()) return; + if(internal_baseDomain().isSingleton() && !isSpecified()) + internalSpecify(internal_baseDomain().getSingletonValue()); } void ConstrainedVariable::open() { @@ -431,12 +453,12 @@ namespace EUROPA { return(true); } - void ConstrainedVariable::notifyAdded(const ConstrainedVariableListenerId& listener){ + void ConstrainedVariable::notifyAdded(const ConstrainedVariableListenerId listener){ check_error(m_listeners.find(listener) == m_listeners.end()); m_listeners.insert(listener); } - void ConstrainedVariable::notifyRemoved(const ConstrainedVariableListenerId& listener) { + void ConstrainedVariable::notifyRemoved(const ConstrainedVariableListenerId listener) { check_error(m_listeners.find(listener) != m_listeners.end()); m_listeners.erase(listener); } @@ -476,37 +498,36 @@ namespace EUROPA { return os.str(); } - const DataTypeId& ConstrainedVariable::getDataType() const + const DataTypeId ConstrainedVariable::getDataType() const { return baseDomain().getDataType(); } // PS-Specific stuff below here: - PSVarType ConstrainedVariable::getType() const - { - PSVarType answer = STRING; - if(baseDomain().isString()) - answer = STRING; - else if(baseDomain().isSymbolic()) { - if(baseDomain().isEmpty() || LabelStr::isString(baseDomain().getLowerBound())) - answer = STRING; - else - answer = OBJECT; //this may not be the best assumption ~MJI - } - else if(baseDomain().isBool()) - answer = BOOLEAN; - else if(baseDomain().isNumeric()) { - if(baseDomain().minDelta() < 1) - answer = DOUBLE; - else - answer = INTEGER; - } - else { - checkError(ALWAYS_FAIL, "Failed to correctly determine the type of " << toString()); - } - return answer; +PSVarType ConstrainedVariable::getType() const { + PSVarType answer = STRING; + if(baseDomain().isString()) + answer = STRING; + else if(baseDomain().isSymbolic()) { + if(baseDomain().isEmpty() || LabelStr::isString(baseDomain().getLowerBound())) + answer = STRING; + else + answer = OBJECT; //this may not be the best assumption ~MJI } + else if(baseDomain().isBool()) + answer = BOOLEAN; + else if(baseDomain().isNumeric()) { + if(baseDomain().minDelta() < 1) + answer = DOUBLE; + else + answer = INTEGER; + } + else { + checkError(ALWAYS_FAIL, "Failed to correctly determine the type of " << toString()); + } + return answer; +} bool ConstrainedVariable::isEnumerated() const { @@ -555,18 +576,17 @@ namespace EUROPA { return retval; } - PSList ConstrainedVariable::getConstraints() const - { - check_runtime_error(isValid()); - check_error(!Entity::isPurging()); - PSList retval; - ConstraintList::const_iterator it = m_constraints.begin(); - for ( ; it != m_constraints.end(); ++it) { - ConstraintId cId = it->first; - retval.push_back( (PSConstraint *) cId); - } - return retval; - } +PSList ConstrainedVariable::getConstraints() const { + check_runtime_error(isValid()); + check_error(!Entity::isPurging()); + PSList retval; + ConstraintList::const_iterator it = m_constraints.begin(); + for ( ; it != m_constraints.end(); ++it) { + ConstraintId cId = it->first; + retval.push_back(dynamic_cast(static_cast(cId))); + } + return retval; +} @@ -602,57 +622,57 @@ namespace EUROPA { debugMsg("ConstrainedVariable:specify","After propagate for var:" << toString()); } - PSEntity* ConstrainedVariable::getParent() const { - //EntityId parent(m_parent);//getParentEntity()); - if(m_parent.isNoId()) - return NULL; - - /* TODO: fix this - else if(TokenId::convertable(parent)) - return new PSTokenImpl((TokenId) parent); - else if(ObjectId::convertable(parent)) - return new PSObjectImpl((ObjectId) parent); - else if(RuleInstanceId::convertable(parent)) - return new PSTokenImpl(((RuleInstanceId)parent)->getToken()); - else { - checkRuntimeError(ALWAYS_FAIL, - "Variable " << toString() << " has a parent that isn't a token, " << - "object, or rule: " << m_var->getParent()->toString()); +PSEntity* ConstrainedVariable::getParent() const { + //EntityId parent(m_parent);//getParentEntity()); + if(m_parent.isNoId()) + return NULL; + + /* TODO: fix this + else if(TokenId::convertable(parent)) + return new PSTokenImpl((TokenId) parent); + else if(ObjectId::convertable(parent)) + return new PSObjectImpl((ObjectId) parent); + else if(RuleInstanceId::convertable(parent)) + return new PSTokenImpl(((RuleInstanceId)parent)->getToken()); + else { + checkRuntimeError(ALWAYS_FAIL, + "Variable " << toString() << " has a parent that isn't a token, " << + "object, or rule: " << m_var->getParent()->toString()); + } + */ + + return dynamic_cast(static_cast(m_parent)); +} + +std::string ConstrainedVariable::toString() const { + std::ostringstream os; + + if (isNull()) + os << "NULL"; + else if (isSingleton()) + os << getSingletonValue().toString(); + else if (isInterval()) + os << "[" << getLowerBound() << "," << getUpperBound() << "]"; + else if (isEnumerated()) { + os << "{"; + PSList values = getValues(); + for (unsigned int i=0;i 0) + os << ", "; + os << values.get(i).toString(); } - */ - - return (PSEntity *) m_parent; - } - - std::string ConstrainedVariable::toString() const { - std::ostringstream os; - - if (isNull()) - os << "NULL"; - else if (isSingleton()) - os << getSingletonValue().toString(); - else if (isInterval()) - os << "[" << getLowerBound() << "," << getUpperBound() << "]"; - else if (isEnumerated()) { - os << "{"; - PSList values = getValues(); - for (int i=0;i 0) - os << ", "; - os << values.get(i).toString(); - } - os << "}"; - } - else - os << "ERROR!"; - - return os.str(); - } - - // Used to be toString, but the above is shorter and more user-friendly - std::string ConstrainedVariable::toLongString() const{ - std::stringstream sstr; - sstr << Entity::toString() << (specifiedFlag() ? " (S) " : "") << " DERIVED=" << lastDomain().toString() << " BASE=" << baseDomain().toString(); - return sstr.str(); - } + os << "}"; + } + else + os << "ERROR!"; + + return os.str(); +} + +// Used to be toString, but the above is shorter and more user-friendly +std::string ConstrainedVariable::toLongString() const{ + std::stringstream sstr; + sstr << Entity::toString() << (specifiedFlag() ? " (S) " : "") << " DERIVED=" << lastDomain().toString() << " BASE=" << baseDomain().toString(); + return sstr.str(); +} } diff --git a/src/PLASMA/ConstraintEngine/base/ConstrainedVariable.hh b/src/PLASMA/ConstraintEngine/base/ConstrainedVariable.hh index 75386460a..916a17e9a 100644 --- a/src/PLASMA/ConstraintEngine/base/ConstrainedVariable.hh +++ b/src/PLASMA/ConstraintEngine/base/ConstrainedVariable.hh @@ -1,5 +1,5 @@ -#ifndef _H_ConstrainedVariable -#define _H_ConstrainedVariable +#ifndef H_ConstrainedVariable +#define H_ConstrainedVariable /** * @file ConstrainedVariable.hh @@ -9,11 +9,9 @@ */ #include "ConstraintEngineDefs.hh" -#include "PSVarValue.hh" #include "PSConstraintEngine.hh" #include "Entity.hh" -#include "LabelStr.hh" -#include "Domain.hh" +#include "unused.hh" #include namespace EUROPA { @@ -24,12 +22,12 @@ namespace EUROPA { class ConstrainedVariableListener{ public: virtual ~ConstrainedVariableListener(); - const ConstrainedVariableListenerId& getId() const; - virtual void notifyDiscard() {} // message for listener creator to immediately delete listener - virtual void notifyConstraintAdded(const ConstraintId& constr, int argIndex) {} - virtual void notifyConstraintRemoved(const ConstraintId& constr, int argIndex) {} + const ConstrainedVariableListenerId getId() const; + virtual void notifyDiscard(); // message for listener creator to immediately delete listener + virtual void notifyConstraintAdded(const ConstraintId constr, unsigned int argIndex); + virtual void notifyConstraintRemoved(const ConstraintId constr, unsigned int argIndex); protected: - ConstrainedVariableListener(const ConstrainedVariableId& var); + ConstrainedVariableListener(const ConstrainedVariableId var); ConstrainedVariableListenerId m_id; ConstrainedVariableId m_var; }; @@ -57,10 +55,7 @@ namespace EUROPA { public: DECLARE_ENTITY_TYPE(ConstrainedVariable); - static const LabelStr& NO_NAME() { - static const LabelStr sl_noName(NO_VAR_NAME); - return(sl_noName); - } + static const std::string& NO_NAME(); /** * Should not be called unless all constraints have been removed. @@ -70,11 +65,11 @@ namespace EUROPA { /** * @brief Simple accessor. */ - const ConstrainedVariableId& getId() const; + const ConstrainedVariableId getId() const; const std::string& getEntityType() const; - const DataTypeId& getDataType() const; + const DataTypeId getDataType() const; /** * @brief Validates the relationships of the class. @@ -100,12 +95,12 @@ namespace EUROPA { /** * @brief Retrive the count of constraints direclt on this variable */ - unsigned int constraintCount() const; + unsigned long constraintCount() const; /** * @brief Retrieve one constraint on this variable. Returns noId if there are none. */ - const ConstraintId& getFirstConstraint() const; + const ConstraintId getFirstConstraint() const; /** * @brief Test of the variable has at least one active constraint @@ -169,7 +164,7 @@ namespace EUROPA { * * @note I don't think this is adequate since it provides no * feedback whether the lock was acquired or not. - * --wedgingt@ptolemy.arc.nasa.gov 2004 Feb 11 + * --wedgingt 2004 Feb 11 * * CMG: Wrong. if you try lock, and already locked it will error * out. There is a method to test if a lock is already present. @@ -179,7 +174,7 @@ namespace EUROPA { * before either gets the lock and then both would try to get the * lock, causing one to error out despite following the * interface's requirement to test if unlocked first. - * --wedgingt@ptolemy.arc.nasa.gov 2004 Apr 21 + * --wedgingt 2004 Apr 21 * * This does not have any support in a multi-theraded environment. One must first * obtain a mutex elsewhere. Therefore, this is quite adequate. @@ -201,19 +196,19 @@ namespace EUROPA { /** * @brief Accessor for variable name. */ - const LabelStr& getName() const; + const std::string& getName() const; /** * @brief Convenience method to get at parents of variables. In some cases, * variables may not have a parent entity, so the default implementation * is to return noId. */ - const EntityId& parent() const; + const EntityId parent() const; /** * @brief Accessor for the ConstraintEngine */ - const ConstraintEngineId& getConstraintEngine() const; + const ConstraintEngineId getConstraintEngine() const; /** * @brief Utility to capture the state of the constraint. @@ -221,7 +216,7 @@ namespace EUROPA { virtual std::string toString() const; virtual std::string toLongString() const; - static const int NO_INDEX = -1; + static const unsigned long NO_INDEX = 0; /** * @brief Access the index. @@ -229,7 +224,7 @@ namespace EUROPA { * a ConstrainedVariable to have an index reflecting its location in the parent. * @return NO_INDEX if there is no parent, otherwise a value > 0 indicating a position relevant to the caller. */ - int getIndex() const; + unsigned long getIndex() const; /** * @brief Retrieve the last computed domain of the variable. @@ -322,12 +317,12 @@ namespace EUROPA { /** * @brief Supports the merging of variables by propagating messages on restriction of a base domain of a variable */ - virtual void handleBase(const Domain&) {} + virtual void handleBase(const Domain& dom); /** * @brief Supports the merging of variables by propagating messages on specification of a variable */ - virtual void handleSpecified(edouble value) {} + virtual void handleSpecified(edouble value); /** * @brief Supports the merging of variables by propagating message on reset of a specified domain @@ -337,12 +332,12 @@ namespace EUROPA { /** * @brief Hook up a listener to propagate notifications of deletion */ - void notifyAdded(const ConstrainedVariableListenerId& listener); + void notifyAdded(const ConstrainedVariableListenerId listener); /** * @brief Remove a listener */ - void notifyRemoved(const ConstrainedVariableListenerId& listener); + void notifyRemoved(const ConstrainedVariableListenerId listener); /** * @brief Utility to obtain a display version of a double encoded value. */ @@ -396,12 +391,12 @@ namespace EUROPA { * @param parent An optional parent entity reference. * @param index An optional index indicating the position in the parent entity collection. */ - ConstrainedVariable(const ConstraintEngineId& constraintEngine, + ConstrainedVariable(const ConstraintEngineId constraintEngine, const bool internal, bool canBeSpecified, - const LabelStr& name, - const EntityId& parent = EntityId::noId(), - int index = NO_INDEX); + const std::string& name, + const EntityId parent = EntityId::noId(), + unsigned long index = NO_INDEX); /** * @brief Allows subclass to add specific extra-work without over-riding core behavior. @@ -432,7 +427,7 @@ namespace EUROPA { friend class ConstraintEngine; /**< Grant access so the ConstraintEngine can reset the variable domain without exposing this behaviour publicly.*/ - friend class Propagator; /* - Id id(const ConstrainedVariableId& var){ - return var->baseDomain().getSingletonValue(); - } + // template + // Id id(const ConstrainedVariableId var){ + // return var->baseDomain().getSingletonValue(); + // } diff --git a/src/PLASMA/ConstraintEngine/base/Constraint.cc b/src/PLASMA/ConstraintEngine/base/Constraint.cc index fdd152d4e..8cc4f3588 100644 --- a/src/PLASMA/ConstraintEngine/base/Constraint.cc +++ b/src/PLASMA/ConstraintEngine/base/Constraint.cc @@ -10,67 +10,68 @@ namespace EUROPA { - Constraint::Constraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) +Constraint::Constraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) : Entity() , m_name(name) , m_constraintEngine(constraintEngine) , m_variables(variables) , m_violationExpl("") , m_id(this) + , m_propagator() , m_isUnary(true) , m_createdBy("UNKNOWN") , m_deactivationRefCount(0) , m_isRedundant(false) - { - check_error(m_constraintEngine.isValid()); - check_error(!m_variables.empty()); +{ + check_error(m_constraintEngine.isValid()); + check_error(!m_variables.empty()); - m_constraintEngine->add(m_id, propagatorName); - //m_entityId = m_id; + m_constraintEngine->add(m_id, propagatorName); + //m_entityId = m_id; - debugMsg("Constraint:Constraint", - "Creating constraint " << getKey() << ":" << name.toString() - << " propagator: " << propagatorName.toString() - << " arity: " << variables.size() - << " violationExpl: " << m_violationExpl.toString() - ); + debugMsg("Constraint:Constraint", + "Creating constraint " << getKey() << ":" << name + << " propagator: " << propagatorName + << " arity: " << variables.size() + << " violationExpl: " << m_violationExpl + ); - check_error(isValid()); + check_error(isValid()); - int variableCount = 0; - for (unsigned int i = 0; i < m_variables.size(); i++) { + int variableCount = 0; + for (unsigned int i = 0; i < m_variables.size(); i++) { - // To support determining if it is in fact a Unary, we test for the possible - // volatility of a variable. Extend this when locking comes on stream! - if(!m_variables[i]->baseDomain().isSingleton()) - variableCount++; + // To support determining if it is in fact a Unary, we test for the possible + // volatility of a variable. Extend this when locking comes on stream! + if(!m_variables[i]->baseDomain().isSingleton()) + variableCount++; - if(!m_variables[i]->isActive()) - m_deactivationRefCount++; + if(!m_variables[i]->isActive()) + m_deactivationRefCount++; - checkError(m_variables[i].isValid(), - "The argIndex " << i << " is not a valid variable for constraint " << name.toString()); + checkError(m_variables[i].isValid(), + "The argIndex " << i << " is not a valid variable for constraint " << name); - // It is important that the call to add the constraint is only made after the deactivation reference - // count has been adjusted since the former effects the active status of the constraint and that may be used by - // a handler in figuring how to treat the constraint - m_variables[i]->addConstraint(m_id, i); - } + // It is important that the call to add the constraint is only made after the deactivation reference + // count has been adjusted since the former effects the active status of the constraint and that may be used by + // a handler in figuring how to treat the constraint + m_variables[i]->addConstraint(m_id, i); + } - if(variableCount > 1) - m_isUnary = false; + if(variableCount > 1) + m_isUnary = false; - // Update if redundant immediately - notifyBaseDomainRestricted(m_variables[0]); + // Update if redundant immediately + notifyBaseDomainRestricted(m_variables[0]); - if(!isActive()){ - m_constraintEngine->notifyDeactivated(m_id); - handleDeactivate(); - } + if(!isActive()){ + m_constraintEngine->notifyDeactivated(m_id); + handleDeactivate(); } +} Constraint::~Constraint(){ debugMsg("Constraint:~Constraint", Entity::toString() << " Id=" << m_id); @@ -85,7 +86,7 @@ namespace EUROPA { } void Constraint::handleDiscard(){ - debugMsg("Constraint:handleDiscard", getName().toString() << "(" << getKey() << ") " << m_id); + debugMsg("Constraint:handleDiscard", getName() << "(" << getKey() << ") " << m_id); if(!Entity::isPurging()){ check_error(isValid()); @@ -109,16 +110,16 @@ namespace EUROPA { std::string Constraint::getViolationExpl() const { - if (m_violationExpl.toString().length() > 0) - return m_violationExpl.toString(); + if (m_violationExpl.length() > 0) + return m_violationExpl; std::ostringstream os; - os << getName().toString() << "("; + os << getName() << "("; for(unsigned int i=0;i 0) os << ","; - std::string name = m_variables[i]->getName().toString(); + std::string name = m_variables[i]->getName(); if (name.substr(0,4) != "$VAR") os << name << "(" << m_variables[i]->getKey() << ")"; else @@ -134,37 +135,36 @@ namespace EUROPA { m_violationExpl = msg; } - PSList Constraint::getVariables() const - { - PSList retval; - for(size_t i = 0; i < m_variables.size(); ++i) - { - ConstrainedVariableId id = m_variables[i]; - retval.push_back((PSVariable *) id); - } - return retval; +PSList Constraint::getVariables() const { + PSList retval; + for(std::vector::const_iterator it = m_variables.begin(); + it != m_variables.end(); ++it) { + ConstrainedVariableId id = *it; + retval.push_back(dynamic_cast(static_cast(id))); } + return retval; +} - const ConstraintId& Constraint::getId() const { + const ConstraintId Constraint::getId() const { return m_id; } - const LabelStr& Constraint::getName() const {return m_name;} +const std::string& Constraint::getName() const {return m_name;} - const PropagatorId& Constraint::getPropagator() const {return m_propagator;} + const PropagatorId Constraint::getPropagator() const {return m_propagator;} const std::vector& Constraint::getScope() const {return m_variables;} - const LabelStr& Constraint::getCreatedBy() const {return m_createdBy;} +const std::string& Constraint::getCreatedBy() const {return m_createdBy;} - void Constraint::setPropagator(const PropagatorId& propagator){ + void Constraint::setPropagator(const PropagatorId propagator){ check_error(m_propagator.isNoId()); check_error(propagator->getConstraintEngine() == m_constraintEngine); m_propagator = propagator; } - bool Constraint::isVariableOf(const ConstrainedVariableId& variable){ + bool Constraint::isVariableOf(const ConstrainedVariableId variable){ std::vector::iterator it = m_variables.begin(); while(it != m_variables.end()){ if (*it == variable) @@ -185,9 +185,9 @@ namespace EUROPA { m_variables[i]->setCurrentPropagatingConstraint(ConstraintId::noId()); } - void Constraint::execute(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) { + void Constraint::execute(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType) { for(unsigned int i=0;isetCurrentPropagatingConstraint(m_id); @@ -198,21 +198,22 @@ namespace EUROPA { m_variables[i]->setCurrentPropagatingConstraint(ConstraintId::noId()); } - void Constraint::handleExecute(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) { + void Constraint::handleExecute(const ConstrainedVariableId, + unsigned int, + const DomainListener::ChangeType&) { handleExecute(); } - bool Constraint::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) { + bool Constraint::canIgnore(const ConstrainedVariableId, + unsigned int, + const DomainListener::ChangeType&) { return false; } - const std::vector& Constraint::getModifiedVariables(const ConstrainedVariableId& variable) const { - return getScope(); - } +const std::vector& +Constraint::getModifiedVariables(const ConstrainedVariableId) const { + return getScope(); +} const std::vector& Constraint::getModifiedVariables() const { return getScope(); @@ -222,7 +223,7 @@ namespace EUROPA { * @todo Figure a way to propagate first and deactivate only after safe * propagation. */ - void Constraint::notifyBaseDomainRestricted(const ConstrainedVariableId& var) { + void Constraint::notifyBaseDomainRestricted(const ConstrainedVariableId var) { debugMsg("Constraint:notifyBaseDomainRestricted", "Base domain of " << var->toString() << " restricted in " << m_id->toString()); @@ -241,7 +242,7 @@ namespace EUROPA { /** * @brief Passed the variable to allow a quick exit test */ - bool Constraint::testIsRedundant(const ConstrainedVariableId& var) const { + bool Constraint::testIsRedundant(const ConstrainedVariableId var) const { if(var.isId() && (!var->baseDomain().isSingleton() || var->baseDomain().isOpen())) return false; @@ -260,7 +261,7 @@ namespace EUROPA { return true; } - Domain& Constraint::getCurrentDomain(const ConstrainedVariableId& var) { + Domain& Constraint::getCurrentDomain(const ConstrainedVariableId var) { check_error(var.isValid()); return var->getCurrentDomain(); @@ -322,7 +323,7 @@ namespace EUROPA { m_propagator->getConstraintEngine()->getViolationMgr().removeViolatedConstraint(m_id); } - std::vector makeScope(const ConstrainedVariableId& arg1){ + std::vector makeScope(const ConstrainedVariableId arg1){ std::vector scope; check_error(arg1.isValid()); @@ -331,8 +332,8 @@ namespace EUROPA { return scope; } - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2){ + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2){ check_error(arg1.isValid()); check_error(arg2.isValid()); @@ -341,88 +342,88 @@ namespace EUROPA { return scope; } - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3){ + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3){ check_error(arg3.isValid()); std::vector scope = makeScope(arg1, arg2); scope.push_back(arg3); return scope; } - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4){ + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4){ check_error(arg4.isValid()); std::vector scope = makeScope(arg1, arg2, arg3); scope.push_back(arg4); return scope; } - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5){ + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5){ check_error(arg5.isValid()); std::vector scope = makeScope(arg1, arg2, arg3, arg4); scope.push_back(arg5); return scope; } - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5, - const ConstrainedVariableId& arg6){ + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5, + const ConstrainedVariableId arg6){ check_error(arg6.isValid()); std::vector scope = makeScope(arg1, arg2, arg3, arg4, arg5); scope.push_back(arg6); return scope; } - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5, - const ConstrainedVariableId& arg6, - const ConstrainedVariableId& arg7){ + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5, + const ConstrainedVariableId arg6, + const ConstrainedVariableId arg7){ check_error(arg7.isValid()); std::vector scope = makeScope(arg1, arg2, arg3, arg4, arg5, arg6); scope.push_back(arg7); return scope; } - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5, - const ConstrainedVariableId& arg6, - const ConstrainedVariableId& arg7, - const ConstrainedVariableId& arg8){ + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5, + const ConstrainedVariableId arg6, + const ConstrainedVariableId arg7, + const ConstrainedVariableId arg8){ check_error(arg8.isValid()); std::vector scope = makeScope(arg1, arg2, arg3, arg4, arg5, arg6, arg7); scope.push_back(arg8); return scope; } - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5, - const ConstrainedVariableId& arg6, - const ConstrainedVariableId& arg7, - const ConstrainedVariableId& arg8, - const ConstrainedVariableId& arg9, - const ConstrainedVariableId& arg10, - const ConstrainedVariableId& arg11, - const ConstrainedVariableId& arg12, - const ConstrainedVariableId& arg13){ + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5, + const ConstrainedVariableId arg6, + const ConstrainedVariableId arg7, + const ConstrainedVariableId arg8, + const ConstrainedVariableId arg9, + const ConstrainedVariableId arg10, + const ConstrainedVariableId arg11, + const ConstrainedVariableId arg12, + const ConstrainedVariableId arg13){ check_error(arg13.isValid()); std::vector scope = makeScope(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); scope.push_back(arg9); @@ -447,8 +448,8 @@ namespace EUROPA { sstr << " ARG[" << i++ << "]:" << var->toLongString() << std::endl; } - if (m_violationExpl.toString().length()>0) - sstr << "{ViolationExpl:" << m_violationExpl.toString() << "}"; + if (m_violationExpl.length()>0) + sstr << "{ViolationExpl:" << m_violationExpl << "}"; return sstr.str(); } diff --git a/src/PLASMA/ConstraintEngine/base/Constraint.hh b/src/PLASMA/ConstraintEngine/base/Constraint.hh index 2eb1fa944..2bf58df5e 100644 --- a/src/PLASMA/ConstraintEngine/base/Constraint.hh +++ b/src/PLASMA/ConstraintEngine/base/Constraint.hh @@ -1,5 +1,5 @@ -#ifndef _H_Constraint -#define _H_Constraint +#ifndef H_Constraint +#define H_Constraint /** * @file Constraint.hh @@ -13,7 +13,6 @@ #include "ConstraintEngineDefs.hh" #include "PSConstraintEngine.hh" #include "DomainListener.hh" -#include "LabelStr.hh" #include #include @@ -58,9 +57,9 @@ namespace EUROPA { * @param constraintEngine The constraintEngine instance to wich the constraint belongs. There is exactly one. * @param variables The variables that will form the scope of the constraint. */ - Constraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + Constraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); virtual ~Constraint(); @@ -70,29 +69,29 @@ namespace EUROPA { /** * @brief Accessor */ - const ConstraintId& getId() const; + const ConstraintId getId() const; /** * @brief Accessor */ - const LabelStr& getName() const; + const std::string& getName() const; /** * @brief Accessor */ - const PropagatorId& getPropagator() const; + const PropagatorId getPropagator() const; /** * @brief Accessor */ - const LabelStr& getCreatedBy() const; + const std::string& getCreatedBy() const; /** * @brief Test if the given variable is constrained by this constraint. * @param variable The variable to test. * @return true if var is a member of the constraint scope */ - bool isVariableOf(const ConstrainedVariableId& variable); + bool isVariableOf(const ConstrainedVariableId variable); /** * @brief Check if the constraint is to be actively used in propagation. @@ -134,7 +133,7 @@ namespace EUROPA { * @brief Informs the constraint that it is a copy of another constraint. It is up to the receiever * to use this information or disregard it. */ - virtual void setSource(const ConstraintId& sourceConstraint) { + virtual void setSource(const ConstraintId sourceConstraint) { check_error(sourceConstraint.isValid()); } @@ -147,7 +146,7 @@ namespace EUROPA { * @brief Notification from a variable that its base domain has been retricted. May cause the constraint to be * deactivated */ - void notifyBaseDomainRestricted(const ConstrainedVariableId& var); + void notifyBaseDomainRestricted(const ConstrainedVariableId var); /** * @brief Test the status of redundant flag @@ -186,7 +185,7 @@ namespace EUROPA { * @brief Base implementation will require all variables in scope have the base domains as singletons. Over-ride * for weaker criteria which may apply for certain constraints. */ - virtual bool testIsRedundant(const ConstrainedVariableId& var = ConstrainedVariableId::noId()) const; + virtual bool testIsRedundant(const ConstrainedVariableId var = ConstrainedVariableId::noId()) const; friend class ConstraintEngine; /**< Grant access to protected event handler methods handleExecute, and canIgnore */ @@ -198,14 +197,16 @@ namespace EUROPA { * @param var The variable whose domain is requested. * @return A mutable reference to the domain. */ - static Domain& getCurrentDomain(const ConstrainedVariableId& var); + static Domain& getCurrentDomain(const ConstrainedVariableId var); /** * @brief Wrapper for handleExecute calls, will set propagation context for all the variables in this constraint * */ virtual void execute(); - virtual void execute(const ConstrainedVariableId& variable,int argIndex,const DomainListener::ChangeType& changeType); + virtual void execute(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); /** * @brief Called when no specific change event on a variable is reported. @@ -226,8 +227,8 @@ namespace EUROPA { * @param changeType - the nature of the change occuring in the given variable. * @see ConstraintEngine::execute(), ConstraintEngine::PENDING, DomainListener::ChangeType */ - virtual void handleExecute(const ConstrainedVariableId& variable, - int argIndex, + virtual void handleExecute(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); /** @@ -242,8 +243,8 @@ namespace EUROPA { * @return true if the event cannot impact the consistency of the Constraint given its current state. Othwerwise false. * @see ConstraintEngine::notify() */ - virtual bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, + virtual bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); @@ -256,7 +257,7 @@ namespace EUROPA { * @return the vector of variables that this constraint modifies. Defaults to the scope. * @see ConstraintEngine::getScope(), ConstraintEngine::handleRelax() */ - virtual const std::vector& getModifiedVariables(const ConstrainedVariableId& variable) const; + virtual const std::vector& getModifiedVariables(const ConstrainedVariableId variable) const; /** @@ -276,7 +277,6 @@ namespace EUROPA { /** * @brief Allow implementation class to take action in the event of deactivation - * @param delegate The constraint which will justify deactivation */ virtual void handleDeactivate(){} @@ -285,10 +285,10 @@ namespace EUROPA { */ virtual void handleDiscard(); - const LabelStr m_name; /**< Name used on stratup to bind to the correct factory and then present as a debugging aid. */ + const std::string m_name; /**< Name used on stratup to bind to the correct factory and then present as a debugging aid. */ const ConstraintEngineId m_constraintEngine; /**< The owner ConstraintEngine */ std::vector m_variables; /**< The variable scope of the Constraint. */ - LabelStr m_violationExpl; /**< optional explanation string, typically coming from the model */ + std::string m_violationExpl; /**< optional explanation string, typically coming from the model */ private: /** @@ -296,7 +296,7 @@ namespace EUROPA { * relationships. * @param propagator The single Propagator in the ConstraintEngine that can accept this constraint. */ - void setPropagator(const PropagatorId& propagator); + void setPropagator(const PropagatorId propagator); bool isValid() const; @@ -305,67 +305,67 @@ namespace EUROPA { ConstraintId m_id; /**< Self reference */ PropagatorId m_propagator; /**< The owner Propagator. */ bool m_isUnary; /**< True if constructed with a single variable */ - const LabelStr m_createdBy; /**< Populated on construction. Indicates the user that created the constraint. */ + const std::string m_createdBy; /**< Populated on construction. Indicates the user that created the constraint. */ unsigned int m_deactivationRefCount; /*!< Tracks number of outstanding deactivation calls */ bool m_isRedundant; /*!< True of the constraint is redundant */ }; - std::vector makeScope(const ConstrainedVariableId& arg1); - - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2); - - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3); - - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4); - - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5); - - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5, - const ConstrainedVariableId& arg6); - - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5, - const ConstrainedVariableId& arg6, - const ConstrainedVariableId& arg7); - - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5, - const ConstrainedVariableId& arg6, - const ConstrainedVariableId& arg7, - const ConstrainedVariableId& arg8); - - std::vector makeScope(const ConstrainedVariableId& arg1, - const ConstrainedVariableId& arg2, - const ConstrainedVariableId& arg3, - const ConstrainedVariableId& arg4, - const ConstrainedVariableId& arg5, - const ConstrainedVariableId& arg6, - const ConstrainedVariableId& arg7, - const ConstrainedVariableId& arg8, - const ConstrainedVariableId& arg9, - const ConstrainedVariableId& arg10, - const ConstrainedVariableId& arg11, - const ConstrainedVariableId& arg12, - const ConstrainedVariableId& arg13); + std::vector makeScope(const ConstrainedVariableId arg1); + + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2); + + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3); + + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4); + + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5); + + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5, + const ConstrainedVariableId arg6); + + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5, + const ConstrainedVariableId arg6, + const ConstrainedVariableId arg7); + + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5, + const ConstrainedVariableId arg6, + const ConstrainedVariableId arg7, + const ConstrainedVariableId arg8); + + std::vector makeScope(const ConstrainedVariableId arg1, + const ConstrainedVariableId arg2, + const ConstrainedVariableId arg3, + const ConstrainedVariableId arg4, + const ConstrainedVariableId arg5, + const ConstrainedVariableId arg6, + const ConstrainedVariableId arg7, + const ConstrainedVariableId arg8, + const ConstrainedVariableId arg9, + const ConstrainedVariableId arg10, + const ConstrainedVariableId arg11, + const ConstrainedVariableId arg12, + const ConstrainedVariableId arg13); } #endif diff --git a/src/PLASMA/ConstraintEngine/base/ConstraintEngine.cc b/src/PLASMA/ConstraintEngine/base/ConstraintEngine.cc index cbba08439..38e98fa84 100644 --- a/src/PLASMA/ConstraintEngine/base/ConstraintEngine.cc +++ b/src/PLASMA/ConstraintEngine/base/ConstraintEngine.cc @@ -9,14 +9,12 @@ #include "Utils.hh" #include "Debug.hh" #include "DomainListener.hh" +#include "ConstraintType.hh" +#include "CESchema.hh" #include #include -#ifndef INT_MAX -static int const INT_MAX(std::numeric_limits::max()); -#endif - namespace EUROPA { @@ -58,7 +56,8 @@ namespace EUROPA }; ViolationMgrImpl::ViolationMgrImpl(unsigned int maxViolationsAllowed, ConstraintEngine& ce) - : m_maxViolationsAllowed(maxViolationsAllowed), m_relaxing(false), m_ce(ce) + : m_maxViolationsAllowed(maxViolationsAllowed), m_violatedConstraints(), + m_emptyVariables(), m_relaxing(false), m_ce(ce) { } @@ -104,15 +103,14 @@ namespace EUROPA return retval; } - PSList ViolationMgrImpl::getAllViolations() const - { - PSList retval; - for (ConstraintSet::const_iterator it = m_violatedConstraints.begin(); it != m_violatedConstraints.end(); ++it) { - ConstraintId id = *it; - retval.push_back((PSConstraint *) id); - } - return retval; +PSList ViolationMgrImpl::getAllViolations() const { + PSList retval; + for (ConstraintSet::const_iterator it = m_violatedConstraints.begin(); it != m_violatedConstraints.end(); ++it) { + ConstraintId id = *it; + retval.push_back(id_cast(id)); } + return retval; +} bool ViolationMgrImpl::isViolated(ConstraintId c) const { @@ -230,22 +228,21 @@ namespace EUROPA m_relaxing = false; } -#ifndef _MSC_VER - static bool allActiveVariables(const std::vector& vars) check_error_function; -#endif - static bool allActiveVariables(const std::vector& vars) { - for (std::vector::const_iterator it = vars.begin(); it != vars.end(); ++it) { - ConstrainedVariableId var = *it; - check_error(var.isValid()); - condDebugMsg(!var->isActive(), "allActiveVariables", - var->toString() << " is not active but it participates in an active constraint."); - +namespace { +bool allActiveVariables(const std::vector& vars) { + for (std::vector::const_iterator it = vars.begin(); it != vars.end(); ++it) { + ConstrainedVariableId var = *it; + check_error(var.isValid()); + condDebugMsg(!var->isActive(), "allActiveVariables", + var->toString() << " is not active but it participates in an active constraint."); + if(!var->isActive()) - return false; - } - - return true; + return false; } + + return true; +} +} std::string DomainListener::toString(const ChangeType& changeType){ switch (changeType) { @@ -281,7 +278,7 @@ namespace EUROPA #define notifyMsg(Event, Source) \ condDebugMsg(changeType == DomainListener::Event, \ "ConstraintEngine:notify", \ - Source->getName().toString() << " (" << Source->getKey() << ") " << \ + Source->getName() << " (" << Source->getKey() << ") " << \ DomainListener::toString(changeType) << " => " << Source->lastDomain()); #define publish(message){ \ @@ -292,15 +289,19 @@ namespace EUROPA } /** DEFINE CONSTANTS DECLARED IN COMMON DEFS **/ - DEFINE_GLOBAL_CONST(char*, g_noVarName, "NO_NAME"); + DEFINE_GLOBAL_CONST(std::string, g_noVarName, "NO_NAME"); - DomainListenerId ConstraintEngine::allocateVariableListener(const ConstrainedVariableId& variable, - const ConstraintList& constraints) const{ - return ((new VariableChangeListener(variable, m_id))->getId()); - } +DomainListenerId ConstraintEngine::allocateVariableListener(const ConstrainedVariableId variable, + const ConstraintList&) const{ + return ((new VariableChangeListener(variable, m_id))->getId()); +} - ConstraintEngine::ConstraintEngine(const CESchemaId& schema) + ConstraintEngine::ConstraintEngine(const CESchemaId schema) : m_id(this) + , m_variables() + , m_constraints() + , m_propagators() + , m_propagatorsByName() , m_relaxing(false) , m_relaxingViolation(false) //, m_relaxed(false) @@ -311,8 +312,12 @@ namespace EUROPA , m_dirty(false) , m_cycleCount(1) , m_mostRecentRepropagation(1) + , m_listeners() + , m_redundantConstraints() + , m_violationMgr(NULL) , m_autoPropagate(true) , m_schema(schema) + , m_callbacks() { m_violationMgr = new ViolationMgrImpl(0, *this); } @@ -349,12 +354,12 @@ namespace EUROPA } } - const ConstraintEngineId& ConstraintEngine::getId() const + const ConstraintEngineId ConstraintEngine::getId() const { return(m_id); } - const CESchemaId& ConstraintEngine::getCESchema() const + const CESchemaId ConstraintEngine::getCESchema() const { return m_schema; } @@ -389,7 +394,7 @@ namespace EUROPA for(std::list::iterator it = m_callbacks.begin(); it != m_callbacks.end(); ++it) { PostPropagationCallbackId callback = *it; check_error(callback.isValid()); - delete (PostPropagationCallback*) callback; + delete static_cast(callback); } } @@ -420,7 +425,7 @@ namespace EUROPA (*it)->constraints(constrs); for(std::set::const_iterator temp = constrs.begin(); temp != constrs.end(); ++temp) { condDebugMsg((*temp)->isActive(), "ConstraintEngine:pending", - " " << (*temp)->getName().toString() << "(" << (*temp)->getKey() << ")"); + " " << (*temp)->getName() << "(" << (*temp)->getKey() << ")"); } } condDebugMsg(provenInconsistent(), "ConstraintEngine:pending", "Proven inconsistent."); @@ -432,16 +437,16 @@ namespace EUROPA return m_propInProgress; } - void ConstraintEngine::add(const ConstrainedVariableId& variable){ + void ConstraintEngine::add(const ConstrainedVariableId variable){ check_error(m_variables.find(variable) == m_variables.end()); m_variables.insert(variable); publish(notifyAdded(variable)); debugMsg("ConstraintEngine:add:ConstrainedVariable", - variable->getName().toString() << "(" << variable->getKey() << ")"); + variable->getName() << "(" << variable->getKey() << ")"); } - void ConstraintEngine::remove(const ConstrainedVariableId& variable){ + void ConstraintEngine::remove(const ConstrainedVariableId variable){ check_error(!m_propInProgress); /*!< Prohibit relaxations during propagation */ check_error(m_variables.find(variable) != m_variables.end()); m_variables.erase(variable); @@ -455,36 +460,36 @@ namespace EUROPA publish(notifyRemoved(variable)); debugMsg("ConstraintEngine:remove:ConstrainedVariable", - variable->getName().toString() << "(" << variable->getKey() << ")"); + variable->getName() << "(" << variable->getKey() << ")"); } - void ConstraintEngine::add(const ConstraintId& constraint, const LabelStr& propagatorName){ - check_error(m_constraints.find(constraint) == m_constraints.end(), - "Attempted to add constraint " + constraint->getName().toString() + " but it already exists."); - check_error(m_propagatorsByName.find(propagatorName.getKey()) != m_propagatorsByName.end(), - "Propagator " + propagatorName.toString() + " has not been registered."); +void ConstraintEngine::add(const ConstraintId constraint, const std::string& propagatorName){ + check_error(m_constraints.find(constraint) == m_constraints.end(), + "Attempted to add constraint " + constraint->getName() + " but it already exists."); + check_error(m_propagatorsByName.find(propagatorName) != m_propagatorsByName.end(), + "Propagator " + propagatorName + " has not been registered."); - m_constraints.insert(constraint); + m_constraints.insert(constraint); - // If constraint initially redundant, then store it. - if(constraint->isRedundant()) - m_redundantConstraints.insert(constraint); + // If constraint initially redundant, then store it. + if(constraint->isRedundant()) + m_redundantConstraints.insert(constraint); - PropagatorId propagator = m_propagatorsByName.find(propagatorName.getKey())->second; - propagator->addConstraint(constraint); - constraint->setPropagator(propagator); + PropagatorId propagator = m_propagatorsByName.find(propagatorName)->second; + propagator->addConstraint(constraint); + constraint->setPropagator(propagator); - publish(notifyAdded(constraint)); - debugMsg("ConstraintEngine:add:constraint:Propagator", - constraint->toLongString() << std::endl << " added to " << propagatorName.toString()); - //constraint->getName().toString() << "(" << constraint->getKey() << ") added to " << propagatorName.toString()); - } + publish(notifyAdded(constraint)); + debugMsg("ConstraintEngine:add:constraint:Propagator", + constraint->toLongString() << std::endl << " added to " << propagatorName); + //constraint->getName().toString() << "(" << constraint->getKey() << ") added to " << propagatorName.toString()); +} /** * Process removals even if purging, since compound constraints will cause multiple * deletions and so we have to synchronize the set. */ - void ConstraintEngine::remove(const ConstraintId& constraint){ + void ConstraintEngine::remove(const ConstraintId constraint){ check_error(m_constraints.find(constraint) != m_constraints.end()); check_error(!m_propInProgress); /*!< Prohibit relaxations during propagation */ m_constraints.erase(constraint); @@ -498,7 +503,7 @@ namespace EUROPA // If the constraint is inactive, there is no need to relax. So just worry if it is actually active if(constraint->isActive()){ debugMsg("ConstraintEngine:remove:Constraint", - "Propagating relaxations for " << constraint->getName().toString() << "(" << constraint->getKey() << ")"); + "Propagating relaxations for " << constraint->getName() << "(" << constraint->getKey() << ")"); const std::vector& scope = constraint->getModifiedVariables(); for(std::vector::const_iterator it = scope.begin(); it != scope.end(); ++it){ @@ -511,63 +516,65 @@ namespace EUROPA publish(notifyRemoved(constraint)); debugMsg("ConstraintEngine:remove:Constraint", - constraint->getName().toString() << "(" << constraint->getKey() << ")"); + constraint->getName() << "(" << constraint->getKey() << ")"); } - void ConstraintEngine::add(const PropagatorId& propagator){ - check_error(propagator.isValid()); - std::map::iterator it = m_propagatorsByName.find(propagator->getName().getKey()); - if(it != m_propagatorsByName.end()) { - europaWarn("Overwriting propagator named " + propagator->getName().toString()); - m_propagators.erase(std::find(m_propagators.begin(), m_propagators.end(), it->second)); - it->second->discard(); - m_propagatorsByName.erase(it); - } - size_t before = m_propagators.size(); - m_propagators.insert(propagator); - m_propagatorsByName.insert(std::make_pair(propagator->getName().getKey(), propagator)); - - debugMsg("ConstraintEngine:add:Propagator", propagator->getName().toString() << "cntBefore="<getName()); + m_propagators.erase(std::find(m_propagators.begin(), m_propagators.end(), it->second)); + it->second->discard(); + m_propagatorsByName.erase(it); } + size_t before = m_propagators.size(); + m_propagators.insert(propagator); + m_propagatorsByName.insert(std::make_pair(propagator->getName(), propagator)); + + debugMsg("ConstraintEngine:add:Propagator", + propagator->getName() << "cntBefore="<getName().toString() << "(" << deactivatedConstraint->getKey() << ")"); + deactivatedConstraint->getName() << "(" << deactivatedConstraint->getKey() << ")"); } - void ConstraintEngine::notifyActivated(const ConstraintId& constraint){ + void ConstraintEngine::notifyActivated(const ConstraintId constraint){ check_error(!Entity::isPurging()); check_error(constraint.isValid() && constraint->isActive()); constraint->getPropagator()->handleConstraintActivated(constraint); publish(notifyActivated(constraint)); condDebugMsg(constraint->isRedundant(), "ConstraintEngine:notifyRedundant:Constraint", - constraint->getName().toString() << "(" << constraint->getKey() << ")"); + constraint->getName() << "(" << constraint->getKey() << ")"); condDebugMsg(!constraint->isRedundant(), "ConstraintEngine:notifyActivated:Constraint", - constraint->getName().toString() << "(" << constraint->getKey() << ")"); + constraint->getName() << "(" << constraint->getKey() << ")"); } - void ConstraintEngine::notifyRedundant(const ConstraintId& redundantConstraint){ + void ConstraintEngine::notifyRedundant(const ConstraintId redundantConstraint){ debugMsg("ConstraintEngine:notifyRedundant", redundantConstraint->toString()); // If active, want to push it on the agenda for propagation @@ -577,7 +584,7 @@ namespace EUROPA } } - void ConstraintEngine::notifyDeactivated(const ConstrainedVariableId& var){ + void ConstraintEngine::notifyDeactivated(const ConstrainedVariableId var){ check_error(!Entity::isPurging()); check_error(var.isValid() && !var->isActive()); @@ -589,10 +596,10 @@ namespace EUROPA publish(notifyDeactivated(var)); debugMsg("ConstraintEngine:notifyDeactivated:ConstrainedVariable", - var->getName().toString() << "(" << var->getKey() << ")"); + var->getName() << "(" << var->getKey() << ")"); } - void ConstraintEngine::notifyActivated(const ConstrainedVariableId& var){ + void ConstraintEngine::notifyActivated(const ConstrainedVariableId var){ check_error(!Entity::isPurging()); check_error(var.isValid() && var->isActive()); @@ -604,7 +611,7 @@ namespace EUROPA publish(notifyActivated(var)); debugMsg("ConstraintEngine:notifyActivated:ConstrainedVariable", - var->getName().toString() << "(" << var->getKey() << ")"); + var->getName() << "(" << var->getKey() << ")"); } std::string ConstraintEngine::dumpPropagatorState(const PropagatorSet& propagators) const @@ -614,7 +621,7 @@ namespace EUROPA os << std::endl; for(PropagatorSet::const_iterator it = propagators.begin(); it != propagators.end(); ++it){ PropagatorId propagator = *it; - os << propagator->getName().toString() << "("; + os << propagator->getName() << "("; const std::set& constraints = propagator->getConstraints(); int i=0; @@ -622,7 +629,7 @@ namespace EUROPA if (i>0) os << ","; i++; - os << (*cit)->getName().toString(); + os << (*cit)->getName(); } os << ")"; @@ -692,7 +699,7 @@ namespace EUROPA } debugMsg("ConstraintEngine:propagate", - "Executing " << activePropagator->getName().toString() << " propagator."); + "Executing " << activePropagator->getName() << " propagator."); activePropagator->execute(); activePropagator = getNextPropagator(); } @@ -762,50 +769,52 @@ namespace EUROPA return result; } - void ConstraintEngine::notify(const ConstrainedVariableId& source, const DomainListener::ChangeType& changeType){ - check_error(!Entity::isPurging()); - check_error(source.isValid()); - - m_dirty = true; - - // If variable is inavtice, no impact. - if(!source->isActive()) - return; - - if(changeType == DomainListener::EMPTIED) - handleEmpty(source); - else if (changeType == DomainListener::RELAXED || - changeType == DomainListener::OPENED) - handleRelax(source); - else - handleRestrict(source); - - - // In all cases, notify the propagators as well, unless over-ruled by by an empty variable or a decision to ignore it - for(ConstraintList::const_iterator it = source->m_constraints.begin(); it != source->m_constraints.end(); ++it){ - const ConstraintId& constraint = it->first; - checkError(constraint.isValid(), "Constraint is invalid on " << source->toLongString()); - unsigned int argIndex = it->second; - if(constraint->isActive() && !constraint->isDiscarded() && - changeType != DomainListener::EMPTIED && !constraint->canIgnore(source, argIndex, changeType)) - constraint->getPropagator()->handleNotification(source, argIndex, constraint, changeType); - } - - publish(notifyChanged(source, changeType)); - - notifyMsg(UPPER_BOUND_DECREASED, source); - notifyMsg(LOWER_BOUND_INCREASED, source); - notifyMsg(BOUNDS_RESTRICTED, source); - notifyMsg(VALUE_REMOVED, source); - notifyMsg(RESTRICT_TO_SINGLETON, source); - notifyMsg(SET_TO_SINGLETON, source); - notifyMsg(RESET, source); - notifyMsg(RELAXED, source); - notifyMsg(CLOSED, source); - notifyMsg(EMPTIED, source); - } +void ConstraintEngine::notify(const ConstrainedVariableId source, + const DomainListener::ChangeType& changeType){ + check_error(!Entity::isPurging()); + check_error(source.isValid()); + + m_dirty = true; + + // If variable is inavtice, no impact. + if(!source->isActive()) + return; + + if(changeType == DomainListener::EMPTIED) + handleEmpty(source); + else if (changeType == DomainListener::RELAXED || + changeType == DomainListener::OPENED) + handleRelax(source); + else + handleRestrict(source); + + + // In all cases, notify the propagators as well, unless over-ruled by by an empty variable or a decision to ignore it + for(ConstraintList::const_iterator it = source->m_constraints.begin(); it != source->m_constraints.end(); ++it){ + const ConstraintId constraint = it->first; + checkError(constraint.isValid(), "Constraint is invalid on " << source->toLongString()); + unsigned int argIndex = it->second; + if(constraint->isActive() && !constraint->isDiscarded() && + changeType != DomainListener::EMPTIED && + !constraint->canIgnore(source, argIndex, changeType)) + constraint->getPropagator()->handleNotification(source, argIndex, constraint, changeType); + } + + publish(notifyChanged(source, changeType)); + + notifyMsg(UPPER_BOUND_DECREASED, source); + notifyMsg(LOWER_BOUND_INCREASED, source); + notifyMsg(BOUNDS_RESTRICTED, source); + notifyMsg(VALUE_REMOVED, source); + notifyMsg(RESTRICT_TO_SINGLETON, source); + notifyMsg(SET_TO_SINGLETON, source); + notifyMsg(RESET, source); + notifyMsg(RELAXED, source); + notifyMsg(CLOSED, source); + notifyMsg(EMPTIED, source); +} - void ConstraintEngine::handleEmpty(const ConstrainedVariableId& variable){ + void ConstraintEngine::handleEmpty(const ConstrainedVariableId variable){ check_error(variable.isValid()); check_error(variable->getCurrentDomain().isEmpty()); @@ -820,7 +829,7 @@ namespace EUROPA getViolationMgr().handleEmpty(variable); } - void ConstraintEngine::handleRelax(const ConstrainedVariableId& variable) { + void ConstraintEngine::handleRelax(const ConstrainedVariableId variable) { check_error(variable.isValid()); check_error(!m_propInProgress); /*!< Prohibit relaxations during propagation */ @@ -870,7 +879,7 @@ namespace EUROPA for(std::list::iterator it = relaxationAgenda.begin(); it != relaxationAgenda.end(); ++it) { - const ConstrainedVariableId& id(*it); + const ConstrainedVariableId id(*it); checkError(id.isValid(), "Invalid ID in relax"); if(getVariables().find(id) != getVariables().end() && id->lastRelaxed() < m_cycleCount) { @@ -885,12 +894,12 @@ namespace EUROPA m_relaxing = false; } - void ConstraintEngine::handleRestrict(const ConstrainedVariableId& var) { + void ConstraintEngine::handleRestrict(const ConstrainedVariableId var) { check_error(var.isValid()); m_relaxed.erase(var); } - void ConstraintEngine::execute(const ConstraintId& constraint){ + void ConstraintEngine::execute(const ConstraintId constraint){ check_error(!provenInconsistent() && constraint.isValid()); check_error(constraint->isActive()); check_error(constraint->isValid()); @@ -906,9 +915,9 @@ namespace EUROPA debugMsg("ConstraintEngine:execute", "AFTER " << constraint->toLongString()); } - void ConstraintEngine::execute(const ConstraintId& constraint, - const ConstrainedVariableId& variable, - int argIndex, + void ConstraintEngine::execute(const ConstraintId constraint, + const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType){ check_error(!provenInconsistent() && constraint.isValid()); check_error(constraint->isActive()); @@ -916,7 +925,7 @@ namespace EUROPA check_error(constraint->isValid()); check_error(m_propInProgress); publish(notifyExecuted(constraint)); - debugMsg("ConstraintEngine:execute", constraint->getName().toString() << "(" << constraint->getKey() << ")"); + debugMsg("ConstraintEngine:execute", constraint->getName() << "(" << constraint->getKey() << ")"); constraint->execute(variable, argIndex, changeType); } @@ -970,7 +979,7 @@ namespace EUROPA * The naive implementation will just scan through the set with an iterator. Will have to find a faster way. * @see getVariable */ - unsigned int ConstraintEngine::getIndex(const ConstrainedVariableId& var){ + unsigned int ConstraintEngine::getIndex(const ConstrainedVariableId var){ check_error(var.isValid()); unsigned int index = 0; for(ConstrainedVariableSet::const_iterator it = m_variables.begin(); it != m_variables.end(); ++it){ @@ -994,20 +1003,20 @@ namespace EUROPA return *it; } - unsigned int ConstraintEngine::getIndex(const ConstraintId& constr) { + unsigned int ConstraintEngine::getIndex(const ConstraintId constr) { check_error(constr.isValid()); ConstraintSet::iterator it = m_constraints.find(constr); check_error(it != m_constraints.end()); check_error(it->isValid()); - return (unsigned int) std::distance(m_constraints.begin(), it); + return static_cast(std::distance(m_constraints.begin(), it)); } - const PropagatorId& ConstraintEngine::getPropagatorByName(const LabelStr& name) const { - if (m_propagatorsByName.find(name.getKey()) == m_propagatorsByName.end()) - return PropagatorId::noId(); - else - return(m_propagatorsByName.find(name.getKey())->second); - } +const PropagatorId ConstraintEngine::getPropagatorByName(const std::string& name) const { + if (m_propagatorsByName.find(name) == m_propagatorsByName.end()) + return PropagatorId::noId(); + else + return(m_propagatorsByName.find(name)->second); +} /** * @brief Process redundant constraints @@ -1036,7 +1045,7 @@ namespace EUROPA void ConstraintEngine::setAllowViolations(bool v) { if (v) - m_violationMgr->setMaxViolationsAllowed((unsigned int)INT_MAX); + m_violationMgr->setMaxViolationsAllowed(std::numeric_limits::max()); else m_violationMgr->setMaxViolationsAllowed(0); } @@ -1086,116 +1095,113 @@ namespace EUROPA } // TODO: this needs to be optimized - PSVariable* ConstraintEngine::getVariableByName(const std::string& name) - { - const ConstrainedVariableSet& vars = getVariables(); - for(ConstrainedVariableSet::const_iterator it = vars.begin(); it != vars.end(); ++it) { - ConstrainedVariableId id = *it; - if (id->getName().toString() == name) - return (PSVariable *) id; +PSVariable* ConstraintEngine::getVariableByName(const std::string& name) { + const ConstrainedVariableSet& vars = getVariables(); + for(ConstrainedVariableSet::const_iterator it = vars.begin(); it != vars.end(); ++it) { + ConstrainedVariableId id = *it; + if (id->getName() == name) + return id_cast(id); + } + return NULL; +} + + +int ConstraintEngine::addLinkedVarsForRelaxation(const ConstrainedVariableId var, + std::list& dest, + std::list::iterator pos, + ConstrainedVariableSet& visitedVars) { + int count = 0; + for(ConstraintList::const_iterator cIt = var->m_constraints.begin(); + cIt != var->m_constraints.end(); ++cIt) { + const ConstraintId constr = cIt->first; + if(constr->isActive()) { + const std::vector& scope = constr->getModifiedVariables(var); + for(std::vector::const_iterator vIt = scope.begin(); + vIt != scope.end(); ++vIt) { + const ConstrainedVariableId id = *vIt; + + // If a var is specified, relaxation won't change it, so don't add it to the agenda + if((!id->isSpecified()) && (visitedVars.find(id) == visitedVars.end()) && + (id->lastRelaxed() < m_cycleCount)) { + debugMsg("ConstraintEngine:relaxed", + "Cycle: " << m_cycleCount << " From " << var->getName() << + "(" << var->getKey() << "), through constraint " << + constr->getName() << "(" << constr->getKey() << + "), adding " << id->getName() << "(" << id->getKey() << + ") to the relaxation agenda."); + visitedVars.insert(id); + dest.insert(pos, id); + ++count; + } + } } - return NULL; - } - - - int ConstraintEngine::addLinkedVarsForRelaxation(const ConstrainedVariableId& var, - std::list& dest, - std::list::iterator pos, - ConstrainedVariableSet& visitedVars) { - int count = 0; - for(ConstraintList::const_iterator cIt = var->m_constraints.begin(); - cIt != var->m_constraints.end(); ++cIt) { - const ConstraintId& constr = cIt->first; - if(constr->isActive()) { - const std::vector& scope = constr->getModifiedVariables(var); - for(std::vector::const_iterator vIt = scope.begin(); - vIt != scope.end(); ++vIt) { - const ConstrainedVariableId& id = *vIt; - - // If a var is specified, relaxation won't change it, so don't add it to the agenda - if((!id->isSpecified()) && (visitedVars.find(id) == visitedVars.end()) && (id->lastRelaxed() < m_cycleCount)) { - debugMsg("ConstraintEngine:relaxed", - "Cycle: " << m_cycleCount << " From " << var->getName().toString() << - "(" << var->getKey() << "), through constraint " << - constr->getName().toString() << "(" << constr->getKey() << - "), adding " << id->getName().toString() << "(" << id->getKey() << - ") to the relaxation agenda."); - visitedVars.insert(id); - dest.insert(pos, id); - ++count; - } - } - } - } - return count; } + return count; +} - ConstrainedVariableId - ConstraintEngine::createVariable(const char* typeName, - const bool internal, - bool canBeSpecified, - const char* name, - const EntityId& parent, - int index) - { - DataTypeId dt = getCESchema()->getDataType(typeName); - check_error(dt.isValid(), "no DataType found for type '" + std::string(typeName) + "'"); - return createVariable(typeName, dt->baseDomain(), internal, canBeSpecified, name, parent, index); - } +ConstrainedVariableId +ConstraintEngine::createVariable(const std::string& typeName, + const bool internal, + bool canBeSpecified, + const std::string& name, + const EntityId parent, + unsigned int index) { + DataTypeId dt = getCESchema()->getDataType(typeName); + check_error(dt.isValid(), "no DataType found for type '" + std::string(typeName) + "'"); + return createVariable(typeName, dt->baseDomain(), internal, canBeSpecified, name, parent, index); +} - ConstrainedVariableId - ConstraintEngine::createVariable(const char* typeName, - const Domain& baseDomain, - const bool internal, - bool canBeSpecified, - const char* name, - const EntityId& parent, - int index) - { - DataTypeId dt = getCESchema()->getDataType(typeName); - check_error(dt.isValid(), "no DataType found for type '" + std::string(typeName) + "'"); - ConstrainedVariableId variable = dt->createVariable(getId(), baseDomain, internal, canBeSpecified, name, parent, index); - check_error(variable.isValid()); - return variable; - } +ConstrainedVariableId +ConstraintEngine::createVariable(const std::string& typeName, + const Domain& baseDomain, + const bool internal, + bool canBeSpecified, + const std::string& name, + const EntityId parent, + unsigned int index) { + DataTypeId dt = getCESchema()->getDataType(typeName); + check_error(dt.isValid(), "no DataType found for type '" + std::string(typeName) + "'"); + ConstrainedVariableId variable = dt->createVariable(getId(), baseDomain, internal, canBeSpecified, name, parent, index); + check_error(variable.isValid()); + return variable; +} - ConstraintId ConstraintEngine::createConstraint(const LabelStr& name, - const std::vector& scope, - const char* violationExpl) - { - ConstraintTypeId factory = getCESchema()->getConstraintType(name); - check_error(factory.isValid()); - ConstraintId constraint = factory->createConstraint(getId(), scope, violationExpl); +ConstraintId ConstraintEngine::createConstraint(const std::string& name, + const std::vector& scope, + const std::string& violationExpl) { + ConstraintTypeId factory = getCESchema()->getConstraintType(name); + check_error(factory.isValid()); + ConstraintId constraint = factory->createConstraint(getId(), scope, violationExpl); - if (shouldAutoPropagate()) - propagate(); + if (shouldAutoPropagate()) + propagate(); - debugMsg("ConstraintEngine:createConstraint","Created Constraint:" << constraint->toLongString()); - return(constraint); - } + debugMsg("ConstraintEngine:createConstraint","Created Constraint:" << constraint->toLongString()); + return(constraint); +} - void ConstraintEngine::deleteConstraint(const ConstraintId& c) + void ConstraintEngine::deleteConstraint(const ConstraintId c) { check_error(c.isValid()); - delete (Constraint*)c; + delete static_cast(c); if (shouldAutoPropagate()) propagate(); } - edouble ConstraintEngine::createValue(const char* typeName, const std::string& value) + edouble ConstraintEngine::createValue(const std::string& typeName, const std::string& value) { DataTypeId dt = getCESchema()->getDataType(typeName); check_error(dt.isValid(), "no DataType found for type '" + std::string(typeName) + "'"); return dt->createValue(value); } - void ConstraintEngine::addCallback(const PostPropagationCallbackId& callback) { + void ConstraintEngine::addCallback(const PostPropagationCallbackId callback) { m_callbacks.push_back(callback); } - void ConstraintEngine::removeCallback(const PostPropagationCallbackId& callback) { + void ConstraintEngine::removeCallback(const PostPropagationCallbackId callback) { m_callbacks.remove(callback); callback->setConstraintEngine(ConstraintEngineId::noId()); } diff --git a/src/PLASMA/ConstraintEngine/base/ConstraintEngine.hh b/src/PLASMA/ConstraintEngine/base/ConstraintEngine.hh index dfa1ab93a..48113bcc8 100644 --- a/src/PLASMA/ConstraintEngine/base/ConstraintEngine.hh +++ b/src/PLASMA/ConstraintEngine/base/ConstraintEngine.hh @@ -1,5 +1,5 @@ -#ifndef _H_ConstraintEngine -#define _H_ConstraintEngine +#ifndef H_ConstraintEngine +#define H_ConstraintEngine /** * @file ConstraintEngine.hh @@ -11,13 +11,10 @@ #include "ConstraintEngineDefs.hh" #include "PSConstraintEngine.hh" -#include "CESchema.hh" #include "DomainListener.hh" -#include "LabelStr.hh" -#include "ConstraintEngineListener.hh" #include "Entity.hh" -#include "Engine.hh" #include "Propagator.hh" +#include "ConstrainedVariable.hh" #include #include @@ -25,6 +22,9 @@ namespace EUROPA { +class ConstraintEngineListener; +typedef Id ConstraintEngineListenerId; + class ViolationMgr { public: @@ -122,6 +122,7 @@ namespace EUROPA { enum Event { UPPER_BOUND_DECREASED = 0, /**< If the upper bound of an interval domain is reduced. */ LOWER_BOUND_INCREASED, /**< If the lower bound of an interval domain is increased. */ + REFTIME_CHANGED, /**< PHM Support for reftime calculations. */ BOUNDS_RESTRICTED, /**< Both upper and lower are decreased and increased respectively. */ VALUE_REMOVED, /**< A restriction to an enumerated domain. */ RESTRICT_TO_SINGLETON, /**< A restriction of the domain to a singleton value through inference. */ @@ -146,12 +147,12 @@ namespace EUROPA { * @brief Count of possible constraint events. * @note Depends on the first Event having an int value of 0. */ - static const int EVENT_COUNT = (int)LAST_EVENT; + static const int EVENT_COUNT = static_cast(LAST_EVENT); /** * @brief Constructor currently creates a basic configuration of propagators. */ - ConstraintEngine(const CESchemaId& schema); + ConstraintEngine(const CESchemaId schema); /** * @brief Destructor. @@ -161,7 +162,7 @@ namespace EUROPA { /** * @brief Id self reference. */ - const ConstraintEngineId& getId() const; + const ConstraintEngineId getId() const; /** * @brief purge all elements from the Engine. Will delete all variables, constraints, and propagators. @@ -231,7 +232,7 @@ namespace EUROPA { * @brief Get index based on its position in the set of variables. * @note This is not a const in-case it manages some internal cache to optimize later */ - unsigned int getIndex(const ConstrainedVariableId& var); + unsigned int getIndex(const ConstrainedVariableId var); /** * @brief Accessor for all constraints. @@ -246,12 +247,12 @@ namespace EUROPA { /** * @brief Get index based on its position in the set of constraints. */ - unsigned int getIndex(const ConstraintId& constr); + unsigned int getIndex(const ConstraintId constr); /** * @brief Accessor for all propagators */ - const PropagatorId& getPropagatorByName(const LabelStr& name) const; + const PropagatorId getPropagatorByName(const std::string& name) const; /** * @see If AutoPropagation is enabled, the constraint engine will automatically invoke propagate() @@ -305,7 +306,7 @@ namespace EUROPA { */ bool isRelaxed() const; - const CESchemaId& getCESchema() const; + const CESchemaId getCESchema() const; // PSConstraintEngine methods virtual PSVariable* getVariableByKey(PSEntityKey id); @@ -315,38 +316,38 @@ namespace EUROPA { /** * @brief Create a variable */ - ConstrainedVariableId createVariable(const char* typeName, - const bool internal = false, - bool canBeSpecified = true, - const char* name = NO_VAR_NAME, - const EntityId& parent = EntityId::noId(), - int index = ConstrainedVariable::NO_INDEX); - + ConstrainedVariableId createVariable(const std::string& typeName, + const bool internal = false, + bool canBeSpecified = true, + const std::string& name = NO_VAR_NAME, + const EntityId parent = EntityId::noId(), + unsigned int index = ConstrainedVariable::NO_INDEX); + /** * @brief Create a variable */ - ConstrainedVariableId createVariable(const char* typeName, - const Domain& baseDomain, - const bool internal = false, - bool canBeSpecified = true, - const char* name = NO_VAR_NAME, - const EntityId& parent = EntityId::noId(), - int index = ConstrainedVariable::NO_INDEX); + ConstrainedVariableId createVariable(const std::string& typeName, + const Domain& baseDomain, + const bool internal = false, + bool canBeSpecified = true, + const std::string& name = NO_VAR_NAME, + const EntityId parent = EntityId::noId(), + unsigned int index = ConstrainedVariable::NO_INDEX); - ConstraintId createConstraint(const LabelStr& name, - const std::vector& scope, - const char* violationExpl=NULL); + ConstraintId createConstraint(const std::string& name, + const std::vector& scope, + const std::string& violationExpl=""); - void deleteConstraint(const ConstraintId& c); + void deleteConstraint(const ConstraintId c); /** * @brief Create a value for a string */ - edouble createValue(const char* typeName, const std::string& value); + edouble createValue(const std::string& typeName, const std::string& value); - void addCallback(const PostPropagationCallbackId& callback); - void removeCallback(const PostPropagationCallbackId& callback); + void addCallback(const PostPropagationCallbackId callback); + void removeCallback(const PostPropagationCallbackId callback); protected: @@ -360,13 +361,15 @@ namespace EUROPA { * @param constraints the reference to the list of constraints of the variable. * @return A reference to the listener to be registered with the variable. */ - DomainListenerId allocateVariableListener(const ConstrainedVariableId& variable, + DomainListenerId allocateVariableListener(const ConstrainedVariableId variable, const ConstraintList& constraints) const; ViolationMgr& getViolationMgr() { return *m_violationMgr; } const ViolationMgr& getViolationMgr() const { return *m_violationMgr; } private: + ConstraintEngine(const ConstraintEngine& other); + ConstraintEngine operator=(const ConstraintEngine& other); friend class Constraint; friend class VariableChangeListener; friend class Propagator; @@ -377,76 +380,76 @@ namespace EUROPA { * @brief Constraint Constructor will call this method to establish linkage with the ConstraintEngine. * @param constraint The constraint to be added. */ - void add(const ConstraintId& constraint, const LabelStr& propagatorName); + void add(const ConstraintId constraint, const std::string& propagatorName); /** * @brief Constraint destructor will call this method to withdraw links with the ConstraintEngine. * @param constraint The constraint to be removed. */ - void remove(const ConstraintId& constraint); + void remove(const ConstraintId constraint); /** * @brief Called by the VariableListener when a change occurs on its varible. * * This method provides the core event control logic of the ConstraintEngine. - * @param listener The listener with the necessary data for the variable. - * @param change Type the type of change that occured on the variable. + * @param source The changed variable + * @param changeType Type the type of change that occured on the variable. * @see DomainListener::ChangeType, handleEmptied, handleRelaxed, Propagator::handleNotification(), Constraint::canIgnore() */ - void notify(const ConstrainedVariableId& source, const DomainListener::ChangeType& changeType); + void notify(const ConstrainedVariableId source, const DomainListener::ChangeType& changeType); /** * @brief Update appropriately when a variabe domain has been emptied. - * @param the variable that has been emptied. - * @see notify(const ConstrainedVariableId& source, const DomainListener::ChangeType& changeType) + * @param variable The variable that has been emptied. + * @see notify(const ConstrainedVariableId source, const DomainListener::ChangeType& changeType) */ - void handleEmpty(const ConstrainedVariableId& variable); + void handleEmpty(const ConstrainedVariableId variable); /** * @brief Update appropriately when a variable has been relaxed. - * @param the variable that has been relaxed. - * @see notify(const ConstrainedVariableId& source, const DomainListener::ChangeType& changeType) + * @param variable The variable that has been relaxed. + * @see notify(const ConstrainedVariableId source, const DomainListener::ChangeType& changeType) */ - void handleRelax(const ConstrainedVariableId& variable); + void handleRelax(const ConstrainedVariableId variable); /** * @brief Update appropriately when a variable has been restricted but not emptied. - * @param the variable that has been restricted. - * @see notify(const ConstrainedVariableId& source, const DomainListener::ChangeType& changeType) + * @param variable The variable that has been restricted. + * @see notify(const ConstrainedVariableId source, const DomainListener::ChangeType& changeType) */ - void handleRestrict(const ConstrainedVariableId& variable); + void handleRestrict(const ConstrainedVariableId variable); /** * @brief Propagator constructor will call this method to register the Propagator with the ConstraintEngine. * @param propagator the propagator to be added. */ - void add(const PropagatorId& propagator); + void add(const PropagatorId propagator); /** * @brief Notification from a constraint when it has been deactivated. */ - void notifyDeactivated(const ConstraintId& deactivatedConstraint); + void notifyDeactivated(const ConstraintId deactivatedConstraint); /** * @brief Notification from a constraint when it has been activated. */ - void notifyActivated(const ConstraintId& activatedConstraint); + void notifyActivated(const ConstraintId activatedConstraint); /** * @brief Notification that a constraint has become redundant. */ - void notifyRedundant(const ConstraintId& redundantConstraint); + void notifyRedundant(const ConstraintId redundantConstraint); /** - * @breif Notification from a variable when it has been deactivated + * @brief Notification from a variable when it has been deactivated */ - void notifyDeactivated(const ConstrainedVariableId& var); + void notifyDeactivated(const ConstrainedVariableId var); /** * @brief Notification from a variable when it has been activated */ - void notifyActivated(const ConstrainedVariableId& var); + void notifyActivated(const ConstrainedVariableId var); /** * @brief Invokes execution event handler on the designated constraint. @@ -455,7 +458,7 @@ namespace EUROPA { * unavailable. * @param constraint the constraint to be executed. */ - void execute(const ConstraintId& constraint); + void execute(const ConstraintId constraint); /** * @brief Invokes execution event handler on the designated constraint. @@ -466,9 +469,9 @@ namespace EUROPA { * @param argIndex the position of the variable in the scope of the constraint. * @param changeType the nature of change that occurred on the domain. */ - void execute(const ConstraintId& constraint, - const ConstrainedVariableId& variable, - int argIndex, + void execute(const ConstraintId constraint, + const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); friend class ConstrainedVariable; @@ -477,25 +480,25 @@ namespace EUROPA { * @brief Called by ConstrainedVariable constructor to link the variable with the constraint. * @param variable the variable to be constrained. */ - void add(const ConstrainedVariableId& variable); + void add(const ConstrainedVariableId variable); /** * @brief Called by ConstrainedVariable destructor to unlink the variable with the constraint. * @param variable the variable to be removed. */ - void remove(const ConstrainedVariableId& variable); + void remove(const ConstrainedVariableId variable); /** * @brief Called by ConstraintEngineListener constructor. * @param listener The listener to add */ - void add(const ConstraintEngineListenerId& listener); + void add(const ConstraintEngineListenerId listener); /** * @brief Called by ConstraintEngineListener destructor. * @param listener The listener to remove. */ - void remove(const ConstraintEngineListenerId& listener); + void remove(const ConstraintEngineListenerId listener); /** * @brief Accessor to retrieve the next active propagator in the @@ -534,7 +537,7 @@ namespace EUROPA { // debug methods std::string dumpPropagatorState(const PropagatorSet& propagators) const; - int addLinkedVarsForRelaxation(const ConstrainedVariableId& var, + int addLinkedVarsForRelaxation(const ConstrainedVariableId var, std::list& dest, std::list::iterator pos, ConstrainedVariableSet& visitedVars); @@ -546,7 +549,7 @@ namespace EUROPA { PropagatorSet m_propagators; /*!< The list of all propagators. Position in the list indicates execution priority. This is determined by the order of construction. */ - std::map m_propagatorsByName; /*!< Support configuration and lookup by name. */ + std::map m_propagatorsByName; /*!< Support configuration and lookup by name. */ bool m_relaxing; bool m_relaxingViolation; /*!< Flag to record if relax events should be ignored by the ViolationMgr */ @@ -557,8 +560,8 @@ namespace EUROPA { bool m_purged; /*!< Indicates if the engine has been purged of its data */ bool m_dirty; /*!< Flag to record if any messages handled without propagating consequences */ - int m_cycleCount; /*!< A monotonically increasing count of propagation cycles. Identifies - when propagation events have already been queued or handled. */ + unsigned int m_cycleCount; /*!< A monotonically increasing count of propagation cycles. Identifies + when propagation events have already been queued or handled. */ unsigned int m_mostRecentRepropagation; /*!< A monotonically increasing record of cycles where a relaxation occurred. */ std::set m_listeners; /*!< Stores the set of registered listeners. */ @@ -568,7 +571,7 @@ namespace EUROPA { ViolationMgr* m_violationMgr; bool m_autoPropagate; - const CESchemaId& m_schema; + const CESchemaId m_schema; std::list m_callbacks; /*!< Post-propagation callbacks */ }; @@ -583,13 +586,13 @@ namespace EUROPA { * @brief Constructor that does nothing. * */ - PostPropagationCallback() : m_id(this) {} + PostPropagationCallback() : m_id(this), m_ce() {} /** * @brief Constructor with initial constraint engine. * - * @param ce + * @param ce The constraint engine to register with */ - PostPropagationCallback(const ConstraintEngineId& ce) : m_id(this), m_ce(ce) {ce->addCallback(m_id);} + PostPropagationCallback(const ConstraintEngineId ce) : m_id(this), m_ce(ce) {ce->addCallback(m_id);} virtual ~PostPropagationCallback() { if(m_ce.isId()) @@ -605,10 +608,10 @@ namespace EUROPA { */ virtual bool operator()() {return false;} - const PostPropagationCallbackId& getId() const {return m_id;} + const PostPropagationCallbackId getId() const {return m_id;} protected: friend class ConstraintEngine; - void setConstraintEngine(const ConstraintEngineId& ce) {m_ce = ce;} + void setConstraintEngine(const ConstraintEngineId ce) {m_ce = ce;} PostPropagationCallbackId m_id; ConstraintEngineId m_ce; diff --git a/src/PLASMA/ConstraintEngine/base/ConstraintEngineListener.cc b/src/PLASMA/ConstraintEngine/base/ConstraintEngineListener.cc index d15c334e9..2dd2fda1a 100644 --- a/src/PLASMA/ConstraintEngine/base/ConstraintEngineListener.cc +++ b/src/PLASMA/ConstraintEngine/base/ConstraintEngineListener.cc @@ -4,15 +4,15 @@ namespace EUROPA { - ConstraintEngineListener::ConstraintEngineListener(const ConstraintEngineId& constraintEngine) + ConstraintEngineListener::ConstraintEngineListener(const ConstraintEngineId constraintEngine) :m_id(this), m_constraintEngine(constraintEngine){ check_error(m_constraintEngine.isValid()); m_constraintEngine->add(m_id); } - ConstraintEngineListener::ConstraintEngineListener() - :m_id(this) { - } +ConstraintEngineListener::ConstraintEngineListener() + : m_id(this), m_constraintEngine() { +} ConstraintEngineListener::~ConstraintEngineListener(){ check_error(m_id.isValid()); @@ -21,13 +21,60 @@ namespace EUROPA { m_id.remove(); } - const ConstraintEngineListenerId& ConstraintEngineListener::getId() const { + const ConstraintEngineListenerId ConstraintEngineListener::getId() const { return(m_id); } - void ConstraintEngineListener::setConstraintEngine(const ConstraintEngineId& constraintEngine) { + void ConstraintEngineListener::setConstraintEngine(const ConstraintEngineId constraintEngine) { m_constraintEngine = constraintEngine; check_error(m_constraintEngine.isValid()); m_constraintEngine->add(m_id); } + +void ConstraintEngineListener::notifyPropagationCommenced(){ +} + +void ConstraintEngineListener::notifyPropagationCompleted(){ +} + +void ConstraintEngineListener::notifyPropagationPreempted(){ +} + +void ConstraintEngineListener::notifyAdded(const ConstraintId){ +} + +void ConstraintEngineListener::notifyActivated(const ConstraintId){ +} + +void ConstraintEngineListener::notifyDeactivated(const ConstrainedVariableId){ +} + +void ConstraintEngineListener::notifyActivated(const ConstrainedVariableId){ +} + +void ConstraintEngineListener::notifyDeactivated(const ConstraintId){ +} + +void ConstraintEngineListener::notifyRemoved(const ConstraintId){ +} + +void ConstraintEngineListener::notifyExecuted(const ConstraintId){ +} + +void ConstraintEngineListener::notifyAdded(const ConstrainedVariableId){ +} + +void ConstraintEngineListener::notifyRemoved(const ConstrainedVariableId){ +} + +void ConstraintEngineListener::notifyChanged(const ConstrainedVariableId, + const DomainListener::ChangeType&){ +} + +void ConstraintEngineListener::notifyViolationAdded(const ConstraintId){ +} + +void ConstraintEngineListener::notifyViolationRemoved(const ConstraintId){ +} + } diff --git a/src/PLASMA/ConstraintEngine/base/ConstraintEngineListener.hh b/src/PLASMA/ConstraintEngine/base/ConstraintEngineListener.hh index 15234505c..a1b841714 100644 --- a/src/PLASMA/ConstraintEngine/base/ConstraintEngineListener.hh +++ b/src/PLASMA/ConstraintEngine/base/ConstraintEngineListener.hh @@ -1,5 +1,5 @@ -#ifndef _H_ConstraintEngineListener -#define _H_ConstraintEngineListener +#ifndef H_ConstraintEngineListener +#define H_ConstraintEngineListener #include "ConstraintEngineDefs.hh" #include "DomainListener.hh" @@ -19,61 +19,47 @@ namespace EUROPA{ public: virtual ~ConstraintEngineListener(); - virtual void notifyPropagationCommenced(){ - } + virtual void notifyPropagationCommenced(); - virtual void notifyPropagationCompleted(){ - } + virtual void notifyPropagationCompleted(); - virtual void notifyPropagationPreempted(){ - } + virtual void notifyPropagationPreempted(); - virtual void notifyAdded(const ConstraintId& constraint){ - } + virtual void notifyAdded(const ConstraintId constraint); - virtual void notifyActivated(const ConstraintId& constraint){ - } + virtual void notifyActivated(const ConstraintId constraint); - virtual void notifyDeactivated(const ConstrainedVariableId& var){ - } + virtual void notifyDeactivated(const ConstrainedVariableId var); - virtual void notifyActivated(const ConstrainedVariableId& var){ - } + virtual void notifyActivated(const ConstrainedVariableId var); - virtual void notifyDeactivated(const ConstraintId& constraint){ - } + virtual void notifyDeactivated(const ConstraintId constraint); - virtual void notifyRemoved(const ConstraintId& constraint){ - } + virtual void notifyRemoved(const ConstraintId constraint); - virtual void notifyExecuted(const ConstraintId& constraint){ - } + virtual void notifyExecuted(const ConstraintId constraint); - virtual void notifyAdded(const ConstrainedVariableId& variable){ - } + virtual void notifyAdded(const ConstrainedVariableId variable); - virtual void notifyRemoved(const ConstrainedVariableId& variable){ - } + virtual void notifyRemoved(const ConstrainedVariableId variable); - virtual void notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType){ - } + virtual void notifyChanged(const ConstrainedVariableId variable, + const DomainListener::ChangeType& changeType); - virtual void notifyViolationAdded(const ConstraintId& constraint){ - } + virtual void notifyViolationAdded(const ConstraintId constraint); - virtual void notifyViolationRemoved(const ConstraintId& constraint){ - } + virtual void notifyViolationRemoved(const ConstraintId constraint); - const ConstraintEngineListenerId& getId() const; + const ConstraintEngineListenerId getId() const; // for PSConstraintEngineListener, where we don't have access to plan database // at construction time: - virtual void setConstraintEngine(const ConstraintEngineId& constraintEngine); + virtual void setConstraintEngine(const ConstraintEngineId constraintEngine); protected: - ConstraintEngineListener(const ConstraintEngineId& constraintEngine); + ConstraintEngineListener(const ConstraintEngineId constraintEngine); ConstraintEngineListenerId m_id; ConstraintEngineId m_constraintEngine; diff --git a/src/PLASMA/ConstraintEngine/base/ConstraintType.cc b/src/PLASMA/ConstraintEngine/base/ConstraintType.cc index 43d11f87c..b6a385c9d 100644 --- a/src/PLASMA/ConstraintEngine/base/ConstraintType.cc +++ b/src/PLASMA/ConstraintEngine/base/ConstraintType.cc @@ -9,9 +9,9 @@ namespace EUROPA { -ConstraintType::ConstraintType(const LabelStr& name, - const LabelStr& propagatorName, - bool systemDefined) +ConstraintType::ConstraintType(const std::string& name, + const std::string& propagatorName, + bool systemDefined) : m_id(this) , m_name(name) , m_propagatorName(propagatorName) @@ -21,11 +21,13 @@ ConstraintType::ConstraintType(const LabelStr& name, ConstraintType::~ConstraintType() { + if(m_id.isValid()) + m_id.remove(); } -const ConstraintTypeId& ConstraintType::getId() const {return m_id;} +const ConstraintTypeId ConstraintType::getId() const {return m_id;} -const LabelStr& ConstraintType::getName() const { return m_name; } +const std::string& ConstraintType::getName() const { return m_name; } bool ConstraintType::isSystemDefined() const { return m_systemDefined; } diff --git a/src/PLASMA/ConstraintEngine/base/ConstraintType.hh b/src/PLASMA/ConstraintEngine/base/ConstraintType.hh index 8c3ca7d10..05f4f1ad8 100644 --- a/src/PLASMA/ConstraintEngine/base/ConstraintType.hh +++ b/src/PLASMA/ConstraintEngine/base/ConstraintType.hh @@ -1,11 +1,10 @@ -#ifndef _H_ConstraintType -#define _H_ConstraintType +#ifndef H_ConstraintType +#define H_ConstraintType #include "ConstraintEngineDefs.hh" -#include "Domain.hh" -#include "LabelStr.hh" #include "Constraint.hh" #include "DataType.hh" +#include "unused.hh" #include #include @@ -24,130 +23,128 @@ namespace EUROPA { public: virtual ~ConstraintType(); - const ConstraintTypeId& getId() const; + const ConstraintTypeId getId() const; - const LabelStr& getName() const; + const std::string& getName() const; bool isSystemDefined() const; virtual ConstraintId createConstraint( const ConstraintEngineId constraintEngine, const std::vector& scope, - const char* violationExpl) = 0; + const std::string& violationExpl) = 0; // throws an std::string error message if the specified arg types can't be used // to create the constraint this type represents virtual void checkArgTypes(const std::vector& argTypes) const = 0; protected: - ConstraintType(const LabelStr& name, - const LabelStr& propagatorName, - bool systemDefined = false); + ConstraintType(const std::string& name, + const std::string& propagatorName, + bool systemDefined = false); ConstraintTypeId m_id; - const LabelStr m_name; - const LabelStr m_propagatorName; + const std::string m_name; + const std::string m_propagatorName; const bool m_systemDefined; }; /**********************************************************/ - template - ConstraintId makeConstraintInstance( - const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId constraintEngine, - const std::vector& scope, - const char* violationExpl) - { - check_error(constraintEngine.isValid()); - check_error(scope.size() >= 1); - Constraint* constraint = new ConstraintInstance(name, propagatorName, constraintEngine, scope); - check_error(constraint != 0); - check_error(constraint->getId().isValid()); - if (violationExpl != NULL) - constraint->setViolationExpl(violationExpl); - - return(constraint->getId()); - } - - template - class ConcreteConstraintType : public ConstraintType { - public: - // TODO: remove this constructor after all constraint types have been updated to check arg types - ConcreteConstraintType(const LabelStr& name, - const LabelStr& propagatorName, - bool systemDefined = false) - : ConstraintType(name, propagatorName, systemDefined) - { - } +template +ConstraintId makeConstraintInstance( + const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& scope, + const std::string& violationExpl) { + check_error(constraintEngine.isValid()); + check_error(scope.size() >= 1); + Constraint* constraint = new ConstraintInstance(name, propagatorName, constraintEngine, scope); + check_error(constraint != 0); + check_error(constraint->getId().isValid()); + if (!violationExpl.empty()) + constraint->setViolationExpl(violationExpl); + + return(constraint->getId()); +} - ConcreteConstraintType(const LabelStr& name, - const LabelStr& propagatorName, - const std::vector& argTypes, - bool systemDefined = false) +template +class ConcreteConstraintType : public ConstraintType { + public: + // TODO: remove this constructor after all constraint types have been updated to check arg types + ConcreteConstraintType(const std::string& name, + const std::string& propagatorName, + bool systemDefined = false) + : ConstraintType(name, propagatorName, systemDefined), m_argTypes() {} + + ConcreteConstraintType(const std::string& name, + const std::string& propagatorName, + const std::vector& argTypes, + bool systemDefined = false) : ConstraintType(name, propagatorName, systemDefined) , m_argTypes(argTypes) - { - } + { + } - virtual ConstraintId createConstraint( - const ConstraintEngineId constraintEngine, - const std::vector& scope, - const char* violationExpl) - { - return makeConstraintInstance(m_name, m_propagatorName, constraintEngine, scope, violationExpl); - } + virtual ConstraintId createConstraint( + const ConstraintEngineId constraintEngine, + const std::vector& scope, + const std::string& violationExpl) + { + return makeConstraintInstance(m_name, m_propagatorName, constraintEngine, scope, violationExpl); + } - virtual void checkArgTypes(const std::vector& types) const - { - // TODO: remove this after all constraint types have been updated to check arg types - if (m_argTypes.size() == 0) - return; - - if (m_argTypes.size() != types.size()) { - std::ostringstream os; - os << "Constraint "<< m_name.toString() - << " can't take " << types.size() << " parameters." - << " It expects " << m_argTypes.size() << "."; - throw os.str(); - } - - for (unsigned int i=0;iisAssignableFrom(types[i])) { - std::ostringstream os; - os << "Constraint "<< m_name.toString() - << " can't take a " << types[i]->getName().toString() - << " as parameter number " << i << "." - << " It expects " << m_argTypes[i]->getName().toString() << "."; - throw os.str(); - } - } + virtual void checkArgTypes(const std::vector& types) const + { + // TODO: remove this after all constraint types have been updated to check arg types + if (m_argTypes.size() == 0) + return; + + if (m_argTypes.size() != types.size()) { + std::ostringstream os; + os << "Constraint "<< m_name + << " can't take " << types.size() << " parameters." + << " It expects " << m_argTypes.size() << "."; + throw os.str(); } - protected: - std::vector m_argTypes; - }; + for (unsigned int i=0;iisAssignableFrom(types[i])) { + std::ostringstream os; + os << "Constraint "<< m_name + << " can't take a " << types[i]->getName() + << " as parameter number " << i << "." + << " It expects " << m_argTypes[i]->getName() << "."; + throw os.str(); + } + } + } - template - class RotatedNaryConstraintType : public ConstraintType { - public: - RotatedNaryConstraintType(const LabelStr& name, - const LabelStr& propagatorName, - const LabelStr& otherName, - const int& rotateCount) + protected: + std::vector m_argTypes; +}; + +template +class RotatedNaryConstraintType : public ConstraintType { + public: + RotatedNaryConstraintType(const std::string& name, + const std::string& propagatorName, + const std::string& otherName, + const int& rotateCount) : ConstraintType(name, propagatorName) , m_otherName(otherName) , m_rotateCount(rotateCount) - { - assertTrue(name != otherName); + { + checkError(name != otherName, + "Rotated name " << name << " is the same as un-rotated " << otherName); } ConstraintId createConstraint( const ConstraintEngineId constraintEngine, const std::vector& scope, - const char* violationExpl) + const std::string& violationExpl) { check_error(constraintEngine.isValid()); check_error(scope.size() >= 1); @@ -156,37 +153,36 @@ namespace EUROPA { check_error(constraint != 0); check_error(constraint->getId().isValid()); - if (violationExpl != NULL) + if (!violationExpl.empty()) constraint->setViolationExpl(violationExpl); return(constraint->getId()); } - virtual void checkArgTypes(const std::vector& argTypes) const - { - // TODO: implement this - } + virtual void checkArgTypes(unused(const std::vector& argTypes)) const { + // TODO: implement this + } protected: - const LabelStr m_otherName; + const std::string m_otherName; const int m_rotateCount; }; template class SwapTwoVarsNaryConstraintType : public ConstraintType { public: - SwapTwoVarsNaryConstraintType(const LabelStr& name, const LabelStr& propagatorName, - const LabelStr& otherName, const int& first, const int& second) + SwapTwoVarsNaryConstraintType(const std::string& name, const std::string& propagatorName, + const std::string& otherName, const int& first, const int& second) : ConstraintType(name, propagatorName), m_otherName(otherName), m_first(first), m_second(second) { - assertTrue(name != otherName); - assertTrue(first != second); + checkError(name != otherName); + checkError(first != second); } ConstraintId createConstraint( const ConstraintEngineId constraintEngine, const std::vector& scope, - const char* violationExpl) { + const std::string& violationExpl) { check_error(constraintEngine.isValid()); check_error(scope.size() >= 1); Constraint* constraint = new ConstraintInstance(m_name, m_propagatorName, constraintEngine, @@ -194,19 +190,19 @@ namespace EUROPA { check_error(constraint != 0); check_error(constraint->getId().isValid()); - if (violationExpl != NULL) + if (!violationExpl.empty()) constraint->setViolationExpl(violationExpl); return(constraint->getId()); } - virtual void checkArgTypes(const std::vector& argTypes) const + virtual void checkArgTypes(unused(const std::vector& argTypes)) const { // TODO: implement this } protected: - const LabelStr m_otherName; + const std::string m_otherName; const int m_first, m_second; }; @@ -219,7 +215,7 @@ namespace EUROPA { * @param PropagatorName The constraint's propagator's name. */ #define REGISTER_SYSTEM_CONSTRAINT(ceSchema, ConstraintInstance, ConstraintName, PropagatorName) \ - (ceSchema->registerConstraintType((new ConcreteConstraintType(LabelStr(ConstraintName), LabelStr(PropagatorName), true))->getId())) + (ceSchema->registerConstraintType((new ConcreteConstraintType(ConstraintName, PropagatorName, true))->getId())) /** * @def REGISTER_CONSTRAINT @@ -230,20 +226,20 @@ namespace EUROPA { * @param PropagatorName The constraint's propagator's name. */ #define REGISTER_CONSTRAINT(ceSchema,ConstraintInstance, ConstraintName, PropagatorName) \ - (ceSchema->registerConstraintType((new ConcreteConstraintType(LabelStr(ConstraintName), LabelStr(PropagatorName)))->getId())) + (ceSchema->registerConstraintType((new ConcreteConstraintType(ConstraintName, PropagatorName))->getId())) #define REGISTER_CONSTRAINT_TYPE(ceSchema,constraintType,constraintName,propagatorName) \ - (ceSchema->registerConstraintType((new constraintType(LabelStr(constraintName),LabelStr(propagatorName)))->getId())) + (ceSchema->registerConstraintType((new constraintType(constraintName,propagatorName))->getId())) #define REGISTER_CONSTRAINT_TYPE_WITH_SIGNATURE(ceSchema,ConstraintInstance, ConstraintName, PropagatorName, ArgTypes) \ {\ std::vector argTypes;\ - LabelStr types(ArgTypes);\ + std::string types(ArgTypes); \ for (int i=0;igetDataType(types.getElement(i,":").c_str());\ argTypes.push_back(argType);\ }\ - (ceSchema->registerConstraintType((new ConcreteConstraintType(LabelStr(ConstraintName), LabelStr(PropagatorName), argTypes))->getId()));\ + (ceSchema->registerConstraintType((new ConcreteConstraintType(ConstraintName, PropagatorName, argTypes))->getId()));\ } @@ -262,8 +258,8 @@ namespace EUROPA { * if -1, move the first variable to the end. */ #define REGISTER_ROTATED_CONSTRAINT(ceSchema,ConstraintName, PropagatorName, RotateName, RotateCount) \ - (ceSchema->registerConstraintType((new RotatedNaryConstraintType(LabelStr(ConstraintName), LabelStr(PropagatorName),\ - LabelStr(RotateName), (RotateCount)))->getId())) + (ceSchema->registerConstraintType((new RotatedNaryConstraintType(ConstraintName, PropagatorName,\ + RotateName, (RotateCount)))->getId())) /** * @def REGISTER_SWAP_TWO_VARS_CONSTRAINT @@ -281,8 +277,8 @@ namespace EUROPA { * before the last variable, etc. */ #define REGISTER_SWAP_TWO_VARS_CONSTRAINT(ceSchema,ConstraintName, PropagatorName, RotateName, FirstVar, SecondVar) \ - (ceSchema->registerConstraintType((new SwapTwoVarsNaryConstraintType(LabelStr(ConstraintName), LabelStr(PropagatorName), \ - LabelStr(RotateName), (FirstVar), (SecondVar)))->getId())) + (ceSchema->registerConstraintType((new SwapTwoVarsNaryConstraintType((ConstraintName), (PropagatorName), \ + (RotateName), (FirstVar), (SecondVar)))->getId())) } #endif diff --git a/src/PLASMA/ConstraintEngine/base/ConstraintTypeChecking.cc b/src/PLASMA/ConstraintEngine/base/ConstraintTypeChecking.cc new file mode 100644 index 000000000..0598af035 --- /dev/null +++ b/src/PLASMA/ConstraintEngine/base/ConstraintTypeChecking.cc @@ -0,0 +1,10 @@ +#include "ConstraintTypeChecking.hh" +#include "Domain.hh" + +namespace EUROPA { + +bool CanBePositive::operator()(const std::string&, DataTypeId dt, std::ostream&) const { + return dt->baseDomain().getUpperBound() >= 0.0; +} + +} diff --git a/src/PLASMA/ConstraintEngine/base/ConstraintTypeChecking.hh b/src/PLASMA/ConstraintEngine/base/ConstraintTypeChecking.hh new file mode 100644 index 000000000..5c312279d --- /dev/null +++ b/src/PLASMA/ConstraintEngine/base/ConstraintTypeChecking.hh @@ -0,0 +1,504 @@ +#ifndef CONSTRAINTTYPECHECKING_H_ +#define CONSTRAINTTYPECHECKING_H_ + +#include "ConstraintType.hh" +#include "DataType.hh" + +#include + +/** + * @file ConstraintTypeChecking.hh + * @author Michael Iatauro + * + * @brief Defines template expressions for checking of constraint type signatures. + * + * Constraints often have restrictions on the number and types of the variables in their + * scope in much the same way that functions have on their parameters. This header + * provides a system for concisely stating and composing those restrictions + * so that constraint implementors don't have to manually write code to enforce them or to + * duplicate code between constraints with shared type signatures. + * + * It achieves this through an expression template system that consists of predicates, + * accessors, and iterators. + * + * Predicates + * + * Predicates are (mostly) unary functions that evaluate to a boolean value indicating + * a successful (true) or failed (false) check. + * There are two predicates that check the number of arguments rather than properties of + * specific arguments: + * + * `NArgs` specifies an exact number of arguments to check. `NArgs<3>` will check + * that a constraint has three arguments. + * + * `AtLeastNArgs`specified a minimum number of arguments to check. `AtLeastNArgs<3>` + * will check that a constraint has no fewer than three arguments. + * + * The rest of the predicates expect to get the type to check from an accessor or an + * iterator. + * + * `CanBePositive` asserts that a numeric argument has a positive upper bound. + * + * `Numeric` asserts that an argument is numeric @see DataType::isNumeric + * + * `IsEntity` asserts that an argument is of some Entity type (e.g. Object) + * @see DataType::isEntity + * + * `Type` asserts that an argument is of some specific DataType. T must be a subclass + * of DataType. + * + * `Same` asserts that consecutive arguments have the same type. + * (TODO: Redesign this to be consistent with Assignable and Comparable.) + * + * + * The last two predicates, Assignable and Comparable, specify a relationship between two + * argument types. As a result, + * they have two forms: one with no parameter that takes a pair of arguments at checking-time + * (@see Mutually) and one with an accessor parameter for a particular argument. The + * single-parameter form performs the same check as the parameterless, but with the parameter + * as the first argument. + * + * `Comparable` asserts that its first argument can be compared to its second. + * @see DataType::canBeCompared + * + * `Assignable` asserts that its first argument is assignable from its second. + * @see DataType::isAssignableFrom + * + * Accessors + * + * A set of named accessors for specific arguments are provided. Currently they are `First` + * through `Fourth`, as well as an Nth for any access whose index is known at compile time. + * There are two special relative accessors, Last and End, for the final argument and + * one-past-the-end, respectively. + * + * Accessors other than End have two forms, one without parameters that simply acts as an + * accessor and one with a single predicate parameter that asserts a property of a specific + * parameter. `First >` asserts that the first argument to the constraint is + * a boolean variable. + * + * Iterators + * + * `All` asserts that some predicate is true for all arguments in a range. By default, + * the range is from First to End. + * + * `Mutually` asserts that some predicate is true for all pairs of arguments in a range. + * By default, the range is from First to End. + * + * Assertions can be combined with the logical operator `And`. + * And takes two template expressions. When evaluated, it will evaluate both expressions + * and return the logical conjunction of their evaluation. It always evaluates both of its + * arguments in order to present error messages from both checks so the user doesn't have + * to re-run the checking process after fixing the error message from one. + * + * Composition + * + * There are a couple of ways to create a type check intended for composition into larger + * checks (or simply to save typing). If the type check is intended to be used directly, + * a simple typedef will do: + * + * typedef And, And >, All > > TwoAssignableNumeric; + * + * The TwoAssignableNumeric type can then be used directly: + * + * typedef DataTypeCheck AbsoluteValueCT; + * + * or as part of a conjunction: + * + * typedef DataTypeCheck > > AbsoluteValueCT; + * + * On the other hand, some constraints have the same type requirements as other constraints, + * but shifted to account for additional variables in the scope. `allDiff` and `condAllDiff` + * are an excellent example: condAllDiff has a leading boolean parameter that allDiff doesn't, + * but the type requirements on the rest of the parameters are the same. Because typedefs + * aren't allowed to take template arguments, a struct is required: + * + * template, typename End = End> + * struct AllAssignable : Mutually, Start, End> { + * AllAssignable() : Mutually, Start, End>() {} + * AllAssignable(type_iterator start, type_iterator end) + * : Mutually, Start, End>(start, end){} + * }; + * + * The first line declares the parameters for the argument range to check, defaulting to + * the whole range with AllAssignable<>. The second declares AllAssignable as a subclass + * of Mutually > over that range. Lines three through five are boilerplate. + * Creating this struct allows the allDiff constraint check to be declared as AllAssignable + * and the condAllDiff to be declared as + * And, First >, AllAssignable, End> > + * (note that this isn't exactly what's done in the source--the + * And, First > is declared separately to be reused in other + * constraint types) + */ + +namespace EUROPA { + +//TODO: put this in a namespace? +typedef std::vector type_vector; +typedef std::vector::const_iterator type_iterator; + +template +struct NArgs { + NArgs(){} + NArgs(type_iterator, type_iterator) {} + bool operator()(const std::string& name, type_iterator start, type_iterator end, + std::ostream& os) const { + if(std::distance(start, end) != N) { + os << "Constraint " << name << " takes " << N << " args, not " << + std::distance(start, end) << std::endl; + return false; + } + return true; + } +}; + +template +struct AtLeastNArgs { + AtLeastNArgs(){} + AtLeastNArgs(type_iterator, type_iterator){} + bool operator()(const std::string& name, type_iterator start, type_iterator end, + std::ostream& os) const { + if(std::distance(start, end) < N) { + os << "Constraint " << name << " takes at least " << N << " args, not " << + std::distance(start, end) << std::endl; + return false; + } + return true; + } +}; + +struct None; + +template +struct Nth { + Nth(type_iterator, type_iterator) {} + bool operator()(const std::string& name, type_iterator start, type_iterator end, + std::ostream& os) const { + + Check c; + if(start == end) { + os << "Constraint " << name << " ran out of arguments before checking " << + c.description() << std::endl; + return false; + } + std::advance(start, N); + if(!c(name, *start, os)) { + os << "Constraint " << name << " requires that argument " << N << " be " << + c.description() << std::endl; + return false; + } + return true; + } +}; + +template +struct Nth { + Nth() {} + type_iterator operator()(type_iterator start, type_iterator end) const { + std::advance(start, N); + return start; + } +}; + +#define INDEXED_CHECKER(name, number) \ + template \ + struct name : public Nth { \ + name(type_iterator a, type_iterator b) : Nth(a, b) {} \ + }; \ + template<> \ + struct name : public Nth { \ + name() : Nth() {} \ + }; + +INDEXED_CHECKER(First, 0); +INDEXED_CHECKER(Second, 1); +INDEXED_CHECKER(Third, 2); +INDEXED_CHECKER(Fourth, 3); + +template +struct Last { + Last(type_iterator, type_iterator) {} + bool operator()(const std::string& name, type_iterator start, type_iterator end, + std::ostream& os) { + checkError(start != end); + std::advance(start, std::distance(start, end) - 1); + Check c; + if(!c(name, *start, os)) { + os << "Constraint " << name << " requires that its last argument be " << + c.description() << std::endl; + } + return true; + } +}; + +template<> +struct Last { + type_iterator operator()(type_iterator start, type_iterator end) const { + checkError(start != end); + std::advance(start, std::distance(start, end) - 1); + return start; + } +}; + +struct End { + type_iterator operator()(type_iterator start, type_iterator end) const { + return end; + } +}; + +template, typename End = End> +struct All { + All(){} + All(type_iterator, type_iterator){} + bool operator()(const std::string& name, type_iterator start, type_iterator end, + std::ostream& os) const { + bool retval = true; + type_iterator begin = Start()(start, end); + type_iterator finish = End()(start, end); + Check c(start, end); + for(; begin != finish; ++begin) { + if(!c(name, *begin, os)) { + os << "Constraint " << name << " takes a " << c.description() << " argument at " + << std::distance(begin, finish) << ", not a " << (*begin)->getName() << + std::endl; + retval = false; + } + } + return retval; + } + +}; + +template +struct And { + And(){} + And(type_iterator, type_iterator) {} + bool operator()(const std::string& name, type_iterator start, type_iterator end, + std::ostream& os) const { + A m_a(start, end); + B m_b(start, end); + bool a = m_a(name, start, end, os); + bool b = m_b(name, start, end, os); + return a && b; + } + bool operator()(const std::string& name, DataTypeId dt, std::ostream& os) const { + bool retval = true; + A m_a; + B m_b; + if(!m_a(name, dt, os)) { + os << "Constraint " << name << " requires that " << dt->getName() << + " be " << m_a.description() << std::endl; + retval = false; + } + if(!m_b(name, dt, os)) { + os << "Constraint " << name << " requires that " << dt->getName() << + " be " << m_b.description() << std::endl; + retval = false; + } + return retval; + } + std::string description() const { + std::ostringstream str; + A m_a; + B m_b; + str << m_a.description() << " and " << m_b.description(); + return str.str(); + } +}; + +template, typename End = End> +struct Mutually { + Mutually(){} + Mutually(type_iterator, type_iterator){} + bool operator()(const std::string& name, type_iterator start, type_iterator end, + std::ostream& os) const { + Check m_c(start, end); + type_iterator begin = Start()(start, end); + type_iterator finish = End()(start, end); + type_iterator next = begin; + std::advance(next, 1); + bool retval = true; + for(; next != finish; ++begin, ++next) { + retval = (*this)(name, *begin, *next, os) && retval; + } + return retval; + } + + bool operator()(const std::string& name, DataTypeId one, DataTypeId two, + std::ostream& os) const { + Check m_c; + bool a = m_c(name, one, two, os); + bool b = m_c(name, two, one, os); + if(!a || !b) { + os << "Constraint " << name << " requires that " << + one->getName() << " and " << two->getName() << + " be mutually " << m_c.description() << std::endl; + return false; + } + return true; + } +}; + +//predicates +//Bounds accessors? +struct CanBePositive { + CanBePositive(){} + CanBePositive(type_iterator, type_iterator){} + bool operator()(const std::string&, DataTypeId dt, std::ostream&) const; + std::string description() const {return "possibly positive";} +}; + +struct Numeric { + Numeric(){} + Numeric(type_iterator, type_iterator){} + bool operator()(const std::string&, DataTypeId dt, std::ostream&) const { + return dt->isNumeric(); + } + std::string description() const {return "numeric";} +}; + +struct IsEntity { + IsEntity(){} + IsEntity(type_iterator, type_iterator){} + bool operator()(const std::string&, DataTypeId dt, std::ostream&) const { + return dt->isEntity(); + } + std::string description() const {return "entity";} +}; + +template +struct Assignable { + Assignable(type_iterator start, type_iterator end) : m_d() { + checkError(start != end); + Accessor a; + m_d = *a(start, end); + checkError(m_d.isValid()); + } + Assignable() : m_d(Accessor::instance()) {} + bool operator()(const std::string&, DataTypeId dt, std::ostream&) const { + return m_d->isAssignableFrom(dt); + } + std::string description() const {return "assignable";} + + DataTypeId m_d; +}; + +template<> +struct Assignable { + Assignable(){} + Assignable(type_iterator, type_iterator){} + bool operator()(const std::string&, DataTypeId dt1, DataTypeId dt2, std::ostream&) const { + return dt1->isAssignableFrom(dt2) || (dt1->isNumeric() && dt2->isNumeric()); + } + std::string description() const {return "assignable";} +}; + +template +struct Comparable { + Comparable(type_iterator start, type_iterator end) : m_d() { + checkError(start != end); + Accessor a; + m_d = *a(start, end); + checkError(m_d.isValid()); + } + Comparable() : m_d(Accessor::instance()) {} + bool operator()(const std::string&, DataTypeId dt, std::ostream&) const { + return m_d->canBeCompared(dt); + } + std::string description() const {return "assignable";} + + DataTypeId m_d; +}; + +template<> +struct Comparable { + Comparable(){} + Comparable(type_iterator, type_iterator){} + bool operator()(const std::string&, DataTypeId dt1, DataTypeId dt2, std::ostream&) const { + return dt1->canBeCompared(dt2); + } + std::string description() const {return "assignable";} +}; + +/** + * @struct Same + * + */ + +struct Same { + bool operator()(const std::string&, DataTypeId dt, std::ostream&) const { + if(!dtSaved.isValid()) + dtSaved = dt; + return dtSaved == dt; + } + std::string description() const {return "same";} + mutable DataTypeId dtSaved; +}; + +/** + * @struct Type + * Predicate. Checks that a data type is of a specific type by comparing DataType pointers. + */ +template +struct Type { + Type(){} + Type(type_iterator, type_iterator) {} + bool operator()(const std::string&, DataTypeId dt, std::ostream&) const { + return T::instance() == dt; + } + std::string description() const {return T::instance()->getName();} +}; + +/** + * @class DataTypeCheckBase + * DataTypeCheckBase checks the vector of argument types for the constraint against the + * check expression given in the TypeCheck parameter, throwing a message string if + * the check fails (returns false). + */ +//TODO: Make this not use throw. +template +class DataTypeCheckBase : public ConstraintType { + public: + DataTypeCheckBase(const std::string& _name, const std::string& _propagatorName, + bool systemDefined = false) + : ConstraintType(_name, _propagatorName, systemDefined), m_check() {} + + virtual ConstraintId createConstraint(const ConstraintEngineId constraintEngine, + const std::vector& scope, + const std::string& violationExpl) = 0; + + void checkArgTypes(const std::vector& argTypes) const { + std::ostringstream str; + if(!m_check(this->m_name, argTypes.begin(), argTypes.end(), str)) + throw str.str(); + } + private: + TypeCheck m_check; +}; + +/** + * @class DataTypeCheck + * This class is the constraint-developer-level interface to the type-check generator code. + * The Constr type parameter is the type of the constraint class to create and the TypeCheck + * parameter is the statement of the checks to be performed. + * + * All the implementation really does is extend DataTypeCheckBase and implement the + * ConstraintType::createConstraint method. + */ +template +class DataTypeCheck : public DataTypeCheckBase { + public: + DataTypeCheck(const std::string& _name, const std::string& _propagatorName, + bool systemDefined = false) + : DataTypeCheckBase(_name, _propagatorName, systemDefined) {} + + ConstraintId createConstraint(const ConstraintEngineId constraintEngine, + const std::vector& scope, + const std::string& violationExpl) { + return makeConstraintInstance(this->m_name, this->m_propagatorName, + constraintEngine,scope, violationExpl); + + } +}; +} + +#endif /* CONSTRAINTTYPECHECKING_H_ */ diff --git a/src/PLASMA/ConstraintEngine/base/DataType.cc b/src/PLASMA/ConstraintEngine/base/DataType.cc index cedcd3cf2..d5ae3419d 100644 --- a/src/PLASMA/ConstraintEngine/base/DataType.cc +++ b/src/PLASMA/ConstraintEngine/base/DataType.cc @@ -12,7 +12,7 @@ namespace EUROPA { -DataType::DataType(const char* name) +DataType::DataType(const std::string& name) : m_id(this) , m_name(name) , m_isRestricted(false) @@ -29,10 +29,10 @@ DataType::~DataType() delete m_baseDomain; } -const DataTypeId& DataType::getId() const { return m_id; } +const DataTypeId DataType::getId() const { return m_id; } -const LabelStr& DataType::getName() const { return m_name; } -void DataType::setName(const LabelStr& name) { m_name = name; } +const std::string& DataType::getName() const { return m_name; } +void DataType::setName(const std::string& name) { m_name = name; } bool DataType::isEntity() const {return false;} @@ -42,7 +42,7 @@ bool DataType::getIsRestricted() const { return m_isRestricted; } void DataType::setIsRestricted(bool b) { m_isRestricted = b; } // TODO: this can be more sophisticated -bool DataType::canBeCompared(const DataTypeId& rhs) const +bool DataType::canBeCompared(const DataTypeId rhs) const { // Assumes type names don't matter for now @@ -59,7 +59,7 @@ bool DataType::canBeCompared(const DataTypeId& rhs) const } // TODO: make this more sophisticated, may have to delegate to each type -bool DataType::isAssignableFrom(const DataTypeId& rhs) const +bool DataType::isAssignableFrom(const DataTypeId rhs) const { if (isNumeric()) { @@ -86,50 +86,49 @@ edouble DataType::minDelta() const } ConstrainedVariableId -DataType::createVariable(const ConstraintEngineId& constraintEngine, - const Domain& baseDomain, - const bool internal, - bool canBeSpecified, - const char* name, - const EntityId& parent, - int index) const +DataType::createVariable(const ConstraintEngineId constraintEngine, + const Domain& _baseDomain, + const bool internal, + bool canBeSpecified, + const std::string& name, + const EntityId parent, + unsigned int index) const { - // TODO: perform stronger checks here - check_error(Domain::canBeCompared(*m_baseDomain,baseDomain), - std::string("Tried to create a ") + getName().c_str() - + " variable with a different kind of base domain:" - + baseDomain.getTypeName().c_str()); - - Variable* variable = new Variable( - constraintEngine, - baseDomain, - internal, - canBeSpecified, - name, - parent, - index - ); - - check_error(variable != NULL, - std::string("Failed to create Variable of type ")+ getName().c_str() +" with name '" + std::string(name) + "'"); - - ConstrainedVariableId id = variable->getId(); - check_error(id.isValid()); - - debugMsg("DataType::createVariable", "Created Variable : " << id->toLongString()); - - return id; + // TODO: perform stronger checks here + check_error(Domain::canBeCompared(*m_baseDomain,_baseDomain), + std::string("Tried to create a ") + getName().c_str() + + " variable with a different kind of base domain:" + + _baseDomain.getTypeName().c_str()); + + Variable* variable = new Variable( + constraintEngine, + _baseDomain, + internal, + canBeSpecified, + name, + parent, + index + ); + + check_error(variable != NULL, + std::string("Failed to create Variable of type ")+ getName().c_str() +" with name '" + std::string(name) + "'"); + + ConstrainedVariableId id = variable->getId(); + check_error(id.isValid()); + + debugMsg("DataType::createVariable", "Created Variable : " << id->toLongString()); + + return id; } -std::string DataType::toString(edouble value) const -{ - if(isNumeric()) - return EUROPA::toString(value); - else { - checkError(LabelStr::isString(value), "expected LabelStr"); - return LabelStr(value).toString(); - } +std::string DataType::toString(edouble value) const { + if(isNumeric()) + return EUROPA::toString(value); + else { + checkError(LabelStr::isString(value), "expected LabelStr"); + return LabelStr(value).toString(); + } } } diff --git a/src/PLASMA/ConstraintEngine/base/DataType.hh b/src/PLASMA/ConstraintEngine/base/DataType.hh index fed41c2f1..267575fd2 100644 --- a/src/PLASMA/ConstraintEngine/base/DataType.hh +++ b/src/PLASMA/ConstraintEngine/base/DataType.hh @@ -9,7 +9,6 @@ #define DATATYPE_HH_ #include "ConstraintEngineDefs.hh" -#include "LabelStr.hh" #include "ConstrainedVariable.hh" namespace EUROPA { @@ -24,116 +23,119 @@ public: class DataType: public PSDataType { -public: - DataType(const char* name); - - virtual ~DataType(); - - const DataTypeId& getId() const; - - /** - * @brief Get the data type's name. - */ - virtual const LabelStr& getName() const; - - // From PSDataType - const std::string& getNameString() const { return getName().toString(); } - - /** - * @brief Set the data ype's name. - */ - virtual void setName(const LabelStr& name); - - /** - * @brief Check if the domain is numeric. - */ - virtual bool isNumeric() const = 0; - - /** - * @brief Check if the domain is Boolean. - */ - virtual bool isBool() const = 0; - - /** - * @brief Check if the domain is String. - */ - virtual bool isString() const = 0; - - /** - * @brief Check if the domain contains entities - */ - virtual bool isEntity() const; - - /** - * @brief Check if the domain is symbolic. - */ - virtual bool isSymbolic() const; - - /** - * @brief Tests if two data types can be compared. - * For example, one cannot compare a string with and int - * This is useful to enforce type checking, in constraints in particular. - */ - virtual bool canBeCompared(const DataTypeId& rhs) const; - - /* - * @brief Tests if this variables with this data type - * can be assigned values with data type rhs. - * TODO: Do we need canBeCompared and this one? - * It is better to perform type checking with this, - * for instance, floats and ints can be compared, - * but assignment only goes one way, in general. - * isAssignableFrom + a explicit cast/convert method should cover all use cases - */ - virtual bool isAssignableFrom(const DataTypeId& rhs) const; - - /** - * is the original definition for this domain restricted?, for instance : int [3 10], float {3.0,4.0}, etc - */ - virtual bool getIsRestricted() const; - - /** - * is the original definition for this domain restricted?, for instance : int [3 10], float {3.0,4.0}, etc - */ - virtual void setIsRestricted(bool b); - - /** - * @brief Return the base domain - */ - virtual const Domain& baseDomain() const; - - /** - * @brief Create a value for a string - */ - virtual edouble createValue(const std::string& value) const = 0; - - /** - * @brief Returns the minimum allowed delta in values between elements data type - */ - virtual edouble minDelta() const; - - /** - * @brief Create string for a value - */ - virtual std::string toString(edouble value) const; - - /** - * @brief Create a variable - */ - virtual ConstrainedVariableId createVariable(const ConstraintEngineId& constraintEngine, - const Domain& baseDomain, - const bool internal = false, - bool canBeSpecified = true, - const char* name = NO_VAR_NAME, - const EntityId& parent = EntityId::noId(), - int index = ConstrainedVariable::NO_INDEX) const; - -protected: - DataTypeId m_id; - LabelStr m_name; - bool m_isRestricted; - Domain* m_baseDomain; - edouble m_minDelta; /**< The minimum amount by which elements of this data type may vary. Once this is set, DO NOT CHANGE IT.*/ + public: + DataType(const std::string& name); + + virtual ~DataType(); + + const DataTypeId getId() const; + + /** + * @brief Get the data type's name. + */ + virtual const std::string& getName() const; + + // From PSDataType + const std::string& getNameString() const { return getName(); } + + /** + * @brief Set the data ype's name. + */ + virtual void setName(const std::string& name); + + /** + * @brief Check if the domain is numeric. + */ + virtual bool isNumeric() const = 0; + + /** + * @brief Check if the domain is Boolean. + */ + virtual bool isBool() const = 0; + + /** + * @brief Check if the domain is String. + */ + virtual bool isString() const = 0; + + /** + * @brief Check if the domain contains entities + */ + virtual bool isEntity() const; + + /** + * @brief Check if the domain is symbolic. + */ + virtual bool isSymbolic() const; + + /** + * @brief Tests if two data types can be compared. + * For example, one cannot compare a string with and int + * This is useful to enforce type checking, in constraints in particular. + */ + virtual bool canBeCompared(const DataTypeId rhs) const; + + /* + * @brief Tests if this variables with this data type + * can be assigned values with data type rhs. + * TODO: Do we need canBeCompared and this one? + * It is better to perform type checking with this, + * for instance, floats and ints can be compared, + * but assignment only goes one way, in general. + * isAssignableFrom + a explicit cast/convert method should cover all use cases + */ + virtual bool isAssignableFrom(const DataTypeId rhs) const; + + /** + * is the original definition for this domain restricted?, for instance : int [3 10], float {3.0,4.0}, etc + */ + virtual bool getIsRestricted() const; + + /** + * is the original definition for this domain restricted?, for instance : int [3 10], float {3.0,4.0}, etc + */ + virtual void setIsRestricted(bool b); + + /** + * @brief Return the base domain + */ + virtual const Domain& baseDomain() const; + + /** + * @brief Create a value for a string + */ + virtual edouble createValue(const std::string& value) const = 0; + + /** + * @brief Returns the minimum allowed delta in values between elements data type + */ + virtual edouble minDelta() const; + + /** + * @brief Create string for a value + */ + virtual std::string toString(edouble value) const; + + /** + * @brief Create a variable + */ + virtual ConstrainedVariableId createVariable(const ConstraintEngineId constraintEngine, + const Domain& baseDomain, + const bool internal = false, + bool canBeSpecified = true, + const std::string& name = NO_VAR_NAME, + const EntityId parent = EntityId::noId(), + unsigned int index = ConstrainedVariable::NO_INDEX) const; + + protected: + DataTypeId m_id; + std::string m_name; + bool m_isRestricted; + Domain* m_baseDomain; + edouble m_minDelta; /**< The minimum amount by which elements of this data type may vary. Once this is set, DO NOT CHANGE IT.*/ + private: + DataType(const DataType& other); + DataType& operator=(const DataType& other); }; } diff --git a/src/PLASMA/ConstraintEngine/base/Domain.cc b/src/PLASMA/ConstraintEngine/base/Domain.cc index 94e905d4a..30d0f7d74 100644 --- a/src/PLASMA/ConstraintEngine/base/Domain.cc +++ b/src/PLASMA/ConstraintEngine/base/Domain.cc @@ -12,38 +12,17 @@ namespace EUROPA { return(os); } - DomainComparator* DomainComparator::s_instance = NULL; - /** * @brief Constructor overwrites prior static instance, effecting a last-writer wins policy * for establishing the shared allocator. */ DomainComparator::DomainComparator(){ - // Assign instance to current value - s_instance = this; } /** * @brief On destruction, if the static instance is this object, then set it to null. */ DomainComparator::~DomainComparator(){ - if(s_instance == this) - s_instance = NULL; - } - - const DomainComparator& DomainComparator::getComparator(){ - if(s_instance == NULL) - new DomainComparator(); - return *s_instance; - } - - void DomainComparator::setComparator(DomainComparator* comparator) { - //check_error(s_instance == NULL, "The comparator can only be set when it is currently null"); - s_instance = comparator; - } - - bool DomainComparator::comparatorIsNull() { - return s_instance == NULL; } /** @@ -62,14 +41,15 @@ namespace EUROPA { m_id.remove(); } - const DomainListenerId& DomainListener::getId() const { + const DomainListenerId DomainListener::getId() const { return(m_id); } - Domain::Domain(const DataTypeId& dt, bool enumerated, bool closed) + Domain::Domain(const DataTypeId dt, bool enumerated, bool closed) : m_dataType(dt) , m_enumerated(enumerated) , m_closed(closed) + , m_listener() { } @@ -77,6 +57,7 @@ namespace EUROPA { : m_dataType(org.m_dataType) , m_enumerated(org.m_enumerated) , m_closed(org.m_closed) + , m_listener() { } @@ -117,7 +98,7 @@ namespace EUROPA { bool Domain::isInterval() const { return(!m_enumerated); } bool Domain::isInfinite() const { return(!isFinite()); } - void Domain::setListener(const DomainListenerId& listener) { + void Domain::setListener(const DomainListenerId listener) { check_error(m_listener.isNoId()); // Only set once m_listener = listener; @@ -129,7 +110,7 @@ namespace EUROPA { } } - const DomainListenerId& Domain::getListener() const { + const DomainListenerId Domain::getListener() const { return(m_listener); } @@ -147,7 +128,7 @@ namespace EUROPA { } void Domain::operator>>(ostream& os) const { - os << getTypeName().toString() << (m_closed ? ":CLOSED" : ":OPEN"); + os << getTypeName() << (m_closed ? ":CLOSED" : ":OPEN"); } edouble Domain::translateNumber(edouble number, bool) const { @@ -165,10 +146,10 @@ namespace EUROPA { bool Domain::canBeCompared(const Domain& domx, const Domain& domy) { debugMsg("Domain:canBeCompared", "domx.isBool " << domx.isBool() << " domx.isNumeric " << domx.isNumeric() << " domx.isString " << domx.isString() << " domx.isSymbolic " << domx.isSymbolic()); debugMsg("Domain:canBeCompared", "domy.isBool " << domy.isBool() << " domy.isNumeric " << domy.isNumeric() << " domy.isString " << domy.isString() << " domy.isSymbolic " << domy.isSymbolic()); - debugMsg("Domain:canBeCompared", "type of domx " << domx.getTypeName().toString() << " type of domy " << domy.getTypeName().toString()); + debugMsg("Domain:canBeCompared", "type of domx " << domx.getTypeName() << " type of domy " << domy.getTypeName()); debugMsg("Domain:canBeCompared", domx.toString()); debugMsg("Domain:canBeCompared", domy.toString()); - bool result = DomainComparator::getComparator().canCompare(domx, domy); + bool result = domx.getDataType()->canBeCompared(domy.getDataType()); debugMsg("Domain:canBeCompared", "returning " << result); return result; } @@ -193,7 +174,7 @@ namespace EUROPA { void Domain::assertSafeComparison(const Domain& domA, const Domain& domB){ check_error(canBeCompared(domA, domB), - domA.getTypeName().toString() + " cannot be compared with " + domB.getTypeName().toString()); + domA.getTypeName() + " cannot be compared with " + domB.getTypeName()); } @@ -204,11 +185,11 @@ namespace EUROPA { } - const DataTypeId& Domain::getDataType() const { return m_dataType; } - void Domain::setDataType(const DataTypeId& dt) { m_dataType=dt; } + const DataTypeId Domain::getDataType() const { return m_dataType; } + void Domain::setDataType(const DataTypeId dt) { m_dataType=dt; } // TODO: all these just delegate to the data type, should be dropped eventually, preserved for now for backwards compatibility - const LabelStr& Domain::getTypeName() const { return getDataType()->getName(); } +const std::string& Domain::getTypeName() const { return getDataType()->getName(); } bool Domain::isSymbolic() const { return getDataType()->isSymbolic(); } bool Domain::isEntity() const { return getDataType()->isEntity(); } bool Domain::isNumeric() const { return getDataType()->isNumeric(); } diff --git a/src/PLASMA/ConstraintEngine/base/Domain.hh b/src/PLASMA/ConstraintEngine/base/Domain.hh index a31f517ec..4ade2662d 100644 --- a/src/PLASMA/ConstraintEngine/base/Domain.hh +++ b/src/PLASMA/ConstraintEngine/base/Domain.hh @@ -1,5 +1,5 @@ -#ifndef _H_Domain -#define _H_Domain +#ifndef H_Domain +#define H_Domain /** * @file Domain.hh @@ -36,13 +36,10 @@ * @see Variable, Constraint */ #include "ConstraintEngineDefs.hh" -#include "LabelStr.hh" #include "DomainListener.hh" #include "Number.hh" #include -#include #include -#include #ifdef EUROPA_FAST #define safeConversion(value) (value) @@ -55,6 +52,8 @@ #endif namespace EUROPA { +class LabelStr; + using std::ostream; // TODO!: drop this? @@ -69,29 +68,11 @@ namespace EUROPA { DomainComparator(); virtual ~DomainComparator(); - /** - * @brief Retrieve the singleton comparator - */ - static const DomainComparator& getComparator(); - /** * @brief Tests if domains can be compared. */ virtual bool canCompare(const Domain& domx, const Domain& domy) const; - /** - * @brief Set the comparator to be used. Can only be set if it is currently null. - */ - static void setComparator(DomainComparator* comparator); - - /** - * @brief return true iff comparator is null. False otherwise. - */ - bool comparatorIsNull(); - - - private: - static DomainComparator* s_instance; /*!< Access pointer location. Enforces singleton pattern */ }; ostream& operator<<(ostream& os, const Domain& dom); @@ -275,7 +256,7 @@ namespace EUROPA { /** * @brief Remove the given element form the domain. - * @param value. The value to be removed. + * @param value The value to be removed. * @note If the value was in the domain, this call will generate a value removal event. * @see DomainListener::VALUE_REMOVED */ @@ -310,7 +291,7 @@ namespace EUROPA { * @note Can only be called on domains that have no listeners attached, * since it will not cause propagation. It is more of a utility. */ - virtual Domain& operator=(const Domain& dom) { + virtual Domain& operator=(const Domain&) { return(*this); } @@ -334,14 +315,14 @@ namespace EUROPA { /** * @brief Test if this domain is a subset of dom. * @param dom the domain tested against. - * @param true if all elements of this domain are in dom. Otherwise false. + * @return true if all elements of this domain are in dom. Otherwise false. */ virtual bool isSubsetOf(const Domain& dom) const = 0; /** * @brief Test if the intersection between this domain and the given domain is empty. * @param dom the domain tested against. - * @param true if any elements of this domain are in dom. Otherwise false. + * @return true if any elements of this domain are in dom. Otherwise false. */ virtual bool intersects(const Domain& dom) const = 0; @@ -361,13 +342,13 @@ namespace EUROPA { * Will error out if that is not the case. * @param listener the listener to attach. */ - virtual void setListener(const DomainListenerId& listener); + virtual void setListener(const DomainListenerId listener); /** * @brief Accessor for the listener. * @return the listener. May be noId() if no listener attached */ - virtual const DomainListenerId& getListener() const; + virtual const DomainListenerId getListener() const; /** * "Deeply" copy the concrete C++ object into new memory and return a pointer to it. @@ -392,10 +373,10 @@ namespace EUROPA { */ static bool canBeCompared(const Domain& domx, const Domain& domy); - const DataTypeId& getDataType() const; + const DataTypeId getDataType() const; // TODO: all these just delegate to the data type, should be dropped eventually, preserved for now for backwards compatibility - const LabelStr& getTypeName() const; + const std::string& getTypeName() const; bool isSymbolic() const; bool isEntity() const; bool isNumeric() const; @@ -442,13 +423,13 @@ namespace EUROPA { protected: /** * @brief Constructor. + * @param dataType indicates the type name to use + * @param enumerated true if this is an explicit enumeration. * @param closed indicates if the domain is to be dynamic or closed on construction. Once closed, no * additions to extend the contents of the domain will be permitted. - * @param enumerated true if this is an explicit enumeration. - * @param typeName indicates the type name to use * @todo Review how semantics of closed can be enforced in operations. */ - Domain(const DataTypeId& dataType, bool enumerated, bool closed); + Domain(const DataTypeId dataType, bool enumerated, bool closed); /** * @brief Copy Constructor @@ -479,7 +460,7 @@ namespace EUROPA { */ static void assertSafeComparison(const Domain& domA, const Domain& domB); - void setDataType(const DataTypeId& dt); + void setDataType(const DataTypeId dt); friend class RestrictedDT; DataTypeId m_dataType; diff --git a/src/PLASMA/ConstraintEngine/base/DomainListener.hh b/src/PLASMA/ConstraintEngine/base/DomainListener.hh index 4269d3518..109859c68 100644 --- a/src/PLASMA/ConstraintEngine/base/DomainListener.hh +++ b/src/PLASMA/ConstraintEngine/base/DomainListener.hh @@ -1,5 +1,5 @@ -#ifndef _H_DomainListener -#define _H_DomainListener +#ifndef H_DomainListener +#define H_DomainListener /** * @file DomainListener.hh @@ -58,7 +58,7 @@ namespace EUROPA{ * modified when ChangeType is added to. * @see ChangeType */ - static const int EVENT_COUNT = (int)LAST_CHANGE_TYPE; + static const int EVENT_COUNT = static_cast(LAST_CHANGE_TYPE); static std::string toString(const ChangeType& changeType); @@ -83,11 +83,11 @@ namespace EUROPA{ /** * @brief Id accessor */ - const DomainListenerId& getId() const; + const DomainListenerId getId() const; /** * @brief The critical method to implement in order to define how events are to be propagated. - * @param changetype the type of change occuring on the domain. + * @param changeType the type of change occuring on the domain. */ virtual void notifyChange(const ChangeType& changeType) = 0; diff --git a/src/PLASMA/ConstraintEngine/base/PSConstraintEngine.hh b/src/PLASMA/ConstraintEngine/base/PSConstraintEngine.hh index e7d11554c..c90c02fe7 100644 --- a/src/PLASMA/ConstraintEngine/base/PSConstraintEngine.hh +++ b/src/PLASMA/ConstraintEngine/base/PSConstraintEngine.hh @@ -1,9 +1,9 @@ -#ifndef _H_PSConstraintEngine -#define _H_PSConstraintEngine +#ifndef H_PSConstraintEngine +#define H_PSConstraintEngine #include "Engine.hh" -#include "PSUtils.hh" -#include "LabelStr.hh" +#include "PSEntity.hh" +#include "PSList.hh" namespace EUROPA { diff --git a/src/PLASMA/ConstraintEngine/base/PSConstraintEngineListener.cc b/src/PLASMA/ConstraintEngine/base/PSConstraintEngineListener.cc index 87afd63d6..10553ffbf 100644 --- a/src/PLASMA/ConstraintEngine/base/PSConstraintEngineListener.cc +++ b/src/PLASMA/ConstraintEngine/base/PSConstraintEngineListener.cc @@ -12,18 +12,34 @@ namespace EUROPA { // Methods to convert notifications involving internal Europa types to notifications involving 'PS' types: -void PSConstraintEngineListener::notifyViolationAdded(const ConstraintId& constraint){ - notifyViolationAdded((PSConstraint *) constraint); +void PSConstraintEngineListener::notifyViolationAdded(const ConstraintId constraint){ + notifyViolationAdded(id_cast(constraint)); } -void PSConstraintEngineListener::notifyViolationRemoved(const ConstraintId& constraint){ - notifyViolationRemoved((PSConstraint *) constraint); +void PSConstraintEngineListener::notifyViolationRemoved(const ConstraintId constraint){ + notifyViolationRemoved(id_cast(constraint)); } -void PSConstraintEngineListener::notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType) { - notifyChanged((PSVariable *) variable, (PSChangeType) changeType); +void PSConstraintEngineListener::notifyChanged(const ConstrainedVariableId variable, + const DomainListener::ChangeType& changeType) { + notifyChanged(id_cast(variable), static_cast(changeType)); } +void PSConstraintEngineListener::notifyViolationAdded(PSConstraint*) {} +void PSConstraintEngineListener::notifyViolationRemoved(PSConstraint*) {} +void PSConstraintEngineListener::notifyChanged(PSVariable*, PSChangeType){} + +void PSConstraintEngineListener::notifyAdded(const ConstraintId) {} +void PSConstraintEngineListener::notifyActivated(const ConstraintId) {} +void PSConstraintEngineListener::notifyDeactivated(const ConstraintId) {} +void PSConstraintEngineListener::notifyRemoved(const ConstraintId) {} +void PSConstraintEngineListener::notifyExecuted(const ConstraintId) {} + +void PSConstraintEngineListener::notifyDeactivated(const ConstrainedVariableId) {} +void PSConstraintEngineListener::notifyActivated(const ConstrainedVariableId) {} +void PSConstraintEngineListener::notifyAdded(const ConstrainedVariableId) {} +void PSConstraintEngineListener::notifyRemoved(const ConstrainedVariableId) {} + } diff --git a/src/PLASMA/ConstraintEngine/base/PSConstraintEngineListener.hh b/src/PLASMA/ConstraintEngine/base/PSConstraintEngineListener.hh index 1a89153eb..6224676f5 100644 --- a/src/PLASMA/ConstraintEngine/base/PSConstraintEngineListener.hh +++ b/src/PLASMA/ConstraintEngine/base/PSConstraintEngineListener.hh @@ -2,7 +2,6 @@ #define PSCONSTRAINTENGINELISTENER_H_ #include "ConstraintEngineListener.hh" -#include "PSConstraintEngine.hh" /* * PSConstraintEngineListener.h @@ -15,8 +14,8 @@ */ namespace EUROPA { - - +class PSConstraint; +class PSVariable; class PSConstraintEngineListener: public ConstraintEngineListener { public: @@ -27,35 +26,35 @@ public: virtual ~PSConstraintEngineListener() {} /* The subset of notifications available through PSEngine interface */ - virtual void notifyViolationAdded(PSConstraint* constraint) {} - virtual void notifyViolationRemoved(PSConstraint* constraint) {} - virtual void notifyChanged(PSVariable* variable, PSChangeType changeType){} + virtual void notifyViolationAdded(PSConstraint* constraint); + virtual void notifyViolationRemoved(PSConstraint* constraint); + virtual void notifyChanged(PSVariable* variable, PSChangeType changeType); private: - /* We override these base class methods (called by ConstraintEngine) - * to call the above PS interface versions of the same methods. - */ - virtual void notifyViolationAdded(const ConstraintId& variable); - virtual void notifyViolationRemoved(const ConstraintId& variable); - virtual void notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType); - - /* These methods are likely unnecessary to a user. We override the base - * class version only to make private (they still don't do anything) - */ - virtual void notifyPropagationCommenced() {} - virtual void notifyPropagationCompleted() {} - virtual void notifyPropagationPreempted() {} - virtual void notifyAdded(const ConstraintId& constraint) {} - virtual void notifyActivated(const ConstraintId& constraint) {} - virtual void notifyDeactivated(const ConstraintId& constraint) {} - virtual void notifyRemoved(const ConstraintId& constraint) {} - virtual void notifyExecuted(const ConstraintId& constraint) {} - - virtual void notifyDeactivated(const ConstrainedVariableId& variable) {} - virtual void notifyActivated(const ConstrainedVariableId& variable) {} - virtual void notifyAdded(const ConstrainedVariableId& variable) {} - virtual void notifyRemoved(const ConstrainedVariableId& variable) {} + /* We override these base class methods (called by ConstraintEngine) + * to call the above PS interface versions of the same methods. + */ + virtual void notifyViolationAdded(const ConstraintId variable); + virtual void notifyViolationRemoved(const ConstraintId variable); + virtual void notifyChanged(const ConstrainedVariableId variable, const DomainListener::ChangeType& changeType); + + /* These methods are likely unnecessary to a user. We override the base + * class version only to make private (they still don't do anything) + */ + virtual void notifyPropagationCommenced() {} + virtual void notifyPropagationCompleted() {} + virtual void notifyPropagationPreempted() {} + virtual void notifyAdded(const ConstraintId constraint); + virtual void notifyActivated(const ConstraintId constraint); + virtual void notifyDeactivated(const ConstraintId constraint); + virtual void notifyRemoved(const ConstraintId constraint); + virtual void notifyExecuted(const ConstraintId constraint); + + virtual void notifyDeactivated(const ConstrainedVariableId variable); + virtual void notifyActivated(const ConstrainedVariableId variable); + virtual void notifyAdded(const ConstrainedVariableId variable); + virtual void notifyRemoved(const ConstrainedVariableId variable); }; } diff --git a/src/PLASMA/ConstraintEngine/base/PSVarValue.cc b/src/PLASMA/ConstraintEngine/base/PSVarValue.cc index 5036fb4dd..272caa069 100644 --- a/src/PLASMA/ConstraintEngine/base/PSVarValue.cc +++ b/src/PLASMA/ConstraintEngine/base/PSVarValue.cc @@ -29,9 +29,6 @@ namespace EUROPA { os << "OBJECT:" << obj->toString(); } break; - - default: - check_error(ALWAYS_FAILS, "Unknown type"); } return os.str(); @@ -42,11 +39,17 @@ namespace EUROPA { PSVarType PSVarValue::getType() const {return m_type;} - int PSVarValue::asInt() const {check_runtime_error(m_type == INTEGER); return (int) m_val;} +int PSVarValue::asInt() const { + check_runtime_error(m_type == INTEGER); + return static_cast(m_val); +} double PSVarValue::asDouble() const {return m_val;} - bool PSVarValue::asBoolean() const {check_runtime_error(m_type == BOOLEAN); return (bool) m_val;} +bool PSVarValue::asBoolean() const { + check_runtime_error(m_type == BOOLEAN); + return static_cast(m_val); +} const std::string& PSVarValue::asString() const { check_runtime_error(m_type == STRING); @@ -58,8 +61,8 @@ namespace EUROPA { // only works if PSEntity remains pure virtual //Id id(Entity::getEntity(edouble(m_val))); //EntityId entity = Entity::getEntity(edouble(m_val)); - EntityId entity = Entity::getEntity((edouble) m_val); - return (PSEntity *) entity; + EntityId entity = Entity::getEntity(edouble(m_val)); + return id_cast(entity); } diff --git a/src/PLASMA/ConstraintEngine/base/PSVarValue.hh b/src/PLASMA/ConstraintEngine/base/PSVarValue.hh index 858c43ebf..9f0a2a5bf 100644 --- a/src/PLASMA/ConstraintEngine/base/PSVarValue.hh +++ b/src/PLASMA/ConstraintEngine/base/PSVarValue.hh @@ -1,11 +1,12 @@ -#ifndef _H_PSVarValue -#define _H_PSVarValue +#ifndef H_PSVarValue +#define H_PSVarValue #include "PSConstraintEngine.hh" -#include "PSUtils.hh" #include "LabelStr.hh" namespace EUROPA { +class PSEntity; + class PSVarValue { public: @@ -21,11 +22,17 @@ namespace EUROPA { std::string toString() const; - static PSVarValue getInstance(const std::string& val) {return PSVarValue(cast_double((edouble)LabelStr(val)), STRING);} - static PSVarValue getInstance(int val) {return PSVarValue((double)val, INTEGER);} + static PSVarValue getInstance(const std::string& val) { + return PSVarValue(cast_double(static_cast(LabelStr(val))), STRING); + } + static PSVarValue getInstance(int val) { + return PSVarValue(static_cast(val), INTEGER); + } static PSVarValue getInstance(double val) {return PSVarValue(val, DOUBLE);} static PSVarValue getInstance(edouble val) {return PSVarValue(val, DOUBLE);} - static PSVarValue getInstance(bool val) {return PSVarValue((double)val, BOOLEAN);} + static PSVarValue getInstance(bool val) { + return PSVarValue(static_cast(val), BOOLEAN); + } static PSVarValue getObjectInstance(double obj) {return PSVarValue(obj, OBJECT);} private: diff --git a/src/PLASMA/ConstraintEngine/base/Propagator.cc b/src/PLASMA/ConstraintEngine/base/Propagator.cc index 294087b54..6c9049165 100644 --- a/src/PLASMA/ConstraintEngine/base/Propagator.cc +++ b/src/PLASMA/ConstraintEngine/base/Propagator.cc @@ -5,17 +5,19 @@ namespace EUROPA { - Propagator::Propagator(const LabelStr& name, const ConstraintEngineId& constraintEngine, int priority) - : Entity() - , m_id(this) - , m_name(name) - , m_constraintEngine(constraintEngine) - , m_enabled(true) - , m_priority(priority) - { - check_error(!m_constraintEngine.isNoId() && m_constraintEngine.isValid()); - m_constraintEngine->add(m_id); - } +Propagator::Propagator(const std::string& name, const ConstraintEngineId constraintEngine, + int priority) + : Entity() + , m_constraints() + , m_id(this) + , m_name(name) + , m_constraintEngine(constraintEngine) + , m_enabled(true) + , m_priority(priority) +{ + check_error(!m_constraintEngine.isNoId() && m_constraintEngine.isValid()); + m_constraintEngine->add(m_id); +} Propagator::~Propagator(){ discard(false); @@ -24,11 +26,11 @@ namespace EUROPA int Propagator::getPriority() const { return m_priority; } - const PropagatorId& Propagator::getId() const {return m_id;} + const PropagatorId Propagator::getId() const {return m_id;} - const LabelStr& Propagator::getName() const {return m_name;} +const std::string& Propagator::getName() const {return m_name;} - const ConstraintEngineId& Propagator::getConstraintEngine() const {return m_constraintEngine;} + const ConstraintEngineId Propagator::getConstraintEngine() const {return m_constraintEngine;} bool Propagator::isEnabled() const {return m_enabled;} @@ -38,25 +40,25 @@ namespace EUROPA const std::set& Propagator::getConstraints() const {return m_constraints;} - void Propagator::execute(const ConstraintId& constraint){ + void Propagator::execute(const ConstraintId constraint){ check_error(constraint.isValid()); m_constraintEngine->execute(constraint); } - void Propagator::addConstraint(const ConstraintId& constraint){ + void Propagator::addConstraint(const ConstraintId constraint){ check_error(constraint->getPropagator().isNoId()); checkError(!constraint->isDiscarded(), constraint); m_constraints.insert(constraint); handleConstraintAdded(constraint); } - void Propagator::removeConstraint(const ConstraintId& constraint){ + void Propagator::removeConstraint(const ConstraintId constraint){ check_error(constraint->getPropagator() == m_id); m_constraints.erase(constraint); handleConstraintRemoved(constraint); } - Domain& Propagator::getCurrentDomain(const ConstrainedVariableId& var) { + Domain& Propagator::getCurrentDomain(const ConstrainedVariableId var) { check_error(var.isValid()); return var->getCurrentDomain(); } @@ -70,4 +72,9 @@ namespace EUROPA { getConstraintEngine()->getViolationMgr().addEmptyVariable(v); } + +void Propagator::handleVariableDeactivated(const ConstrainedVariableId){} +void Propagator::handleVariableActivated(const ConstrainedVariableId){} + + } diff --git a/src/PLASMA/ConstraintEngine/base/Propagator.hh b/src/PLASMA/ConstraintEngine/base/Propagator.hh index e5e578ee1..b1b593285 100644 --- a/src/PLASMA/ConstraintEngine/base/Propagator.hh +++ b/src/PLASMA/ConstraintEngine/base/Propagator.hh @@ -1,5 +1,5 @@ -#ifndef _H_Propagator -#define _H_Propagator +#ifndef H_Propagator +#define H_Propagator /** * @file Propagator.hh @@ -10,7 +10,6 @@ #include "Entity.hh" #include "ConstraintEngineDefs.hh" #include "DomainListener.hh" -#include "LabelStr.hh" namespace EUROPA { @@ -37,12 +36,12 @@ namespace EUROPA { * @brief Retrieve the ConstraintEngine to which this Propagator belongs. * @return A valid ConstraintEngine reference */ - const ConstraintEngineId& getConstraintEngine() const; + const ConstraintEngineId getConstraintEngine() const; /** * @brief Name of propagator. Used for configuration */ - const LabelStr& getName() const; + const std::string& getName() const; /** * @brief Obtain the list of all constraints managed by this Propagator @@ -66,7 +65,7 @@ namespace EUROPA { /** * @brief Reference to self */ - const PropagatorId& getId() const; + const PropagatorId getId() const; int getPriority() const; @@ -78,7 +77,8 @@ namespace EUROPA { * @brief Constructor guarantees the Propagator belongs to exactly one ConstraintEngine * @param constraintEngine The engine to place it in. Must be a valid id. */ - Propagator(const LabelStr& name, const ConstraintEngineId& constraintEngine, int priority=USER_PRIORITY); + Propagator(const std::string& name, const ConstraintEngineId constraintEngine, + int priority=USER_PRIORITY); /** * @brief Destructor - will remove the Propagator from the ConstraintEngine. @@ -89,13 +89,13 @@ namespace EUROPA { * @brief Constraint may be added to the Propagator by the ConstraintEngine. * @param constraint The Constraint to be added. */ - void addConstraint(const ConstraintId& constraint); + void addConstraint(const ConstraintId constraint); /** * @brief Constraint may be removed from the Propagator by the ConstraintEngine. * @param constraint The Constraint to be removed. It must be present. */ - void removeConstraint(const ConstraintId& constraint); + void removeConstraint(const ConstraintId constraint); /** * @brief Handler interface for variable change events. @@ -104,14 +104,14 @@ namespace EUROPA { * This notification is information rich, so that agenda management and constraints can take advantage * of as much data as possibel if they are sophisticated enough. * @param variable The variable that has changed - * @param argIndiex The position of the variable in the scope of the given Constraint. + * @param argIndex The position of the variable in the scope of the given Constraint. * @param constraint The constraint that may need to be woken up. * @param changeType The nature of the change on the variable. Will always be a restriction * @see ConstraintEngine::notify() */ - virtual void handleNotification(const ConstrainedVariableId& variable, - int argIndex, - const ConstraintId& constraint, + virtual void handleNotification(const ConstrainedVariableId variable, + unsigned int argIndex, + const ConstraintId constraint, const DomainListener::ChangeType& changeType) = 0; /** * @brief Instruction from ConstraintEngine to commence execution of pending propagation events. @@ -130,49 +130,50 @@ namespace EUROPA { * @param constraint The Constraint to be added. * @see addConstraint() */ - virtual void handleConstraintAdded(const ConstraintId& constraint) = 0; + virtual void handleConstraintAdded(const ConstraintId constraint) = 0; /** * @brief Allow custom processing when a Constraint is removed from the Propagator. * @param constraint The Constraint to be removed. * @see removeConstraint() */ - virtual void handleConstraintRemoved(const ConstraintId& constraint) = 0; + virtual void handleConstraintRemoved(const ConstraintId constraint) = 0; /** * @brief Hook to allow a Propagator to update state if one of its constraints has been deactivated. * @param constraint The constraint that has been deactivated. */ - virtual void handleConstraintDeactivated(const ConstraintId& constraint) = 0; + virtual void handleConstraintDeactivated(const ConstraintId constraint) = 0; /** * @brief Hook to allow a Propagator to update state if one of its constraints has been activated. * @param constraint The constraint that has been activated. */ - virtual void handleConstraintActivated(const ConstraintId& constraint) = 0; + virtual void handleConstraintActivated(const ConstraintId constraint) = 0; + //TODO: Figure out why these aren't pure virtual but the other functions are /** * @brief Handle a variable deactivation. * @param var The inactive variable */ - virtual void handleVariableDeactivated(const ConstrainedVariableId& var){} + virtual void handleVariableDeactivated(const ConstrainedVariableId var); /** * @brief Handle a variable Activation. * @param var The active variable */ - virtual void handleVariableActivated(const ConstrainedVariableId& var){} + virtual void handleVariableActivated(const ConstrainedVariableId var); /** * @brief Request execution of a Constraint. * * It is not possible to directly execute a Constraint. This is because we want to ensure control policies defined * can be enforced and not circumvented in derived classes. This call will delegate execution to the ConstraintEngine. - * @param The constraint to be executed. It must be part in m_constraints. + * @param constraint The constraint to be executed. It must be part in m_constraints. */ - virtual void execute(const ConstraintId& constraint); + virtual void execute(const ConstraintId constraint); - static Domain& getCurrentDomain(const ConstrainedVariableId& var); + static Domain& getCurrentDomain(const ConstrainedVariableId var); // Constraint Violation Mgmt virtual void notifyConstraintViolated(ConstraintId c); @@ -183,8 +184,8 @@ namespace EUROPA { std::set m_constraints; /**< The list of all constraints (should be a set) managed by this Propagator. */ PropagatorId m_id; /**< Self reference. */ - const LabelStr m_name; - const ConstraintEngineId& m_constraintEngine; /**< The ConstraintEngine to which this Propagator belongs. Must be valid. */ + const std::string m_name; + const ConstraintEngineId m_constraintEngine; /**< The ConstraintEngine to which this Propagator belongs. Must be valid. */ bool m_enabled; /**< Indicates if the propagator is enabled or not */ int m_priority; }; @@ -192,7 +193,7 @@ namespace EUROPA { class PropagatorComparator { public: - bool operator()(const PropagatorId& x, const PropagatorId& y) const + bool operator()(const PropagatorId x, const PropagatorId y) const { if (x->getPriority() == y->getPriority()) return x->getKey() < y->getKey(); diff --git a/src/PLASMA/ConstraintEngine/base/VariableChangeListener.cc b/src/PLASMA/ConstraintEngine/base/VariableChangeListener.cc index f41d4d0c7..4b73cbb21 100644 --- a/src/PLASMA/ConstraintEngine/base/VariableChangeListener.cc +++ b/src/PLASMA/ConstraintEngine/base/VariableChangeListener.cc @@ -5,8 +5,8 @@ namespace EUROPA { - VariableChangeListener::VariableChangeListener(const ConstrainedVariableId& variable, - const ConstraintEngineId& constraintEngine) + VariableChangeListener::VariableChangeListener(const ConstrainedVariableId variable, + const ConstraintEngineId constraintEngine) :DomainListener(), m_variable(variable), m_constraintEngine(constraintEngine){} void VariableChangeListener::notifyChange(const ChangeType& changeType){ diff --git a/src/PLASMA/ConstraintEngine/base/VariableChangeListener.hh b/src/PLASMA/ConstraintEngine/base/VariableChangeListener.hh index 17008a7ca..8d50c3923 100644 --- a/src/PLASMA/ConstraintEngine/base/VariableChangeListener.hh +++ b/src/PLASMA/ConstraintEngine/base/VariableChangeListener.hh @@ -1,5 +1,5 @@ -#ifndef _H_VariableChangeListener -#define _H_VariableChangeListener +#ifndef H_VariableChangeListener +#define H_VariableChangeListener /** * @file VariableChangeListener.hh @@ -27,8 +27,8 @@ namespace EUROPA { * @param variable The variable to be listened to * @param constraintEngine The ConstraintEngine to whcih the listener belongs. */ - VariableChangeListener(const ConstrainedVariableId& variable, - const ConstraintEngineId& constraintEngine); + VariableChangeListener(const ConstrainedVariableId variable, + const ConstraintEngineId constraintEngine); /** * @brief Implements handler for a domaing change event. Just a pass through to the ConstraintEngine @@ -43,7 +43,7 @@ namespace EUROPA { ~VariableChangeListener(){} /**< Make this protected so only the ConstrainedVariable can delete it */ const ConstrainedVariableId m_variable; /**< The ConstrainedVariable whose domain we are listening to */ - const ConstraintEngineId& m_constraintEngine; /**< Cache the ConstraintEngine - candidate subscriber */ + const ConstraintEngineId m_constraintEngine; /**< Cache the ConstraintEngine - candidate subscriber */ }; } diff --git a/src/PLASMA/ConstraintEngine/component/CFunctions.cc b/src/PLASMA/ConstraintEngine/component/CFunctions.cc new file mode 100644 index 000000000..9874c9e72 --- /dev/null +++ b/src/PLASMA/ConstraintEngine/component/CFunctions.cc @@ -0,0 +1,7 @@ +#include "CFunctions.hh" + +namespace EUROPA { +void IsSingleton::checkArgTypes(const std::vector& ) {} + +void IsSpecified::checkArgTypes(const std::vector& ) {} +} diff --git a/src/PLASMA/ConstraintEngine/component/CFunctions.hh b/src/PLASMA/ConstraintEngine/component/CFunctions.hh index 902d17ff6..cbd96a033 100644 --- a/src/PLASMA/ConstraintEngine/component/CFunctions.hh +++ b/src/PLASMA/ConstraintEngine/component/CFunctions.hh @@ -10,6 +10,7 @@ #include "CFunction.hh" #include "DataTypes.hh" +#include "unused.hh" namespace EUROPA { @@ -24,7 +25,7 @@ public: virtual unsigned int getArgumentCount() { return 1; } // TODO: implement this - virtual void checkArgTypes(const std::vector& argTypes) {} + virtual void checkArgTypes(const std::vector& argTypes); }; class IsSpecified : public CFunction @@ -38,7 +39,7 @@ public: virtual unsigned int getArgumentCount() { return 1; } // TODO: implement this - virtual void checkArgTypes(const std::vector& argTypes) {} + virtual void checkArgTypes(const std::vector& argTypes); }; #define DECLARE_FUNCTION_TYPE(cname, fname, constraint, type, args) \ @@ -51,7 +52,7 @@ public: virtual const char* getConstraint() { return constraint; } \ virtual const DataTypeId getReturnType() { return type::instance(); } \ virtual unsigned int getArgumentCount() { return args; } \ - virtual void checkArgTypes(const std::vector& argTypes) {} \ + virtual void checkArgTypes(unused(const std::vector& argTypes)) {} \ }; // Check args TODO. diff --git a/src/PLASMA/ConstraintEngine/component/Constraints.cc b/src/PLASMA/ConstraintEngine/component/Constraints.cc index f4ca1fe5a..1861934f2 100644 --- a/src/PLASMA/ConstraintEngine/component/Constraints.cc +++ b/src/PLASMA/ConstraintEngine/component/Constraints.cc @@ -5,140 +5,22 @@ #include "Domains.hh" #include "Utils.hh" #include "Debug.hh" +#include "CESchema.hh" #include +#include namespace EUROPA { - void requireArgCount(std::string name, const std::vector& argTypes, const unsigned int count) { - if (argTypes.size() != count) { - std::ostringstream msg; msg << "Constraint " << name << " takes 2 args, not " << argTypes.size(); - throw msg.str(); - } - } - - void mutuallyAssignable(std::string name, DataTypeId a, DataTypeId b) { - if (b->isNumeric() && b->isNumeric()) { - //This is a hopefully temporary hack that makes the constraints work so the tests can pass. Waiting for agreement on the - //mailling list before deciding what to do in this case. Tony T. Pratkanis: 9/11/09. - return; - } - if (!b->isAssignableFrom(a) || !a->isAssignableFrom(b)) { - std::ostringstream msg; msg << "Constraint " << name << " args must be assignable. In this case, " - << a->getName().c_str() << " and " << b->getName().c_str() - << " are not assignable."; - throw msg.str(); - } - } - - void requireNumeric(std::string name, DataTypeId a) { - if (!a->isNumeric()) { - std::ostringstream msg; msg << "Constraint " << name << " args must be numeric. " << a->getName().c_str() << " is not."; - throw msg.str(); - } - } - - void requireBoolean(std::string name, DataTypeId a) { - if (!a->isBool()) { - std::ostringstream msg; msg << "Constraint " << name << " args must be numeric. " << a->getName().c_str() << " is not."; - throw msg.str(); - } - } - - void requireAllSame(std::string name, const std::vector& argTypes) { - for (unsigned int i = 0; i < argTypes.size(); i++) { - for (unsigned int u = i + 1; u < argTypes.size(); u++) { - mutuallyAssignable(name, argTypes[i], argTypes[u]); - } - } - } - - - void TwoSameArgumentsCT::checkArgTypes(const std::vector& argTypes) const - { - requireArgCount(m_name, argTypes, 2); - mutuallyAssignable(m_name, argTypes[0], argTypes[1]); - } - - void TwoSameNumericArgumentsCT::checkArgTypes(const std::vector& argTypes) const - { - requireArgCount(m_name, argTypes, 2); - mutuallyAssignable(m_name, argTypes[0], argTypes[1]); - requireNumeric(m_name, argTypes[0]); - requireNumeric(m_name, argTypes[1]); - } - - void TestOneArgumentCT::checkArgTypes(const std::vector& argTypes) const - { - requireArgCount(m_name, argTypes, 2); - requireBoolean(m_name, argTypes[0]); - } - - void TestTwoSameArgumentsCT::checkArgTypes(const std::vector& argTypes) const - { - requireArgCount(m_name, argTypes, 3); - mutuallyAssignable(m_name, argTypes[1], argTypes[2]); - requireBoolean(m_name, argTypes[0]); - } - - void TestTwoSameNumericArgumentsCT::checkArgTypes(const std::vector& argTypes) const - { - requireArgCount(m_name, argTypes, 3); - mutuallyAssignable(m_name, argTypes[1], argTypes[2]); - requireBoolean(m_name, argTypes[0]); - requireNumeric(m_name, argTypes[1]); - requireNumeric(m_name, argTypes[2]); - } - - void TwoBooleanArgumentsCT::checkArgTypes(const std::vector& argTypes) const - { - requireArgCount(m_name, argTypes, 2); - mutuallyAssignable(m_name, argTypes[0], argTypes[1]); - requireBoolean(m_name, argTypes[0]); - requireBoolean(m_name, argTypes[1]); - } - - void ThreeBooleanArgumentsCT::checkArgTypes(const std::vector& argTypes) const - { - requireArgCount(m_name, argTypes, 3); - mutuallyAssignable(m_name, argTypes[0], argTypes[1]); - mutuallyAssignable(m_name, argTypes[1], argTypes[2]); - mutuallyAssignable(m_name, argTypes[0], argTypes[2]); - requireBoolean(m_name, argTypes[0]); - requireBoolean(m_name, argTypes[1]); - requireBoolean(m_name, argTypes[2]); - } - - void AllSameArgumentsCT::checkArgTypes(const std::vector& argTypes) const - { - requireAllSame(m_name, argTypes); - } - - void AllSameNumericArgumentsCT::checkArgTypes(const std::vector& argTypes) const - { - requireAllSame(m_name, argTypes); - for (unsigned int i = 0; i < argTypes.size(); i++) { - requireNumeric(m_name, argTypes[i]); - } - } - - - - - - - - - UnaryConstraint::UnaryConstraint(const Domain& dom, - const ConstrainedVariableId& var) + const ConstrainedVariableId var) : Constraint("UNARY", "Default", var->getConstraintEngine(), makeScope(var)), m_x(dom.copy()), m_y(static_cast(& (getCurrentDomain(var)))) { } - UnaryConstraint::UnaryConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + UnaryConstraint::UnaryConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_x(0), @@ -164,8 +46,8 @@ namespace EUROPA { m_x = 0; } - bool UnaryConstraint::canIgnore(const ConstrainedVariableId& variable, - int argIndex, + bool UnaryConstraint::canIgnore(const ConstrainedVariableId, + unsigned int argIndex, const DomainListener::ChangeType& changeType){ checkError(argIndex == 0, "Cannot have more than one variable in scope."); @@ -177,53 +59,50 @@ namespace EUROPA { return true; } - void UnaryConstraint::setSource(const ConstraintId& sourceConstraint){ + void UnaryConstraint::setSource(const ConstraintId sourceConstraint){ checkError(m_x == 0, "Already set domain for " << toString() << " and not using " << sourceConstraint->toString()); - UnaryConstraint* source = (UnaryConstraint*) sourceConstraint; + UnaryConstraint* source = id_cast(sourceConstraint); m_x = source->m_x->copy(); } - /*************** AddEqualConstraint **********************/ - - void AddEqualCT::checkArgTypes(const std::vector& argTypes) const - { - if (argTypes.size() != 3) { - std::ostringstream msg; msg << "Constraint AddEqual takes 3 args, not " << argTypes.size(); - throw msg.str(); - } - - for (unsigned int i=0; i< argTypes.size(); i++) { - if (!argTypes[i]->isNumeric()) { - std::ostringstream msg; - msg << "Parameter " << i << " for Constraint AddEqual is not numeric : " - << argTypes[i]->getName().toString(); - throw msg.str(); - } - } - - if (!argTypes[0]->isAssignableFrom(argTypes[1]) || - !argTypes[0]->isAssignableFrom(argTypes[2])) { - std::ostringstream msg; - msg << argTypes[0]->getName().toString() << " can't hold the result of : " - << argTypes[1]->getName().toString() << "+" - << argTypes[2]->getName().toString(); - throw msg.str(); - } - } - - AddEqualConstraint::AddEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + AddEqualConstraint::AddEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_x(getCurrentDomain(m_variables[X])), m_y(getCurrentDomain(m_variables[Y])), m_z(getCurrentDomain(m_variables[Z])) { - check_error(variables.size() == (unsigned int) ARG_COUNT); + check_error(variables.size() == ARG_COUNT); } + + /** + * Utility class that might get promoted later. + */ + class Infinity { + public: + static edouble plus(edouble n1, edouble n2, edouble defaultValue) { + if (std::abs(n1) >= PLUS_INFINITY || std::abs(n2) >= PLUS_INFINITY) + return(defaultValue); + edouble retval = n1 + n2; + if(std::abs(retval) >= PLUS_INFINITY) + return defaultValue; + return retval; + } + + static edouble minus(edouble n1, edouble n2, edouble defaultValue) { + if (std::abs(n1) >= PLUS_INFINITY || std::abs(n2) >= PLUS_INFINITY) + return(defaultValue); + edouble retval = n1 - n2; + if(std::abs(retval) >= PLUS_INFINITY) + return defaultValue; + return retval; + } + }; + void AddEqualConstraint::handleExecute() { static unsigned int sl_counter(0); sl_counter++; @@ -293,13 +172,13 @@ namespace EUROPA { } /*********** MultEqualConstraint: X*Y = Z *************/ - MultEqualConstraint::MultEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + MultEqualConstraint::MultEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { - check_error(variables.size() == (unsigned int) ARG_COUNT); - for (int i = 0; i < ARG_COUNT; i++) + check_error(variables.size() == ARG_COUNT); + for (unsigned int i = 0; i < ARG_COUNT; i++) check_error(!getCurrentDomain(m_variables[i]).isEnumerated()); } /* @@ -406,109 +285,110 @@ namespace EUROPA { */ // Update Z's domain bounds using domains of X and Y in: X * Y = Z. // Return TRUE if we have new bounds for Z - bool updateMultBounds(IntervalDomain& domZ, +namespace { +bool updateMultBounds(IntervalDomain& domZ, const IntervalDomain& domX, const IntervalDomain& domY) - { - // Can not do any update if the domain of any variable is empty - if(domX.isEmpty() || domY.isEmpty() || domZ.isEmpty()) - return false; - - edouble xMin, yMin, xMax, yMax, zMin, zMax, a, b, c, d; - domX.getBounds(xMin, xMax); - domY.getBounds(yMin, yMax); - - a = xMin * yMin; - b = xMin * yMax; - c = xMax * yMin; - d = xMax * yMax; - - zMin = std::min(std::min(a,b),std::min(c,d)); - zMax = std::max(std::max(a,b),std::max(c,d)); +{ + // Can not do any update if the domain of any variable is empty + if(domX.isEmpty() || domY.isEmpty() || domZ.isEmpty()) + return false; - return domZ.intersect(zMin,zMax); - } + edouble xMin, yMin, xMax, yMax, zMin, zMax, a, b, c, d; + domX.getBounds(xMin, xMax); + domY.getBounds(yMin, yMax); + + a = xMin * yMin; + b = xMin * yMax; + c = xMax * yMin; + d = xMax * yMax; + + zMin = std::min(std::min(a,b),std::min(c,d)); + zMax = std::max(std::max(a,b),std::max(c,d)); + + return domZ.intersect(zMin,zMax); +} + +// Update Z's domain bounds using domains of X and Y in: X / Y = Z. +// Return TRUE if we have new bounds for Z +// NOTE: given the division-by-zero problem, there will be many different scenarios that need +// special treatments +bool updateDivBounds(IntervalDomain& domZ, + const IntervalDomain& domX, + const IntervalDomain& domY) +{ + // Can not do any update if the domain of any variable is empty + if(domX.isEmpty() || domY.isEmpty() || domZ.isEmpty()) + return false; - // Update Z's domain bounds using domains of X and Y in: X / Y = Z. - // Return TRUE if we have new bounds for Z - // NOTE: given the division-by-zero problem, there will be many different scenarios that need - // special treatments - bool updateDivBounds(IntervalDomain& domZ, - const IntervalDomain& domX, - const IntervalDomain& domY) - { - // Can not do any update if the domain of any variable is empty - if(domX.isEmpty() || domY.isEmpty() || domZ.isEmpty()) - return false; + edouble xMin, yMin, xMax, yMax, zMin, zMax, a, b, c, d; + domX.getBounds(xMin, xMax); + domY.getBounds(yMin, yMax); - edouble xMin, yMin, xMax, yMax, zMin, zMax, a, b, c, d; - domX.getBounds(xMin, xMax); - domY.getBounds(yMin, yMax); - - - // if [Y] = {0} (singleton 0 value) - if(yMin == 0.0 && yMax == 0.0) { - // If [X] doesn't contain 0 then inconsistent -> empty Z domain - // NOTE: alternatively, [X] can be emptied instead of [Z] but it doesn't matter - // with the current mechanism in Europa - if((xMin > 0.0 || xMax < 0.0)) { - domZ.empty(); - return true; - } else { - // If 0 \in [X] then no bound tightening (because 0/0 can be anything) - return false; - } - } - // If 0 \in [Y] but 0 is not one of the bounds then no tightening - // NOTE: regardless of the bounds of X because [Y] contains both positive & negative values - if(yMin < 0.0 && yMax > 0.0) + // if [Y] = {0} (singleton 0 value) + if(yMin == 0.0 && yMax == 0.0) { + // If [X] doesn't contain 0 then inconsistent -> empty Z domain + // NOTE: alternatively, [X] can be emptied instead of [Z] but it doesn't matter + // with the current mechanism in Europa + if((xMin > 0.0 || xMax < 0.0)) { + domZ.empty(); + return true; + } else { + // If 0 \in [X] then no bound tightening (because 0/0 can be anything) return false; - - // If [Y] doesn't contain 0. Safely compute the two possible new bounds - if(yMin > 0.0 || yMax < 0.0) { - a = xMin / yMin; - b = xMin / yMax; - c = xMax / yMin; - d = xMax / yMax; - - zMin = std::min(std::min(a,b),std::min(c,d)); - zMax = std::max(std::max(a,b),std::max(c,d)); - return domZ.intersect(zMin,zMax); } + } - // if lb[Y] = 0 OR ub[Y] = 0 and ub[Y] > lb[Y] (i.e., 0 is one but not both bounds of [Y]) - // and 0 \in [X] then there is no bound tightening (because 0/0 can be anything) - if((yMin == 0.0 || yMax == 0.0) && (xMin <= 0.0 && xMax >= 0.0)) - return false; - - /* - * if lb[Y] = 0 OR ub[Y] = 0 and [X] doesn't contain 0, then we can compute one of the bounds - */ - // One of the bounds will be \infinity so we will initialize both of the potential - // new [Z]'s bounds with the existing bounds on [Z] - domZ.getBounds(zMin, zMax); - - // Case 1 [+,+] / [0,+]: new bounds [xMin / yMax, +infinity] - if(yMin == 0.0 && xMin > 0.0) - zMin = xMin / yMax; - - // Case 2 [-,-] / [0,+] : new bounds [-infinity, xMax / yMax] - if(yMin == 0.0 && xMax < 0.0) - zMax = xMax / yMax; - - // Case 3 [+,+] / [-,0]: new bounds [-infinity, xMin /yMin] - if(yMax == 0.0 && xMin > 0.0) - zMax = xMin / yMin; + // If 0 \in [Y] but 0 is not one of the bounds then no tightening + // NOTE: regardless of the bounds of X because [Y] contains both positive & negative values + if(yMin < 0.0 && yMax > 0.0) + return false; - // Case 4 [-,-] / [-,0]: new bounds [xMax / yMin, +infinity ] - if(yMax == 0.0 && xMax < 0.0) - zMin = xMax / yMin; + // If [Y] doesn't contain 0. Safely compute the two possible new bounds + if(yMin > 0.0 || yMax < 0.0) { + a = xMin / yMin; + b = xMin / yMax; + c = xMax / yMin; + d = xMax / yMax; - // Set the new bounds + zMin = std::min(std::min(a,b),std::min(c,d)); + zMax = std::max(std::max(a,b),std::max(c,d)); return domZ.intersect(zMin,zMax); } + // if lb[Y] = 0 OR ub[Y] = 0 and ub[Y] > lb[Y] (i.e., 0 is one but not both bounds of [Y]) + // and 0 \in [X] then there is no bound tightening (because 0/0 can be anything) + if((yMin == 0.0 || yMax == 0.0) && (xMin <= 0.0 && xMax >= 0.0)) + return false; + + /* + * if lb[Y] = 0 OR ub[Y] = 0 and [X] doesn't contain 0, then we can compute one of the bounds + */ + // One of the bounds will be \infinity so we will initialize both of the potential + // new [Z]'s bounds with the existing bounds on [Z] + domZ.getBounds(zMin, zMax); + + // Case 1 [+,+] / [0,+]: new bounds [xMin / yMax, +infinity] + if(yMin == 0.0 && xMin > 0.0) + zMin = xMin / yMax; + + // Case 2 [-,-] / [0,+] : new bounds [-infinity, xMax / yMax] + if(yMin == 0.0 && xMax < 0.0) + zMax = xMax / yMax; + + // Case 3 [+,+] / [-,0]: new bounds [-infinity, xMin /yMin] + if(yMax == 0.0 && xMin > 0.0) + zMax = xMin / yMin; + + // Case 4 [-,-] / [-,0]: new bounds [xMax / yMin, +infinity ] + if(yMax == 0.0 && xMax < 0.0) + zMin = xMax / yMin; + + // Set the new bounds + return domZ.intersect(zMin,zMax); +} +} void MultEqualConstraint::handleExecute() { IntervalDomain& domX = static_cast(getCurrentDomain(m_variables[X])); IntervalDomain& domY = static_cast(getCurrentDomain(m_variables[Y])); @@ -542,14 +422,14 @@ namespace EUROPA { /*********** DivEqualConstraint: X/Y = Z *************/ - DivEqualConstraint::DivEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + DivEqualConstraint::DivEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { - check_error(variables.size() == (unsigned int) ARG_COUNT); - for (int i = 0; i < ARG_COUNT; i++) + check_error(variables.size() == ARG_COUNT); + for (unsigned int i = 0; i < ARG_COUNT; i++) check_error(!getCurrentDomain(m_variables[i]).isEnumerated()); } @@ -587,15 +467,15 @@ namespace EUROPA { } /*********** EqualConstraint *************/ - EqualConstraint::EqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + EqualConstraint::EqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_argCount(variables.size()) {} /** * @brief Restrict all variables to the intersection of their domains. - * @see equate(const ConstrainedVariableId& v1, const ConstrainedVariableId& v2, bool& isEmpty) for details of handling + * @see equate(const ConstrainedVariableId v1, const ConstrainedVariableId v2, bool& isEmpty) for details of handling * issues with open and closed domains. */ void EqualConstraint::handleExecute() { @@ -616,7 +496,7 @@ namespace EUROPA { //is now equal to the intersection of all of the variables, //we can just equate backwards and they should all be equal if(changed && m_argCount > 2) { - for(unsigned int i = m_argCount - 2; i >= 1; i--) { + for(unsigned long i = m_argCount - 2; i >= 1; i--) { ConstrainedVariableId v1 = m_variables[i]; ConstrainedVariableId v2 = m_variables[i-1]; bool isEmpty = false; @@ -627,7 +507,7 @@ namespace EUROPA { } } - bool EqualConstraint::equate(const ConstrainedVariableId& v1, const ConstrainedVariableId& v2, bool& isEmpty){ + bool EqualConstraint::equate(const ConstrainedVariableId v1, const ConstrainedVariableId v2, bool& isEmpty){ checkError(isEmpty == false, "Should be initially false."); Domain& d1 = getCurrentDomain(v1); Domain& d2 = getCurrentDomain(v2); @@ -679,14 +559,14 @@ namespace EUROPA { return changed; } - Domain& EqualConstraint::getCurrentDomain(const ConstrainedVariableId& var) { + Domain& EqualConstraint::getCurrentDomain(const ConstrainedVariableId var) { return(Constraint::getCurrentDomain(var)); } /************ SubsetOfConstraint ******************/ - SubsetOfConstraint::SubsetOfConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + SubsetOfConstraint::SubsetOfConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_currentDomain(getCurrentDomain(variables[0])), @@ -701,27 +581,27 @@ namespace EUROPA { m_currentDomain.intersect(m_superSetDomain); } - bool SubsetOfConstraint::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType){ - // If not a relaxation, and if it is the first argument, then we can ignore it as it will already be a subset - if(changeType == DomainListener::RESET || - changeType == DomainListener::RELAXED || - argIndex == 1) - return false; - else - return true; - } +bool SubsetOfConstraint::canIgnore(const ConstrainedVariableId, + unsigned int argIndex, + const DomainListener::ChangeType& changeType){ + // If not a relaxation, and if it is the first argument, then we can ignore it as it will already be a subset + if(changeType == DomainListener::RESET || + changeType == DomainListener::RELAXED || + argIndex == 1) + return false; + else + return true; +} /*********** LessThanEqualConstraint *************/ - LessThanEqualConstraint::LessThanEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + LessThanEqualConstraint::LessThanEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_x(getCurrentDomain(variables[X])), m_y(getCurrentDomain(variables[Y])){ - checkError(variables.size() == (unsigned int) ARG_COUNT, toString()); + checkError(variables.size() == ARG_COUNT, toString()); checkError(m_x.isNumeric(), variables[X]->toString()); checkError(m_y.isNumeric(), variables[Y]->toString()); } @@ -751,35 +631,33 @@ namespace EUROPA { m_y.intersect(m_x.getLowerBound(), m_y.getUpperBound()); } - bool LessThanEqualConstraint::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) { - return((argIndex == X && - (changeType == DomainListener::UPPER_BOUND_DECREASED)) || - (argIndex == Y && - (changeType == DomainListener::LOWER_BOUND_INCREASED))); - } - /** - * @todo - */ - bool LessThanEqualConstraint::testIsRedundant(const ConstrainedVariableId& var) const{ - if(Constraint::testIsRedundant(var)) - return true; +bool LessThanEqualConstraint::canIgnore(const ConstrainedVariableId, + unsigned int argIndex, + const DomainListener::ChangeType& changeType) { + return((argIndex == X && + (changeType == DomainListener::UPPER_BOUND_DECREASED)) || + (argIndex == Y && + (changeType == DomainListener::LOWER_BOUND_INCREASED))); +} - if(getScope()[X]->baseDomain().getUpperBound() <= getScope()[Y]->baseDomain().getLowerBound()) - return true; - - return false; - } +bool LessThanEqualConstraint::testIsRedundant(const ConstrainedVariableId var) const{ + if(Constraint::testIsRedundant(var)) + return true; + + if(getScope()[X]->baseDomain().getUpperBound() <= getScope()[Y]->baseDomain().getLowerBound()) + return true; + + return false; +} /*********** NotEqualConstraint *************/ - NotEqualConstraint::NotEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + NotEqualConstraint::NotEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { - check_error(variables.size() == (unsigned int) ARG_COUNT); + check_error(variables.size() == ARG_COUNT); } void NotEqualConstraint::handleExecute() { @@ -833,28 +711,28 @@ namespace EUROPA { return(false); } - bool NotEqualConstraint::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) { - if(changeType==DomainListener::RESET || changeType == DomainListener::RELAXED) - return false; +bool NotEqualConstraint::canIgnore(const ConstrainedVariableId variable, + unsigned int, + const DomainListener::ChangeType& changeType) { + if(changeType==DomainListener::RESET || changeType == DomainListener::RELAXED) + return false; - const Domain& domain = variable->lastDomain(); + const Domain& domain = variable->lastDomain(); - if(domain.isSingleton() || - (domain.isInterval() && domain.isFinite() && domain.getSize() <=2 )) // Since this transition is key for propagation - return false; + if(domain.isSingleton() || + (domain.isInterval() && domain.isFinite() && domain.getSize() <=2 )) // Since this transition is key for propagation + return false; - return true; - } + return true; +} /*********** LessThanConstraint *************/ - LessThanConstraint::LessThanConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + LessThanConstraint::LessThanConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { - check_error(variables.size() == (unsigned int) ARG_COUNT); + check_error(variables.size() == ARG_COUNT); } void LessThanConstraint::handleExecute() { @@ -894,71 +772,45 @@ namespace EUROPA { } } - bool LessThanConstraint::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) { - return((argIndex == X && - (changeType == DomainListener::UPPER_BOUND_DECREASED)) || - (argIndex == Y && - (changeType == DomainListener::LOWER_BOUND_INCREASED))); - } - - - /** - * @class AddMultEqualConstraint - * @brief A + (B*C) == D - */ - AddMultEqualConstraint::AddMultEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables), - m_interimVariable(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalConstraintVariable"), getId()), - m_multEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, - makeScope(m_variables[B], m_variables[C], m_interimVariable.getId())), - m_addEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, - makeScope(m_interimVariable.getId(), m_variables[A], m_variables[D])) { - check_error(m_variables.size() == (unsigned int) ARG_COUNT); - } - - AddMultEqualConstraint::~AddMultEqualConstraint(){ - discard(false); - } - - void AddMultEqualConstraint::handleDiscard(){ - Constraint::handleDiscard(); - m_interimVariable.discard(); - } +bool LessThanConstraint::canIgnore(const ConstrainedVariableId, + unsigned int argIndex, + const DomainListener::ChangeType& changeType) { + return((argIndex == X && + (changeType == DomainListener::UPPER_BOUND_DECREASED)) || + (argIndex == Y && + (changeType == DomainListener::LOWER_BOUND_INCREASED))); +} /*********** EqualSumConstraint *************/ - EqualSumConstraint::EqualSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) +EqualSumConstraint::EqualSumConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), ARG_COUNT(variables.size()), - m_sum1(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalEqSumVariable"), getId()), - m_sum2(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalEqSumVariable"), getId()), - m_sum3(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalEqSumVariable"), getId()), - m_sum4(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalEqSumVariable"), getId()) { - check_error(ARG_COUNT > 2 && ARG_COUNT == (unsigned int)m_variables.size()); - std::vector scope; - // B is always first and C is always second for the first set, so: - scope.push_back(m_variables[1]); // B + ... - scope.push_back(m_variables[2]); // ... C ... - switch (ARG_COUNT) { + m_eqSumC1(), m_eqSumC2(), m_eqSumC3(), m_eqSumC4(), m_eqSumC5(), + m_sum1(constraintEngine, IntervalDomain(), true, false, std::string("InternalEqSumVariable"), getId()), + m_sum2(constraintEngine, IntervalDomain(), true, false, std::string("InternalEqSumVariable"), getId()), + m_sum3(constraintEngine, IntervalDomain(), true, false, std::string("InternalEqSumVariable"), getId()), + m_sum4(constraintEngine, IntervalDomain(), true, false, std::string("InternalEqSumVariable"), getId()) { + check_error(ARG_COUNT > 2 && ARG_COUNT == m_variables.size()); + std::vector scope; + // B is always first and C is always second for the first set, so: + scope.push_back(m_variables[1]); // B + ... + scope.push_back(m_variables[2]); // ... C ... + switch (ARG_COUNT) { case 3: // A = B + C scope.push_back(m_variables[0]); // ... = A - m_eqSumC1 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqSumC1 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); break; case 4: // A = (B + C) + D scope.push_back(m_sum1.getId()); // ... = (B + C) - m_eqSumC1 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqSumC1 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_sum1.getId()); // (B + C) ... scope.push_back(m_variables[3]); // ... + D = ... scope.push_back(m_variables[0]); // ... A - m_eqSumC2 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqSumC2 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); break; case 5: case 6: case 7: // 5: A = (B + C) + (D + E) @@ -966,46 +818,46 @@ namespace EUROPA { // 7: A = (B + C) + (D + E + F + G) // So, do (B + C) and (D + E ...) for all three: scope.push_back(m_sum1.getId()); // (B + C) - m_eqSumC1 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqSumC1 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_sum1.getId()); // (B + C) + ... scope.push_back(m_sum2.getId()); // (D + E ...) = ... scope.push_back(m_variables[0]); // A - m_eqSumC2 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqSumC2 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_variables[3]); // D + ... scope.push_back(m_variables[4]); // E ... switch (ARG_COUNT) { - case 5: - scope.push_back(m_sum2.getId()); // ... = (D + E) - m_eqSumC3 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); - break; - case 6: - scope.push_back(m_sum3.getId()); // ... = (D + E) - m_eqSumC3 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); - scope.clear(); - scope.push_back(m_sum3.getId()); // (D + E) + ... - scope.push_back(m_variables[5]); // ... F = ... - scope.push_back(m_sum2.getId()); // ... (D + E + F) - m_eqSumC4 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); - break; - case 7: - scope.push_back(m_sum3.getId()); // ... = (D + E) - m_eqSumC3 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); - scope.clear(); - scope.push_back(m_sum3.getId()); // (D + E) + ... - scope.push_back(m_sum4.getId()); // ... (F + G) = ... - scope.push_back(m_sum2.getId()); // (D + E + F + G) - m_eqSumC4 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); - scope.clear(); - scope.push_back(m_variables[5]); // F + ... - scope.push_back(m_variables[6]); // ... G = ... - scope.push_back(m_sum4.getId()); // ... (F + G) - m_eqSumC5 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); - break; - default: - check_error(ALWAYS_FAILS); - break; + case 5: + scope.push_back(m_sum2.getId()); // ... = (D + E) + m_eqSumC3 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + break; + case 6: + scope.push_back(m_sum3.getId()); // ... = (D + E) + m_eqSumC3 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + scope.clear(); + scope.push_back(m_sum3.getId()); // (D + E) + ... + scope.push_back(m_variables[5]); // ... F = ... + scope.push_back(m_sum2.getId()); // ... (D + E + F) + m_eqSumC4 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + break; + case 7: + scope.push_back(m_sum3.getId()); // ... = (D + E) + m_eqSumC3 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + scope.clear(); + scope.push_back(m_sum3.getId()); // (D + E) + ... + scope.push_back(m_sum4.getId()); // ... (F + G) = ... + scope.push_back(m_sum2.getId()); // (D + E + F + G) + m_eqSumC4 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + scope.clear(); + scope.push_back(m_variables[5]); // F + ... + scope.push_back(m_variables[6]); // ... G = ... + scope.push_back(m_sum4.getId()); // ... (F + G) + m_eqSumC5 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + break; + default: + check_error(ALWAYS_FAILS); + break; } // switch (ARGCOUNT) 5, 6, 7 break; default: @@ -1015,24 +867,23 @@ namespace EUROPA { scope.push_back(m_sum1.getId()); // first_half + ... scope.push_back(m_sum2.getId()); // ... second_half = ... scope.push_back(m_variables[0]); // ... A - m_eqSumC1 = (new AddEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqSumC1 = (new AddEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_sum1.getId()); // first_half = ... - unsigned int half = ARG_COUNT/2; - unsigned int i = 1; + unsigned long half = ARG_COUNT/2; + unsigned long i = 1; for ( ; i <= half; i++) scope.push_back(m_variables[i]); // ... X + ... - m_eqSumC2 = (new EqualSumConstraint(LabelStr("EqualSum"), propagatorName, constraintEngine, scope))->getId(); + m_eqSumC2 = (new EqualSumConstraint(std::string("EqualSum"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_sum2.getId()); // second_half = ... for ( ; i < ARG_COUNT; i++) scope.push_back(m_variables[i]); // ... Y + ... - m_eqSumC3 = (new EqualSumConstraint(LabelStr("EqualSum"), propagatorName, constraintEngine, scope))->getId(); + m_eqSumC3 = (new EqualSumConstraint(std::string("EqualSum"), propagatorName, constraintEngine, scope))->getId(); break; } - break; - } } +} EqualSumConstraint::~EqualSumConstraint() { discard(false); @@ -1050,17 +901,18 @@ namespace EUROPA { } /*********** EqualProductConstraint *************/ - EqualProductConstraint::EqualProductConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + EqualProductConstraint::EqualProductConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), ARG_COUNT(variables.size()), - m_product1(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalEqProductVariable"), getId()), - m_product2(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalEqProductVariable"), getId()), - m_product3(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalEqProductVariable"), getId()), - m_product4(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalEqProductVariable"), getId()) { - check_error(ARG_COUNT > 2 && ARG_COUNT == (unsigned int)m_variables.size()); + m_eqProductC1(), m_eqProductC2(), m_eqProductC3(), m_eqProductC4(), m_eqProductC5(), + m_product1(constraintEngine, IntervalDomain(), true, false, std::string("InternalEqProductVariable"), getId()), + m_product2(constraintEngine, IntervalDomain(), true, false, std::string("InternalEqProductVariable"), getId()), + m_product3(constraintEngine, IntervalDomain(), true, false, std::string("InternalEqProductVariable"), getId()), + m_product4(constraintEngine, IntervalDomain(), true, false, std::string("InternalEqProductVariable"), getId()) { + check_error(ARG_COUNT > 2 && ARG_COUNT == m_variables.size()); std::vector scope; // B is always first and C is always second for the first set, so: scope.push_back(m_variables[1]); // B * ... @@ -1068,16 +920,16 @@ namespace EUROPA { switch (ARG_COUNT) { case 3: // A = B * C scope.push_back(m_variables[0]); // ... = A - m_eqProductC1 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC1 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); break; case 4: // A = (B * C) * D scope.push_back(m_product1.getId()); // ... = (B * C) - m_eqProductC1 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC1 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_product1.getId()); // (B * C) ... scope.push_back(m_variables[3]); // ... * D = ... scope.push_back(m_variables[0]); // ... A - m_eqProductC2 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC2 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); break; case 5: case 6: case 7: // 5: A = (B * C) * (D * E) @@ -1085,42 +937,42 @@ namespace EUROPA { // 7: A = (B * C) * (D * E * F * G) // So, do (B * C) and (D * E ...) for all three: scope.push_back(m_product1.getId()); // (B * C) - m_eqProductC1 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC1 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_product1.getId()); // (B * C) * ... scope.push_back(m_product2.getId()); // (D * E ...) = ... scope.push_back(m_variables[0]); // A - m_eqProductC2 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC2 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_variables[3]); // D * ... scope.push_back(m_variables[4]); // E ... switch (ARG_COUNT) { case 5: scope.push_back(m_product2.getId()); // ... = (D * E) - m_eqProductC3 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC3 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); break; case 6: scope.push_back(m_product3.getId()); // ... = (D * E) - m_eqProductC3 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC3 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_product3.getId()); // (D * E) * ... scope.push_back(m_variables[5]); // ... F = ... scope.push_back(m_product2.getId()); // ... (D * E * F) - m_eqProductC4 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC4 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); break; case 7: scope.push_back(m_product3.getId()); // ... = (D * E) - m_eqProductC3 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC3 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_product3.getId()); // (D * E) * ... scope.push_back(m_product4.getId()); // ... (F * G) = ... scope.push_back(m_product2.getId()); // (D * E * F * G) - m_eqProductC4 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC4 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_variables[5]); // F * ... scope.push_back(m_variables[6]); // ... G = ... scope.push_back(m_product4.getId()); // ... (F * G) - m_eqProductC5 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC5 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); break; default: check_error(ALWAYS_FAILS); @@ -1134,22 +986,21 @@ namespace EUROPA { scope.push_back(m_product1.getId()); // first_half * ... scope.push_back(m_product2.getId()); // ... second_half = ... scope.push_back(m_variables[0]); // ... A - m_eqProductC1 = (new MultEqualConstraint(LabelStr("MultEqual"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC1 = (new MultEqualConstraint(std::string("MultEqual"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_product1.getId()); // first_half = ... - unsigned int half = ARG_COUNT/2; - unsigned int i = 1; + unsigned long half = ARG_COUNT/2; + unsigned long i = 1; for ( ; i <= half; i++) scope.push_back(m_variables[i]); // ... X * ... - m_eqProductC2 = (new EqualProductConstraint(LabelStr("EqualProduct"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC2 = (new EqualProductConstraint(std::string("EqualProduct"), propagatorName, constraintEngine, scope))->getId(); scope.clear(); scope.push_back(m_product2.getId()); // second_half = ... for ( ; i < ARG_COUNT; i++) scope.push_back(m_variables[i]); // ... Y * ... - m_eqProductC3 = (new EqualProductConstraint(LabelStr("EqualProduct"), propagatorName, constraintEngine, scope))->getId(); + m_eqProductC3 = (new EqualProductConstraint(std::string("EqualProduct"), propagatorName, constraintEngine, scope))->getId(); break; } - break; } } @@ -1168,88 +1019,10 @@ namespace EUROPA { m_product4.discard(); } - /*********** LessOrEqualThanSumConstraint *************/ - LessOrEqThanSumConstraint::LessOrEqThanSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables), - m_interimVariable(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalConstraintVariable"), getId()), - m_lessOrEqualConstraint(LabelStr("LessThanEq"), propagatorName, constraintEngine, - makeScope(m_variables[0], m_interimVariable.getId())) { - std::vector eqSumScope = m_variables; - eqSumScope[0] = m_interimVariable.getId(); - m_eqSumConstraint = (new EqualSumConstraint(LabelStr("EqualSum"), propagatorName, - constraintEngine, eqSumScope))->getId(); - } - - LessOrEqThanSumConstraint::~LessOrEqThanSumConstraint(){ - discard(false); - } - - void LessOrEqThanSumConstraint::handleExecute(){} - - void LessOrEqThanSumConstraint::handleDiscard(){ - Constraint::handleDiscard(); - - // Discarding the variable will discard the constraints - m_interimVariable.discard(); - } - - - /*********** LessThanSumConstraint *************/ - LessThanSumConstraint::LessThanSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables), - m_interimVariable(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalConstraintVariable"), getId()), - m_lessThanConstraint(LabelStr("LessThan"), propagatorName, constraintEngine, - makeScope(m_variables[0], m_interimVariable.getId())) { - std::vector eqSumScope = m_variables; - eqSumScope[0] = m_interimVariable.getId(); - m_eqSumConstraint = (new EqualSumConstraint(LabelStr("EqualSum"), propagatorName, - constraintEngine, eqSumScope))->getId(); - check_error(m_eqSumConstraint.isValid()); - } - - /*********** GreaterOrEqThanSumConstraint *************/ - GreaterOrEqThanSumConstraint::GreaterOrEqThanSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables), - m_interimVariable(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalConstraintVariable"), getId()), - m_lessOrEqualConstraint(LabelStr("LessThanEqual"), propagatorName, constraintEngine, - makeScope(m_interimVariable.getId(), m_variables[0])) { - std::vector eqSumScope = m_variables; - eqSumScope[0] = m_interimVariable.getId(); - m_eqSumConstraint = (new EqualSumConstraint(LabelStr("EqualSum"), propagatorName, - constraintEngine, eqSumScope))->getId(); - } - - /*********** GreaterThanSumConstraint *************/ - GreaterThanSumConstraint::GreaterThanSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables), - m_interimVariable(constraintEngine, constraintEngine->getCESchema()->baseDomain(m_variables[0]->baseDomain().getTypeName().c_str()), - true, false, LabelStr("InternalConstraintVariable"), getId()), - m_lessThanConstraint(LabelStr("LessThan"), propagatorName, constraintEngine, - makeScope(m_interimVariable.getId(), m_variables[0])) - { - std::vector eqSumScope = m_variables; - eqSumScope[0] = m_interimVariable.getId(); - m_eqSumConstraint = (new EqualSumConstraint(LabelStr("EqualSum"), propagatorName, - constraintEngine, eqSumScope))->getId(); - check_error(m_eqSumConstraint.isValid()); - } - /*********** CondAllSameConstraint *************/ - CondAllSameConstraint::CondAllSameConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + CondAllSameConstraint::CondAllSameConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), ARG_COUNT(variables.size()) { @@ -1370,8 +1143,7 @@ namespace EUROPA { && (domj.isMember(domToTrim.getLowerBound()) || domj.isMember(domToTrim.getUpperBound())))) domToTrim.remove(single); - else - ; // Can ignore relax events until condition var is relaxed. + else {} // Can ignore relax events until condition var is relaxed. return; } else { @@ -1397,9 +1169,9 @@ namespace EUROPA { /*********** CondAllDiffConstraint *************/ - CondAllDiffConstraint::CondAllDiffConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + CondAllDiffConstraint::CondAllDiffConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), ARG_COUNT(variables.size()) { @@ -1410,6 +1182,7 @@ namespace EUROPA { getCurrentDomain(m_variables[i]))); } +namespace { /** * @brief Helper function: add domToAdd to unionOfDomains "usefully". * Adds all of the members of domToAdd and, if needed and useful, @@ -1424,79 +1197,80 @@ namespace EUROPA { * simply returning a single larger interval that 'covers' both * original intervals. */ - static void addToUnion(Domain **unionOfDomains, - const Domain& domToAdd) { - check_error(unionOfDomains != 0 && *unionOfDomains != 0); - check_error(!(*unionOfDomains)->isEmpty() && !(*unionOfDomains)->isOpen()); - check_error(!domToAdd.isEmpty() && !domToAdd.isOpen()); - Domain *newUnion = 0; - std::list membersToAdd; - std::list newMembers; - if (((*unionOfDomains)->isEnumerated() || (*unionOfDomains)->isSingleton()) - && (domToAdd.isEnumerated() || domToAdd.isSingleton())) { - if (domToAdd.isEnumerated()) - domToAdd.getValues(membersToAdd); - else - membersToAdd.push_back(domToAdd.getSingletonValue()); - if ((*unionOfDomains)->isEnumerated()) - (*unionOfDomains)->getValues(newMembers); - else - newMembers.push_back((*unionOfDomains)->getSingletonValue()); - for (std::list::const_iterator it = membersToAdd.begin(); - it != membersToAdd.end(); it++) { - std::list::const_iterator it2 = newMembers.begin(); - for ( ; it2 != newMembers.end(); it2++) - if (*it == *it2) - break; - if (it2 == newMembers.end()) - newMembers.push_back(*it); - } - newUnion = new EnumeratedDomain( - (*unionOfDomains)->getDataType(), - newMembers); - - // Could just add to current unionOfDomains rather than failing here, but - // very messy to implement using current interface to *Domain classes. - assertFalse(newUnion == 0); - delete *unionOfDomains; - *unionOfDomains = newUnion; - return; - } - // At least one is a non-singleton interval, so the result will be - // also be one. - edouble toAddMin, toAddMax, newMin, newMax; - domToAdd.getBounds(toAddMin, toAddMax); - (*unionOfDomains)->getBounds(newMin, newMax); - bool changing = false; - if (toAddMin < newMin) { - newMin = toAddMin; - changing = true; - } - if (newMax < toAddMax) { - newMax = toAddMax; - changing = true; - } - if (changing) { - if((*unionOfDomains)->minDelta() < 1.0) - newUnion = new IntervalDomain(newMin, newMax); - else - newUnion = new IntervalIntDomain((eint)newMin, (eint)newMax); - - /* BOOL should be not get to here since both are non-singleton - * but then unionOfDomains "covers" domToAdd and changing - * would be false. - * USER_DEFINED and REAL_ENUMERATION should not get to here - * since enumerations are dealt with above. - * As above, a memory failure here could be dealt with, but - * messy to implement, but note that this also checks the - * assumptions/logic earlier in this comment. - */ - checkError(newUnion != 0, "Failed to allocate memory."); - delete *unionOfDomains; - *unionOfDomains = newUnion; - return; +void addToUnion(Domain **unionOfDomains, + const Domain& domToAdd) { + check_error(unionOfDomains != 0 && *unionOfDomains != 0); + check_error(!(*unionOfDomains)->isEmpty() && !(*unionOfDomains)->isOpen()); + check_error(!domToAdd.isEmpty() && !domToAdd.isOpen()); + Domain *newUnion = 0; + std::list membersToAdd; + std::list newMembers; + if (((*unionOfDomains)->isEnumerated() || (*unionOfDomains)->isSingleton()) + && (domToAdd.isEnumerated() || domToAdd.isSingleton())) { + if (domToAdd.isEnumerated()) + domToAdd.getValues(membersToAdd); + else + membersToAdd.push_back(domToAdd.getSingletonValue()); + if ((*unionOfDomains)->isEnumerated()) + (*unionOfDomains)->getValues(newMembers); + else + newMembers.push_back((*unionOfDomains)->getSingletonValue()); + for (std::list::const_iterator it = membersToAdd.begin(); + it != membersToAdd.end(); it++) { + std::list::const_iterator it2 = newMembers.begin(); + for ( ; it2 != newMembers.end(); it2++) + if (*it == *it2) + break; + if (it2 == newMembers.end()) + newMembers.push_back(*it); } + newUnion = new EnumeratedDomain( + (*unionOfDomains)->getDataType(), + newMembers); + + // Could just add to current unionOfDomains rather than failing here, but + // very messy to implement using current interface to *Domain classes. + assertFalse(newUnion == NULL); + delete *unionOfDomains; + *unionOfDomains = newUnion; + return; + } + // At least one is a non-singleton interval, so the result will be + // also be one. + edouble toAddMin, toAddMax, newMin, newMax; + domToAdd.getBounds(toAddMin, toAddMax); + (*unionOfDomains)->getBounds(newMin, newMax); + bool changing = false; + if (toAddMin < newMin) { + newMin = toAddMin; + changing = true; + } + if (newMax < toAddMax) { + newMax = toAddMax; + changing = true; + } + if (changing) { + if((*unionOfDomains)->minDelta() < 1.0) + newUnion = new IntervalDomain(newMin, newMax); + else + newUnion = new IntervalIntDomain(static_cast(newMin), static_cast(newMax)); + + /* BOOL should be not get to here since both are non-singleton + * but then unionOfDomains "covers" domToAdd and changing + * would be false. + * USER_DEFINED and REAL_ENUMERATION should not get to here + * since enumerations are dealt with above. + * As above, a memory failure here could be dealt with, but + * messy to implement, but note that this also checks the + * assumptions/logic earlier in this comment. + */ + checkError(newUnion != 0, "Failed to allocate memory."); + delete *unionOfDomains; + *unionOfDomains = newUnion; + return; } +} +} void CondAllDiffConstraint::handleExecute() { BoolDomain& boolDom = static_cast(getCurrentDomain(m_variables[0])); @@ -1539,7 +1313,7 @@ namespace EUROPA { canProveTrue = false; // Add members of current to unionOfOthers "usefully". addToUnion(&unionOfOthers, current); - if (unionOfOthers->isFinite() && (unsigned int)(unionOfOthers->getSize()) < i) { + if (unionOfOthers->isFinite() && (unionOfOthers->getSize()) < i) { // At least two of the variables must have same value. boolDom.remove(true); canProveTrue = false; @@ -1627,25 +1401,25 @@ namespace EUROPA { } // for changedOne = true; changedOne; } // end of CondAllDiffConstraint::handleExecute() - AllDiffConstraint::AllDiffConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) +AllDiffConstraint::AllDiffConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), - m_condVar(constraintEngine, BoolDomain(true), true, false, LabelStr("Internal:AllDiff:cond"), getId()) - { + m_condVar(constraintEngine, BoolDomain(true), true, false, std::string("Internal:AllDiff:cond"), getId()), + m_condAllDiffConstraint() { std::vector condAllDiffScope; condAllDiffScope.reserve(m_variables.size() + 1); condAllDiffScope.push_back(m_condVar.getId()); condAllDiffScope.insert(condAllDiffScope.end(), m_variables.begin(), m_variables.end()); check_error(m_variables.size() + 1 == condAllDiffScope.size()); - m_condAllDiffConstraint = (new CondAllDiffConstraint(LabelStr("CondAllDiff"), propagatorName, + m_condAllDiffConstraint = (new CondAllDiffConstraint(std::string("CondAllDiff"), propagatorName, constraintEngine, condAllDiffScope))->getId(); } - MemberImplyConstraint::MemberImplyConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + MemberImplyConstraint::MemberImplyConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), ARG_COUNT(variables.size()) { @@ -1672,38 +1446,38 @@ namespace EUROPA { (void) domA.intersect(domD); } - CountZerosConstraint::CountZerosConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + CountZeroesConstraint::CountZeroesConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { for (unsigned int i = 0; i < m_variables.size(); i++) check_error(getCurrentDomain(m_variables[i]).isNumeric() || getCurrentDomain(m_variables[i]).isBool()); } - void CountZerosConstraint::handleExecute() { + void CountZeroesConstraint::handleExecute() { unsigned int i = 1; // Count the other vars that must be zero ... - unsigned int minZeros = 0; + unsigned int minZeroes = 0; // ... and that could be zero. - unsigned int maxZeros = 0; + unsigned int maxZeroes = 0; for ( ; i < m_variables.size(); i++) { Domain& other = getCurrentDomain(m_variables[i]); if (other.isMember(0.0)) { - ++maxZeros; + ++maxZeroes; if (other.isSingleton()) - ++minZeros; + ++minZeroes; } } - // The count of zeros is the first variable. + // The count of zeroes is the first variable. Domain& countDom = getCurrentDomain(m_variables[0]); // If all that could be zero must be zero to get the count high // enough, set all that could be zero to zero. - if (minZeros < countDom.getLowerBound() && - maxZeros == countDom.getLowerBound()) { + if (minZeroes < countDom.getLowerBound() && + maxZeroes == countDom.getLowerBound()) { // Find those that could be zero but might not be // and restrict them to 0. for (i = 1; i < m_variables.size(); i++) { @@ -1720,8 +1494,8 @@ namespace EUROPA { // If all that might be zero are needed to be non-zero to get the // count low enough, restrict all that might be zero to not be // zero. - if (maxZeros > countDom.getUpperBound() && - minZeros == countDom.getUpperBound()) { + if (maxZeroes > countDom.getUpperBound() && + minZeroes == countDom.getUpperBound()) { // Find those that could be zero but might not be and restrict // them to not be 0. for (i = 1; i < m_variables.size(); i++) { @@ -1744,69 +1518,55 @@ namespace EUROPA { } // If the counts seen restrict the count variable, do so. - if (minZeros > countDom.getLowerBound() || - countDom.getUpperBound() > maxZeros) - countDom.intersect(make_int_int(minZeros, maxZeros)); + if (minZeroes > countDom.getLowerBound() || + countDom.getUpperBound() > maxZeroes) + countDom.intersect(make_int_int(minZeroes, maxZeroes)); } - CountNonZerosConstraint::CountNonZerosConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables), - m_zeros(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalCountNonZerosVar"), getId()), - m_otherVars(constraintEngine, IntervalDomain(), true, false, LabelStr("InternalCountNonZerosOtherVars"), getId()), - m_superset(constraintEngine, IntervalDomain((edouble)(variables.size() - 1)), true, false, LabelStr("InternalCountNonZerosSuperset"), getId()), - m_addEqualConstraint(LabelStr("AddEqual"), propagatorName, constraintEngine, - makeScope(m_zeros.getId(), m_variables[0], m_otherVars.getId())) - { - m_subsetConstraint = (new SubsetOfConstraint(LabelStr("SubsetOf"), propagatorName, constraintEngine, - makeScope(m_otherVars.getId(), m_superset.getId())))->getId(); - std::vector cZCScope = m_variables; - cZCScope[0] = m_zeros.getId(); - check_error(m_variables.size() == cZCScope.size()); - m_countZerosConstraint = (new CountZerosConstraint(LabelStr("CountZeros"), - propagatorName, constraintEngine, cZCScope))->getId(); - } - - CardinalityConstraint::CardinalityConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) +CountNonZeroesConstraint::CountNonZeroesConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), - m_nonZeros(constraintEngine, IntervalIntDomain(0, PLUS_INFINITY), true, false, LabelStr("InternalCardinalityVar"), getId()), - m_lessThanEqualConstraint(LabelStr("LessThanEqual"), propagatorName, - constraintEngine, makeScope(m_nonZeros.getId(), m_variables[0])) - { - std::vector cCScope = m_variables; - cCScope[0] = m_nonZeros.getId(); - check_error(m_variables.size() == cCScope.size()); - m_countNonZerosConstraint = (new CountNonZerosConstraint(LabelStr("CountNonZeros"), - propagatorName, constraintEngine, cCScope))->getId(); - } - - OrConstraint::OrConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + m_zeroes(constraintEngine, IntervalDomain(), true, false, std::string("InternalCountNonZeroesVar"), getId()), + m_otherVars(constraintEngine, IntervalDomain(), true, false, std::string("InternalCountNonZeroesOtherVars"), getId()), + m_superset(constraintEngine, IntervalDomain(edouble(variables.size() - 1)), true, false, std::string("InternalCountNonZeroesSuperset"), getId()), + m_addEqualConstraint(std::string("AddEqual"), propagatorName, constraintEngine, + makeScope(m_zeroes.getId(), m_variables[0], m_otherVars.getId())), + m_subsetConstraint(), m_countZeroesConstraint() { + m_subsetConstraint = (new SubsetOfConstraint(std::string("SubsetOf"), propagatorName, constraintEngine, + makeScope(m_otherVars.getId(), m_superset.getId())))->getId(); + std::vector cZCScope = m_variables; + cZCScope[0] = m_zeroes.getId(); + check_error(m_variables.size() == cZCScope.size()); + m_countZeroesConstraint = (new CountZeroesConstraint(std::string("CountZeroes"), + propagatorName, constraintEngine, cZCScope))->getId(); +} + + + OrConstraint::OrConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), - m_nonZeros(constraintEngine, IntervalIntDomain(1, PLUS_INFINITY), true, false, LabelStr("InternalVar:Or:nonZeros"), getId()), - m_superset(constraintEngine, IntervalIntDomain(1, eint(variables.size())), true, false, LabelStr("InternalVar:Or:superset"), getId()) + m_nonZeroes(constraintEngine, IntervalIntDomain(1, PLUS_INFINITY), true, false, std::string("InternalVar:Or:nonZeroes"), getId()), + m_superset(constraintEngine, IntervalIntDomain(1, eint(variables.size())), true, false, std::string("InternalVar:Or:superset"), getId()), + m_subsetConstraint(), m_countNonZeroesConstraint() { - m_subsetConstraint = (new SubsetOfConstraint(LabelStr("SubsetOf"), propagatorName, constraintEngine, - makeScope(m_nonZeros.getId(), m_superset.getId())))->getId(); + m_subsetConstraint = (new SubsetOfConstraint(std::string("SubsetOf"), propagatorName, constraintEngine, + makeScope(m_nonZeroes.getId(), m_superset.getId())))->getId(); std::vector cNZCScope; cNZCScope.reserve(m_variables.size() + 1); - cNZCScope.push_back(m_nonZeros.getId()); + cNZCScope.push_back(m_nonZeroes.getId()); cNZCScope.insert(cNZCScope.end(), m_variables.begin(), m_variables.end()); check_error(m_variables.size() + 1 == cNZCScope.size()); - m_countNonZerosConstraint = (new CountNonZerosConstraint(LabelStr("CountNonZeros"), propagatorName, + m_countNonZeroesConstraint = (new CountNonZeroesConstraint(std::string("CountNonZeroes"), propagatorName, constraintEngine, cNZCScope))->getId(); } - EqualMinimumConstraint::EqualMinimumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + EqualMinimumConstraint::EqualMinimumConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { check_error(m_variables.size() > 1); @@ -1888,9 +1648,9 @@ namespace EUROPA { } } - EqualMaximumConstraint::EqualMaximumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + EqualMaximumConstraint::EqualMaximumConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { check_error(m_variables.size() > 1); @@ -1972,83 +1732,67 @@ namespace EUROPA { } } - CondEqualSumConstraint::CondEqualSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables), - m_sumVar(constraintEngine, constraintEngine->getCESchema()->baseDomain(m_variables[1]->baseDomain().getTypeName().c_str()), - true, false, LabelStr("InternalConstraintVariable"), getId()), - m_condAllSameConstraint(LabelStr("CondAllSame"), propagatorName, constraintEngine, - makeScope(m_variables[0], m_variables[1], m_sumVar.getId())) - { - check_error(m_variables.size() > 2); - std::vector eqSumScope; - eqSumScope.reserve(m_variables.size() - 1); - eqSumScope.push_back(m_sumVar.getId()); - std::vector::iterator it = m_variables.begin(); - ++it; ++it; - eqSumScope.insert(eqSumScope.end(), it, m_variables.end()); - check_error(m_variables.size() - 1 == eqSumScope.size()); - m_eqSumConstraint = (new EqualSumConstraint(LabelStr("EqualSum"), propagatorName, - constraintEngine, eqSumScope))->getId(); - check_error(m_eqSumConstraint.isValid()); - } - - RotateScopeRightConstraint::RotateScopeRightConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables, - const LabelStr& otherName, - const int& rotateCount) - : Constraint(name, propagatorName, constraintEngine, variables) + +RotateScopeRightConstraint::RotateScopeRightConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables, + const std::string& otherName, + const int& rotateCount) + : Constraint(name, propagatorName, constraintEngine, variables), m_otherConstraint() { - check_error((unsigned) abs(rotateCount) < m_variables.size()); + check_error(static_cast(abs(rotateCount)) < m_variables.size()); std::vector otherScope; otherScope.reserve(m_variables.size()); - unsigned int i; + + unsigned long i; if (rotateCount > 0) { + unsigned long realCount = static_cast(rotateCount); // Rotate to right: last var becomes first, pushing others to the right. - for (i = rotateCount; i > 0; i--) + for (i = realCount; i > 0; i--) otherScope.push_back(m_variables[m_variables.size() - i]); - for (i = 0; i < m_variables.size() - rotateCount; i++) + for (i = 0; i < m_variables.size() - realCount; i++) otherScope.push_back(m_variables[i]); - } else { + } + else { // Rotate to left: first var becomes last, pushing others to the left. - for (i = (unsigned) abs(rotateCount); i < m_variables.size(); i++) + for (i = static_cast(abs(rotateCount)); i < m_variables.size(); i++) otherScope.push_back(m_variables[i]); - for (i = 0; i < (unsigned) abs(rotateCount); i++) + for (i = 0; i < static_cast(abs(rotateCount)); i++) otherScope.push_back(m_variables[i]); } check_error(m_variables.size() == otherScope.size()); m_otherConstraint = constraintEngine->createConstraint(otherName, otherScope); } - SwapTwoVarsConstraint::SwapTwoVarsConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables, - const LabelStr& otherName, - int firstIndex, int secondIndex) - : Constraint(name, propagatorName, constraintEngine, variables) +SwapTwoVarsConstraint::SwapTwoVarsConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables, + const std::string& otherName, + int firstIndex, int secondIndex) + : Constraint(name, propagatorName, constraintEngine, variables), m_otherConstraint() { - check_error((unsigned) abs(firstIndex) < m_variables.size()); - check_error((unsigned) abs(secondIndex) < m_variables.size()); + check_error(static_cast(abs(firstIndex)) < m_variables.size()); + check_error(static_cast(abs(secondIndex)) < m_variables.size()); check_error(firstIndex != secondIndex); - if (firstIndex < 0) - firstIndex = m_variables.size() - firstIndex; - if (secondIndex < 0) - secondIndex = m_variables.size() - secondIndex; + unsigned long realFirstIndex = (firstIndex < 0 ? + (m_variables.size() - static_cast(std::abs(firstIndex))) : + static_cast(firstIndex)); + unsigned long realSecondIndex = (secondIndex < 0 ? + (m_variables.size() - static_cast(std::abs(secondIndex))) : + static_cast(secondIndex)); + check_error(realFirstIndex != realSecondIndex); std::vector otherScope(m_variables); - otherScope[firstIndex] = m_variables[secondIndex]; - otherScope[secondIndex] = m_variables[firstIndex]; + otherScope[realFirstIndex] = m_variables[realSecondIndex]; + otherScope[realSecondIndex] = m_variables[realFirstIndex]; m_otherConstraint = constraintEngine->createConstraint(otherName, otherScope); } - LockConstraint::LockConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + LockConstraint::LockConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_currentDomain(getCurrentDomain(variables[0])), @@ -2078,9 +1822,9 @@ namespace EUROPA { } // Enforces X >=0, Y<=0, X+Y==0 - NegateConstraint::NegateConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + NegateConstraint::NegateConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { check_error(variables.size() == 2); @@ -2112,9 +1856,9 @@ namespace EUROPA { } - TestEQ::TestEQ(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + TestEQ::TestEQ(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_test(getCurrentDomain(variables[0])), @@ -2144,9 +1888,9 @@ namespace EUROPA { } } - TestSingleton::TestSingleton(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + TestSingleton::TestSingleton(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_test(getCurrentDomain(variables[0])), @@ -2170,9 +1914,9 @@ namespace EUROPA { return m_modifiedVariables; } - TestSpecified::TestSpecified(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + TestSpecified::TestSpecified(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_test(getCurrentDomain(variables[0])), @@ -2191,9 +1935,9 @@ namespace EUROPA { //what is test if m_arg1 is not a singleton. } - TestNEQ::TestNEQ(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + TestNEQ::TestNEQ(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_test(getCurrentDomain(variables[0])), @@ -2231,9 +1975,9 @@ namespace EUROPA { } - TestOr::TestOr(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + TestOr::TestOr(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_test(getCurrentDomain(variables[0])), @@ -2274,9 +2018,9 @@ namespace EUROPA { } } - TestAnd::TestAnd(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + TestAnd::TestAnd(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_test(getCurrentDomain(variables[0])), @@ -2317,9 +2061,9 @@ namespace EUROPA { } - TestLessThan::TestLessThan(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + TestLessThan::TestLessThan(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_test(getCurrentDomain(variables[0])), @@ -2351,9 +2095,9 @@ namespace EUROPA { } } - TestLEQ::TestLEQ(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + TestLEQ::TestLEQ(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_test(getCurrentDomain(variables[0])), @@ -2391,9 +2135,9 @@ namespace EUROPA { /** * WithinBounds Implementation */ - WithinBounds::WithinBounds(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + WithinBounds::WithinBounds(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_x(static_cast(getCurrentDomain(variables[0]))), @@ -2408,33 +2152,33 @@ namespace EUROPA { m_x.intersect(m_y.getLowerBound(), m_z.getUpperBound()); } - void AbsoluteValueCT::checkArgTypes(const std::vector& argTypes) const - { - if (argTypes.size() != 2) { - std::ostringstream msg; msg << "Constraint AbsoluteValue takes 2 args, not " << argTypes.size(); - throw msg.str(); - } - - for (unsigned int i=0; i< argTypes.size(); i++) { - if (!argTypes[i]->isNumeric()) { - std::ostringstream msg; - msg << "Parameter " << i << " for Constraint AbsoluteValue is not numeric : " - << argTypes[i]->getName().toString(); - throw msg.str(); - } - } - - if (!argTypes[0]->isAssignableFrom(argTypes[1])) { - std::ostringstream msg; - msg << argTypes[0]->getName().toString() << " can't hold AbsoluteValue for : " - << argTypes[1]->getName().toString(); - throw msg.str(); - } - } - - AbsoluteValue::AbsoluteValue(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + // void AbsoluteValueCT::checkArgTypes(const std::vector& argTypes) const + // { + // if (argTypes.size() != 2) { + // std::ostringstream msg; msg << "Constraint AbsoluteValue takes 2 args, not " << argTypes.size(); + // throw msg.str(); + // } + + // for (unsigned int i=0; i< argTypes.size(); i++) { + // if (!argTypes[i]->isNumeric()) { + // std::ostringstream msg; + // msg << "Parameter " << i << " for Constraint AbsoluteValue is not numeric : " + // << argTypes[i]->getName().toString(); + // throw msg.str(); + // } + // } + + // if (!argTypes[0]->isAssignableFrom(argTypes[1])) { + // std::ostringstream msg; + // msg << argTypes[0]->getName().toString() << " can't hold AbsoluteValue for : " + // << argTypes[1]->getName().toString(); + // throw msg.str(); + // } + // } + + AbsoluteValue::AbsoluteValue(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_x(static_cast(getCurrentDomain(variables[0]))), @@ -2477,12 +2221,12 @@ namespace EUROPA { m_y.intersect(IntervalDomain(-ub, -lb)); } - SquareOfDifferenceConstraint::SquareOfDifferenceConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + SquareOfDifferenceConstraint::SquareOfDifferenceConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { - check_error(variables.size() == (unsigned int) ARG_COUNT); + check_error(variables.size() == ARG_COUNT); } /** @@ -2510,12 +2254,12 @@ namespace EUROPA { } - DistanceFromSquaresConstraint::DistanceFromSquaresConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + DistanceFromSquaresConstraint::DistanceFromSquaresConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { - check_error(variables.size() == (unsigned int) ARG_COUNT); + check_error(variables.size() == ARG_COUNT); } /** @@ -2544,9 +2288,9 @@ namespace EUROPA { // cout << "DistanceFromSquares "<& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_distance(getCurrentDomain(variables[DISTANCE])), @@ -2554,7 +2298,7 @@ namespace EUROPA { m_y1(getCurrentDomain(variables[Y1])), m_x2(getCurrentDomain(variables[X2])), m_y2(getCurrentDomain(variables[Y2])){ - checkError(variables.size() == ARG_COUNT, variables.size() << " is the wrong number of arguments for " << name.toString()); + checkError(variables.size() == ARG_COUNT, variables.size() << " is the wrong number of arguments for " << name); } void CalcDistanceConstraint::handleExecute(){ @@ -2603,14 +2347,14 @@ namespace EUROPA { /**************************************************************************************/ - SineFunction::SineFunction(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + SineFunction::SineFunction(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_target(getCurrentDomain(variables[0])), m_source(getCurrentDomain(variables[1])){ - checkError(variables.size() == ARG_COUNT, variables.size() << " is the wrong number of arguments for " << name.toString()); + checkError(variables.size() == ARG_COUNT, variables.size() << " is the wrong number of arguments for " << name); } void SineFunction::handleExecute(){ @@ -2630,9 +2374,9 @@ namespace EUROPA { /**************************************************************************************/ - RandConstraint::RandConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + RandConstraint::RandConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_rvalue(rand() % 32768) {} @@ -2640,9 +2384,10 @@ namespace EUROPA { getCurrentDomain(m_variables[0]).intersect(m_rvalue, m_rvalue); } - eint mod(eint a, eint b) { return a % b; } - eint mod(edouble a, edouble b) {return cast_int(a) % cast_int(b);} - +namespace { +//eint mod(eint a, eint b) { return a % b; } +eint mod(edouble a, edouble b) {return static_cast(std::fmod(cast_basis(a), cast_basis(b)));} +} CREATE_FUNCTION_CONSTRAINT_TWO_ARG(Max, std::max, edouble); CREATE_FUNCTION_CONSTRAINT_TWO_ARG(Min, std::min, edouble); CREATE_FUNCTION_CONSTRAINT_ONE_ARG(Abs, std::abs, edouble); @@ -2655,6 +2400,95 @@ namespace EUROPA { CREATE_FUNCTION_CONSTRAINT_ONE_ARG(Floor, std::floor, edouble); CREATE_FUNCTION_CONSTRAINT_ONE_ARG(Ceil, std::ceil, edouble); +EqUnionConstraint::EqUnionConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) + : Constraint(name, propagatorName, constraintEngine, variables) {} + +void EqUnionConstraint::handleExecute() { + if(getCurrentDomain(m_variables[0]).isEnumerated()) { + handleExecuteEnumerated(dynamic_cast(getCurrentDomain(m_variables[0])), + m_variables.begin() + 1, m_variables.end()); + } + else { + handleExecuteInterval(dynamic_cast(getCurrentDomain(m_variables[0])), + m_variables.begin() + 1, m_variables.end()); + } +} + +void EqUnionConstraint::handleExecuteInterval(IntervalDomain& dest, + std::vector::const_iterator start, + const std::vector::const_iterator end) { + edouble minValue = std::numeric_limits::max(), + maxValue = std::numeric_limits::min(); + + for(std::vector::const_iterator it = start; it != end; ++it) { + minValue = std::min(minValue, getCurrentDomain(*it).getLowerBound()); + maxValue = std::max(maxValue, getCurrentDomain(*it).getUpperBound()); + } + minValue = std::max(minValue, dest.getLowerBound()); + maxValue = std::min(maxValue, dest.getUpperBound()); + + dest.intersect(minValue, maxValue); + for(std::vector::const_iterator it = start; it != end; ++it) { + if(dest.isEmpty()) + getCurrentDomain(*it).empty(); + else + getCurrentDomain(*it).intersect(dest); + } +} + +namespace { +struct InInterval { + InInterval(const edouble v) : m_v(v) {} + bool operator()(const std::pair& i) { + return i.first <= m_v && m_v <= i.second; + } + private: + edouble m_v; +}; +} +void EqUnionConstraint::handleExecuteEnumerated(EnumeratedDomain& dest, + std::vector::const_iterator start, + const std::vector::const_iterator end) { + std::set enumUnion; + std::vector > intervalUnion; + + //collect enumerated and interval unions separately + for(std::vector::const_iterator it = start; it != end; ++it) { + Domain& temp = getCurrentDomain(*it); + if(temp.isEnumerated()) { + EnumeratedDomain& etemp = dynamic_cast(getCurrentDomain(*it)); + enumUnion.insert(etemp.getValues().begin(), etemp.getValues().end()); + } + else { + intervalUnion.push_back(std::make_pair(temp.getLowerBound(), temp.getUpperBound())); + } + } + //NOTE: if it turns out that a lot of time is being spent in checking values against + //the intervalUnion, it may be worth it to combine contiguous unions + + std::list existingValues; + dest.getValues(existingValues); + for(std::list::const_iterator it = existingValues.begin(); + it != existingValues.end(); ++it) { + if((enumUnion.find(*it) == enumUnion.end()) && + (std::find_if(intervalUnion.begin(), intervalUnion.end(), InInterval(*it)) == + intervalUnion.end())) + dest.remove(*it); + } + + + for(std::vector::const_iterator it = start; it != end; ++it) { + if(dest.isEmpty()) + getCurrentDomain(*it).empty(); + else + getCurrentDomain(*it).intersect(dest); + } +} + + } // end namespace EUROPA diff --git a/src/PLASMA/ConstraintEngine/component/Constraints.hh b/src/PLASMA/ConstraintEngine/component/Constraints.hh index 3f4e8186a..50409d1b4 100644 --- a/src/PLASMA/ConstraintEngine/component/Constraints.hh +++ b/src/PLASMA/ConstraintEngine/component/Constraints.hh @@ -1,76 +1,30 @@ -#ifndef _H_Constraints -#define _H_Constraints +#ifndef H_Constraints +#define H_Constraints #include "ConstraintEngineDefs.hh" #include "Constraint.hh" #include "Variable.hh" #include "Domains.hh" +#include "ConstraintType.hh" +#include "ConstraintTypeChecking.hh" namespace EUROPA { -#define CREATE_CONSTRAINT_BASE(basename) \ - class basename : public ConstraintType { \ - public: \ - basename(const LabelStr& name, \ - const LabelStr& propagatorName, \ - bool systemDefined = false) \ - : ConstraintType(name,propagatorName,systemDefined) { m_name = name.c_str(); } \ - \ - virtual ~basename() {} \ - \ - virtual ConstraintId createConstraint( \ - const ConstraintEngineId constraintEngine, \ - const std::vector& scope, \ - const char* violationExpl) = 0; \ - \ - virtual void checkArgTypes(const std::vector& argTypes) const; \ - protected: \ - std::string m_name; \ - }; - - CREATE_CONSTRAINT_BASE(TwoSameArgumentsCT); - CREATE_CONSTRAINT_BASE(TwoSameNumericArgumentsCT); - CREATE_CONSTRAINT_BASE(TestTwoSameArgumentsCT); - CREATE_CONSTRAINT_BASE(TestTwoSameNumericArgumentsCT); - CREATE_CONSTRAINT_BASE(TwoBooleanArgumentsCT); - CREATE_CONSTRAINT_BASE(ThreeBooleanArgumentsCT); - CREATE_CONSTRAINT_BASE(AllSameArgumentsCT); - CREATE_CONSTRAINT_BASE(AllSameNumericArgumentsCT); - CREATE_CONSTRAINT_BASE(TestOneArgumentCT); - - -#define CREATE_CONSTRAINT_TYPE(base, name, constraint) \ - class name : public base { \ - public: \ - name(const LabelStr& name, \ - const LabelStr& propagatorName, \ - bool systemDefined = false) \ - : base(name,propagatorName,systemDefined) {} \ - ~name() {} \ - virtual ConstraintId createConstraint(const ConstraintEngineId constraintEngine, \ - const std::vector& scope,\ - const char* violationMsg) \ - { \ - return makeConstraintInstance(m_name, m_propagatorName, constraintEngine, scope, violationMsg); \ - } \ - }; - - #define CREATE_FUNCTION_CONSTRAINT(cname) \ class cname##Constraint : public Constraint { \ public: \ - cname##Constraint(const LabelStr& name, \ - const LabelStr& propagatorName, \ - const ConstraintEngineId& constraintEngine, \ + cname##Constraint(const std::string& name, \ + const std::string& propagatorName, \ + const ConstraintEngineId constraintEngine, \ const std::vector& variables); \ void handleExecute(); \ private: \ }; #define CREATE_FUNCTION_CONSTRAINT_ONE_ARG(cname, function, rt) \ - cname##Constraint::cname##Constraint(const LabelStr& name, \ - const LabelStr& propagatorName, \ - const ConstraintEngineId& constraintEngine, \ + cname##Constraint::cname##Constraint(const std::string& name, \ + const std::string& propagatorName, \ + const ConstraintEngineId constraintEngine, \ const std::vector& variables) \ : Constraint(name, propagatorName, constraintEngine, variables) {} \ void cname##Constraint::handleExecute() { \ @@ -82,9 +36,9 @@ namespace EUROPA { } #define CREATE_FUNCTION_CONSTRAINT_TWO_ARG(cname, function, rt) \ - cname##Constraint::cname##Constraint(const LabelStr& name, \ - const LabelStr& propagatorName, \ - const ConstraintEngineId& constraintEngine, \ + cname##Constraint::cname##Constraint(const std::string& name, \ + const std::string& propagatorName, \ + const ConstraintEngineId constraintEngine, \ const std::vector& variables) \ : Constraint(name, propagatorName, constraintEngine, variables) {} \ void cname##Constraint::handleExecute() { \ @@ -99,737 +53,583 @@ namespace EUROPA { - CREATE_FUNCTION_CONSTRAINT(Max); - CREATE_FUNCTION_CONSTRAINT(Min); - CREATE_FUNCTION_CONSTRAINT(Abs); - CREATE_FUNCTION_CONSTRAINT(Pow); - CREATE_FUNCTION_CONSTRAINT(Sqrt); - CREATE_FUNCTION_CONSTRAINT(Mod); - CREATE_FUNCTION_CONSTRAINT(Floor); - CREATE_FUNCTION_CONSTRAINT(Ceil); - - - - /** - * @brief AbsoluteValue(x, y) maintains the relation: - * @li x.lb >= 0 - * @li x.ub = max(abs(y.lb), abs(y.ub)) - * @li y.lb >= -x.lb - * @li y.ub <= x.ub - */ - class AbsoluteValue : public Constraint { - public: - AbsoluteValue(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, +CREATE_FUNCTION_CONSTRAINT(Max); +typedef And, All > TwoArgNumericFun; +typedef DataTypeCheck MaxCT; +CREATE_FUNCTION_CONSTRAINT(Min); +typedef DataTypeCheck MinCT; +CREATE_FUNCTION_CONSTRAINT(Abs); +typedef And, All > OneArgNumericFun; +typedef DataTypeCheck AbsCT; +CREATE_FUNCTION_CONSTRAINT(Pow); +typedef DataTypeCheck PowCT; +CREATE_FUNCTION_CONSTRAINT(Sqrt); +typedef DataTypeCheck SqrtCT; +CREATE_FUNCTION_CONSTRAINT(Mod); +typedef DataTypeCheck ModCT; +CREATE_FUNCTION_CONSTRAINT(Floor); +typedef DataTypeCheck FloorCT; +CREATE_FUNCTION_CONSTRAINT(Ceil); +typedef DataTypeCheck CeilCT; + + + +/** + * @brief AbsoluteValue(x, y) maintains the relation: + * @li x.lb >= 0 + * @li x.ub = max(abs(y.lb), abs(y.ub)) + * @li y.lb >= -x.lb + * @li y.ub <= x.ub + */ +class AbsoluteValue : public Constraint { + public: + AbsoluteValue(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); - void handleExecute(); - private: - IntervalDomain& m_x; - IntervalDomain& m_y; - static const unsigned int ARG_COUNT = 2; - }; - - class AbsoluteValueCT : public ConstraintType { - public: - AbsoluteValueCT(const LabelStr& name, - const LabelStr& propagatorName, - bool systemDefined = false) - : ConstraintType(name,propagatorName,systemDefined) {} - - virtual ~AbsoluteValueCT() {} - - virtual ConstraintId createConstraint( - const ConstraintEngineId constraintEngine, - const std::vector& scope, - const char* violationExpl) - { - return makeConstraintInstance(m_name, m_propagatorName, constraintEngine, scope, violationExpl); - } - - virtual void checkArgTypes(const std::vector& argTypes) const; - }; - - - class AddEqualConstraint : public Constraint { - public: - AddEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - // X + Y = Z - Domain& m_x; - Domain& m_y; - Domain& m_z; - - static const int X = 0; - static const int Y = 1; - static const int Z = 2; - static const int ARG_COUNT = 3; - }; - - class AddEqualCT : public ConstraintType { - public: - AddEqualCT(const LabelStr& name, - const LabelStr& propagatorName, - bool systemDefined = false) - : ConstraintType(name,propagatorName,systemDefined) {} - - virtual ~AddEqualCT() {} - - virtual ConstraintId createConstraint(const ConstraintEngineId constraintEngine, - const std::vector& scope, - const char* violationExpl) - { - return makeConstraintInstance(m_name, m_propagatorName, constraintEngine, scope, violationExpl); - } - - virtual void checkArgTypes(const std::vector& argTypes) const; - }; - - - - class MultEqualConstraint : public Constraint { - public: - MultEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - static const int X = 0; - static const int Y = 1; - static const int Z = 2; - static const int ARG_COUNT = 3; - }; - - - class DivEqualConstraint : public Constraint { - public: - DivEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - static const int X = 0; - static const int Y = 1; - static const int Z = 2; - static const int ARG_COUNT = 3; - }; - - - // A + (B * C) = D - class AddMultEqualConstraint : public Constraint { - public: - AddMultEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~AddMultEqualConstraint(); - private: - // All the work is done by the member constraints - inline void handleExecute() { } - void handleDiscard(); - - static const int A = 0; - static const int B = 1; - static const int C = 2; - static const int D = 3; - static const int ARG_COUNT = 4; - - Variable m_interimVariable; - MultEqualConstraint m_multEqualConstraint; - AddEqualConstraint m_addEqualConstraint; - }; - - class AllDiffConstraint : public Constraint { - public: - AllDiffConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + void handleExecute(); + private: + IntervalDomain& m_x; + IntervalDomain& m_y; + static const unsigned int ARG_COUNT = 2; +}; +typedef And, And >, All > > TwoAssignableNumeric; +typedef DataTypeCheck AbsoluteValueCT; + +class AddEqualConstraint : public Constraint { + public: + AddEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + + private: + // X + Y = Z + Domain& m_x; + Domain& m_y; + Domain& m_z; + + static const unsigned int X = 0; + static const unsigned int Y = 1; + static const unsigned int Z = 2; + static const unsigned int ARG_COUNT = 3; +}; + +//TODO: fix this +// typedef And, And, All > > > > ThreeNumericEq; +typedef And, And, All > > > > ThreeNumericEq; +typedef DataTypeCheck AddEqualCT; + +class MultEqualConstraint : public Constraint { + public: + MultEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); + + void handleExecute(); + + private: + static const unsigned int X = 0; + static const unsigned int Y = 1; + static const unsigned int Z = 2; + static const unsigned int ARG_COUNT = 3; +}; + +typedef DataTypeCheck MultEqualCT; + + +class DivEqualConstraint : public Constraint { + public: + DivEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + + private: + static const unsigned int X = 0; + static const unsigned int Y = 1; + static const unsigned int Z = 2; + static const unsigned int ARG_COUNT = 3; +}; +typedef DataTypeCheck DivEqualCT; + + +/** + * @class AllDiff + * @brief A != B && A != C && B != C && A != D && B != D && ... + */ + +class AllDiffConstraint : public Constraint { + public: + AllDiffConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + ~AllDiffConstraint() { + discard(false); + } - ~AllDiffConstraint() { - discard(false); - } - - private: - void handleExecute() { } + private: + void handleExecute() { } - void handleDiscard(){ - Constraint::handleDiscard(); - m_condVar.discard(); - m_condAllDiffConstraint->discard(); - } + void handleDiscard(){ + Constraint::handleDiscard(); + m_condVar.discard(); + m_condAllDiffConstraint->discard(); + } - Variable m_condVar; - ConstraintId m_condAllDiffConstraint; - }; + Variable m_condVar; + ConstraintId m_condAllDiffConstraint; +}; +typedef DataTypeCheck, Mutually > > > +AllDiffCT; + /** + * @brief Calculate the euclidean distance in 2-d space between between 2 points + */ class CalcDistanceConstraint : public Constraint { - public: - CalcDistanceConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + public: + CalcDistanceConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - void handleExecute(); + void handleExecute(); - /** - * Calculates the actual distance - */ - static edouble compute(edouble x1, edouble y1, edouble x2, edouble y2); + /** + * Calculates the actual distance + */ + static edouble compute(edouble x1, edouble y1, edouble x2, edouble y2); - /** - * Calculates the hypotenuse w. pythagaras - */ - static edouble compute(edouble a, edouble b); + /** + * Calculates the hypotenuse w. pythagaras + */ + static edouble compute(edouble a, edouble b); - private: + private: - static const unsigned int ARG_COUNT = 5; - static const unsigned int DISTANCE = 0; - static const unsigned int X1 = 1; - static const unsigned int Y1 = 2; - static const unsigned int X2 = 3; - static const unsigned int Y2 = 4; - - Domain& m_distance; - Domain& m_x1; - Domain& m_y1; - Domain& m_x2; - Domain& m_y2; - }; + static const unsigned int ARG_COUNT = 5; + static const unsigned int DISTANCE = 0; + static const unsigned int X1 = 1; + static const unsigned int Y1 = 2; + static const unsigned int X2 = 3; + static const unsigned int Y2 = 4; + + Domain& m_distance; + Domain& m_x1; + Domain& m_y1; + Domain& m_x2; + Domain& m_y2; +}; + +typedef DataTypeCheck, And, + All >, Second<>, Last<> > > > > +CalcDistanceCT; class LessThanEqualConstraint : public Constraint { public: - LessThanEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + LessThanEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); void handleExecute(); - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); static void propagate(Domain& domx, Domain& domy); private: - bool testIsRedundant(const ConstrainedVariableId& var = ConstrainedVariableId::noId()) const; + bool testIsRedundant(const ConstrainedVariableId var = ConstrainedVariableId::noId()) const; Domain& m_x; Domain& m_y; - static const int X = 0; - static const int Y = 1; - static const int ARG_COUNT = 2; + static const unsigned int X = 0; + static const unsigned int Y = 1; + static const unsigned int ARG_COUNT = 2; }; - CREATE_CONSTRAINT_TYPE(TwoSameNumericArgumentsCT, LessThanEqualCT, LessThanEqualConstraint); - -class CardinalityConstraint : public Constraint { - public: - CardinalityConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~CardinalityConstraint() { - discard(false); - } +typedef DataTypeCheck, And, Mutually > > > > +LessThanEqualCT; - private: - // All the work is done by the member constraints. - inline void handleExecute() { } - void handleDiscard(){ - Constraint::handleDiscard(); - m_nonZeros.discard(); - m_lessThanEqualConstraint.discard(); - m_countNonZerosConstraint->discard(); - } - - Variable m_nonZeros; - LessThanEqualConstraint m_lessThanEqualConstraint; - ConstraintId m_countNonZerosConstraint; - }; + /** + * @class CondAllDiff + * @brief If A, then B != C && B != D && C != D && ... ; if not A, then !(B != C && B != D && C != D && ...). + */ class CondAllDiffConstraint : public Constraint { - public: - CondAllDiffConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - + public: + CondAllDiffConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + ~CondAllDiffConstraint() { } + + void handleExecute(); + + private: + const unsigned long ARG_COUNT; +}; +template, typename End = End> +struct AllAssignable : Mutually, Start, End> { + AllAssignable() : Mutually, Start, End>() {} + AllAssignable(type_iterator start, type_iterator end) + : Mutually, Start, End>(start, end){} +}; +struct CondCondition : And, First > > { + CondCondition() : And, First > >() {} + CondCondition(type_iterator start, type_iterator end) + : And, First > >(start, end) {} +}; +typedef And, End> > CondAllAssignableCondition; +typedef DataTypeCheck CondAllDiffCT; - void handleExecute(); - - private: - const unsigned int ARG_COUNT; - }; + /** + * @class CondAllSame + * @brief If A, then B == C && B == D && C == D && ... ; if not A, then !(B == C && B == D && C == D && ...). + */ class CondAllSameConstraint : public Constraint { - public: - CondAllSameConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~CondAllSameConstraint() { } - - void handleExecute(); - - private: - const unsigned int ARG_COUNT; - }; - -class CondEqualSumConstraint : public Constraint { - public: - CondEqualSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + public: + CondAllSameConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + ~CondAllSameConstraint() { } + + void handleExecute(); + + private: + const unsigned long ARG_COUNT; +}; +typedef DataTypeCheck CondAllSameCT; + + +template, typename End = End> +struct EqThreeNumeric : public And, And, All, Start, End > > > { + EqThreeNumeric() : And, And, All, Start, End > > >() {} + EqThreeNumeric(type_iterator start, type_iterator end) + : And, And, All, Start, End > > >(start, end) {} +}; + +class CountNonZeroesConstraint : public Constraint { + public: + CountNonZeroesConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); - ~CondEqualSumConstraint() { - discard(false); - } - - private: - // All the work is done by the member constraints. - inline void handleExecute() { } - - void handleDiscard(){ - Constraint::handleDiscard(); - m_sumVar.discard(); - m_condAllSameConstraint.discard(); - m_eqSumConstraint->discard(); - } - - Variable m_sumVar; - CondAllSameConstraint m_condAllSameConstraint; - ConstraintId m_eqSumConstraint; - }; - -class CountNonZerosConstraint : public Constraint { - public: - CountNonZerosConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~CountNonZerosConstraint() { - discard(false); - } - - // All the work is done by the member constraints. - inline void handleExecute() { } - - void handleDiscard(){ - Constraint::handleDiscard(); - m_zeros.discard(); - m_otherVars.discard(); - m_superset.discard(); - m_addEqualConstraint.discard(); - m_countZerosConstraint->discard(); - m_subsetConstraint->discard(); - } - - private: - Variable m_zeros, m_otherVars, m_superset; - AddEqualConstraint m_addEqualConstraint; - ConstraintId m_subsetConstraint; - ConstraintId m_countZerosConstraint; - }; - -class CountZerosConstraint : public Constraint { - public: - CountZerosConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + ~CountNonZeroesConstraint() { + discard(false); + } - ~CountZerosConstraint() { } + // All the work is done by the member constraints. + inline void handleExecute() { } + + void handleDiscard(){ + Constraint::handleDiscard(); + m_zeroes.discard(); + m_otherVars.discard(); + m_superset.discard(); + m_addEqualConstraint.discard(); + m_countZeroesConstraint->discard(); + m_subsetConstraint->discard(); + } - void handleExecute(); - }; + private: + Variable m_zeroes, m_otherVars, m_superset; + AddEqualConstraint m_addEqualConstraint; + ConstraintId m_subsetConstraint; + ConstraintId m_countZeroesConstraint; +}; +typedef And, All >, First > > AtLeastTwoNumericFirstAssignable; +typedef DataTypeCheck +CountNonZeroesCT; /** - * @class CountNonZerosConstraint - * @brief First variable is the count of the rest that can be non-zero. + * @class CountZeroesConstraint + * @brief First variable is the count of the rest that can be zero. * @note Supports boolean domains with the usual C/C++ convention of false * being zero and true being non-zero. */ - class DistanceFromSquaresConstraint : public Constraint { - public: - DistanceFromSquaresConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - static const int V1 = 0; - static const int V2 = 1; - static const int RES = 2; - static const int ARG_COUNT = 3; - }; - - class EqualConstraint : public Constraint { - public: - EqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - /** - * @brief Accessor required for EqualityConstraintPropagator. - */ - static Domain& getCurrentDomain(const ConstrainedVariableId& var); - - private: - bool equate(const ConstrainedVariableId& v1, const ConstrainedVariableId& v2, bool& isEmpty); - const unsigned int m_argCount; - }; - CREATE_CONSTRAINT_TYPE(AllSameArgumentsCT, EqualCT, EqualConstraint); - - class EqualMaximumConstraint : public Constraint { - public: - EqualMaximumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); +class CountZeroesConstraint : public Constraint { + public: + CountZeroesConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + ~CountZeroesConstraint() { } + + void handleExecute(); +}; +typedef DataTypeCheck CountZeroesCT; + + +/** + * @brief DistanceFromSquaresConstraint(x, y, a) maintains the relation + * @li a = sqrt(x + y) + * if x and y are singleton + */ + +class DistanceFromSquaresConstraint : public Constraint { + public: + DistanceFromSquaresConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + + private: + static const unsigned int V1 = 0; + static const unsigned int V2 = 1; + static const unsigned int RES = 2; + static const unsigned int ARG_COUNT = 3; +}; +typedef DataTypeCheck, All >, Last > > > +DistanceFromSquaresCT; + +class EqualConstraint : public Constraint { + public: + EqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + + /** + * @brief Accessor required for EqualityConstraintPropagator. + */ + static Domain& getCurrentDomain(const ConstrainedVariableId var); + + private: + bool equate(const ConstrainedVariableId v1, const ConstrainedVariableId v2, bool& isEmpty); + const unsigned long m_argCount; +}; +typedef And, Mutually > > EqualCondition; +typedef DataTypeCheck EqualCT; + +/** + * @class EqualMaximumConstraint + * @brief First variable is the maximum value of the others. + */ + +class EqualMaximumConstraint : public Constraint { + public: + EqualMaximumConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - ~EqualMaximumConstraint() { } + ~EqualMaximumConstraint() { } + + void handleExecute(); +}; +typedef DataTypeCheck > EqualMaximumCT; - void handleExecute(); - }; + /** + * @class EqualMinimumConstraint + * @brief First variable is the minimum value of the others. + */ class EqualMinimumConstraint : public Constraint { public: - EqualMinimumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~EqualMinimumConstraint() { } + EqualMinimumConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + ~EqualMinimumConstraint() { } + + void handleExecute(); +}; +typedef DataTypeCheck > EqualMinimumCT; - void handleExecute(); - }; + /** + * @class EqualProductConstraint + * @brief A = B * C where B and C can each be products. + * Converted into an AddEqualConstraint and/or two EqProductConstraints with fewer variables. + */ class EqualProductConstraint : public Constraint { - public: - EqualProductConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + public: + EqualProductConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - ~EqualProductConstraint(); + ~EqualProductConstraint(); - private: + private: - // All the work is done by the member constraints - inline void handleExecute() { } + // All the work is done by the member constraints + inline void handleExecute() { } - void handleDiscard(); + void handleDiscard(); - const unsigned int ARG_COUNT; + const unsigned long ARG_COUNT; - ConstraintId m_eqProductC1, m_eqProductC2, m_eqProductC3, m_eqProductC4, m_eqProductC5; - Variable m_product1, m_product2, m_product3, m_product4; - }; + ConstraintId m_eqProductC1, m_eqProductC2, m_eqProductC3, m_eqProductC4, m_eqProductC5; + Variable m_product1, m_product2, m_product3, m_product4; +}; +typedef DataTypeCheck > EqualProductCT; +/** + * @class EqualSumConstraint + * @brief A = B + C where B and C can each be sums. + * Converted into an AddEqualConstraint and/or two EqSumConstraints with fewer variables. + */ class EqualSumConstraint : public Constraint { - public: - EqualSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~EqualSumConstraint(); - - private: - - // All the work is done by the member constraints - inline void handleExecute() { } + public: + EqualSumConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - void handleDiscard(); + ~EqualSumConstraint(); - const unsigned int ARG_COUNT; + private: - ConstraintId m_eqSumC1, m_eqSumC2, m_eqSumC3, m_eqSumC4, m_eqSumC5; - Variable m_sum1, m_sum2, m_sum3, m_sum4; - }; + // All the work is done by the member constraints + inline void handleExecute() { } -class GreaterOrEqThanSumConstraint : public Constraint { - public: - GreaterOrEqThanSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~GreaterOrEqThanSumConstraint() { - discard(false); - } + void handleDiscard(); - private: - // All the work is done by the member constraints - inline void handleExecute() { } + const unsigned long ARG_COUNT; - void handleDiscard(){ - Constraint::handleDiscard(); - m_interimVariable.discard(); - m_lessOrEqualConstraint.discard(); - m_eqSumConstraint->discard(); - } + ConstraintId m_eqSumC1, m_eqSumC2, m_eqSumC3, m_eqSumC4, m_eqSumC5; + Variable m_sum1, m_sum2, m_sum3, m_sum4; +}; +typedef DataTypeCheck > EqualSumCT; - Variable m_interimVariable; - LessThanEqualConstraint m_lessOrEqualConstraint; - ConstraintId m_eqSumConstraint; - }; class LessThanConstraint : public Constraint { - public: - LessThanConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - - void handleExecute(); - - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); - - static void propagate(IntervalDomain& domx, IntervalDomain& domy); - - private: - static const int X = 0; - static const int Y = 1; - static const int ARG_COUNT = 2; - }; - CREATE_CONSTRAINT_TYPE(TwoSameNumericArgumentsCT, LessThanCT, LessThanConstraint); - -class GreaterThanSumConstraint : public Constraint { - public: - GreaterThanSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~GreaterThanSumConstraint() { - discard(false); - } - - private: - // All the work is done by the member constraints - inline void handleExecute() { } + public: + LessThanConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - void handleDiscard(){ - Constraint::handleDiscard(); - m_interimVariable.discard(); - m_lessThanConstraint.discard(); - m_eqSumConstraint->discard(); - } - Variable m_interimVariable; - LessThanConstraint m_lessThanConstraint; - ConstraintId m_eqSumConstraint; - }; + void handleExecute(); -class LessOrEqThanSumConstraint : public Constraint { - public: - LessOrEqThanSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); - ~LessOrEqThanSumConstraint(); + static void propagate(IntervalDomain& domx, IntervalDomain& domy); - private: - void handleExecute(); - void handleDiscard(); - Variable m_interimVariable; - LessThanEqualConstraint m_lessOrEqualConstraint; - ConstraintId m_eqSumConstraint; - }; - - class LessThanSumConstraint : public Constraint { - public: - LessThanSumConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + private: + static const unsigned int X = 0; + static const unsigned int Y = 1; + static const unsigned int ARG_COUNT = 2; +}; +typedef DataTypeCheck, Mutually > > > LessThanCT; - ~LessThanSumConstraint() { - discard(false); - } - - private: - - // All the work is done by the member constraints - inline void handleExecute() { } - - void handleDiscard(){ - Constraint::handleDiscard(); - m_interimVariable.discard(); - m_lessThanConstraint.discard(); - m_eqSumConstraint->discard(); - } - - Variable m_interimVariable; - LessThanConstraint m_lessThanConstraint; - ConstraintId m_eqSumConstraint; - }; class LockConstraint : public Constraint { - public: - LockConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + public: + LockConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - ~LockConstraint(); + ~LockConstraint(); - void handleExecute(); + void handleExecute(); - const Domain& getDomain() const; + const Domain& getDomain() const; - private: - Domain& m_currentDomain; - Domain& m_lockDomain; - }; + private: + Domain& m_currentDomain; + Domain& m_lockDomain; +}; +typedef DataTypeCheck, All > > > > LockCT; class NegateConstraint : public Constraint { - public: - NegateConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - private: - static const int X=0; - static const int Y=1; - }; + public: + NegateConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + private: + static const unsigned int X=0; + static const unsigned int Y=1; +}; +typedef DataTypeCheck NegateCT; class NotEqualConstraint : public Constraint { - public: - NotEqualConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + public: + NotEqualConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - void handleExecute(); + void handleExecute(); - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); - /** - * @brief Helper method to do domain comparisons, and process removals if necessary - */ - static bool checkAndRemove(const Domain& domx, Domain& domy); + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); + /** + * @brief Helper method to do domain comparisons, and process removals if necessary + */ + static bool checkAndRemove(const Domain& domx, Domain& domy); - private: - static const int X = 0; - static const int Y = 1; - static const int ARG_COUNT = 2; - }; + private: + static const unsigned int X = 0; + static const unsigned int Y = 1; + static const unsigned int ARG_COUNT = 2; +}; +typedef DataTypeCheck NotEqualCT; /** * Enforces the relation x < y */ - /** - * @class EqualSumConstraint - * @brief A = B + C where B and C can each be sums. - * Converted into an AddEqualConstraint and/or two EqSumConstraints with fewer variables. - */ - /** - * @class EqualProductConstraint - * @brief A = B * C where B and C can each be products. - * Converted into an AddEqualConstraint and/or two EqProductConstraints with fewer variables. - */ - /** - * @class LessOrEqThanSumConstraint - * @brief A <= B + C + ... - * Converted into two constraints: A <= temp and temp equal to the sum of the rest. - */ - /** - * @class LessThanSumConstraint - * @brief A < B + C + ... - * Converted into two constraints: A < temp and temp equal to the sum of the rest. - */ - /** - * @class GreaterOrEqThanSumConstraint - * @brief A >= B + C + ... - * Converted into two constraints: A >= temp and temp equal to the sum of the rest. - */ - /** - * @class GreaterThanSumConstraint - * @brief A > B + C + ... - * Converted into two constraints: A < temp and temp equal to the sum of the rest. - */ - /** - * @class CondAllSame - * @brief If A, then B == C && B == D && C == D && ... ; if not A, then !(B == C && B == D && C == D && ...). - */ - /** - * @class CondAllDiff - * @brief If A, then B != C && B != D && C != D && ... ; if not A, then !(B != C && B != D && C != D && ...). - */ - /** - * @class AllDiff - * @brief A != B && A != C && B != C && A != D && B != D && ... - */ /** * @class MemberImplyConstraint * @brief If A is subset of B, then require that C is subset of D. */ - class MemberImplyConstraint : public Constraint { - public: - MemberImplyConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~MemberImplyConstraint() { } +class MemberImplyConstraint : public Constraint { + public: + MemberImplyConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + ~MemberImplyConstraint() { } + + void handleExecute(); + + private: + const unsigned long ARG_COUNT; +}; +//TODO: come up with better syntax for this +typedef DataTypeCheck, And >, Second<>, Third<> >, + All >, Fourth<>, Last<> > > > > +MemberImplyCT; - void handleExecute(); - private: - const unsigned int ARG_COUNT; - }; - - /** - * @class CountZerosConstraint - * @brief First variable is the count of the rest that can be zero. - * @note Supports boolean domains with the usual C/C++ convention of false - * being zero and true being non-zero. - */ - /** - * @class CardinalityConstraint - * @brief First variable must be greater than or equal the count of the - * other variables that are true. - * @note Supports numeric domains for the other variables with the - * usual C/C++ convention of false being zero and true being - * any non-zero value. - */ /** * @class OrConstraint * @brief At least one of the variables must be true. @@ -837,59 +637,49 @@ class NotEqualConstraint : public Constraint { * usual C/C++ convention of false being zero and true being * any non-zero value. */ - class OrConstraint : public Constraint { - public: - OrConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); +class OrConstraint : public Constraint { + public: + OrConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + ~OrConstraint() { + discard(false); + } - ~OrConstraint() { - discard(false); - } + private: + // All the work is done by the member constraints. + inline void handleExecute() { } - private: - // All the work is done by the member constraints. - inline void handleExecute() { } + void handleDiscard(){ + Constraint::handleDiscard(); + m_nonZeroes.discard(); + m_superset.discard(); + m_subsetConstraint->discard(); + m_countNonZeroesConstraint->discard(); + } - void handleDiscard(){ - Constraint::handleDiscard(); - m_nonZeros.discard(); - m_superset.discard(); - m_subsetConstraint->discard(); - m_countNonZerosConstraint->discard(); - } + Variable m_nonZeroes; + Variable m_superset; + ConstraintId m_subsetConstraint; + ConstraintId m_countNonZeroesConstraint; +}; +typedef DataTypeCheck, All > > OrCT; - Variable m_nonZeros; - Variable m_superset; - ConstraintId m_subsetConstraint; - ConstraintId m_countNonZerosConstraint; - }; - class RandConstraint : public Constraint { - public: - RandConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - void handleExecute(); - private: - unsigned int m_rvalue; - }; +class RandConstraint : public Constraint { + public: + RandConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + void handleExecute(); + private: + unsigned int m_rvalue; +}; +typedef DataTypeCheck, All > > RandCT; - /** - * @class EqualMinimumConstraint - * @brief First variable is the minimum value of the others. - */ - /** - * @class EqualMaximumConstraint - * @brief First variable is the maximum value of the others. - */ - /** - * @class CondEqualSumConstraint - * @brief If A is true, then B = C + D ...; if A is false, B != C + D ... - * Converted into two constraints: CondAllSame(A, B, sum) and EqualSum(sum, C, D, ...). - */ /** * @class RotateScopeRightConstraint * @brief Rotate the scope right rotateCount places and call the otherName @@ -898,115 +688,145 @@ class NotEqualConstraint : public Constraint { * "pushing" all of the other variables to the right. * @note Negative and zero values for rotateCount are supported. */ - class RotateScopeRightConstraint : public Constraint { - public: - RotateScopeRightConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables) { - // Called via REGISTER_NARY() macro's factory rather than via the - // REGISTER_ROTATED_NARY() macro's factory: not enough information - // to create the constraint. - assertTrue(false); - } +class RotateScopeRightConstraint : public Constraint { + public: + RotateScopeRightConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) __attribute__((noreturn)) + : Constraint(name, propagatorName, constraintEngine, variables), + m_otherConstraint() { + // Called via REGISTER_NARY() macro's factory rather than via the + // REGISTER_ROTATED_NARY() macro's factory: not enough information + // to create the constraint. + assertTrue(false); + } - RotateScopeRightConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables, - const LabelStr& otherName, - const int& rotateCount); + RotateScopeRightConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables, + const std::string& otherName, + const int& rotateCount); - ~RotateScopeRightConstraint() { - discard(false); - } + ~RotateScopeRightConstraint() { + discard(false); + } - private: - void handleExecute() { } + private: + void handleExecute() { } - void handleDiscard(){ - Constraint::handleDiscard(); - m_otherConstraint->discard(); - } + void handleDiscard(){ + Constraint::handleDiscard(); + m_otherConstraint->discard(); + } - ConstraintId m_otherConstraint; - }; + ConstraintId m_otherConstraint; +}; /** * @class SwapTwoVarsConstraint * @brief Swap two variables in the scope and call the otherName * constraint. */ - class SineFunction : public Constraint { - public: - SineFunction(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - void handleExecute(); - - private: - static const unsigned int ARG_COUNT = 2; - Domain& m_target; - Domain& m_source; - }; +/** + * @brief Computes the sine of a given variable. Varable is in degrees. The constraint is a function + * rather than a relation. The range of the source variable must be in [0 90]. + */ +class SineFunction : public Constraint { + public: + SineFunction(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + + private: + static const unsigned int ARG_COUNT = 2; + Domain& m_target; + Domain& m_source; +}; +//TODO: Fix this syntax, too +typedef DataTypeCheck, And >, + Second > > > > +SineCT; + +/** + * @brief SquareOfDifference(x, y, a) maintains the relation: + * @li a = (x - y)^2 + * if x and y are singleton. + */ class SquareOfDifferenceConstraint : public Constraint { - public: - SquareOfDifferenceConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - static const int V1 = 0; - static const int V2 = 1; - static const int RES = 2; - static const int ARG_COUNT = 3; - }; + public: + SquareOfDifferenceConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + + private: + static const unsigned int V1 = 0; + static const unsigned int V2 = 1; + static const unsigned int RES = 2; + static const unsigned int ARG_COUNT = 3; +}; +typedef DataTypeCheck, And >, First<>, End>, + First > > > +SquareOfDifferenceCT; + +/** + * @brief Maintains a unary relation from a constant to a variable such that the variable + * is a subset of the given constant. + */ class SubsetOfConstraint : public Constraint { - public: - SubsetOfConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~SubsetOfConstraint(); - - void handleExecute(); - - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); - - private: - Domain& m_currentDomain; - Domain& m_superSetDomain; - }; + public: + SubsetOfConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + ~SubsetOfConstraint(); + + void handleExecute(); + + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); + + private: + Domain& m_currentDomain; + Domain& m_superSetDomain; +}; +//TODO: fix this syntax +typedef DataTypeCheck, + All >, First<>, Last<> > > > +SubsetOfCT; + class SwapTwoVarsConstraint : public Constraint { - public: - SwapTwoVarsConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables) { - // Called via REGISTER_NARY() macro's factory rather than via the - // REGISTER_SWAP_TWO_VARS_NARY() macro's factory: not enough information - // to create the constraint. - assertTrue(false); - } - - SwapTwoVarsConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + public: + SwapTwoVarsConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) __attribute__((noreturn)) + : Constraint(name, propagatorName, constraintEngine, variables), m_otherConstraint() { + // Called via REGISTER_NARY() macro's factory rather than via the + // REGISTER_SWAP_TWO_VARS_NARY() macro's factory: not enough information + // to create the constraint. + assertTrue(false); + } + + SwapTwoVarsConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables, - const LabelStr& otherName, + const std::string& otherName, int firstIndex, int secondIndex); ~SwapTwoVarsConstraint() { @@ -1025,198 +845,185 @@ class SwapTwoVarsConstraint : public Constraint { }; // Enforce X+Y=0. X >=0. Y <=0. - class TestAnd : public Constraint { - public: - TestAnd(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - Domain& m_test; - Domain& m_arg1; - Domain& m_arg2; - static const unsigned int ARG_COUNT = 3; - }; - CREATE_CONSTRAINT_TYPE(ThreeBooleanArgumentsCT, TestAndCT, TestAnd); - - class TestEQ : public Constraint { - public: - TestEQ(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - Domain& m_test; - Domain& m_arg1; - Domain& m_arg2; - static const unsigned int ARG_COUNT = 3; - }; - CREATE_CONSTRAINT_TYPE(TestTwoSameArgumentsCT, TestEQCT, TestEQ); - - class TestLessThan : public Constraint { - public: - TestLessThan(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - Domain& m_test; - Domain& m_arg1; - Domain& m_arg2; - static const unsigned int ARG_COUNT = 3; - }; - CREATE_CONSTRAINT_TYPE(TestTwoSameNumericArgumentsCT, TestLessThanCT, TestLessThan); - - class TestLEQ : public Constraint { - public: - TestLEQ(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); +class TestAnd : public Constraint { + public: + TestAnd(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - private: - Domain& m_test; - Domain& m_arg1; - Domain& m_arg2; - static const unsigned int ARG_COUNT = 3; - }; - CREATE_CONSTRAINT_TYPE(TestTwoSameNumericArgumentsCT, TestLEQCT, TestLEQ); + void handleExecute(); + + private: + Domain& m_test; + Domain& m_arg1; + Domain& m_arg2; + static const unsigned int ARG_COUNT = 3; +}; +struct TestCondition : And, First > > { + TestCondition() : And, First > >() {} + TestCondition(type_iterator start, type_iterator end) + : And, First > >(start, end) {} +}; + +typedef And, All > > ThreeBooleanArgs; +typedef DataTypeCheck > TestAndCT; + +class TestEQ : public Constraint { + public: + TestEQ(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + void handleExecute(); + + private: + Domain& m_test; + Domain& m_arg1; + Domain& m_arg2; + static const unsigned int ARG_COUNT = 3; +}; +typedef And, Second<>, End> > TestCompareCondition; +typedef DataTypeCheck TestEQCT; + + +class TestLessThan : public Constraint { + public: + TestLessThan(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + + private: + Domain& m_test; + Domain& m_arg1; + Domain& m_arg2; + static const unsigned int ARG_COUNT = 3; +}; +typedef DataTypeCheck TestLessThanCT; + +class TestLEQ : public Constraint { + public: + TestLEQ(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - /** - * @brief Calculate the euclidean distance in 2-d space between between 2 points - */ - /** - * @brief Computes the sign of a given variable. Varable is in degrees. The constraint is a function - * rather than a relation. The range of the source variable must be in [0 90]. - */ - /** - * @brief SquareOfDifference(x, y, a) maintains the relation: - * @li a = (x - y)^2 - * if x and y are singleton. - */ - /** - * @brief DistanceFromSquaresConstraint(x, y, a) maintains the relation - * @li a = sqrt(x + y) - * if x and y are singleton - */ - /** - * @brief Maintains a unary relation from a constant to a variable such that the variable - * is a subset of the given constant. - */ - class TestNEQ : public Constraint { - public: - TestNEQ(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + void handleExecute(); + + private: + Domain& m_test; + Domain& m_arg1; + Domain& m_arg2; + static const unsigned int ARG_COUNT = 3; +}; +typedef DataTypeCheck TestLEQCT; + +class TestNEQ : public Constraint { + public: + TestNEQ(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - void handleExecute(); + void handleExecute(); - private: - Domain& m_test; - Domain& m_arg1; - Domain& m_arg2; - static const unsigned int ARG_COUNT = 3; - }; - CREATE_CONSTRAINT_TYPE(TestTwoSameArgumentsCT, TestNEQCT, TestNEQ); + private: + Domain& m_test; + Domain& m_arg1; + Domain& m_arg2; + static const unsigned int ARG_COUNT = 3; +}; +typedef DataTypeCheck TestNEQCT; class TestOr : public Constraint { - public: - TestOr(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + public: + TestOr(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - void handleExecute(); - - private: - Domain& m_test; - Domain& m_arg1; - Domain& m_arg2; - static const unsigned int ARG_COUNT = 3; - }; - CREATE_CONSTRAINT_TYPE(ThreeBooleanArgumentsCT, TestOrCT, TestOr); + void handleExecute(); + private: + Domain& m_test; + Domain& m_arg1; + Domain& m_arg2; + static const unsigned int ARG_COUNT = 3; +}; +typedef DataTypeCheck TestOrCT; class TestSingleton : public Constraint { - public: - TestSingleton(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + public: + TestSingleton(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - void handleExecute(); + void handleExecute(); const std::vector& getModifiedVariables() const; -private: - Domain& m_test; - Domain& m_arg1; + private: + Domain& m_test; + Domain& m_arg1; std::vector m_modifiedVariables; - static const unsigned int ARG_COUNT = 2; - }; - - CREATE_CONSTRAINT_TYPE(TestOneArgumentCT, TestSingletonCT, TestSingleton); + static const unsigned int ARG_COUNT = 2; +}; +typedef DataTypeCheck, First > > > TestSingletonCT; class TestSpecified : public Constraint { - public: - TestSpecified(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + public: + TestSpecified(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - void handleExecute(); + void handleExecute(); - private: - Domain& m_test; - Domain& m_arg1; - static const unsigned int ARG_COUNT = 2; - }; - CREATE_CONSTRAINT_TYPE(TestOneArgumentCT, TestSpecifiedCT, TestSpecified); + private: + Domain& m_test; + Domain& m_arg1; + static const unsigned int ARG_COUNT = 2; +}; +typedef DataTypeCheck, First > > > TestSpecifiedCT; class UnaryConstraint : public Constraint { - public: - /** - * @brief Specialized constructor - */ - UnaryConstraint(const Domain& dom, const ConstrainedVariableId& var); - - /** - * @brief Standard constructor - */ - UnaryConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); + public: + /** + * @brief Specialized constructor + */ + UnaryConstraint(const Domain& dom, const ConstrainedVariableId var); - ~UnaryConstraint(); + /** + * @brief Standard constructor + */ + UnaryConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); - private: + ~UnaryConstraint(); - void handleExecute(); + private: + UnaryConstraint(const UnaryConstraint&); + UnaryConstraint& operator=(const UnaryConstraint&); + void handleExecute(); - void handleDiscard(); + void handleDiscard(); - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); - void setSource(const ConstraintId& sourceConstraint); + void setSource(const ConstraintId sourceConstraint); - Domain* m_x; - Domain* m_y; - }; + Domain* m_x; + Domain* m_y; +}; +typedef DataTypeCheck > UnaryCT; /** * @brief WithinBounds(x, y, z) maintains the relations: @@ -1224,23 +1031,45 @@ class UnaryConstraint : public Constraint { * @li x.ub <= z.ub * @li y <= z */ - class WithinBounds : public Constraint { - public: - WithinBounds(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - void handleExecute(); - - private: - IntervalDomain& m_x; - IntervalDomain& m_y; - IntervalDomain& m_z; - LessThanEqualConstraint m_leq; - static const unsigned int ARG_COUNT = 3; - }; - - +class WithinBounds : public Constraint { + public: + WithinBounds(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + + private: + IntervalDomain& m_x; + IntervalDomain& m_y; + IntervalDomain& m_z; + LessThanEqualConstraint m_leq; + static const unsigned int ARG_COUNT = 3; +}; +typedef DataTypeCheck, And, + Mutually > > > > +WithinBoundsCT; + + +class EqUnionConstraint : public Constraint { + public: + EqUnionConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); + + void handleExecute(); + void handleExecuteInterval(IntervalDomain& dest, + std::vector::const_iterator start, + const std::vector::const_iterator end); + void handleExecuteEnumerated(EnumeratedDomain& dest, + std::vector::const_iterator start, + const std::vector::const_iterator end); + +}; +typedef DataTypeCheck, + All >, Second<>, End > > > +EqUnionCT; } #endif diff --git a/src/PLASMA/ConstraintEngine/component/DataTypes.cc b/src/PLASMA/ConstraintEngine/component/DataTypes.cc index 078b0bebf..8ce007d68 100644 --- a/src/PLASMA/ConstraintEngine/component/DataTypes.cc +++ b/src/PLASMA/ConstraintEngine/component/DataTypes.cc @@ -13,7 +13,7 @@ #define DT_STATIC_MEMBERS(dataType,dtName) \ const std::string& dataType::NAME() { static std::string sl_name(#dtName); return sl_name; } \ -const DataTypeId& dataType::instance() { static dataType sl_instance; return sl_instance.getId(); } +const DataTypeId dataType::instance() { static dataType sl_instance; return sl_instance.getId(); } namespace EUROPA @@ -40,20 +40,20 @@ bool VoidDT::isNumeric() const { return false; } bool VoidDT::isBool() const { return false; } bool VoidDT::isString() const { return false; } -edouble VoidDT::createValue(const std::string& value) const +edouble VoidDT::createValue(const std::string&) const { check_error(ALWAYS_FAILS, "can't create void value"); return -1; } ConstrainedVariableId -VoidDT::createVariable(const ConstraintEngineId& constraintEngine, - const Domain& baseDomain, - const bool internal, - bool canBeSpecified, - const char* name, - const EntityId& parent, - int index) const +VoidDT::createVariable(const ConstraintEngineId, + const Domain&, + const bool, + bool, + const std::string&, + const EntityId, + unsigned int) const { check_error(ALWAYS_FAILS, "can't create void variable"); return ConstrainedVariableId::noId(); @@ -142,15 +142,15 @@ edouble BoolDT::createValue(const std::string& value) const return -1; } -std::string BoolDT::toString(edouble value) const +std::string BoolDT::toString(edouble value) const { - static const LabelStr sl_true("true"); - static const LabelStr sl_false("false"); + static const std::string sl_true("true"); + static const std::string sl_false("false"); checkError(value == true || value == false, value << "is not a bool value" ); if(value == true) - return sl_true.toString(); + return sl_true; else - return sl_false.toString(); + return sl_false; } StringDT::StringDT() @@ -191,11 +191,12 @@ edouble SymbolDT::createValue(const std::string& value) const return LabelStr(value); } -RestrictedDT::RestrictedDT(const char* name, const DataTypeId& baseType, const Domain& baseDomain) +RestrictedDT::RestrictedDT(const std::string& name, const DataTypeId baseType, + const Domain& _baseDomain) : DataType(name) , m_baseType(baseType) { - m_baseDomain = baseDomain.copy(); + m_baseDomain = _baseDomain.copy(); m_baseDomain->setDataType(getId()); setIsRestricted(true); } diff --git a/src/PLASMA/ConstraintEngine/component/DataTypes.hh b/src/PLASMA/ConstraintEngine/component/DataTypes.hh index e20f8ce25..583ce7c7e 100644 --- a/src/PLASMA/ConstraintEngine/component/DataTypes.hh +++ b/src/PLASMA/ConstraintEngine/component/DataTypes.hh @@ -23,16 +23,16 @@ public: virtual bool isString() const; virtual edouble createValue(const std::string& value) const; - virtual ConstrainedVariableId createVariable(const ConstraintEngineId& constraintEngine, + virtual ConstrainedVariableId createVariable(const ConstraintEngineId constraintEngine, const Domain& baseDomain, const bool internal = false, bool canBeSpecified = true, - const char* name = NO_VAR_NAME, - const EntityId& parent = EntityId::noId(), - int index = ConstrainedVariable::NO_INDEX) const; + const std::string& name = NO_VAR_NAME, + const EntityId parent = EntityId::noId(), + unsigned int index = ConstrainedVariable::NO_INDEX) const; static const std::string& NAME(); - static const DataTypeId& instance(); + static const DataTypeId instance(); }; class FloatDT : public DataType @@ -48,7 +48,7 @@ public: virtual edouble createValue(const std::string& value) const; static const std::string& NAME(); - static const DataTypeId& instance(); + static const DataTypeId instance(); }; class IntDT : public DataType @@ -64,7 +64,7 @@ public: virtual edouble createValue(const std::string& value) const; static const std::string& NAME(); - static const DataTypeId& instance(); + static const DataTypeId instance(); }; class BoolDT : public DataType @@ -81,7 +81,7 @@ public: virtual std::string toString(edouble value) const; static const std::string& NAME(); - static const DataTypeId& instance(); + static const DataTypeId instance(); }; class StringDT : public DataType @@ -97,7 +97,7 @@ public: virtual edouble createValue(const std::string& value) const; static const std::string& NAME(); - static const DataTypeId& instance(); + static const DataTypeId instance(); }; class SymbolDT : public DataType @@ -113,13 +113,13 @@ public: virtual edouble createValue(const std::string& value) const; static const std::string& NAME(); - static const DataTypeId& instance(); + static const DataTypeId instance(); }; class RestrictedDT : public DataType { public: - RestrictedDT(const char* name, const DataTypeId& baseType, const Domain& baseDomain); + RestrictedDT(const std::string& name, const DataTypeId baseType, const Domain& baseDomain); virtual ~RestrictedDT(); virtual bool isNumeric() const; diff --git a/src/PLASMA/ConstraintEngine/component/Domains.cc b/src/PLASMA/ConstraintEngine/component/Domains.cc index 83589ad7c..9d7897bd8 100644 --- a/src/PLASMA/ConstraintEngine/component/Domains.cc +++ b/src/PLASMA/ConstraintEngine/component/Domains.cc @@ -31,42 +31,42 @@ namespace EUROPA { // return(true); // } - EnumeratedDomain::EnumeratedDomain(const DataTypeId& dt) - : Domain(dt,true,false) - { - } +EnumeratedDomain::EnumeratedDomain(const DataTypeId dt) + : Domain(dt,true,false), m_values() +{ +} - EnumeratedDomain::EnumeratedDomain(const DataTypeId& dt, const std::list& values) - : Domain(dt,true,false) - { - for (std::list::const_iterator it = values.begin(); it != values.end(); ++it) - insert(*it); +EnumeratedDomain::EnumeratedDomain(const DataTypeId dt, const std::list& values) + : Domain(dt,true,false), m_values() +{ + for (std::list::const_iterator it = values.begin(); it != values.end(); ++it) + insert(*it); - close(); - } + close(); +} - EnumeratedDomain::EnumeratedDomain(const DataTypeId& dt, edouble value) - : Domain(dt,true,false) - { - insert(value); - close(); - } +EnumeratedDomain::EnumeratedDomain(const DataTypeId dt, edouble value) + : Domain(dt,true,false), m_values() +{ + insert(value); + close(); +} - EnumeratedDomain::EnumeratedDomain(const DataTypeId& dt, double value) - : Domain(dt,true,false) - { - insert(value); - close(); - } +EnumeratedDomain::EnumeratedDomain(const DataTypeId dt, double value) + : Domain(dt,true,false), m_values() +{ + insert(value); + close(); +} - EnumeratedDomain::EnumeratedDomain(const Domain& org) - : Domain(org) - { - check_error(org.isEnumerated(), - "Invalid source domain " + org.getTypeName().toString() + " for enumeration"); - const EnumeratedDomain& enumOrg = static_cast(org); - m_values = enumOrg.m_values; - } +EnumeratedDomain::EnumeratedDomain(const Domain& org) + : Domain(org), m_values() +{ + check_error(org.isEnumerated(), + "Invalid source domain " + org.getTypeName() + " for enumeration"); + const EnumeratedDomain& enumOrg = static_cast(org); + m_values = enumOrg.m_values; +} bool EnumeratedDomain::isFinite() const { return(true); // Always finite, even if bounds are infinite, since there are always a finite number of values to select. @@ -481,13 +481,13 @@ namespace EUROPA { return(value_removed); } - Domain& EnumeratedDomain::operator=(const Domain& dom) { - safeComparison(*this, dom); - check_error(m_listener.isNoId(), "Can only do direct assigment if not registered with a listener"); - const EnumeratedDomain& e_dom = static_cast(dom); - m_values = e_dom.m_values; - return(*this); - } +Domain& EnumeratedDomain::operator=(const Domain& dom) { + safeComparison(*this, dom); + check_error(m_listener.isNoId(), "Can only do direct assigment if not registered with a listener"); + const EnumeratedDomain& e_dom = dynamic_cast(dom); + m_values = e_dom.m_values; + return *this; +} bool EnumeratedDomain::isSubsetOf(const Domain& dom) const { safeComparison(*this, dom); @@ -548,6 +548,8 @@ namespace EUROPA { os << "}"; } +void EnumeratedDomain::testPrecision(const edouble&) const {} + std::string EnumeratedDomain::toString() const { return Domain::toString(); @@ -559,7 +561,7 @@ namespace EUROPA { return(ptr); } - IntervalDomain::IntervalDomain(const DataTypeId& dt) + IntervalDomain::IntervalDomain(const DataTypeId dt) : Domain(dt,false,true) , m_ub(PLUS_INFINITY) , m_lb(MINUS_INFINITY) @@ -567,7 +569,7 @@ namespace EUROPA { commonInit(); } - IntervalDomain::IntervalDomain(edouble lb, edouble ub, const DataTypeId& dt) + IntervalDomain::IntervalDomain(edouble lb, edouble ub, const DataTypeId dt) : Domain(dt,false,true) , m_ub(ub) , m_lb(lb) @@ -575,7 +577,7 @@ namespace EUROPA { commonInit(); } - IntervalDomain::IntervalDomain(edouble value, const DataTypeId& dt) + IntervalDomain::IntervalDomain(edouble value, const DataTypeId dt) : Domain(dt,false,true) , m_ub(value) , m_lb(value) @@ -583,7 +585,7 @@ namespace EUROPA { commonInit(); } - IntervalDomain::IntervalDomain(double lb, double ub, const DataTypeId& dt) + IntervalDomain::IntervalDomain(double lb, double ub, const DataTypeId dt) : Domain(dt,false,true) , m_ub(ub) , m_lb(lb) @@ -591,7 +593,7 @@ namespace EUROPA { commonInit(); } - IntervalDomain::IntervalDomain(double value, const DataTypeId& dt) + IntervalDomain::IntervalDomain(double value, const DataTypeId dt) : Domain(dt,false,true) , m_ub(value) , m_lb(value) @@ -608,7 +610,7 @@ namespace EUROPA { , m_ub(org.getUpperBound()) , m_lb(org.getLowerBound()) { - check_error(org.isInterval(),"Attempted to create an Interval domain from " + org.getTypeName().toString()); + check_error(org.isInterval(),"Attempted to create an Interval domain from " + org.getTypeName()); commonInit(); } @@ -669,11 +671,11 @@ namespace EUROPA { relax(dom.getLowerBound(), dom.getUpperBound()); } - void IntervalDomain::insert(edouble value) { + void IntervalDomain::insert(edouble) { check_error(ALWAYS_FAILS, "Cannot insert to an interval domain"); } - void IntervalDomain::insert(const std::list& values){ + void IntervalDomain::insert(const std::list&){ check_error(ALWAYS_FAILS, "Cannot insert to an interval domain"); } @@ -775,13 +777,15 @@ namespace EUROPA { if(!isMember(value)) empty(); else { - bool changed = (m_lb != value || m_ub != value); - if(changed == true){ + //TODO: possibly add a "specify" to domains that publishes rather than + //forcing this method to publish all the time + // bool changed = (m_lb != value || m_ub != value); + // if(changed == true){ m_lb = value; m_ub = value; notifyChange(DomainListener::SET_TO_SINGLETON); - } + // } } } @@ -900,9 +904,9 @@ namespace EUROPA { else if (isSingleton()) // Need to test separately in case of rounding errors return(1); else if(isFinite()) - return(cast_int(m_ub - m_lb + 1)); + return static_cast(cast_int(m_ub - m_lb + 1)); else - return cast_int(PLUS_INFINITY); + return static_cast(cast_int(PLUS_INFINITY)); } void IntervalDomain::getValues(std::list& results) const { @@ -918,7 +922,7 @@ namespace EUROPA { } - void IntervalDomain::testPrecision(const edouble& value) const {} + void IntervalDomain::testPrecision(const edouble&) const {} void IntervalDomain::operator>>(ostream& os) const { Domain::operator>>(os); @@ -980,12 +984,13 @@ std::list convert(const std::list& values) { } } - StringDomain::StringDomain(const DataTypeId& dt) : EnumeratedDomain(dt) {} - StringDomain::StringDomain(edouble value, const DataTypeId& dt) : EnumeratedDomain(dt,value) {} - StringDomain::StringDomain(double value, const DataTypeId& dt) : EnumeratedDomain(dt,value) {} - StringDomain::StringDomain(const std::string& value, const DataTypeId& dt) : EnumeratedDomain(dt,LabelStr(value)) {} - StringDomain::StringDomain(const std::list& values, const DataTypeId& dt) : EnumeratedDomain(dt,values) {} -StringDomain::StringDomain(const std::list& values, const DataTypeId& dt) : EnumeratedDomain(dt, convert(values)) {} + StringDomain::StringDomain(const DataTypeId dt) : EnumeratedDomain(dt) {} + StringDomain::StringDomain(const LabelStr& value, const DataTypeId dt) : EnumeratedDomain(dt,value) {} + StringDomain::StringDomain(edouble value, const DataTypeId dt) : EnumeratedDomain(dt,value) {} + StringDomain::StringDomain(double value, const DataTypeId dt) : EnumeratedDomain(dt,value) {} + StringDomain::StringDomain(const std::string& value, const DataTypeId dt) : EnumeratedDomain(dt,LabelStr(value)) {} + StringDomain::StringDomain(const std::list& values, const DataTypeId dt) : EnumeratedDomain(dt,values) {} +StringDomain::StringDomain(const std::list& values, const DataTypeId dt) : EnumeratedDomain(dt, convert(values)) {} StringDomain::StringDomain(const Domain& org) : EnumeratedDomain(org) {} @@ -1005,6 +1010,15 @@ StringDomain::StringDomain(const std::list& values, const DataTypeId& EnumeratedDomain::set(value); } +void StringDomain::set(const LabelStr& value) { + checkError(isEmpty() || isMember(value), + value << " is not a member of the domain :" << toString()); + + // Insert the value into the set as a special behavior for strings + m_values.insert(value); + EnumeratedDomain::set(value); +} + bool StringDomain::isMember(edouble value) const { // This is a hack so that specify() will work // string domain needs to be able to handle all situations that involve literal string gracefully @@ -1018,27 +1032,35 @@ StringDomain::StringDomain(const std::list& values, const DataTypeId& void StringDomain::set(const std::string& value){ LabelStr lbl(value); - set((edouble) lbl); + set(static_cast(lbl)); } bool StringDomain::isMember(const std::string& value) const{ LabelStr lbl(value); - return isMember((edouble) lbl); + return isMember(static_cast(lbl)); + } + + bool StringDomain::isMember(const LabelStr& value) const{ + return isMember(static_cast(value)); } void StringDomain::insert(const std::string& value){ LabelStr lbl(value); - EnumeratedDomain::insert((edouble) lbl); + EnumeratedDomain::insert(static_cast(lbl)); } void StringDomain::insert(edouble value){ EnumeratedDomain::insert(value); } - SymbolDomain::SymbolDomain(const DataTypeId& dt) : EnumeratedDomain(dt) {} - SymbolDomain::SymbolDomain(edouble value, const DataTypeId& dt) : EnumeratedDomain(dt,value) {} - SymbolDomain::SymbolDomain(double value, const DataTypeId& dt) : EnumeratedDomain(dt,value) {} - SymbolDomain::SymbolDomain(const std::list& values, const DataTypeId& dt) : EnumeratedDomain(dt,values) {} +void StringDomain::insert(const LabelStr& value) { + EnumeratedDomain::insert(value.getKey()); +} + + SymbolDomain::SymbolDomain(const DataTypeId dt) : EnumeratedDomain(dt) {} + SymbolDomain::SymbolDomain(edouble value, const DataTypeId dt) : EnumeratedDomain(dt,value) {} + SymbolDomain::SymbolDomain(double value, const DataTypeId dt) : EnumeratedDomain(dt,value) {} + SymbolDomain::SymbolDomain(const std::list& values, const DataTypeId dt) : EnumeratedDomain(dt,values) {} SymbolDomain::SymbolDomain(const Domain& org) : EnumeratedDomain(org) {} @@ -1049,10 +1071,10 @@ StringDomain::StringDomain(const std::list& values, const DataTypeId& return ptr; } - NumericDomain::NumericDomain(const DataTypeId& dt) : EnumeratedDomain(dt) {} - NumericDomain::NumericDomain(edouble value, const DataTypeId& dt) : EnumeratedDomain(dt,value) {} - NumericDomain::NumericDomain(double value, const DataTypeId& dt) : EnumeratedDomain(dt,value) {} - NumericDomain::NumericDomain(const std::list& values, const DataTypeId& dt) : EnumeratedDomain(dt,values) {} + NumericDomain::NumericDomain(const DataTypeId dt) : EnumeratedDomain(dt) {} + NumericDomain::NumericDomain(edouble value, const DataTypeId dt) : EnumeratedDomain(dt,value) {} + NumericDomain::NumericDomain(double value, const DataTypeId dt) : EnumeratedDomain(dt,value) {} + NumericDomain::NumericDomain(const std::list& values, const DataTypeId dt) : EnumeratedDomain(dt,values) {} NumericDomain::NumericDomain(const Domain& org) : EnumeratedDomain(org) {} @@ -1063,11 +1085,16 @@ StringDomain::StringDomain(const std::list& values, const DataTypeId& return ptr; } - IntervalIntDomain::IntervalIntDomain(const DataTypeId& dt) : IntervalDomain(dt) {} - IntervalIntDomain::IntervalIntDomain(eint lb, eint ub, const DataTypeId& dt) : IntervalDomain(lb,ub,dt) {} - IntervalIntDomain::IntervalIntDomain(eint value, const DataTypeId& dt) : IntervalDomain(value,dt) {} - IntervalIntDomain::IntervalIntDomain(eint::basis_type lb, eint::basis_type ub, const DataTypeId& dt) : IntervalDomain(lb,ub,dt) {} - IntervalIntDomain::IntervalIntDomain(eint::basis_type value, const DataTypeId& dt) : IntervalDomain(value,dt) {} + IntervalIntDomain::IntervalIntDomain(const DataTypeId dt) : IntervalDomain(dt) {} + IntervalIntDomain::IntervalIntDomain(eint lb, eint ub, const DataTypeId dt) : IntervalDomain(lb,ub,dt) {} + IntervalIntDomain::IntervalIntDomain(eint value, const DataTypeId dt) : IntervalDomain(value,dt) {} +IntervalIntDomain::IntervalIntDomain(eint::basis_type lb, eint::basis_type ub, + const DataTypeId dt) + : IntervalDomain(static_cast(lb), + static_cast(ub),dt) {} +IntervalIntDomain::IntervalIntDomain(eint::basis_type value, + const DataTypeId dt) + : IntervalDomain(static_cast(value),dt) {} IntervalIntDomain::IntervalIntDomain(const Domain& org) : IntervalDomain(org) {} IntervalIntDomain::~IntervalIntDomain() @@ -1086,15 +1113,15 @@ StringDomain::StringDomain(const std::list& values, const DataTypeId& void IntervalIntDomain::testPrecision(const edouble& value) const { #ifndef EUROPA_FAST eint::basis_type intValue = cast_int(value); - edouble::basis_type dblValue = (edouble::basis_type) intValue; + edouble::basis_type dblValue = static_cast(intValue); checkError(dblValue == value, value << " must be an integer."); // confirms no loss in precision #endif } - edouble IntervalIntDomain::convert(const edouble& value) const { - return(cast_int(value)); - } +edouble IntervalIntDomain::convert(const edouble& value) const { + return(static_cast(value)); +} void IntervalIntDomain::insert(edouble value) { check_error(check_value(value)); @@ -1157,12 +1184,12 @@ StringDomain::StringDomain(const std::list& values, const DataTypeId& return intersect(dom.getLowerBound(), dom.getUpperBound()); } - BoolDomain::BoolDomain(const DataTypeId& dt) + BoolDomain::BoolDomain(const DataTypeId dt) : IntervalIntDomain(0,1,dt) { } - BoolDomain::BoolDomain(bool value, const DataTypeId& dt) + BoolDomain::BoolDomain(bool value, const DataTypeId dt) : IntervalIntDomain(value, dt) { } diff --git a/src/PLASMA/ConstraintEngine/component/Domains.hh b/src/PLASMA/ConstraintEngine/component/Domains.hh index 8d124fb6c..5d00d048f 100644 --- a/src/PLASMA/ConstraintEngine/component/Domains.hh +++ b/src/PLASMA/ConstraintEngine/component/Domains.hh @@ -28,7 +28,7 @@ namespace EUROPA { * @param dt Indicate the type to use as a specialization of enumeration types * @see Domain::isDynamic() */ - EnumeratedDomain(const DataTypeId& dt); + EnumeratedDomain(const DataTypeId dt); /** * @brief Constructor. @@ -36,21 +36,21 @@ namespace EUROPA { * @param values The initial set of values to populate the domain. * @see Domain::isDynamic() */ - EnumeratedDomain(const DataTypeId& dt, const std::list& values); + EnumeratedDomain(const DataTypeId dt, const std::list& values); /** * @brief Constructor. * @param dt Indicate the type to use as a specialization of enumeration types * @param value Constructs a singleton domain. Closed on construction. */ - EnumeratedDomain(const DataTypeId& dt, edouble value); + EnumeratedDomain(const DataTypeId dt, edouble value); /** * @brief Constructor. * @param dt Indicate the type to use as a specialization of enumeration types * @param value Constructs a singleton domain. Closed on construction. */ - EnumeratedDomain(const DataTypeId& dt, double value); + EnumeratedDomain(const DataTypeId dt, double value); /** * @brief Copy constructor. @@ -105,7 +105,7 @@ namespace EUROPA { /** * @brief Remove the given element form the domain. - * @param value. The value to be removed. If present, removal will generate a value removal event + * @param value The value to be removed. If present, removal will generate a value removal event * @see DomainListener::VALUE_REMOVED */ void remove(edouble value); @@ -127,14 +127,14 @@ namespace EUROPA { /** * @brief Indicates assigment to the target domain as a relaxation triggered internally. - * @param value the target singleton value. + * @param dom The target domain * @see relax */ void relax(const Domain& dom); /** * @brief Indicates relaxation to a singleton value. Occurs when domain has been emptied previously - * @param The value to relax to + * @param value The value to relax to */ void relax(edouble value); @@ -143,7 +143,7 @@ namespace EUROPA { * * This method is provided as a more efficient way to handle the common operation of equating 2 EnumeratedDomain domains. * Tackling changes to both domains at once allows us to take advantage of the sorted order of the domains. - * @param The domain to be equated with this object. It may change. + * @param dom The domain to be equated with this object. It may change. * @return true if a change to either domain has occurred. * @see DomainListener::EMPTIED, DomainListener::SET_TO_SINGLETON, DomainListener::VALUE_REMOVED */ @@ -258,7 +258,7 @@ namespace EUROPA { /** * @brief test if the intersection between this domain and the given domain is empty * @param dom the domain tested against. - * @param true if any elements of this domain are in dom. Otherwise false. + * @return true if any elements of this domain are in dom. Otherwise false. */ bool intersects(const Domain& dom) const; @@ -281,7 +281,7 @@ namespace EUROPA { * @note Will be compiled out for fast version. * @note No-op for enumerations. */ - virtual void testPrecision(const edouble& value) const {} + virtual void testPrecision(const edouble& value) const; /** * @brief Implements equate where both are closed enumerations @@ -299,7 +299,7 @@ namespace EUROPA { * * @todo Possible additions: support for open ended intervals and multiple intervals, * preferably as new classes rather than impacting the performance of this class. - * --wedgingt@email.arc.nasa.gov 2004 Feb 26 + * --wedgingt 2004 Feb 26 */ class IntervalDomain : public Domain { public: @@ -309,11 +309,11 @@ namespace EUROPA { */ void operator>>(ostream& os) const; - IntervalDomain(const DataTypeId& dt = FloatDT::instance()); - IntervalDomain(edouble lb, edouble ub, const DataTypeId& dt = FloatDT::instance()); - IntervalDomain(double lb, double ub, const DataTypeId& dt = FloatDT::instance()); - IntervalDomain(edouble value, const DataTypeId& dt = FloatDT::instance()); - IntervalDomain(double value, const DataTypeId& dt = FloatDT::instance()); + IntervalDomain(const DataTypeId dt = FloatDT::instance()); + IntervalDomain(edouble lb, edouble ub, const DataTypeId dt = FloatDT::instance()); + IntervalDomain(double lb, double ub, const DataTypeId dt = FloatDT::instance()); + IntervalDomain(edouble value, const DataTypeId dt = FloatDT::instance()); + IntervalDomain(double value, const DataTypeId dt = FloatDT::instance()); IntervalDomain(const Domain& org); /** @@ -360,7 +360,7 @@ namespace EUROPA { /** * @brief Indicates assigment to the target domain as a relaxation triggered externally. - * @param value the target singleton value. + * @param dom the target singleton domain. * @see relax */ void reset(const Domain& dom); @@ -437,7 +437,7 @@ namespace EUROPA { /** * @brief Remove the given element form the domain. - * @param value. The value to be removed. + * @param value The value to be removed. * @note If the value was in the domain, this call will generate a * value removal event. * @note An error for real intervals unless not in the set or was @@ -491,14 +491,14 @@ namespace EUROPA { /** * @brief Test if this domain is a subset of dom. * @param dom the domain tested against. - * @param true if all elements of this domain are in dom, otherwise false. + * @return true if all elements of this domain are in dom, otherwise false. */ bool isSubsetOf(const Domain& dom) const; /** * @brief Test if the intersection between this domain and the given domain is empty. * @param dom the domain tested against. - * @param true if any elements of this domain are in dom, otherwise false. + * @return true if any elements of this domain are in dom, otherwise false. */ bool intersects(const Domain& dom) const; @@ -568,12 +568,13 @@ namespace EUROPA { class StringDomain : public EnumeratedDomain { public: - StringDomain(const DataTypeId& dt = StringDT::instance()); - StringDomain(edouble value, const DataTypeId& dt = StringDT::instance()); - StringDomain(double value, const DataTypeId& dt = StringDT::instance()); - StringDomain(const std::string& value, const DataTypeId& dt = StringDT::instance()); - StringDomain(const std::list& values, const DataTypeId& dt = StringDT::instance()); - StringDomain(const std::list& values, const DataTypeId& dt = StringDT::instance()); + StringDomain(const DataTypeId dt = StringDT::instance()); + StringDomain(edouble value, const DataTypeId dt = StringDT::instance()); + StringDomain(double value, const DataTypeId dt = StringDT::instance()); + StringDomain(const LabelStr& value, const DataTypeId dt = StringDT::instance()); + StringDomain(const std::string& value, const DataTypeId dt = StringDT::instance()); + StringDomain(const std::list& values, const DataTypeId dt = StringDT::instance()); + StringDomain(const std::list& values, const DataTypeId dt = StringDT::instance()); StringDomain(const Domain& org); virtual StringDomain *copy() const; @@ -583,14 +584,19 @@ namespace EUROPA { * @param value The value to set. Must be a LabelStr. */ void set(edouble value); - bool isMember(edouble value) const; /** String specific bindings for user convenience **/ void set(const std::string& value); + void set(const LabelStr& value); bool isMember(const std::string& value) const; + bool isMember(const LabelStr& value) const; + bool isMember(const char* value) const {return isMember(LabelStr(value));} void insert(const std::string& value); + void insert(const LabelStr& value); + void insert(const char* value) {insert(LabelStr(value));} void insert(edouble value); + void insert(const std::list& values) {EnumeratedDomain::insert(values);} }; /** @@ -599,10 +605,10 @@ namespace EUROPA { */ class SymbolDomain : public EnumeratedDomain { public: - SymbolDomain(const DataTypeId& dt = SymbolDT::instance()); - SymbolDomain(edouble value,const DataTypeId& dt = SymbolDT::instance()); - SymbolDomain(double value,const DataTypeId& dt = SymbolDT::instance()); - SymbolDomain(const std::list& values,const DataTypeId& dt = SymbolDT::instance()); + SymbolDomain(const DataTypeId dt = SymbolDT::instance()); + SymbolDomain(edouble value,const DataTypeId dt = SymbolDT::instance()); + SymbolDomain(double value,const DataTypeId dt = SymbolDT::instance()); + SymbolDomain(const std::list& values,const DataTypeId dt = SymbolDT::instance()); SymbolDomain(const Domain& org); virtual SymbolDomain *copy() const; @@ -611,10 +617,10 @@ namespace EUROPA { class NumericDomain : public EnumeratedDomain { public: - NumericDomain(const DataTypeId& dt = FloatDT::instance()); - NumericDomain(edouble value, const DataTypeId& dt = FloatDT::instance()); - NumericDomain(double value, const DataTypeId& dt = FloatDT::instance()); - NumericDomain(const std::list& values, const DataTypeId& dt = FloatDT::instance()); + NumericDomain(const DataTypeId dt = FloatDT::instance()); + NumericDomain(edouble value, const DataTypeId dt = FloatDT::instance()); + NumericDomain(double value, const DataTypeId dt = FloatDT::instance()); + NumericDomain(const std::list& values, const DataTypeId dt = FloatDT::instance()); NumericDomain(const Domain& org); virtual NumericDomain *copy() const; @@ -633,11 +639,11 @@ namespace EUROPA { class IntervalIntDomain: public IntervalDomain { public: - IntervalIntDomain(const DataTypeId& dt = IntDT::instance()); - IntervalIntDomain(eint lb, eint ub, const DataTypeId& dt = IntDT::instance()); - IntervalIntDomain(eint::basis_type lb, eint::basis_type ub, const DataTypeId& dt = IntDT::instance()); - IntervalIntDomain(eint value, const DataTypeId& dt = IntDT::instance()); - IntervalIntDomain(eint::basis_type value, const DataTypeId& dt = IntDT::instance()); + IntervalIntDomain(const DataTypeId dt = IntDT::instance()); + IntervalIntDomain(eint lb, eint ub, const DataTypeId dt = IntDT::instance()); + IntervalIntDomain(eint::basis_type lb, eint::basis_type ub, const DataTypeId dt = IntDT::instance()); + IntervalIntDomain(eint value, const DataTypeId dt = IntDT::instance()); + IntervalIntDomain(eint::basis_type value, const DataTypeId dt = IntDT::instance()); IntervalIntDomain(const Domain& org); virtual ~IntervalIntDomain(); @@ -704,8 +710,8 @@ namespace EUROPA { class BoolDomain : public IntervalIntDomain { public: - BoolDomain(const DataTypeId& dt = BoolDT::instance()); - BoolDomain(bool value, const DataTypeId& dt = BoolDT::instance()); + BoolDomain(const DataTypeId dt = BoolDT::instance()); + BoolDomain(bool value, const DataTypeId dt = BoolDT::instance()); BoolDomain(const Domain& org); bool isFinite() const; diff --git a/src/PLASMA/ConstraintEngine/component/EquivalenceClassCollection.cc b/src/PLASMA/ConstraintEngine/component/EquivalenceClassCollection.cc index e2fd580af..8c1695772 100644 --- a/src/PLASMA/ConstraintEngine/component/EquivalenceClassCollection.cc +++ b/src/PLASMA/ConstraintEngine/component/EquivalenceClassCollection.cc @@ -3,8 +3,8 @@ namespace EUROPA{ - ConstraintNode::ConstraintNode(const ConstrainedVariableId& variable) - : m_variable(variable), m_graph(0), m_lastUpdated(0){} +ConstraintNode::ConstraintNode(const ConstrainedVariableId variable) + : m_variable(variable), m_graph(0), m_lastUpdated(0), m_neighbours(){} bool ConstraintNode::hasBeenUpdated(int nextCycle) const { check_error(nextCycle >= m_lastUpdated); @@ -29,36 +29,36 @@ namespace EUROPA{ (*it)->update(nextCycle, connectedVariables, graph, oldGraphKeys); } - void ConstraintNode::addNeighbour(const ConstraintNodeId& node){ + void ConstraintNode::addNeighbour(const ConstraintNodeId node){ check_error(m_neighbours.find(node) == m_neighbours.end()); m_neighbours.insert(node); } - void ConstraintNode::removeNeighbour(const ConstraintNodeId& node){ + void ConstraintNode::removeNeighbour(const ConstraintNodeId node){ check_error(m_neighbours.find(node) != m_neighbours.end()); m_neighbours.erase(node); } EquivalenceClassCollection::EquivalenceClassCollection() - :m_requiresUpdate(false){} + : m_nodesByVar(), m_graphsByKey(), m_requiresUpdate(false), m_nextCycle(0), m_nextGraph(0) {} EquivalenceClassCollection::~EquivalenceClassCollection(){ for(std::map::iterator it = m_nodesByVar.begin(); it != m_nodesByVar.end(); ++it) it->second.release(); } - void EquivalenceClassCollection::addConnection(const ConstrainedVariableId& v1, const ConstrainedVariableId& v2){ + void EquivalenceClassCollection::addConnection(const ConstrainedVariableId v1, const ConstrainedVariableId v2){ const ConstraintNodeId n1 = getNode(v1); const ConstraintNodeId n2 = getNode(v2); n1->addNeighbour(n2); n2->addNeighbour(n1); if(!recomputeIfNecessary()){ // Most commonly this will be true, meaning no full reprop was required. - s_nextCycle++; + m_nextCycle++; recomputeSingleGraph(n1); } } - void EquivalenceClassCollection::removeConnection(const ConstrainedVariableId& v1, const ConstrainedVariableId& v2){ + void EquivalenceClassCollection::removeConnection(const ConstrainedVariableId v1, const ConstrainedVariableId v2){ ConstraintNodeId n1 = getNode(v1); ConstraintNodeId n2 = getNode(v2); @@ -82,14 +82,14 @@ namespace EUROPA{ m_requiresUpdate = true; } - int EquivalenceClassCollection::getGraphCount(){ +unsigned long EquivalenceClassCollection::getGraphCount(){ recomputeIfNecessary(); return m_graphsByKey.size(); } - int EquivalenceClassCollection::getGraphKey(const ConstrainedVariableId& variable){ + int EquivalenceClassCollection::getGraphKey(const ConstrainedVariableId variable){ recomputeIfNecessary(); - const ConstraintNodeId& node = getNode(variable); + const ConstraintNodeId node = getNode(variable); return node->getGraph(); } @@ -118,38 +118,38 @@ namespace EUROPA{ m_requiresUpdate = false; // Increment the cycle count to force all nodes to be tested again. - s_nextCycle++; + m_nextCycle++; // Iterate over all nodes for(std::map::iterator it = m_nodesByVar.begin(); it != m_nodesByVar.end(); ++it){ - const ConstraintNodeId& node = it->second; + const ConstraintNodeId node = it->second; check_error(node.isValid()); - if(!node->hasBeenUpdated(s_nextCycle)) // means we have a new graph to build. + if(!node->hasBeenUpdated(m_nextCycle)) // means we have a new graph to build. recomputeSingleGraph(node); } return true; } - void EquivalenceClassCollection::recomputeSingleGraph(const ConstraintNodeId& node){ - s_nextGraph++; + void EquivalenceClassCollection::recomputeSingleGraph(const ConstraintNodeId node){ + m_nextGraph++; // Initialize new graph with an empty set and obtain the reference to fill it up std::set emptySet; std::map >::iterator newGraphEntry = - m_graphsByKey.insert(std::pair >(s_nextGraph, emptySet)).first; + m_graphsByKey.insert(std::pair >(m_nextGraph, emptySet)).first; - check_error(newGraphEntry->first == s_nextGraph); + check_error(newGraphEntry->first == m_nextGraph); std::set& newGraph = newGraphEntry->second; // Now fill it up std::set graphKeysToRemove; - node->update(s_nextCycle, newGraph, s_nextGraph, graphKeysToRemove); + node->update(m_nextCycle, newGraph, m_nextGraph, graphKeysToRemove); check_error(graphKeysToRemove.size() <= 2); for(std::set::iterator it = graphKeysToRemove.begin(); it != graphKeysToRemove.end(); ++it) m_graphsByKey.erase(*it); } - const ConstraintNodeId& EquivalenceClassCollection::getNode(const ConstrainedVariableId& variable){ + const ConstraintNodeId EquivalenceClassCollection::getNode(const ConstrainedVariableId variable){ std::map::iterator it = m_nodesByVar.find(variable); if (it == m_nodesByVar.end()){ // Not present yet, so create a new entry @@ -163,7 +163,7 @@ namespace EUROPA{ return it->second; } - void EquivalenceClassCollection::removeNode(const ConstrainedVariableId& variable){ + void EquivalenceClassCollection::removeNode(const ConstrainedVariableId variable){ check_error(m_nodesByVar.find(variable) != m_nodesByVar.end()); m_nodesByVar.erase(variable); } @@ -175,6 +175,4 @@ namespace EUROPA{ return true; } - int EquivalenceClassCollection::s_nextCycle(0); - int EquivalenceClassCollection::s_nextGraph(0); } diff --git a/src/PLASMA/ConstraintEngine/component/EquivalenceClassCollection.hh b/src/PLASMA/ConstraintEngine/component/EquivalenceClassCollection.hh index 7d9e412eb..acdeea452 100644 --- a/src/PLASMA/ConstraintEngine/component/EquivalenceClassCollection.hh +++ b/src/PLASMA/ConstraintEngine/component/EquivalenceClassCollection.hh @@ -1,5 +1,5 @@ -#ifndef _H_EquivalenceClassCollection -#define _H_EquivalenceClassCollection +#ifndef H_EquivalenceClassCollection +#define H_EquivalenceClassCollection /** * @file EquivalenceClassCollection.hh @@ -30,7 +30,7 @@ namespace EUROPA{ * @brief Constructor. The node shadows exatly one variable. * @param variable The constrainedVariable represented in the graph */ - ConstraintNode(const ConstrainedVariableId& variable); + ConstraintNode(const ConstrainedVariableId variable); /** * @brief Return true of the nodes graph membership has been recomputed during the given cycle. @@ -51,14 +51,14 @@ namespace EUROPA{ * @brief Synonomous to the addition of an equality constraint with the given node. Creates a link in the graph. * @param node The node to which a link is being created */ - void addNeighbour(const ConstraintNodeId& node); + void addNeighbour(const ConstraintNodeId node); /** * @brief Synonomous with removal of an equality constraint with the given node. Removes a link from the graph. * @param node The node from which a link is being removed * @see isAlone */ - void removeNeighbour(const ConstraintNodeId& node); + void removeNeighbour(const ConstraintNodeId node); /** * @brief Accessor for the current graph to which this node belongs. All nodes with the same graph key form an equivalence class. @@ -86,22 +86,22 @@ namespace EUROPA{ public: EquivalenceClassCollection(); ~EquivalenceClassCollection(); - void addConnection(const ConstrainedVariableId& v1, const ConstrainedVariableId& v2); - void removeConnection(const ConstrainedVariableId& v1, const ConstrainedVariableId& v2); + void addConnection(const ConstrainedVariableId v1, const ConstrainedVariableId v2); + void removeConnection(const ConstrainedVariableId v1, const ConstrainedVariableId v2); bool updateRequired() const {return m_requiresUpdate;} - int getGraphCount(); - int getGraphKey(const ConstrainedVariableId& variable); + unsigned long getGraphCount(); + int getGraphKey(const ConstrainedVariableId variable); void getGraphKeys(std::set& keys); const std::set& getGraphVariables(int key) const; private: - const ConstraintNodeId& getNode(const ConstrainedVariableId& variable); + const ConstraintNodeId getNode(const ConstrainedVariableId variable); /** * @brief Remove a node if it has become disconnected from all neighbours * @see Node::isAlone() */ - void removeNode(const ConstrainedVariableId& variable); + void removeNode(const ConstrainedVariableId variable); /** * @brief May recompute the set of graphs if necessary. @@ -114,7 +114,7 @@ namespace EUROPA{ * @brief Recompute the graph for this ndoe and all connected nodes. Accomplished by depth first search as in Europa code. * @param node The node to start from */ - void recomputeSingleGraph(const ConstraintNodeId& node); + void recomputeSingleGraph(const ConstraintNodeId node); /** * @brief Helper method to ensure integrity of the data @@ -126,8 +126,8 @@ namespace EUROPA{ inferred to be equivalent. This changes when constraints are added or removed. */ bool m_requiresUpdate; /**< Indicates of we must recompute all graps. True of a constraint has been removed. Made false by recomputing. */ - static int s_nextCycle; /**< Monotonically increasing counter used to ensure we do not visit nodes more than once when recomputing a graph.*/ - static int s_nextGraph; /**< Monotnically increasing counter used to allocate new graph keys when the need arises to recompute a graph. The + int m_nextCycle; /**< Monotonically increasing counter used to ensure we do not visit nodes more than once when recomputing a graph.*/ + int m_nextGraph; /**< Monotnically increasing counter used to allocate new graph keys when the need arises to recompute a graph. The cases are when a constraint addition occurs, thus allowing for the possibility of graph merging, or a constraint removal occurs allowing for the possibility of graph splitting. */ }; diff --git a/src/PLASMA/ConstraintEngine/component/Propagators.cc b/src/PLASMA/ConstraintEngine/component/Propagators.cc index f1ed85953..3e88724e7 100644 --- a/src/PLASMA/ConstraintEngine/component/Propagators.cc +++ b/src/PLASMA/ConstraintEngine/component/Propagators.cc @@ -16,45 +16,46 @@ namespace EUROPA { - DefaultPropagator::DefaultPropagator(const LabelStr& name, const ConstraintEngineId& constraintEngine, int priority) - : Propagator(name, constraintEngine, priority) - , m_activeConstraint(0) - { - } - - void DefaultPropagator::handleConstraintAdded(const ConstraintId& constraint){ - debugMsg("DefaultPropagator:handleConstraintAdded", "Adding to the agenda: " << constraint->getName().toString() << "(" << constraint->getKey() << ")"); +DefaultPropagator::DefaultPropagator(const std::string& name, + const ConstraintEngineId constraintEngine, + int priority) + : Propagator(name, constraintEngine, priority), + m_agenda(), + m_activeConstraint(0) { } + + void DefaultPropagator::handleConstraintAdded(const ConstraintId constraint){ + debugMsg("DefaultPropagator:handleConstraintAdded", "Adding to the agenda: " << constraint->getName() << "(" << constraint->getKey() << ")"); m_agenda.insert(constraint); } - void DefaultPropagator::handleConstraintRemoved(const ConstraintId& constraint){ + void DefaultPropagator::handleConstraintRemoved(const ConstraintId constraint){ // Remove from agenda - debugMsg("DefaultPropagator:handleConstraintRemoved", "Removing from the agenda: " << constraint->getName().toString() << "(" << constraint->getKey() << ")"); + debugMsg("DefaultPropagator:handleConstraintRemoved", "Removing from the agenda: " << constraint->getName() << "(" << constraint->getKey() << ")"); m_agenda.erase(constraint); check_error(isValid()); } - void DefaultPropagator::handleConstraintActivated(const ConstraintId& constraint){ - debugMsg("DefaultPropagator:handleConstraintActivated", "Adding to the agenda: " << constraint->getName().toString() << "(" << constraint->getKey() << ")"); + void DefaultPropagator::handleConstraintActivated(const ConstraintId constraint){ + debugMsg("DefaultPropagator:handleConstraintActivated", "Adding to the agenda: " << constraint->getName() << "(" << constraint->getKey() << ")"); m_agenda.insert(constraint); check_error(isValid()); } - void DefaultPropagator::handleConstraintDeactivated(const ConstraintId& constraint){ + void DefaultPropagator::handleConstraintDeactivated(const ConstraintId constraint){ // Remove from agenda - debugMsg("DefaultPropagator:handleConstraintDeactivated", "Removing from the agenda: " << constraint->getName().toString() << "(" << constraint->getKey() << ")"); + debugMsg("DefaultPropagator:handleConstraintDeactivated", "Removing from the agenda: " << constraint->getName() << "(" << constraint->getKey() << ")"); m_agenda.erase(constraint); check_error(isValid()); } - void DefaultPropagator::handleNotification(const ConstrainedVariableId& variable, - int argIndex, - const ConstraintId& constraint, + void DefaultPropagator::handleNotification(const ConstrainedVariableId variable, + unsigned int, + const ConstraintId constraint, const DomainListener::ChangeType& changeType){ checkError(!constraint->isDiscarded(), constraint); if(constraint->getKey() != m_activeConstraint) { debugMsg("DefaultPropagator:handleNotification", - "Adding to the agenda: " << constraint->getName().toString() << "(" << constraint->getKey() << ")" + "Adding to the agenda: " << constraint->getName() << "(" << constraint->getKey() << ")" << " because of " << DomainListener::toString(changeType) << " change to " << variable->toString() ); m_agenda.insert(constraint); @@ -101,14 +102,16 @@ namespace EUROPA { ConstraintId constraint = *it; checkError(constraint.isValid(), constraint); checkError(!constraint->isDiscarded(), - constraint->getName().toString() << "(" << constraint->getKey() << ") Id=" << constraint); + constraint->getName() << "(" << constraint->getKey() << ") Id=" << constraint); } return true; } - EqualityConstraintPropagator::EqualityConstraintPropagator(const LabelStr& name, const ConstraintEngineId& constraintEngine) - : Propagator(name, constraintEngine), m_fullReprop(false), m_active(false){} +EqualityConstraintPropagator::EqualityConstraintPropagator(const std::string& name, + const ConstraintEngineId constraintEngine) + : Propagator(name, constraintEngine), m_fullReprop(false), m_active(false), + m_eqClassCollection(), m_eqClassAgenda() {} EqualityConstraintPropagator::~EqualityConstraintPropagator(){} @@ -134,10 +137,10 @@ namespace EUROPA { return (!m_eqClassAgenda.empty() || m_fullReprop); } - void EqualityConstraintPropagator::handleConstraintAdded(const ConstraintId& constraint){ + void EqualityConstraintPropagator::handleConstraintAdded(const ConstraintId constraint){ check_error(!m_active); - const ConstrainedVariableId& x = constraint->getScope()[0]; - const ConstrainedVariableId& y = constraint->getScope()[1]; + const ConstrainedVariableId x = constraint->getScope()[0]; + const ConstrainedVariableId y = constraint->getScope()[1]; // Remove old equivalence classes for these variables from the agenda since they are abut to be merged. m_eqClassAgenda.erase(m_eqClassCollection.getGraphKey(x)); @@ -148,26 +151,26 @@ namespace EUROPA { m_eqClassAgenda.insert(m_eqClassCollection.getGraphKey(x)); } - void EqualityConstraintPropagator::handleConstraintRemoved(const ConstraintId& constraint){ + void EqualityConstraintPropagator::handleConstraintRemoved(const ConstraintId constraint){ check_error(!m_active); - const ConstrainedVariableId& x = constraint->getScope()[0]; - const ConstrainedVariableId& y = constraint->getScope()[1]; + const ConstrainedVariableId x = constraint->getScope()[0]; + const ConstrainedVariableId y = constraint->getScope()[1]; m_eqClassCollection.removeConnection(x, y); m_fullReprop = true; } - void EqualityConstraintPropagator::handleConstraintActivated(const ConstraintId& constraint){ + void EqualityConstraintPropagator::handleConstraintActivated(const ConstraintId constraint){ handleConstraintAdded(constraint); } - void EqualityConstraintPropagator::handleConstraintDeactivated(const ConstraintId& constraint){ + void EqualityConstraintPropagator::handleConstraintDeactivated(const ConstraintId constraint){ handleConstraintRemoved(constraint); } - void EqualityConstraintPropagator::handleNotification(const ConstrainedVariableId& variable, - int argIndex, - const ConstraintId& constraint, - const DomainListener::ChangeType& changeType){ + void EqualityConstraintPropagator::handleNotification(const ConstrainedVariableId variable, + unsigned int, + const ConstraintId constraint, + const DomainListener::ChangeType&){ check_error(Id::convertable(constraint)); if(!m_fullReprop && !m_active){ @@ -178,61 +181,63 @@ namespace EUROPA { } } - void processScope(const std::set& scope) { - Domain& domain(EqualConstraint::getCurrentDomain(* (scope.begin()))); +namespace { +void processScope(const std::set& scope) { + Domain& domain(EqualConstraint::getCurrentDomain(* (scope.begin()))); + + if (domain.isOpen()) + return; + + // Set up the initial values to match others against. + bool isFinite = domain.isFinite(); + + // int domainType = domain.getType(); // Unused; see below. + + // Iterate over, restricting domain as we go. + for (std::set::const_iterator it = scope.begin(); + it != scope.end(); ++it) { + Domain& currentDomain = EqualConstraint::getCurrentDomain(*it); + + // This next check is incorrect: could be false when they can be + // compared (real enumerations and integer intervals, e.g.) and + // could be true when they cannot be compared (e.g., two distinct + // label sets, which both have a DomainType of USER_DEFINED). + // The correct check follows. + // --wedgingt@ptolemy.arc.nasa.gov 2004 Apr 21 + // check_error(currentDomain.getType() == domainType); - if (domain.isOpen()) + check_error(Domain::canBeCompared(domain, currentDomain)); + + // This will preclude possible propagation to the point of allowing + // an arbitrary amount of useless search during planning, including + // not even intersecting with closed domains later in the scope. + // --wedgingt@ptolemy.arc.nasa.gov 2004 Apr 21 + if (currentDomain.isOpen()) return; - // Set up the initial values to match others against. - bool isFinite = domain.isFinite(); - - // int domainType = domain.getType(); // Unused; see below. - - // Iterate over, restricting domain as we go. - for (std::set::const_iterator it = scope.begin(); - it != scope.end(); ++it) { - Domain& currentDomain = EqualConstraint::getCurrentDomain(*it); - - // This next check is incorrect: could be false when they can be - // compared (real enumerations and integer intervals, e.g.) and - // could be true when they cannot be compared (e.g., two distinct - // label sets, which both have a DomainType of USER_DEFINED). - // The correct check follows. - // --wedgingt@ptolemy.arc.nasa.gov 2004 Apr 21 - // check_error(currentDomain.getType() == domainType); - - check_error(Domain::canBeCompared(domain, currentDomain)); - - // This will preclude possible propagation to the point of allowing - // an arbitrary amount of useless search during planning, including - // not even intersecting with closed domains later in the scope. - // --wedgingt@ptolemy.arc.nasa.gov 2004 Apr 21 - if (currentDomain.isOpen()) - return; - - // What if the domains are (numeric) [-Inf Inf] and (integer) [0 1] ? - // This would appear to incorrectly provoke an inconsistency in that case. - // --wedgingt@ptolemy.arc.nasa.gov 2004 Apr 22 - // - //I don't even know what this is supposed to express. It seems wrong in every case. - //I'm adding parens here in the most sensible-ish place to quiet a warning. ~MJI - if ((currentDomain.isFinite() != isFinite || - domain.intersect(currentDomain)) && domain.isEmpty()) { - currentDomain.empty(); - return; - } + // What if the domains are (numeric) [-Inf Inf] and (integer) [0 1] ? + // This would appear to incorrectly provoke an inconsistency in that case. + // --wedgingt@ptolemy.arc.nasa.gov 2004 Apr 22 + // + //I don't even know what this is supposed to express. It seems wrong in every case. + //I'm adding parens here in the most sensible-ish place to quiet a warning. ~MJI + if ((currentDomain.isFinite() != isFinite || + domain.intersect(currentDomain)) && domain.isEmpty()) { + currentDomain.empty(); + return; } + } - // If we get to here, we have computed the new domain for all - // variables in the scope and we know that no domain has been - // emptied (this could be optimized by recording the last change - // to domain). - for (std::set::const_iterator it = scope.begin(); it != scope.end(); ++it) { - Domain& currentDomain = EqualConstraint::getCurrentDomain(*it); - currentDomain.intersect(domain); - } + // If we get to here, we have computed the new domain for all + // variables in the scope and we know that no domain has been + // emptied (this could be optimized by recording the last change + // to domain). + for (std::set::const_iterator it = scope.begin(); it != scope.end(); ++it) { + Domain& currentDomain = EqualConstraint::getCurrentDomain(*it); + currentDomain.intersect(domain); } +} +} void EqualityConstraintPropagator::equate(const std::set& scope) { check_error(!scope.empty()); diff --git a/src/PLASMA/ConstraintEngine/component/Propagators.hh b/src/PLASMA/ConstraintEngine/component/Propagators.hh index 69c902638..5c70115be 100644 --- a/src/PLASMA/ConstraintEngine/component/Propagators.hh +++ b/src/PLASMA/ConstraintEngine/component/Propagators.hh @@ -18,17 +18,17 @@ namespace EUROPA { class DefaultPropagator: public Propagator { public: - DefaultPropagator(const LabelStr& name, const ConstraintEngineId& constraintEngine, int priority=USER_PRIORITY); + DefaultPropagator(const std::string& name, const ConstraintEngineId constraintEngine, int priority=USER_PRIORITY); virtual void execute(); virtual bool updateRequired() const; protected: - virtual void handleConstraintAdded(const ConstraintId& constrain); - virtual void handleConstraintRemoved(const ConstraintId& constraint); - virtual void handleConstraintActivated(const ConstraintId& constrain); - virtual void handleConstraintDeactivated(const ConstraintId& constraint); - virtual void handleNotification(const ConstrainedVariableId& variable, - int argIndex, - const ConstraintId& constraint, + virtual void handleConstraintAdded(const ConstraintId constrain); + virtual void handleConstraintRemoved(const ConstraintId constraint); + virtual void handleConstraintActivated(const ConstraintId constrain); + virtual void handleConstraintDeactivated(const ConstraintId constraint); + virtual void handleNotification(const ConstrainedVariableId variable, + unsigned int argIndex, + const ConstraintId constraint, const DomainListener::ChangeType& changeType); ConstraintSet m_agenda; @@ -55,7 +55,7 @@ namespace EUROPA { class EqualityConstraintPropagator: public Propagator { public: - EqualityConstraintPropagator(const LabelStr& name, const ConstraintEngineId& constraintEngine); + EqualityConstraintPropagator(const std::string& name, const ConstraintEngineId constraintEngine); ~EqualityConstraintPropagator(); @@ -65,17 +65,17 @@ namespace EUROPA { private: - void handleConstraintAdded(const ConstraintId& constraint); + void handleConstraintAdded(const ConstraintId constraint); - void handleConstraintRemoved(const ConstraintId& constraint); + void handleConstraintRemoved(const ConstraintId constraint); - void handleConstraintActivated(const ConstraintId& constrain); + void handleConstraintActivated(const ConstraintId constrain); - void handleConstraintDeactivated(const ConstraintId& constraint); + void handleConstraintDeactivated(const ConstraintId constraint); - void handleNotification(const ConstrainedVariableId& variable, - int argIndex, - const ConstraintId& constraint, + void handleNotification(const ConstrainedVariableId variable, + unsigned int argIndex, + const ConstraintId constraint, const DomainListener::ChangeType& changeType); /** diff --git a/src/PLASMA/ConstraintEngine/component/Variable.hh b/src/PLASMA/ConstraintEngine/component/Variable.hh index 93b0f3a74..193aab667 100644 --- a/src/PLASMA/ConstraintEngine/component/Variable.hh +++ b/src/PLASMA/ConstraintEngine/component/Variable.hh @@ -1,5 +1,5 @@ -#ifndef _H_AbstractVar -#define _H_AbstractVar +#ifndef H_AbstractVar +#define H_AbstractVar #include "Domain.hh" #include "ConstrainedVariable.hh" @@ -32,13 +32,13 @@ namespace EUROPA { * @param parent owner if appropriate. * @param index position in parent collection. */ - Variable(const ConstraintEngineId& constraintEngine, + Variable(const ConstraintEngineId constraintEngine, const Domain& baseDomain, const bool internal = false, bool canBeSpecified = true, - const LabelStr& name = ConstrainedVariable::NO_NAME(), - const EntityId& parent = EntityId::noId(), - int index = ConstrainedVariable::NO_INDEX); + const std::string& name = ConstrainedVariable::NO_NAME(), + const EntityId parent = EntityId::noId(), + unsigned long index = ConstrainedVariable::NO_INDEX); /** * Destructor. @@ -89,7 +89,8 @@ namespace EUROPA { virtual void handleRestrictBaseDomain(const Domain& baseDomain); private: - Variable(const Variable&); // Prohibit compiler from generating copy constructor + Variable(const Variable&); // Prohibit compiler from generating copy constructor + Variable& operator=(const Variable&); /** * @brief returns the current domain without checking for pending propagation first. @@ -106,19 +107,19 @@ namespace EUROPA { }; template - Variable::Variable(const ConstraintEngineId& constraintEngine, - const Domain& baseDomain, + Variable::Variable(const ConstraintEngineId constraintEngine, + const Domain& _baseDomain, const bool internal, - bool canBeSpecified, - const LabelStr& name, - const EntityId& parent, - int index) - : ConstrainedVariable(constraintEngine, internal, canBeSpecified, name, parent, index), - m_baseDomain(static_cast(baseDomain.copy())), - m_derivedDomain(static_cast(baseDomain.copy())) { + bool _canBeSpecified, + const std::string& name, + const EntityId _parent, + unsigned long index) + : ConstrainedVariable(constraintEngine, internal, _canBeSpecified, name, _parent, index), + m_baseDomain(static_cast(_baseDomain.copy())), + m_derivedDomain(static_cast(_baseDomain.copy())) { - debugMsg("Variable:Variable", "Name " << name.toString()); - debugMsg("Variable:Variable", "Base Domain = " << baseDomain.toString()); + debugMsg("Variable:Variable", "Name " << name); + debugMsg("Variable:Variable", "Base Domain = " << _baseDomain.toString()); // Note that we permit the domain to be empty initially m_derivedDomain->setListener(m_listener); @@ -146,20 +147,24 @@ namespace EUROPA { const DomainType& Variable::getDerivedDomain() { if (!getConstraintEngine()->isPropagating() && pending()) update(); - - if (!provenInconsistent()) - return(*m_derivedDomain); - - static bool sl_initialized = false; - static DomainType* sl_emptyDomain = 0; - if (!sl_initialized) { - sl_emptyDomain = static_cast(m_derivedDomain->copy()); - if (sl_emptyDomain->isOpen()) - sl_emptyDomain->close(); - sl_emptyDomain->empty(); - sl_initialized = true; - } - return(*sl_emptyDomain); + + if(provenInconsistent()) + m_derivedDomain->empty(); + return *m_derivedDomain; + + // if (!provenInconsistent()) + // return(*m_derivedDomain); + + // static bool sl_initialized = false; + // static DomainType* sl_emptyDomain = 0; + // if (!sl_initialized) { + // sl_emptyDomain = static_cast(m_derivedDomain->copy()); + // if (sl_emptyDomain->isOpen()) + // sl_emptyDomain->close(); + // sl_emptyDomain->empty(); + // sl_initialized = true; + // } + // return(*sl_emptyDomain); } template diff --git a/src/PLASMA/ConstraintEngine/test/CLibTestCases.xml b/src/PLASMA/ConstraintEngine/test/CLibTestCases.xml index ce7d1135c..80998e0bd 100644 --- a/src/PLASMA/ConstraintEngine/test/CLibTestCases.xml +++ b/src/PLASMA/ConstraintEngine/test/CLibTestCases.xml @@ -10,7 +10,7 @@ - + @@ -22,7 +22,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -94,7 +94,7 @@ - + @@ -106,29376 +106,1578 @@ - - - - - - - - - - - - - - - + - - - - + + - - - + + - - - + - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - - - - - + - - - - - - - + - - - + - - - - + + - + - - - - + + - - - - + + - + - - - + - - - + - - - - - + - - - - - + - - - + - - - - + + - + - - - + - - - - + + - + - - - + - - - - + + - + - - - + - - - + - - - - - + - - - - - + - - - + - - - - + + - + - - - + - - - + - - - - - + - - - - - + - - - - - + - - - + - - - + - + - - - - + + - - - + + - - - - - - + - - - - + + - - - + - - + - - - - - + + - + - - - - + + - - - + + - - - - + + - - - - + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - + - - - + - - - + - + - - - + - - - + - + + - - - - + + - - - - + + - + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - + - - - - + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - + - - - + - + - - - + - - - + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + - - - - + + - - - - + + - + + - - - - + + - - - - + + - + - - - - + + - - - - + + - + - - - - + + - - - - + + - + - - - - + + - - - - + + - + - - - - + + - - - - + + - + - - - - + + - - - - + + - + - - - - + + - - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - - + + - + - - - + + - - - + + - + - - + - - + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - + - - + - - + - - + - - + - + - - + - - - + + - + - + + + + + + + + + + - - + - - - + - - - - - - + + + + - + - - - - + + - + - - - + + - - - + + - + - - - + + - - + - - + - - + + - - - - + - + - - - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - + - - - - + + - + - + - - + - - + - + - - - + + - - - - - + + - + - + - - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - + + + + + + + + + + + - - + - - - + + - - + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - + - + - - - + + - - + - - - + + - - - + + - + - - + - - - + + - + - - + - - - + + - + - - + - - + - + - - + - - + - + - - + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - - + + - + - - - + + - - + - + - - - + + - - - + + - + - - - + + - - + - - - + + - - + - - + - - - + + - + - - - + + - - + - - - + - - - + + - - - + + - + - - - + + - - - + + - + + + + + + + + + + + + + + + + + + + - + - - - + + - - - + + - + - - + - - + - + - - - + + + + + + + + + - + + + - + - - + + - - - + + + + + - + + + + + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - + + - - + - - - + + - - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - + - - - + + - - - + + - + - - - + + - - - + + - + + + + + + + + + + + + + - - - + + + @@ -29483,11 +1685,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + @@ -29495,47 +1721,35 @@ - + - - + + - - + + - + - + - - - - - - - - - - - - - + - + - + @@ -29543,23 +1757,23 @@ - + - + - - - + + + - + - - + + @@ -29567,10 +1781,22 @@ - + + + + + + + + + + + + + - + @@ -29579,23 +1805,23 @@ - + - + - - - + + + - + - + @@ -29603,11 +1829,11 @@ - + - - - + + + @@ -29615,11 +1841,11 @@ - + - - + + @@ -29627,59 +1853,23 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - + + @@ -29687,275 +1877,311 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - + + + - + - - - - - - - - - - - - - + - - - - - - - - - - - - - + - + - - + + - - - + + + - + - - - + + + - + - + - - + + - - - + + + - + - - - + + + - - - + + + - + - - + + - - - + + + - + + + + + + + + + + + + + - - + + - - - + + + - + - - - + + + - - - + + + - + - - + + - - - + + + - + - - - + + + - - - + + + - + + + + + + + + + + + + + - - + + - - + + - + - + - - - + + + - + - - + + - - - + + + - + - - - + + + - - - + + + - + - - + + - - - + + + - + + + + + + + + + + + + + - - - + + + - - - + + + - + + + - - - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + @@ -29963,79 +2189,515 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + - - - + + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -30047,7 +2709,7 @@ - + @@ -30059,7 +2721,7 @@ - + @@ -30071,7 +2733,7 @@ - + @@ -30083,7 +2745,7 @@ - + @@ -30095,19 +2757,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -30119,7 +2781,7 @@ - + @@ -30131,7 +2793,7 @@ - + @@ -30143,7 +2805,7 @@ - + @@ -30155,23 +2817,59 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - + + + + + + + + + + + + + @@ -30179,11 +2877,11 @@ - + - - + + @@ -30191,23 +2889,35 @@ - + - + - - - + + + - + + + + + + + + + + + + + + + - - @@ -30215,11 +2925,11 @@ - + + - @@ -30227,11 +2937,11 @@ - + - - + + @@ -30239,23 +2949,23 @@ - + - + - - - + + + - + - - + + @@ -30263,10 +2973,22 @@ - + + + + + + + + + + + + + - + @@ -30275,9 +2997,45 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -30287,11 +3045,11 @@ - + - + @@ -30299,11 +3057,23 @@ - + + + + + + + + + + + + + @@ -30311,10 +3081,22 @@ - + + + + + + + + + + + + + - - + + @@ -30323,11 +3105,11 @@ - + - - - + + + @@ -30335,47 +3117,47 @@ - + - - + + - - - + + + - + + - - - - + + + - + - - + + - - - + + + - + - - + + @@ -30383,11 +3165,3201 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -30395,22 +6367,22 @@ - + - - + + - - + + - + - - + + @@ -30419,11 +6391,119 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -30431,35 +6511,23 @@ - + + - - - - - - - - + - - - - - - - + + + - - @@ -30467,11 +6535,11 @@ - + - - + + @@ -30479,11 +6547,11 @@ - + - + @@ -30491,11 +6559,23 @@ - + + + + + + + + + + + + + - - + + @@ -30503,10 +6583,10 @@ - + - - + + @@ -30515,10 +6595,10 @@ - + - - + + @@ -30527,58 +6607,10 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -30587,1291 +6619,4359 @@ - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - + + + - + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - + - - + + - - - + + + - + - - - - - - - - - - - - - + - - - + + + - + - - + + - - + + - + - - - + + + - - - + + + - + + + + + + + + + + + + + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - + - - - + + - - + - - + - - - + + - + - - + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - - + + - + - - - + + - - + - - - + + - - + - + - + - - - - + + - + - - - - - - - - - - - - - - + - - - + + - + - - - + + - - - + + - + - - - + - - + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - - + + + + + + + + + + + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - - + + - + - - + - - + - - - + - - + - - + - + - - - + - - - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + - + - - - + - - - - + + - + - - - + + - - + - - + - - - + + - + - - + - - + - + - - + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - + - - + - - + + - - + - - - + + - - - + + - - - + + - + - - + - - + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - + - - + - + - - + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + - - - + + - + - - - + + + + - - - + + + + - + - - + + + - + + - - - - + + + + + - - + + + - + - - + + + - - + + + - + - - + + + - - - + + + + - + - - - + + + + - - + + + - + - - + + + - - + + + - + - - - + + + + - - - + + + + - + - - + + + - - + + + - + - - + + + - - + + + - + - - - + + + + - - - + + + + - + - - + + + + + - - + - - + + + - - - + + + + - + - - - + + + + - - - + + + + - + @@ -31883,7 +10983,7 @@ - + @@ -31895,19 +10995,19 @@ - + - - - + + + - + @@ -31919,7 +11019,7 @@ - + @@ -31931,7 +11031,7 @@ - + @@ -31940,10 +11040,10 @@ - + - + @@ -31955,7 +11055,7 @@ - + @@ -31967,7 +11067,7 @@ - + @@ -31979,7 +11079,7 @@ - + @@ -31991,7 +11091,7 @@ - + @@ -32003,31 +11103,31 @@ - + - - - + + + - + - - - + + + - + @@ -32039,19 +11139,31 @@ - + + + + + + + + - + + + + + + - + @@ -32063,7 +11175,7 @@ - + @@ -32075,43 +11187,43 @@ - + - - - + + + - + - - - + + + - + - - - + + + - + @@ -32123,19 +11235,19 @@ - + - - - + + + - + @@ -32147,7 +11259,7 @@ - + @@ -32159,7 +11271,7 @@ - + @@ -32171,7 +11283,7 @@ - + @@ -32183,7 +11295,7 @@ - + @@ -32195,7 +11307,7 @@ - + @@ -32207,7 +11319,7 @@ - + @@ -32219,7 +11331,7 @@ - + @@ -32231,7 +11343,7 @@ - + @@ -32243,7 +11355,7 @@ - + @@ -32255,19 +11367,19 @@ - + - - - + + + - + @@ -32279,7 +11391,7 @@ - + @@ -32291,19 +11403,19 @@ - + - - - + + + - + @@ -32315,55 +11427,55 @@ - + - - - + + + - + - - - + + + - + - - - + + + - + - - + + - + @@ -32371,11 +11483,11 @@ - + - + @@ -32383,11 +11495,11 @@ - + - + @@ -32399,43 +11511,43 @@ - + - - - + + + - + - - + + - + - - + + - + @@ -32443,11 +11555,11 @@ - + - + @@ -32459,7 +11571,7 @@ - + @@ -32471,43 +11583,43 @@ - + - - + + - + - - + + - + - - + + - + @@ -32519,7 +11631,7 @@ - + @@ -32531,7 +11643,7 @@ - + @@ -32543,31 +11655,31 @@ - + - + - + - + - + @@ -32579,7 +11691,7 @@ - + @@ -32591,7 +11703,7 @@ - + @@ -32603,7 +11715,7 @@ - + @@ -32615,19 +11727,19 @@ - + - + - + @@ -32639,7 +11751,7 @@ - + @@ -32651,7 +11763,7 @@ - + @@ -32663,7 +11775,7 @@ - + @@ -32675,7 +11787,7 @@ - + @@ -32687,7 +11799,7 @@ - + @@ -32699,7 +11811,7 @@ - + @@ -32711,7 +11823,7 @@ - + @@ -32723,7 +11835,7 @@ - + @@ -32735,7 +11847,7 @@ - + @@ -32747,7 +11859,7 @@ - + @@ -32759,7 +11871,7 @@ - + @@ -32771,7 +11883,7 @@ - + @@ -32783,19 +11895,19 @@ - + - - - + + + - + @@ -32807,7 +11919,7 @@ - + @@ -32819,7 +11931,7 @@ - + @@ -32828,10 +11940,10 @@ - + - + @@ -32843,7 +11955,7 @@ - + @@ -32855,7 +11967,7 @@ - + @@ -32867,7 +11979,7 @@ - + @@ -32879,7 +11991,7 @@ - + @@ -32891,31 +12003,31 @@ - + - - - + + + - + - - - + + + - + @@ -32927,19 +12039,31 @@ - + + + + + + + + - + + + + + + - + @@ -32951,7 +12075,7 @@ - + @@ -32963,43 +12087,43 @@ - + - - - + + + - + - - - + + + - + - - - + + + - + @@ -33011,19 +12135,19 @@ - + - - - + + + - + @@ -33035,7 +12159,7 @@ - + @@ -33047,7 +12171,7 @@ - + @@ -33059,7 +12183,7 @@ - + @@ -33071,7 +12195,7 @@ - + @@ -33083,7 +12207,7 @@ - + @@ -33095,7 +12219,7 @@ - + @@ -33107,7 +12231,7 @@ - + @@ -33119,7 +12243,7 @@ - + @@ -33131,7 +12255,7 @@ - + @@ -33143,19 +12267,19 @@ - + - - - + + + - + @@ -33167,7 +12291,7 @@ - + @@ -33179,19 +12303,19 @@ - + - - - + + + - + @@ -33203,55 +12327,55 @@ - + - - - + + + - + - - - + + + - + - - - + + + - + - - + + - + @@ -33259,11 +12383,11 @@ - + - + @@ -33271,11 +12395,11 @@ - + - + @@ -33287,43 +12411,43 @@ - + - - - + + + - + - - + + - + - - + + - + @@ -33331,11 +12455,11 @@ - + - + @@ -33347,7 +12471,7 @@ - + @@ -33359,43 +12483,43 @@ - + - - + + - + - - + + - + - - + + - + @@ -33407,7 +12531,7 @@ - + @@ -33419,7 +12543,7 @@ - + @@ -33431,31 +12555,31 @@ - + - + - + - + - + @@ -33467,7 +12591,7 @@ - + @@ -33479,7 +12603,7 @@ - + @@ -33491,7 +12615,7 @@ - + @@ -33503,19 +12627,19 @@ - + - + - + @@ -33527,7 +12651,7 @@ - + @@ -33539,7 +12663,7 @@ - + @@ -33551,7 +12675,7 @@ - + @@ -33563,7 +12687,7 @@ - + @@ -33575,7 +12699,7 @@ - + @@ -33587,7 +12711,7 @@ - + @@ -33599,7 +12723,7 @@ - + @@ -33611,7 +12735,7 @@ - + @@ -33623,7 +12747,7 @@ - + @@ -33635,7 +12759,7 @@ - + @@ -33647,7 +12771,7 @@ - + @@ -33659,31 +12783,31 @@ - + - - - + + + - + - - - + + + - + @@ -33695,19 +12819,19 @@ - + - - - + + + - + @@ -33716,10 +12840,10 @@ - + - + @@ -33731,7 +12855,7 @@ - + @@ -33743,7 +12867,7 @@ - + @@ -33755,61 +12879,71 @@ - - + - - - + + + - - - + + + - - + - - - + + + - - - + + + - + - + + + + + + + + + + + + + - + - + - + - + - + @@ -33817,19 +12951,19 @@ - + - + - - - + + + - + @@ -33841,55 +12975,55 @@ - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + @@ -33901,19 +13035,19 @@ - + - - - + + + - + @@ -33925,7 +13059,7 @@ - + @@ -33937,43 +13071,43 @@ - + - - - + + + - + - - - + + + - + - - - + + + - + @@ -33985,7 +13119,7 @@ - + @@ -33997,19 +13131,19 @@ - + - - - - + + + + - + @@ -34021,7 +13155,7 @@ - + @@ -34033,19 +13167,19 @@ - + - - - + + + - + @@ -34057,7 +13191,7 @@ - + @@ -34069,19 +13203,19 @@ - + - - - + + + - + @@ -34093,55 +13227,55 @@ - + - - - + + + - + - - - + + + - + - - - + + + - + - - + + - + @@ -34149,11 +13283,11 @@ - + - + @@ -34161,59 +13295,59 @@ - + - + - - - + + + - - - + + + - + - - - + + + - + - - + + - + - - + + - + @@ -34221,239 +13355,239 @@ - + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - + + - + - - + + - + - - + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - + - + - + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - + - + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - + @@ -34465,46 +13599,58 @@ - + - - - + + + - - - + + + - + - - - + + + - - - + + + + + + + + + + + + + + + - + - - - + + + - - - + + + - + - + @@ -34513,10 +13659,10 @@ - + - + @@ -34525,11 +13671,47 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -34667,7 +13849,7 @@ - + @@ -34677,7 +13859,7 @@ - + @@ -34687,7 +13869,7 @@ - + @@ -34697,7 +13879,7 @@ - + @@ -34707,7 +13889,7 @@ - + @@ -34717,7 +13899,7 @@ - + @@ -34727,7 +13909,7 @@ - + @@ -34737,7 +13919,7 @@ - + @@ -34747,7 +13929,7 @@ - + @@ -34757,7 +13939,7 @@ - + @@ -34767,7 +13949,7 @@ - + @@ -34777,7 +13959,7 @@ - + @@ -34787,7 +13969,7 @@ - + @@ -34797,7 +13979,7 @@ - + @@ -34807,7 +13989,7 @@ - + @@ -34817,7 +13999,7 @@ - + @@ -34827,7 +14009,7 @@ - + @@ -34837,7 +14019,7 @@ - + @@ -34847,7 +14029,7 @@ - + @@ -34857,7 +14039,7 @@ - + @@ -34867,7 +14049,7 @@ - + @@ -34877,7 +14059,7 @@ - + @@ -34887,7 +14069,7 @@ - + @@ -34897,7 +14079,7 @@ - + @@ -34907,7 +14089,7 @@ - + @@ -34917,7 +14099,7 @@ - + @@ -34927,7 +14109,7 @@ - + @@ -34937,7 +14119,7 @@ - + @@ -34947,7 +14129,7 @@ - + @@ -34957,7 +14139,7 @@ - + @@ -34967,7 +14149,7 @@ - + @@ -34977,7 +14159,7 @@ - + @@ -34987,7 +14169,7 @@ - + @@ -34997,7 +14179,7 @@ - + @@ -35007,7 +14189,7 @@ - + @@ -35021,7 +14203,7 @@ - + @@ -35035,7 +14217,7 @@ - + @@ -35049,7 +14231,7 @@ - + @@ -35063,7 +14245,7 @@ - + @@ -35077,7 +14259,7 @@ - + @@ -35091,7 +14273,7 @@ - + @@ -35105,7 +14287,7 @@ - + @@ -35119,7 +14301,7 @@ - + @@ -35133,7 +14315,7 @@ - + @@ -35147,7 +14329,7 @@ - + @@ -35161,7 +14343,7 @@ - + @@ -35175,7 +14357,7 @@ - + @@ -35189,7 +14371,7 @@ - + @@ -35203,7 +14385,7 @@ - + @@ -35217,7 +14399,7 @@ - + @@ -35231,7 +14413,7 @@ - + @@ -35245,7 +14427,7 @@ - + @@ -35259,7 +14441,7 @@ - + @@ -35273,7 +14455,7 @@ - + @@ -35287,7 +14469,7 @@ - + @@ -35301,7 +14483,7 @@ - + @@ -35315,7 +14497,7 @@ - + @@ -35329,7 +14511,7 @@ - + @@ -35343,7 +14525,7 @@ - + @@ -35357,7 +14539,7 @@ - + @@ -35371,7 +14553,7 @@ - + @@ -35385,7 +14567,7 @@ - + @@ -35399,7 +14581,7 @@ - + @@ -35413,7 +14595,7 @@ - + @@ -35427,7 +14609,7 @@ - + @@ -35441,7 +14623,7 @@ - + @@ -35455,7 +14637,7 @@ - + @@ -35469,7 +14651,7 @@ - + @@ -35483,7 +14665,7 @@ - + @@ -35497,7 +14679,7 @@ - + @@ -35511,7 +14693,7 @@ - + @@ -35525,7 +14707,7 @@ - + @@ -35539,7 +14721,7 @@ - + @@ -35553,7 +14735,7 @@ - + @@ -35567,7 +14749,7 @@ - + @@ -35581,7 +14763,7 @@ - + @@ -35595,7 +14777,7 @@ - + @@ -35609,7 +14791,7 @@ - + @@ -35623,7 +14805,7 @@ - + @@ -35637,7 +14819,7 @@ - + @@ -35651,7 +14833,7 @@ - + @@ -35665,7 +14847,7 @@ - + @@ -35679,7 +14861,7 @@ - + @@ -35693,7 +14875,7 @@ - + @@ -35707,7 +14889,7 @@ - + @@ -35721,7 +14903,7 @@ - + @@ -35735,7 +14917,7 @@ - + @@ -35749,7 +14931,7 @@ - + @@ -35763,7 +14945,7 @@ - + @@ -35777,7 +14959,7 @@ - + @@ -35791,7 +14973,7 @@ - + @@ -35805,7 +14987,7 @@ - + @@ -35819,7 +15001,7 @@ - + @@ -35833,7 +15015,7 @@ - + @@ -35847,7 +15029,7 @@ - + @@ -35861,7 +15043,7 @@ - + @@ -35875,7 +15057,7 @@ - + @@ -35889,7 +15071,7 @@ - + @@ -35903,7 +15085,7 @@ - + @@ -35917,7 +15099,7 @@ - + @@ -35931,7 +15113,7 @@ - + @@ -35945,7 +15127,7 @@ - + @@ -35959,7 +15141,7 @@ - + @@ -35973,7 +15155,7 @@ - + @@ -35987,7 +15169,7 @@ - + @@ -36001,7 +15183,7 @@ - + @@ -36015,7 +15197,7 @@ - + @@ -36029,7 +15211,7 @@ - + @@ -36043,7 +15225,7 @@ - + @@ -36057,7 +15239,7 @@ - + @@ -36067,7 +15249,7 @@ - + @@ -36077,7 +15259,7 @@ - + @@ -36087,7 +15269,7 @@ - + @@ -36097,7 +15279,7 @@ - + @@ -36107,7 +15289,7 @@ - + @@ -36117,7 +15299,7 @@ - + @@ -36127,7 +15309,7 @@ - + @@ -36137,7 +15319,7 @@ - + @@ -36147,7 +15329,7 @@ - + @@ -36157,7 +15339,7 @@ - + @@ -36167,7 +15349,7 @@ - + @@ -36177,7 +15359,7 @@ - + @@ -36187,7 +15369,7 @@ - + @@ -36197,7 +15379,7 @@ - + @@ -36207,7 +15389,7 @@ - + @@ -36217,7 +15399,7 @@ - + @@ -36227,7 +15409,7 @@ - + @@ -36237,7 +15419,7 @@ - + @@ -36247,7 +15429,7 @@ - + @@ -36257,7 +15439,7 @@ - + @@ -36267,7 +15449,7 @@ - + @@ -36277,7 +15459,7 @@ - + @@ -36287,7 +15469,7 @@ - + @@ -36297,7 +15479,7 @@ - + @@ -36307,7 +15489,7 @@ - + @@ -36317,7 +15499,7 @@ - + @@ -36327,7 +15509,7 @@ - + @@ -36337,7 +15519,7 @@ - + @@ -36347,7 +15529,7 @@ - + @@ -36357,7 +15539,7 @@ - + @@ -36367,7 +15549,7 @@ - + @@ -36377,7 +15559,7 @@ - + @@ -36387,7 +15569,7 @@ - + @@ -36397,7 +15579,7 @@ - + @@ -36407,7 +15589,7 @@ - + @@ -36421,7 +15603,7 @@ - + @@ -36435,7 +15617,7 @@ - + @@ -36449,7 +15631,7 @@ - + @@ -36463,7 +15645,7 @@ - + @@ -36477,7 +15659,7 @@ - + @@ -36491,7 +15673,7 @@ - + @@ -36505,7 +15687,7 @@ - + @@ -36519,7 +15701,7 @@ - + @@ -36533,7 +15715,7 @@ - + @@ -36547,7 +15729,7 @@ - + @@ -36561,7 +15743,7 @@ - + @@ -36575,7 +15757,7 @@ - + @@ -36589,7 +15771,7 @@ - + @@ -36603,7 +15785,7 @@ - + @@ -36617,7 +15799,7 @@ - + @@ -36631,7 +15813,7 @@ - + @@ -36645,7 +15827,7 @@ - + @@ -36659,7 +15841,7 @@ - + @@ -36673,7 +15855,7 @@ - + @@ -36687,7 +15869,7 @@ - + @@ -36701,7 +15883,7 @@ - + @@ -36715,7 +15897,7 @@ - + @@ -36729,7 +15911,7 @@ - + @@ -36743,7 +15925,7 @@ - + @@ -36757,7 +15939,7 @@ - + @@ -36771,7 +15953,7 @@ - + @@ -36785,7 +15967,7 @@ - + @@ -36799,7 +15981,7 @@ - + @@ -36813,7 +15995,7 @@ - + @@ -36827,7 +16009,7 @@ - + @@ -36841,7 +16023,7 @@ - + @@ -36855,7 +16037,7 @@ - + @@ -36869,7 +16051,7 @@ - + @@ -36883,7 +16065,7 @@ - + @@ -36897,7 +16079,7 @@ - + @@ -36911,7 +16093,7 @@ - + @@ -36925,7 +16107,7 @@ - + @@ -36939,7 +16121,7 @@ - + @@ -36953,7 +16135,7 @@ - + @@ -36967,7 +16149,7 @@ - + @@ -36981,7 +16163,7 @@ - + @@ -36995,7 +16177,7 @@ - + @@ -37009,7 +16191,7 @@ - + @@ -37023,7 +16205,7 @@ - + @@ -37037,7 +16219,7 @@ - + @@ -37051,7 +16233,7 @@ - + @@ -37065,7 +16247,7 @@ - + @@ -37079,7 +16261,7 @@ - + @@ -37093,7 +16275,7 @@ - + @@ -37107,7 +16289,7 @@ - + @@ -37121,7 +16303,7 @@ - + @@ -37135,7 +16317,7 @@ - + @@ -37149,7 +16331,7 @@ - + @@ -37163,7 +16345,7 @@ - + @@ -37177,7 +16359,7 @@ - + @@ -37191,7 +16373,7 @@ - + @@ -37205,7 +16387,7 @@ - + @@ -37219,7 +16401,7 @@ - + @@ -37233,7 +16415,7 @@ - + @@ -37247,7 +16429,7 @@ - + @@ -37261,7 +16443,7 @@ - + @@ -37275,7 +16457,7 @@ - + @@ -37289,7 +16471,7 @@ - + @@ -37303,7 +16485,7 @@ - + @@ -37317,7 +16499,7 @@ - + @@ -37331,7 +16513,7 @@ - + @@ -37345,7 +16527,7 @@ - + @@ -37359,7 +16541,7 @@ - + @@ -37373,7 +16555,7 @@ - + @@ -37387,7 +16569,7 @@ - + @@ -37401,7 +16583,7 @@ - + @@ -37415,7 +16597,7 @@ - + @@ -37429,7 +16611,7 @@ - + @@ -37443,7 +16625,7 @@ - + @@ -37457,7 +16639,7 @@ - + @@ -37471,7 +16653,7 @@ - + @@ -37486,7 +16668,7 @@ - + @@ -37500,7 +16682,7 @@ - + @@ -37510,7 +16692,7 @@ - + @@ -37520,7 +16702,7 @@ - + @@ -37530,7 +16712,7 @@ - + @@ -37540,7 +16722,7 @@ - + @@ -37550,7 +16732,7 @@ - + @@ -37560,7 +16742,7 @@ - + @@ -37570,7 +16752,7 @@ - + @@ -37580,7 +16762,7 @@ - + @@ -37590,7 +16772,7 @@ - + @@ -37600,7 +16782,7 @@ - + @@ -37610,7 +16792,7 @@ - + @@ -37620,7 +16802,7 @@ - + @@ -37630,7 +16812,7 @@ - + @@ -37640,7 +16822,7 @@ - + @@ -37650,7 +16832,7 @@ - + @@ -37660,7 +16842,7 @@ - + @@ -37670,7 +16852,7 @@ - + @@ -37680,7 +16862,7 @@ - + @@ -37690,7 +16872,7 @@ - + @@ -37700,7 +16882,7 @@ - + @@ -37710,7 +16892,7 @@ - + @@ -37720,7 +16902,7 @@ - + @@ -37730,7 +16912,7 @@ - + @@ -37740,7 +16922,7 @@ - + @@ -37750,7 +16932,7 @@ - + @@ -37760,7 +16942,7 @@ - + @@ -37770,7 +16952,7 @@ - + @@ -37780,7 +16962,7 @@ - + @@ -37790,7 +16972,7 @@ - + @@ -37800,7 +16982,7 @@ - + @@ -37810,7 +16992,7 @@ - + @@ -37820,7 +17002,7 @@ - + @@ -37830,7 +17012,7 @@ - + @@ -37840,7 +17022,7 @@ - + @@ -37854,7 +17036,7 @@ - + @@ -37868,7 +17050,7 @@ - + @@ -37882,7 +17064,7 @@ - + @@ -37896,7 +17078,7 @@ - + @@ -37910,7 +17092,7 @@ - + @@ -37924,7 +17106,7 @@ - + @@ -37938,7 +17120,7 @@ - + @@ -37952,7 +17134,7 @@ - + @@ -37966,7 +17148,7 @@ - + @@ -37980,7 +17162,7 @@ - + @@ -37994,7 +17176,7 @@ - + @@ -38008,7 +17190,7 @@ - + @@ -38022,7 +17204,7 @@ - + @@ -38036,7 +17218,7 @@ - + @@ -38050,7 +17232,7 @@ - + @@ -38064,7 +17246,7 @@ - + @@ -38078,7 +17260,7 @@ - + @@ -38092,7 +17274,7 @@ - + @@ -38106,7 +17288,7 @@ - + @@ -38120,7 +17302,7 @@ - + @@ -38134,7 +17316,7 @@ - + @@ -38148,7 +17330,7 @@ - + @@ -38162,7 +17344,7 @@ - + @@ -38176,7 +17358,7 @@ - + @@ -38190,7 +17372,7 @@ - + @@ -38204,7 +17386,7 @@ - + @@ -38218,7 +17400,7 @@ - + @@ -38232,7 +17414,7 @@ - + @@ -38246,7 +17428,7 @@ - + @@ -38260,7 +17442,7 @@ - + @@ -38274,7 +17456,7 @@ - + @@ -38288,7 +17470,7 @@ - + @@ -38302,7 +17484,7 @@ - + @@ -38316,7 +17498,7 @@ - + @@ -38330,7 +17512,7 @@ - + @@ -38344,7 +17526,7 @@ - + @@ -38358,7 +17540,7 @@ - + @@ -38372,7 +17554,7 @@ - + @@ -38386,7 +17568,7 @@ - + @@ -38400,7 +17582,7 @@ - + @@ -38414,7 +17596,7 @@ - + @@ -38428,7 +17610,7 @@ - + @@ -38442,7 +17624,7 @@ - + @@ -38456,7 +17638,7 @@ - + @@ -38470,7 +17652,7 @@ - + @@ -38484,7 +17666,7 @@ - + @@ -38498,7 +17680,7 @@ - + @@ -38512,7 +17694,7 @@ - + @@ -38526,7 +17708,7 @@ - + @@ -38540,7 +17722,7 @@ - + @@ -38554,7 +17736,7 @@ - + @@ -38568,7 +17750,7 @@ - + @@ -38582,7 +17764,7 @@ - + @@ -38596,7 +17778,7 @@ - + @@ -38610,7 +17792,7 @@ - + @@ -38624,7 +17806,7 @@ - + @@ -38638,7 +17820,7 @@ - + @@ -38652,7 +17834,7 @@ - + @@ -38666,7 +17848,7 @@ - + @@ -38680,7 +17862,7 @@ - + @@ -38694,7 +17876,7 @@ - + @@ -38708,7 +17890,7 @@ - + @@ -38722,7 +17904,7 @@ - + @@ -38736,7 +17918,7 @@ - + @@ -38750,7 +17932,7 @@ - + @@ -38764,7 +17946,7 @@ - + @@ -38778,7 +17960,7 @@ - + @@ -38792,7 +17974,7 @@ - + @@ -38806,7 +17988,7 @@ - + @@ -38820,7 +18002,7 @@ - + @@ -38834,7 +18016,7 @@ - + @@ -38848,7 +18030,7 @@ - + @@ -38862,7 +18044,7 @@ - + @@ -38876,7 +18058,7 @@ - + @@ -42982,7 +22164,7 @@ - + @@ -42994,7 +22176,7 @@ - + @@ -43006,7 +22188,7 @@ - + @@ -43018,7 +22200,7 @@ - + @@ -43030,7 +22212,7 @@ - + @@ -43042,7 +22224,7 @@ - + @@ -43054,7 +22236,7 @@ - + @@ -43066,7 +22248,7 @@ - + @@ -43078,7 +22260,7 @@ - + @@ -43090,7 +22272,7 @@ - + @@ -43102,7 +22284,7 @@ - + @@ -43114,7 +22296,7 @@ - + @@ -43126,7 +22308,7 @@ - + @@ -43138,7 +22320,7 @@ - + @@ -43150,7 +22332,7 @@ - + @@ -43162,7 +22344,7 @@ - + @@ -43174,7 +22356,7 @@ - + @@ -43186,7 +22368,7 @@ - + @@ -43198,7 +22380,7 @@ - + @@ -43422,235 +22604,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -43827,7 +22780,7 @@ - + @@ -43840,7 +22793,7 @@ - + @@ -43865,7 +22818,7 @@ - + @@ -44079,7 +23032,7 @@ - + @@ -44104,7 +23057,7 @@ - + @@ -44307,7 +23260,7 @@ @@ -44406,5 +23359,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PLASMA/ConstraintEngine/test/ConstraintTesting.cc b/src/PLASMA/ConstraintEngine/test/ConstraintTesting.cc index a5f20bc44..6ac717d25 100644 --- a/src/PLASMA/ConstraintEngine/test/ConstraintTesting.cc +++ b/src/PLASMA/ConstraintEngine/test/ConstraintTesting.cc @@ -25,6 +25,7 @@ #include "ConstrainedVariable.hh" #include "Debug.hh" #include "DataTypes.hh" +#include "CESchema.hh" namespace EUROPA { @@ -104,37 +105,37 @@ namespace EUROPA { return dom; } else if(strcmp(tagname, "SymbolDomain") == 0) { - const char * type = element.Attribute("type"); - DataTypeId dt; - - if (ce->getCESchema()->isDataType(type)) - dt = ce->getCESchema()->getDataType(type); - else { - dt = (new RestrictedDT(type,SymbolDT::instance(),SymbolDomain()))->getId(); - ce->getCESchema()->registerDataType(dt); - } + const char * type = element.Attribute("type"); + DataTypeId dt; + + if (ce->getCESchema()->isDataType(type)) + dt = ce->getCESchema()->getDataType(type); + else { + dt = (new RestrictedDT(type,SymbolDT::instance(),SymbolDomain()))->getId(); + ce->getCESchema()->registerDataType(dt); + } - SymbolDomain * dom = new SymbolDomain((edouble)LabelStr("foo"),dt); - dom->empty(); dom->open(); + SymbolDomain * dom = new SymbolDomain(LabelStr("foo").getKey(),dt); + dom->empty(); dom->open(); - SymbolDomain * base = ConstraintTestCase::symbolDomainsMap()[std::string(type)]; - if(!base) { - base = new SymbolDomain((edouble)LabelStr("foo"),dt->getId()); - base->empty(); base->open(); - ConstraintTestCase::symbolDomainsMap()[std::string(type)] = base; - } + SymbolDomain * base = ConstraintTestCase::symbolDomainsMap()[std::string(type)]; + if(!base) { + base = new SymbolDomain(LabelStr("foo").getKey(),dt->getId()); + base->empty(); base->open(); + ConstraintTestCase::symbolDomainsMap()[std::string(type)] = base; + } - for (const TiXmlElement * child = element.FirstChildElement() ; - child != NULL ; child = child->NextSiblingElement()) { - check_error(strcmp(child->Value(), "element") == 0); + for (const TiXmlElement * child = element.FirstChildElement() ; + child != NULL ; child = child->NextSiblingElement()) { + check_error(strcmp(child->Value(), "element") == 0); - const char * value = child->Attribute("value"); + const char * value = child->Attribute("value"); - dom->insert(LabelStr(value)); - base->insert(LabelStr(value)); - } - dom->close(); - return dom; + dom->insert(LabelStr(value)); + base->insert(LabelStr(value)); + } + dom->close(); + return dom; } else { check_error(false); @@ -250,7 +251,7 @@ namespace EUROPA { return true; } - bool executeTestCases(const ConstraintEngineId& engine, + bool executeTestCases(const ConstraintEngineId engine, std::list& testCases) { // Run each test, in the same order they appear in the list, // keeping a count of failed test cases. @@ -353,11 +354,11 @@ namespace EUROPA { } // Print that the test succeeded, count the successes for this constraint function, or whatever. - delete (Constraint*) constraint; + delete static_cast(constraint); while (!scope.empty()) { cVarId = scope.back(); scope.pop_back(); - delete (ConstrainedVariable*) cVarId; + delete static_cast(cVarId); } } if (problemCount > 0) { diff --git a/src/PLASMA/ConstraintEngine/test/ConstraintTesting.hh b/src/PLASMA/ConstraintEngine/test/ConstraintTesting.hh index 54c7b2a0e..6843790f3 100644 --- a/src/PLASMA/ConstraintEngine/test/ConstraintTesting.hh +++ b/src/PLASMA/ConstraintEngine/test/ConstraintTesting.hh @@ -1,5 +1,5 @@ -#ifndef _H_CONSTRAINT_TESTING -#define _H_CONSTRAINT_TESTING +#ifndef H_CONSTRAINT_TESTING +#define H_CONSTRAINT_TESTING /** * @file ConstraintTesting.hh @@ -62,7 +62,7 @@ namespace EUROPA { /** * @brief Execute the tests described by the test cases. */ - bool executeTestCases(const ConstraintEngineId& engine, std::list& testCases); + bool executeTestCases(const ConstraintEngineId engine, std::list& testCases); }; /* namespace EUROPA */ #endif // ifndef.. diff --git a/src/PLASMA/ConstraintEngine/test/DomainTest.cc b/src/PLASMA/ConstraintEngine/test/DomainTest.cc index 7be85c924..477deb0ea 100644 --- a/src/PLASMA/ConstraintEngine/test/DomainTest.cc +++ b/src/PLASMA/ConstraintEngine/test/DomainTest.cc @@ -65,7 +65,7 @@ static void outerLoopForTestEquate() { testEquate(ls_a, ls_b); } -static void testLabelSetEqualityPerformance(const ConstraintEngineId& ce) { +static void testLabelSetEqualityPerformance(const ConstraintEngineId ce) { // std::list values; // values.push_back(EUROPA::LabelStr("V0")); // values.push_back(EUROPA::LabelStr("V1")); @@ -175,7 +175,7 @@ static void outerLoopLabelSetEqualConstraint(bool useEquivalenceClasses) { // testLabelSetEqualityPerformance(ce.getId()); } -static void testIntervalEqualityPerformance(const ConstraintEngineId& ce) { +static void testIntervalEqualityPerformance(const ConstraintEngineId ce) { // IntervalIntDomain intSort(-1000, 1000); // Variable v0(ce, intSort); // Variable v1(ce, intSort); diff --git a/src/PLASMA/ConstraintEngine/test/NewTestCases.xml b/src/PLASMA/ConstraintEngine/test/NewTestCases.xml index 59e091586..c5b35c640 100644 --- a/src/PLASMA/ConstraintEngine/test/NewTestCases.xml +++ b/src/PLASMA/ConstraintEngine/test/NewTestCases.xml @@ -1,6 +1,6 @@ - + @@ -12,7 +12,7 @@ - + @@ -24,7 +24,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -94,7 +94,7 @@ - + @@ -108,7 +108,7 @@ - + @@ -122,7 +122,7 @@ - + @@ -134,7 +134,7 @@ - + @@ -146,7 +146,7 @@ - + @@ -158,7 +158,7 @@ - + @@ -170,7 +170,7 @@ - + @@ -180,7 +180,7 @@ - + @@ -192,7 +192,7 @@ - + @@ -204,7 +204,7 @@ - + @@ -216,7 +216,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -240,7 +240,7 @@ - + @@ -254,7 +254,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -280,7 +280,7 @@ - + @@ -296,7 +296,7 @@ - + @@ -312,7 +312,7 @@ - + @@ -328,7 +328,7 @@ - + @@ -344,7 +344,7 @@ - + @@ -360,7 +360,7 @@ - + @@ -376,7 +376,7 @@ - + @@ -392,7 +392,7 @@ - + @@ -408,7 +408,7 @@ - + @@ -420,7 +420,7 @@ - + @@ -456,7 +456,7 @@ - + @@ -480,7 +480,7 @@ - + @@ -504,23 +504,7 @@ - - - - - - - - - - - - - - - - - + @@ -532,7 +516,7 @@ - + @@ -544,7 +528,7 @@ - + diff --git a/src/PLASMA/ConstraintEngine/test/ce-test-module.cc b/src/PLASMA/ConstraintEngine/test/ce-test-module.cc index cea026d3a..98ba45159 100644 --- a/src/PLASMA/ConstraintEngine/test/ce-test-module.cc +++ b/src/PLASMA/ConstraintEngine/test/ce-test-module.cc @@ -5,17 +5,19 @@ * @brief Read the source for details */ #include "ce-test-module.hh" +#include "TestUtils.hh" #include "Utils.hh" #include "Variable.hh" #include "Constraints.hh" #include "ConstraintType.hh" #include "Propagators.hh" - +#include "ConstraintEngineListener.hh" /* Include for domain management */ #include "Domains.hh" #include "LabelStr.hh" #include "DataTypes.hh" +#include "CESchema.hh" #include "ConstraintTesting.hh" @@ -29,33 +31,33 @@ #include #include - +#include using namespace EUROPA; class DefaultEngineAccessor { - public: - static const ConstraintEngineId& instance() { - if (s_instance.isNoId()) { - CESchema* ces = new CESchema(); - s_instance = (new ConstraintEngine(ces->getId()))->getId(); - new DefaultPropagator(LabelStr("Default"), s_instance); - new DefaultPropagator(LabelStr("Temporal"), s_instance); - } - return s_instance; - } - - static void reset() { - if (!s_instance.isNoId()) { - const CESchemaId& tfm = s_instance->getCESchema(); - delete (ConstraintEngine*) s_instance; - delete (CESchema*) tfm; - s_instance = ConstraintEngineId::noId(); - } - } - - private: - static ConstraintEngineId s_instance; + public: + static const ConstraintEngineId instance() { + if (s_instance.isNoId()) { + CESchema* ces = new CESchema(); + s_instance = (new ConstraintEngine(ces->getId()))->getId(); + new DefaultPropagator("Default", s_instance); + new DefaultPropagator("Temporal", s_instance); + } + return s_instance; + } + + static void reset() { + if (!s_instance.isNoId()) { + const CESchemaId tfm = s_instance->getCESchema(); + delete static_cast(s_instance); + delete static_cast(tfm); + s_instance = ConstraintEngineId::noId(); + } + } + + private: + static ConstraintEngineId s_instance; }; ConstraintEngineId DefaultEngineAccessor::s_instance; @@ -63,41 +65,42 @@ ConstraintEngineId DefaultEngineAccessor::s_instance; #define ENGINE DefaultEngineAccessor::instance() // TODO: getting rid of the ENGINE shortcut would allow us to use the macro from Utils.hh -#define EUROPA_runCETest(test, args...) { \ - try { \ - DefaultEngineAccessor::instance(); \ - unsigned int id_count = EUROPA::IdTable::size(); \ - bool result = test(args); \ - DefaultEngineAccessor::reset(); \ - EUROPA::IdTable::checkResult(result,id_count); \ - } \ - catch (Error err){ \ - err.print(std::cout); \ - } \ - catch(std::exception e) { \ - std::cout << e.what() << std::endl; \ - } \ -} +#define EUROPA_runCETest(test) { \ + try { \ + DefaultEngineAccessor::instance(); \ + unsigned long id_count = EUROPA::IdTable::size(); \ + bool result = test(); \ + DefaultEngineAccessor::reset(); \ + EUROPA::IdTable::checkResult(result,id_count); \ + } \ + catch (Error err){ \ + err.print(std::cout); \ + } \ + catch(std::exception e) { \ + std::cout << e.what() << std::endl; \ + CPPUNIT_FAIL(e.what()); \ + } \ + } class DelegationTestConstraint : public Constraint { public: - DelegationTestConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) +DelegationTestConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables){s_instanceCount++;} - ~DelegationTestConstraint(){s_instanceCount--;} +~DelegationTestConstraint(){s_instanceCount--;} - void handleExecute(){ - s_executionCount++; - ConstrainedVariableId var = getScope().front(); - CPPUNIT_ASSERT_MESSAGE("Should be able to access derived domain during propagation safely.", !var->derivedDomain().isSingleton()); - } +void handleExecute(){ +s_executionCount++; +ConstrainedVariableId var = getScope().front(); +CPPUNIT_ASSERT_MESSAGE("Should be able to access derived domain during propagation safely.", !var->derivedDomain().isSingleton()); +} - void handleExecute(const ConstrainedVariableId&,int, const DomainListener::ChangeType&){} +void handleExecute(const ConstrainedVariableId, unsigned int, const DomainListener::ChangeType&){} - static int s_executionCount; - static int s_instanceCount; +static int s_executionCount; +static int s_instanceCount; }; int DelegationTestConstraint::s_executionCount = 0; @@ -107,31 +110,30 @@ typedef SymbolDomain Locations; class CETestEngine : public EngineBase { - public: - CETestEngine(); - virtual ~CETestEngine(); - const ConstraintEngineId& getConstraintEngine() const; +public: +CETestEngine(); +virtual ~CETestEngine(); +const ConstraintEngineId getConstraintEngine() const; - protected: - void createModules(); +protected: +void createModules(); }; -CETestEngine::CETestEngine() -{ - createModules(); - doStart(); - ConstraintEngine* ce = (ConstraintEngine*)getComponent("ConstraintEngine"); - - SymbolDomain locationsBaseDomain; - locationsBaseDomain.insert(LabelStr("Hill")); - locationsBaseDomain.insert(LabelStr("Rock")); - locationsBaseDomain.insert(LabelStr("Lander")); - locationsBaseDomain.close(); - - ce->getCESchema()->registerDataType( - (new RestrictedDT("Locations",SymbolDT::instance(),locationsBaseDomain))->getId() - ); - REGISTER_CONSTRAINT(ce->getCESchema(),DelegationTestConstraint, "TestOnly", "Default"); +CETestEngine::CETestEngine() { +createModules(); +doStart(); +ConstraintEngine* ce = reinterpret_cast(getComponent("ConstraintEngine")); + +SymbolDomain locationsBaseDomain; +locationsBaseDomain.insert(LabelStr("Hill")); +locationsBaseDomain.insert(LabelStr("Rock")); +locationsBaseDomain.insert(LabelStr("Lander")); +locationsBaseDomain.close(); + +ce->getCESchema()->registerDataType( +(new RestrictedDT("Locations",SymbolDT::instance(),locationsBaseDomain))->getId() +); +REGISTER_CONSTRAINT(ce->getCESchema(),DelegationTestConstraint, "TestOnly", "Default"); } CETestEngine::~CETestEngine() @@ -145,25 +147,24 @@ void CETestEngine::createModules() addModule((new ModuleConstraintLibrary())->getId()); } -const ConstraintEngineId& CETestEngine::getConstraintEngine() const -{ - return ((ConstraintEngine*)getComponent("ConstraintEngine"))->getId(); +const ConstraintEngineId CETestEngine::getConstraintEngine() const { + return (boost::polymorphic_cast(getComponent("ConstraintEngine")))->getId(); } class TestListener: public ConstraintEngineListener{ public: - TestListener(const ConstraintEngineId& ce):ConstraintEngineListener(ce){ + TestListener(const ConstraintEngineId ce):ConstraintEngineListener(ce){ for (int i=0;i(engine.getComponent("ConstraintEngine")); IntervalIntDomain d0(5); eint v0 = cast_int(ce->createValue(d0.getTypeName().c_str(), "5")); @@ -197,16 +199,16 @@ class TypeFactoryTests { CPPUNIT_ASSERT(d1.compareEqual(d1.getSingletonValue(), v1)); BoolDomain d2(true); - bool v2 = (bool) cast_int(ce->createValue(d2.getTypeName().c_str(), "true")); + bool v2 = static_cast(cast_int(ce->createValue(d2.getTypeName().c_str(), "true"))); CPPUNIT_ASSERT(d2.compareEqual(d2.getSingletonValue(), v2)); return true; } static bool testDomainCreation() { - CETestEngine engine; - CESchema* tfm = (CESchema*)engine.getComponent("CESchema"); - const Domain& locationsBaseDomain = tfm->getDataType("Locations")->baseDomain(); + CETestEngine engine; + CESchema* tfm = boost::polymorphic_cast(engine.getComponent("CESchema")); + const Domain& locationsBaseDomain = tfm->getDataType("Locations")->baseDomain(); const IntervalIntDomain & bd0 = dynamic_cast(tfm->baseDomain(IntervalIntDomain().getTypeName().c_str())); CPPUNIT_ASSERT(bd0.isMember(0)); @@ -263,16 +265,17 @@ class TypeFactoryTests { } static bool testVariableCreation(){ - CETestEngine engine; + CETestEngine engine; - ConstraintEngineId ce = ((ConstraintEngine*)engine.getComponent("ConstraintEngine"))->getId(); - ConstrainedVariableId cv0 = ce->createVariable(IntervalIntDomain().getTypeName().c_str()); - CPPUNIT_ASSERT(cv0->baseDomain().getTypeName() == IntervalIntDomain().getTypeName()); - ConstrainedVariableId cv1 = ce->createVariable(IntervalDomain().getTypeName().c_str()); - CPPUNIT_ASSERT(cv1->baseDomain().getTypeName() == IntervalDomain().getTypeName()); - ConstrainedVariableId cv2 = ce->createVariable(BoolDomain().getTypeName().c_str()); - CPPUNIT_ASSERT(cv2->baseDomain().getTypeName() == BoolDomain().getTypeName()); - return true; + ConstraintEngineId ce = + boost::polymorphic_cast(engine.getComponent("ConstraintEngine"))->getId(); + ConstrainedVariableId cv0 = ce->createVariable(IntervalIntDomain().getTypeName().c_str()); + CPPUNIT_ASSERT(cv0->baseDomain().getTypeName() == IntervalIntDomain().getTypeName()); + ConstrainedVariableId cv1 = ce->createVariable(IntervalDomain().getTypeName().c_str()); + CPPUNIT_ASSERT(cv1->baseDomain().getTypeName() == IntervalDomain().getTypeName()); + ConstrainedVariableId cv2 = ce->createVariable(BoolDomain().getTypeName().c_str()); + CPPUNIT_ASSERT(cv2->baseDomain().getTypeName() == BoolDomain().getTypeName()); + return true; } static bool testVariableWithDomainCreation(){ @@ -282,7 +285,8 @@ class TypeFactoryTests { IntervalDomain d1(2.3); BoolDomain d2(true); - ConstraintEngineId ce = ((ConstraintEngine*)engine.getComponent("ConstraintEngine"))->getId(); + ConstraintEngineId ce = + boost::polymorphic_cast(engine.getComponent("ConstraintEngine"))->getId(); ConstrainedVariableId cv0 = ce->createVariable(d0.getTypeName().c_str(), d0); CPPUNIT_ASSERT(cv0->baseDomain() == d0); ConstrainedVariableId cv1 = ce->createVariable(d1.getTypeName().c_str(), d1); @@ -303,7 +307,7 @@ class EntityTests { class TwicePropagator : public PostPropagationCallback { public: TwicePropagator(int& counter) : PostPropagationCallback(), m_counter(counter) {counter = 0;} - TwicePropagator(const ConstraintEngineId& ce, int& counter) : PostPropagationCallback(ce), m_counter(counter) {counter = 0;} + TwicePropagator(const ConstraintEngineId ce, int& counter) : PostPropagationCallback(ce), m_counter(counter) {counter = 0;} bool operator()() { ++m_counter; return m_counter < 2; @@ -314,7 +318,7 @@ class TwicePropagator : public PostPropagationCallback { class PropagationCounter : public ConstraintEngineListener { public: - PropagationCounter(const ConstraintEngineId& ce) : ConstraintEngineListener(ce), m_counter(0) {} + PropagationCounter(const ConstraintEngineId ce) : ConstraintEngineListener(ce), m_counter(0) {} void notifyPropagationCompleted() {++m_counter;} int counter() const {return m_counter;} private: @@ -335,7 +339,8 @@ class ConstraintEngineTest static bool testPostPropagation() { CETestEngine engine; - ConstraintEngineId ce = ((ConstraintEngine*)engine.getComponent("ConstraintEngine"))->getId(); + ConstraintEngineId ce = + boost::polymorphic_cast(engine.getComponent("ConstraintEngine"))->getId(); int postProp = 0; PropagationCounter* counter = new PropagationCounter(ce); @@ -354,7 +359,7 @@ class ConstraintEngineTest for(int i=0;i<100;i++){ Id > v0 = (new Variable (ce, intBaseDomain))->getId(); Id > v1 = (new Variable(ce, intBaseDomain))->getId(); - new EqualConstraint(LabelStr("EqualConstraint"), LabelStr("Default"), ce, makeScope(v0, v1)); + new EqualConstraint("EqualConstraint", "Default", ce, makeScope(v0, v1)); } CPPUNIT_ASSERT(ce->propagate()); @@ -365,8 +370,9 @@ class ConstraintEngineTest } static bool testDeallocationWithPurging(){ - CETestEngine engine; - ConstraintEngineId ce = ((ConstraintEngine*)engine.getComponent("ConstraintEngine"))->getId(); + CETestEngine engine; + ConstraintEngineId ce = + boost::polymorphic_cast(engine.getComponent("ConstraintEngine"))->getId(); // Set up a base domain NumericDomain intBaseDomain; @@ -380,7 +386,7 @@ class ConstraintEngineTest for(int i=0;i<100;i++){ Id > v0 = (new Variable (ce, intBaseDomain))->getId(); Id > v1 = (new Variable(ce, intBaseDomain))->getId(); - new EqualConstraint(LabelStr("EqualConstraint"), LabelStr("Default"), ce, makeScope(v0, v1)); + new EqualConstraint("EqualConstraint", "Default", ce, makeScope(v0, v1)); } CPPUNIT_ASSERT(ce->propagate()); @@ -424,14 +430,14 @@ class ConstraintEngineTest Variable v2(ENGINE, IntervalIntDomain(0, 10)); Variable v3(ENGINE, IntervalIntDomain(0, 10)); - Constraint* c0 = new EqualConstraint(LabelStr("EqualConstraint"), - LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + Constraint* c0 = new EqualConstraint("EqualConstraint", + "Default", ENGINE, makeScope(v0.getId(), v1.getId())); - Constraint* c1 = new EqualConstraint(LabelStr("EqualConstraint"), - LabelStr("Default"), ENGINE, makeScope(v2.getId(), v3.getId())); + Constraint* c1 = new EqualConstraint("EqualConstraint", + "Default", ENGINE, makeScope(v2.getId(), v3.getId())); - Constraint* c2 = new EqualConstraint(LabelStr("EqualConstraint"), - LabelStr("Default"), ENGINE, makeScope(v2.getId(), v3.getId())); + Constraint* c2 = new EqualConstraint("EqualConstraint", + "Default", ENGINE, makeScope(v2.getId(), v3.getId())); v0.specify(1); v1.specify(2); @@ -456,11 +462,11 @@ class ConstraintEngineTest v3.specify(3); // Now delete constraints in the order that relaxes the empty variable last - delete (Constraint*) c1; + delete static_cast(c1); CPPUNIT_ASSERT(!ENGINE->propagate()); - delete (Constraint*) c2; + delete static_cast(c2); CPPUNIT_ASSERT(!ENGINE->propagate()); - delete (Constraint*) c0; + delete static_cast(c0); CPPUNIT_ASSERT(ENGINE->propagate()); return true; @@ -474,7 +480,7 @@ class ConstraintEngineTest // Assumes listener has been created using new class TestVariableListener: public ConstrainedVariableListener{ public: - TestVariableListener(const ConstrainedVariableId& observedVar) + TestVariableListener(const ConstrainedVariableId observedVar) : ConstrainedVariableListener(observedVar) {} void notifyDiscard() { delete this; @@ -511,9 +517,9 @@ class VariableTest v0.restrictBaseDomain(dom2); CPPUNIT_ASSERT(v0.getDerivedDomain() == dom2); - Variable v1(ENGINE, dom1, false, false, LabelStr("TEST VARIABLE")); + Variable v1(ENGINE, dom1, false, false, "TEST VARIABLE"); CPPUNIT_ASSERT(!v1.canBeSpecified()); - CPPUNIT_ASSERT(v1.getName() == LabelStr("TEST VARIABLE")); + CPPUNIT_ASSERT(v1.getName() == "TEST VARIABLE"); CPPUNIT_ASSERT(v1.isValid()); return true; } @@ -535,7 +541,7 @@ class VariableTest { Variable v0(ENGINE, IntervalIntDomain(0, 100)); Variable v1(ENGINE, IntervalIntDomain(0, 10)); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(listener.getCount(ConstraintEngine::UPPER_BOUND_DECREASED) == 1); v0.specify(7); @@ -574,7 +580,7 @@ class VariableTest d0.close(); Variable v1(ENGINE, d0); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); ENGINE->propagate(); // Should see values removed from both variables domains. CPPUNIT_ASSERT(listener.getCount(ConstraintEngine::VALUE_REMOVED) == 2); v0.specify(3); @@ -612,7 +618,7 @@ class VariableTest v1.close(); // Post equality constraint between v0 and v1. - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); // When we propagate, the derived domain of v0 will now be closed and bound to the same domain as v1 CPPUNIT_ASSERT(ENGINE->propagate()); @@ -632,7 +638,7 @@ class VariableTest v1.insert(3); // Post equality constraint between v0 and v1. - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); // Now close v0, and we should see a restriction on v1 v0.close(); CPPUNIT_ASSERT(v1.getDerivedDomain().isSingleton()); @@ -672,7 +678,7 @@ class VariableTest static bool testListener(){ ConstrainedVariableId v0 = (new Variable(ENGINE, IntervalIntDomain()))->getId(); new TestVariableListener(v0); // deletes itself when v0 deleted - delete (ConstrainedVariable*) v0; + delete static_cast(v0); return true; } @@ -717,7 +723,7 @@ class VariableTest Variable v0(ENGINE, e0); Variable v1(ENGINE, e0); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); // Specify v0 and propagate v0.specify(1); @@ -809,7 +815,6 @@ class ConstraintTest EUROPA_runCETest(testDelegation); EUROPA_runCETest(testNotEqual); EUROPA_runCETest(testMultEqualConstraint); - EUROPA_runCETest(testAddMultEqualConstraint); EUROPA_runCETest(testEqualSumConstraint); EUROPA_runCETest(testCondAllSameConstraint); EUROPA_runCETest(testCondAllDiffConstraint); @@ -845,7 +850,7 @@ class ConstraintTest dom.insert(6); Variable v1(ENGINE, dom); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); CPPUNIT_ASSERT(ENGINE->propagate()); @@ -903,7 +908,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(-10, 10)); Variable v1(ENGINE, IntervalIntDomain(-10, 10)); Variable v2(ENGINE, IntervalDomain(0.01, 0.99)); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(!res); } @@ -913,7 +918,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(-10, 10)); Variable v1(ENGINE, IntervalIntDomain(-10, 10)); Variable v2(ENGINE, IntervalDomain(0.01, 1.99)); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); // Require correct result to be in v2's domain. @@ -927,7 +932,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(-1, -1)); Variable v1(ENGINE, IntervalDomain(10.4, 10.4)); Variable v2(ENGINE, IntervalDomain(9.4, 9.4)); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); } @@ -937,7 +942,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(-1, -1)); Variable v1(ENGINE, IntervalDomain(10.4, 10.4)); Variable v2(ENGINE, IntervalDomain(9.39, 9.39)); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(!res); } @@ -947,7 +952,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(0, PLUS_INFINITY)); Variable v1(ENGINE, IntervalDomain(0, PLUS_INFINITY)); Variable v2(ENGINE, IntervalDomain(9.390, 9.390)); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(v0.getDerivedDomain() == IntervalIntDomain(0, 9)); @@ -959,7 +964,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(MINUS_INFINITY, MINUS_INFINITY)); Variable v1(ENGINE, IntervalIntDomain(1, PLUS_INFINITY)); Variable v2(ENGINE, IntervalIntDomain(PLUS_INFINITY, PLUS_INFINITY)); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(v0.getDerivedDomain() == IntervalIntDomain(MINUS_INFINITY, MINUS_INFINITY)); @@ -972,7 +977,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(10, PLUS_INFINITY)); Variable v1(ENGINE, IntervalIntDomain(1, PLUS_INFINITY)); Variable v2(ENGINE, IntervalIntDomain(MINUS_INFINITY, eint(100))); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(v0.getDerivedDomain() == IntervalIntDomain(10, 99)); @@ -985,7 +990,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(MINUS_INFINITY, PLUS_INFINITY)); Variable v1(ENGINE, IntervalIntDomain(1)); Variable v2(ENGINE, IntervalIntDomain(MINUS_INFINITY, PLUS_INFINITY)); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(v0.getDerivedDomain() == IntervalIntDomain(MINUS_INFINITY, PLUS_INFINITY)); @@ -997,7 +1002,7 @@ class ConstraintTest { Variable v0(ENGINE, IntervalIntDomain(10, 14)); Variable v1(ENGINE, IntervalIntDomain(0, 1)); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v0.getId())); + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v0.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); v1.specify(1); @@ -1015,7 +1020,7 @@ class ConstraintTest static bool testLessThanEqualConstraint() {/* TO DO Variable v0(ENGINE, IntervalIntDomain(1, 100)); Variable v1(ENGINE, IntervalIntDomain(1, 100)); - LessThanEqualConstraint c0(LabelStr("LessThanEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + LessThanEqualConstraint c0("LessThanEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v0.getDerivedDomain() == v1.getDerivedDomain()); @@ -1034,7 +1039,7 @@ class ConstraintTest // Handle propagation of infinities Variable v2(ENGINE, IntervalIntDomain(2, PLUS_INFINITY)); Variable v3(ENGINE, IntervalIntDomain(MINUS_INFINITY, 100)); - LessThanEqualConstraint c2(LabelStr("LessThanEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v2.getId(), v3.getId())); + LessThanEqualConstraint c2("LessThanEqualConstraint", "Default", ENGINE, makeScope(v2.getId(), v3.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(v2.getDerivedDomain().getUpperBound() == 100); @@ -1044,8 +1049,8 @@ class ConstraintTest Variable v4(ENGINE, IntervalIntDomain(0, 10)); Variable v5(ENGINE, IntervalIntDomain(5, 15)); Variable v6(ENGINE, IntervalIntDomain(0, 100)); - LessThanEqualConstraint c3(LabelStr("LessThanEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v4.getId(), v5.getId())); - EqualConstraint c4(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v5.getId(), v6.getId())); + LessThanEqualConstraint c3("LessThanEqualConstraint", "Default", ENGINE, makeScope(v4.getId(), v5.getId())); + EqualConstraint c4("EqualConstraint", "Default", ENGINE, makeScope(v5.getId(), v6.getId())); res = ENGINE->propagate(); CPPUNIT_ASSERT(res); v6.specify(9); @@ -1065,7 +1070,7 @@ class ConstraintTest Variable realVar1(ENGINE, realBaseDomain); Variable realVar2(ENGINE, realBaseDomain); - LessThanEqualConstraint cRealTest(LabelStr("LessThanEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(realVar2.getId(), realVar1.getId())); + LessThanEqualConstraint cRealTest("LessThanEqualConstraint", "Default", ENGINE, makeScope(realVar2.getId(), realVar1.getId())); res = ENGINE->propagate(); CPPUNIT_ASSERT(res); @@ -1082,7 +1087,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(0, 100)); Variable v1(ENGINE, IntervalIntDomain(0, 100)); Variable v2(ENGINE, IntervalIntDomain(0, 100)); - LessOrEqThanSumConstraint c0(LabelStr("LessOrEqThanSumConstraint"), LabelStr("Default"), ENGINE, + LessOrEqThanSumConstraint c0("LessOrEqThanSumConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); @@ -1110,18 +1115,18 @@ class ConstraintTest // v0 == v1 Variable v0(ENGINE, IntervalIntDomain(1, 10)); Variable v1(ENGINE, IntervalIntDomain(1, 10)); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); // v2 + v3 == v0 Variable v2(ENGINE, IntervalIntDomain(1, 4)); Variable v3(ENGINE, IntervalIntDomain(1, 1)); - AddEqualConstraint c1(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v2.getId(), v3.getId(), v0.getId())); + AddEqualConstraint c1("AddEqualConstraint", "Default", ENGINE, makeScope(v2.getId(), v3.getId(), v0.getId())); CPPUNIT_ASSERT(!v0.getDerivedDomain().isEmpty()); // v4 + v5 == v1 Variable v4(ENGINE, IntervalIntDomain(1, 10)); Variable v5(ENGINE, IntervalIntDomain(1, 1000)); - AddEqualConstraint c2(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v4.getId(), v5.getId(), v1.getId())); + AddEqualConstraint c2("AddEqualConstraint", "Default", ENGINE, makeScope(v4.getId(), v5.getId(), v1.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); @@ -1133,7 +1138,7 @@ class ConstraintTest // v0 == v1 Variable v0(ENGINE, IntervalIntDomain(1, 10)); Variable v1(ENGINE, IntervalIntDomain(1, 10)); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); @@ -1175,7 +1180,7 @@ class ConstraintTest Variable v2(ENGINE, IntervalIntDomain(1, 10)); Variable v3(ENGINE, IntervalIntDomain(1, 10)); - EqualConstraint c1(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v2.getId(), v3.getId())); + EqualConstraint c1("EqualConstraint", "Default", ENGINE, makeScope(v2.getId(), v3.getId())); ENGINE->propagate(); v2.restrictBaseDomain(IntervalIntDomain(1, 1)); v3.restrictBaseDomain(IntervalIntDomain(2, 2)); @@ -1191,17 +1196,17 @@ class ConstraintTest // v0 == v1 Variable v0(ENGINE, IntervalIntDomain(1, 10)); Variable v1(ENGINE, IntervalIntDomain(1, 10)); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); // v2 + v3 == v0 Variable v2(ENGINE, IntervalIntDomain(1, 1)); Variable v3(ENGINE, IntervalIntDomain(1, 1)); - AddEqualConstraint c1(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v2.getId(), v3.getId(), v0.getId())); + AddEqualConstraint c1("AddEqualConstraint", "Default", ENGINE, makeScope(v2.getId(), v3.getId(), v0.getId())); // v4 + v5 == v1 Variable v4(ENGINE, IntervalIntDomain(2, 2)); Variable v5(ENGINE, IntervalIntDomain(2, 2)); - AddEqualConstraint c2(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v4.getId(), v5.getId(), v1.getId())); + AddEqualConstraint c2("AddEqualConstraint", "Default", ENGINE, makeScope(v4.getId(), v5.getId(), v1.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->provenInconsistent()); @@ -1217,7 +1222,7 @@ class ConstraintTest int emptyCount(0); for(std::vector::iterator it = variables.begin(); it != variables.end(); ++it){ - Variable* id = (Variable*) (*it); + Variable* id = id_cast >(*it); if(id->lastDomain().isEmpty()) emptyCount++; } @@ -1230,18 +1235,18 @@ class ConstraintTest // v0 == v1 Variable v0(ENGINE, IntervalIntDomain(1, 10)); Variable v1(ENGINE, IntervalIntDomain(1, 10)); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + EqualConstraint c0("EqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); // v2 + v3 == v0 Variable v2(ENGINE, IntervalIntDomain(1, 10)); Variable v3(ENGINE, IntervalIntDomain(1, 10)); - AddEqualConstraint c1(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v2.getId(), v3.getId(), v0.getId())); + AddEqualConstraint c1("AddEqualConstraint", "Default", ENGINE, makeScope(v2.getId(), v3.getId(), v0.getId())); // v4 + v5 == v1 Variable v4(ENGINE, IntervalIntDomain(1, 10)); Variable v5(ENGINE, IntervalIntDomain(1, 10)); - AddEqualConstraint c2(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v4.getId(), v5.getId(), v1.getId())); + AddEqualConstraint c2("AddEqualConstraint", "Default", ENGINE, makeScope(v4.getId(), v5.getId(), v1.getId())); ENGINE->propagate(); /* TODO @@ -1276,7 +1281,7 @@ class ConstraintTest variables.push_back(v0.getId()); Variable v1(ENGINE, IntervalIntDomain(1, 10)); variables.push_back(v1.getId()); - ConstraintId c0((new EqualConstraint(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, variables))->getId()); + ConstraintId c0((new EqualConstraint("EqualConstraint", "Default", ENGINE, variables))->getId()); // v2 + v3 == v0 variables.clear(); @@ -1285,13 +1290,13 @@ class ConstraintTest Variable v3(ENGINE, IntervalIntDomain(1, 10)); variables.push_back(v3.getId()); variables.push_back(v0.getId()); - ConstraintId c1((new AddEqualConstraint(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, variables))->getId()); + ConstraintId c1((new AddEqualConstraint("AddEqualConstraint", "Default", ENGINE, variables))->getId()); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); /* Show that we can simply delete a constraint and confirm that the system is still consistent. */ - delete (Constraint*) c1; + delete static_cast(c1); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); @@ -1299,12 +1304,12 @@ class ConstraintTest Variable v4(ENGINE, IntervalIntDomain(1, 1)); variables.push_back(v0.getId()); variables.push_back(v4.getId()); - ConstraintId c2((new EqualConstraint(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, variables))->getId()); + ConstraintId c2((new EqualConstraint("EqualConstraint", "Default", ENGINE, variables))->getId()); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v1.getDerivedDomain().getSingletonValue() == 1); - delete (Constraint*) c2; + delete static_cast(c2); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v1.getDerivedDomain().getUpperBound() == 10); @@ -1315,30 +1320,31 @@ class ConstraintTest Variable v5(ENGINE, IntervalIntDomain(0, 0)); variables.push_back(v0.getId()); variables.push_back(v5.getId()); - ConstraintId c3((new EqualConstraint(LabelStr("EqualConstraint"), LabelStr("Default"), ENGINE, variables))->getId()); + ConstraintId c3((new EqualConstraint("EqualConstraint", "Default", ENGINE, variables))->getId()); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->provenInconsistent()); - delete (Constraint*) c3; + delete static_cast(c3); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); // Clean up remaining constraint - delete (Constraint*) c0; + delete static_cast(c0); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); return true; } static bool testDelegation(){ - CETestEngine eng; - const ConstraintEngineId& engine=((ConstraintEngine*)eng.getComponent("ConstraintEngine"))->getId(); + CETestEngine eng; + const ConstraintEngineId engine= + boost::polymorphic_cast(eng.getComponent("ConstraintEngine"))->getId(); Variable v0(engine, IntervalIntDomain(0, 1000)); - ConstraintId c0 = engine->createConstraint(LabelStr("TestOnly"), makeScope(v0.getId())); - ConstraintId c1 = engine->createConstraint(LabelStr("TestOnly"), makeScope(v0.getId())); - ConstraintId c2 = engine->createConstraint(LabelStr("TestOnly"), makeScope(v0.getId())); - ConstraintId c3 = engine->createConstraint(LabelStr("TestOnly"), makeScope(v0.getId())); - ConstraintId c4 = engine->createConstraint(LabelStr("TestOnly"), makeScope(v0.getId())); + ConstraintId c0 = engine->createConstraint("TestOnly", makeScope(v0.getId())); + ConstraintId c1 = engine->createConstraint("TestOnly", makeScope(v0.getId())); + ConstraintId c2 = engine->createConstraint("TestOnly", makeScope(v0.getId())); + ConstraintId c3 = engine->createConstraint("TestOnly", makeScope(v0.getId())); + ConstraintId c4 = engine->createConstraint("TestOnly", makeScope(v0.getId())); engine->propagate(); CPPUNIT_ASSERT(engine->constraintConsistent()); CPPUNIT_ASSERT(DelegationTestConstraint::s_instanceCount == 5); @@ -1354,7 +1360,7 @@ class ConstraintTest CPPUNIT_ASSERT(DelegationTestConstraint::s_executionCount == 9); // Delete the delegate and verify instance counts and that the prior delegate has been reinstated and executed. - delete (Constraint*) c1; + delete static_cast(c1); c0->undoDeactivation(); engine->propagate(); CPPUNIT_ASSERT(engine->constraintConsistent()); @@ -1362,7 +1368,7 @@ class ConstraintTest CPPUNIT_ASSERT(DelegationTestConstraint::s_executionCount == 10); // Now create a new instance and mark it for delegation only. Add remaining constraints as delegates - ConstraintId c5 = engine->createConstraint(LabelStr("TestOnly"), makeScope(v0.getId())); + ConstraintId c5 = engine->createConstraint("TestOnly", makeScope(v0.getId())); c0->deactivate(); c2->deactivate(); c3->deactivate(); @@ -1377,11 +1383,11 @@ class ConstraintTest CPPUNIT_ASSERT(DelegationTestConstraint::s_executionCount == 12); // Now confirm correct handling of constraint deletions - delete (Constraint*) c5; - delete (Constraint*) c4; - delete (Constraint*) c3; - delete (Constraint*) c2; - delete (Constraint*) c0; + delete static_cast(c5); + delete static_cast(c4); + delete static_cast(c3); + delete static_cast(c2); + delete static_cast(c0); CPPUNIT_ASSERT(DelegationTestConstraint::s_instanceCount == 0); return true; } @@ -1409,8 +1415,8 @@ class ConstraintTest Variable v4(ENGINE, dom3); Variable v5(ENGINE, dom2); - NotEqualConstraint c4(LabelStr("neq"), LabelStr("Default"), ENGINE, makeScope(v4.getId(), v5.getId())); - NotEqualConstraint c3(LabelStr("neq"), LabelStr("Default"), ENGINE, makeScope(v4.getId(), v3.getId())); + NotEqualConstraint c4("neq", "Default", ENGINE, makeScope(v4.getId(), v5.getId())); + NotEqualConstraint c3("neq", "Default", ENGINE, makeScope(v4.getId(), v3.getId())); CPPUNIT_ASSERT(ENGINE->pending()); bool res = ENGINE->propagate(); CPPUNIT_ASSERT(res); @@ -1419,9 +1425,9 @@ class ConstraintTest // Test not equals among variables which are not singletons - NotEqualConstraint c0(LabelStr("neq"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); - NotEqualConstraint c1(LabelStr("neq"), LabelStr("Default"), ENGINE, makeScope(v1.getId(), v2.getId())); - NotEqualConstraint c2(LabelStr("neq"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v2.getId())); + NotEqualConstraint c0("neq", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); + NotEqualConstraint c1("neq", "Default", ENGINE, makeScope(v1.getId(), v2.getId())); + NotEqualConstraint c2("neq", "Default", ENGINE, makeScope(v0.getId(), v2.getId())); CPPUNIT_ASSERT(ENGINE->pending()); res = ENGINE->propagate(); CPPUNIT_ASSERT(res); @@ -1451,7 +1457,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(1, 10)); Variable v1(ENGINE, IntervalIntDomain(1, 1)); Variable v2(ENGINE, IntervalIntDomain(0, 2)); - MultEqualConstraint c0(LabelStr("MultEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + MultEqualConstraint c0("MultEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v0.getDerivedDomain() == v2.getDerivedDomain()); @@ -1462,7 +1468,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(0, PLUS_INFINITY)); Variable v1(ENGINE, IntervalDomain(1, PLUS_INFINITY)); Variable v2(ENGINE, IntervalIntDomain(MINUS_INFINITY, eint(6))); - MultEqualConstraint c0(LabelStr("MultEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + MultEqualConstraint c0("MultEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v0.getDerivedDomain().getUpperBound() == 6); @@ -1476,7 +1482,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(-4, 10)); Variable v1(ENGINE, IntervalDomain(1, 10)); Variable v2(ENGINE, IntervalIntDomain()); - MultEqualConstraint c0(LabelStr("MultEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + MultEqualConstraint c0("MultEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v2.getDerivedDomain().getLowerBound() == -40); @@ -1488,7 +1494,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalDomain(1.0)); Variable v1(ENGINE, IntervalDomain(MINUS_INFINITY, PLUS_INFINITY)); Variable v2(ENGINE, IntervalDomain(1.0, 2.0)); - MultEqualConstraint c0(LabelStr("MultEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + MultEqualConstraint c0("MultEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v1.getDerivedDomain() == IntervalDomain(1.0, 2.0)); @@ -1498,7 +1504,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalDomain(-2.3, -1.8)); Variable v1(ENGINE, IntervalIntDomain(1, PLUS_INFINITY)); Variable v2(ENGINE, IntervalDomain(-11.6, 12.4)); - MultEqualConstraint c0(LabelStr("MultEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + MultEqualConstraint c0("MultEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT_MESSAGE(v0.getDerivedDomain().toString(), v0.getDerivedDomain() == IntervalDomain(-2.3, -1.8)); @@ -1511,7 +1517,7 @@ class ConstraintTest Variable v0(ENGINE, IntervalIntDomain(1, PLUS_INFINITY)); Variable v1(ENGINE, IntervalDomain(-2.3, -1.8)); Variable v2(ENGINE, IntervalDomain(-11.6, 12.4)); - MultEqualConstraint c0(LabelStr("MultEqualConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); + MultEqualConstraint c0("MultEqualConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT_MESSAGE(v0.getDerivedDomain().toString(), v0.getDerivedDomain() == IntervalIntDomain(1, 6)); @@ -1529,69 +1535,6 @@ class ConstraintTest return true; } - static bool testAddMultEqualConstraint() { - // 1 + 2 * 3 == 7 - { - Variable v0(ENGINE, IntervalIntDomain(1, 1)); - Variable v1(ENGINE, IntervalIntDomain(2, 2)); - Variable v2(ENGINE, IntervalIntDomain(3, 3)); - Variable v3(ENGINE, IntervalIntDomain(7, 7)); - AddMultEqualConstraint c0(LabelStr("AddMultEqualConstraint"), - LabelStr("Default"), - ENGINE, - makeScope(v0.getId(), v1.getId(), v2.getId(), v3.getId())); - bool res = ENGINE->propagate(); - CPPUNIT_ASSERT(res); - } - - // 1 + 2 * 3 == 8 => empty - { - Variable v0(ENGINE, IntervalIntDomain(1, 1)); - Variable v1(ENGINE, IntervalIntDomain(2, 2)); - Variable v2(ENGINE, IntervalIntDomain(3, 3)); - Variable v3(ENGINE, IntervalIntDomain(8, 8)); - AddMultEqualConstraint c0(LabelStr("AddMultEqualConstraint"), - LabelStr("Default"), - ENGINE, - makeScope(v0.getId(), v1.getId(), v2.getId(), v3.getId())); - bool res = ENGINE->propagate(); - CPPUNIT_ASSERT(!res); - } - - // 1 + 1 * [-infty 0] = 1 -> 1 + 1 * 0 = 1 - { - Variable v0(ENGINE, IntervalIntDomain(1, 1)); - Variable v1(ENGINE, IntervalIntDomain(1, 1)); - Variable v2(ENGINE, IntervalIntDomain(MINUS_INFINITY, eint(0))); - Variable v3(ENGINE, IntervalIntDomain(1, 1)); - AddMultEqualConstraint c0(LabelStr("AddMultEqualConstraint"), - LabelStr("Default"), - ENGINE, - makeScope(v0.getId(), v1.getId(), v2.getId(), v3.getId())); - bool res = ENGINE->propagate(); - CPPUNIT_ASSERT(res); - CPPUNIT_ASSERT(v2.getDerivedDomain().getSingletonValue() == 0); - } - - // [1.0 10.0] + 1.0 * [1.0 10.0] = 10.0 -> [1.0 9.0] + 1.0 * [1.0 9.0] = 10.0 - { - Variable v0(ENGINE, IntervalIntDomain(1, 10)); - Variable v1(ENGINE, IntervalDomain(1.0, 1.0)); - Variable v2(ENGINE, IntervalDomain(1.0, 10.0)); - Variable v3(ENGINE, IntervalDomain(10.0, 10.0)); - AddMultEqualConstraint c0(LabelStr("AddMultEqualConstraint"), - LabelStr("Default"), - ENGINE, - makeScope(v0.getId(), v1.getId(), v2.getId(), v3.getId())); - bool res = ENGINE->propagate(); - CPPUNIT_ASSERT(res); - CPPUNIT_ASSERT(v0.getDerivedDomain() == IntervalIntDomain(1, 9)); - CPPUNIT_ASSERT(v2.getDerivedDomain() == IntervalDomain(1.0, 9.0)); - } - - - return true; - } static bool testEqualSumConstraint() { Variable v0(ENGINE, IntervalIntDomain(1, 10)); @@ -1613,7 +1556,7 @@ class ConstraintTest Variable vG(ENGINE, IntervalIntDomain(0, 27)); { // Duplicate first test case in testAddEqualConstraint(), // but note args are in different order in scope to get same result - EqualSumConstraint c0(LabelStr("EqualSumConstraint"), LabelStr("Default"), ENGINE, makeScope(v2.getId(), v0.getId(), v1.getId())); + EqualSumConstraint c0("EqualSumConstraint", "Default", ENGINE, makeScope(v2.getId(), v0.getId(), v1.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v0.getDerivedDomain().getSingletonValue() == 1); @@ -1626,7 +1569,7 @@ class ConstraintTest scope.push_back(v0.getId()); scope.push_back(v1.getId()); scope.push_back(v3.getId()); - EqualSumConstraint c0(LabelStr("EqualSumConstraint"), LabelStr("Default"), ENGINE, scope); + EqualSumConstraint c0("EqualSumConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v0.getDerivedDomain().getSingletonValue() == 1); @@ -1653,7 +1596,7 @@ class ConstraintTest scope.push_back(vE.getId()); scope.push_back(vF.getId()); scope.push_back(vG.getId()); - EqualSumConstraint c0(LabelStr("EqualSumConstraint"), LabelStr("Default"), ENGINE, scope); + EqualSumConstraint c0("EqualSumConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v0.getDerivedDomain().getSingletonValue() == 1); @@ -1701,7 +1644,7 @@ class ConstraintTest scope.push_back(bothVar.getId()); scope.push_back(v0.getId()); scope.push_back(v1.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().isSingleton()); @@ -1714,7 +1657,7 @@ class ConstraintTest scope.push_back(bothVar.getId()); scope.push_back(v0.getId()); scope.push_back(vA.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(bothVar.getDerivedDomain() == BoolDomain(false)); @@ -1726,7 +1669,7 @@ class ConstraintTest scope.push_back(v6.getId()); scope.push_back(v7.getId()); scope.push_back(v8.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(bothVar.getDerivedDomain() == BoolDomain(true)); @@ -1739,7 +1682,7 @@ class ConstraintTest scope.push_back(v6.getId()); scope.push_back(v7.getId()); scope.push_back(v8.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().isSingleton()); @@ -1752,7 +1695,7 @@ class ConstraintTest scope.push_back(v7.getId()); scope.push_back(v8.getId()); scope.push_back(v2.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().isSingleton()); @@ -1765,7 +1708,7 @@ class ConstraintTest scope.push_back(v7.getId()); scope.push_back(v2.getId()); scope.push_back(v8.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().isSingleton()); @@ -1777,7 +1720,7 @@ class ConstraintTest scope.push_back(v2.getId()); scope.push_back(v6.getId()); scope.push_back(v7.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v2.getDerivedDomain() == IntervalIntDomain(eint(0))); @@ -1789,7 +1732,7 @@ class ConstraintTest scope.push_back(v3.getId()); scope.push_back(v6.getId()); scope.push_back(v7.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v2.getDerivedDomain() == IntervalIntDomain(eint(0))); @@ -1800,7 +1743,7 @@ class ConstraintTest scope.push_back(trueVar.getId()); scope.push_back(v2.getId()); scope.push_back(v3.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v2.getDerivedDomain() == IntervalIntDomain(0, 2)); @@ -1812,7 +1755,7 @@ class ConstraintTest scope.push_back(v1.getId()); scope.push_back(v2.getId()); scope.push_back(v3.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v2.getDerivedDomain() == IntervalIntDomain(1)); @@ -1826,7 +1769,7 @@ class ConstraintTest scope.push_back(v3.getId()); scope.push_back(v6.getId()); scope.push_back(v7.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v3.getDerivedDomain().isSubsetOf(IntervalIntDomain(1, 27))); @@ -1836,7 +1779,7 @@ class ConstraintTest scope.push_back(falseVar.getId()); scope.push_back(v6.getId()); scope.push_back(v7.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(!ENGINE->constraintConsistent()); } @@ -1847,7 +1790,7 @@ class ConstraintTest scope.push_back(falseVar.getId()); scope.push_back(v2.getId()); scope.push_back(v3.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v2.getDerivedDomain() == IntervalIntDomain(0, 2)); @@ -1860,7 +1803,7 @@ class ConstraintTest scope.push_back(trueVar.getId()); scope.push_back(v0.getId()); scope.push_back(vA.getId()); - CondAllSameConstraint c0(LabelStr("CondAllSameConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllSameConstraint c0("CondAllSameConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(!ENGINE->constraintConsistent()); } @@ -1910,7 +1853,7 @@ class ConstraintTest scope.push_back(bothVar.getId()); scope.push_back(v0.getId()); scope.push_back(v1.getId()); - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().isSingleton()); @@ -1923,7 +1866,7 @@ class ConstraintTest scope.push_back(v0.getId()); scope.push_back(v6.getId()); scope.push_back(vA.getId()); - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(bothVar.getDerivedDomain().getSingletonValue()); @@ -1939,7 +1882,7 @@ class ConstraintTest scope.push_back(v6.getId()); scope.push_back(v9.getId()); scope.push_back(vA.getId()); - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().isSingleton()); @@ -1957,7 +1900,7 @@ class ConstraintTest scope.push_back(v9.getId()); // 3 10, 2, 0, 1 scope.push_back(vA.getId()); // 3 10, 2, 0, 1, 11 27 scope.push_back(vB.getId()); // 3 10, 2, 0, 1, 11 27, -1 - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(trueVar.getDerivedDomain().isSingleton()); @@ -1978,7 +1921,7 @@ class ConstraintTest scope.push_back(v6.getId()); // 1 10, 0 (inconsistent) scope.push_back(v9.getId()); // 1, 0, 1 scope.push_back(vA.getId()); // 1, 0, 1, 11 27 - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); // This next restriction is correct but the current implementation @@ -1998,7 +1941,7 @@ class ConstraintTest scope.push_back(v8.getId()); scope.push_back(v9.getId()); scope.push_back(vA.getId()); - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().getSingletonValue()); @@ -2014,7 +1957,7 @@ class ConstraintTest scope.push_back(bothVar.getId()); scope.push_back(vC.getId()); // 10 11 scope.push_back(vD.getId()); // 10 11, 10 11 - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().isSingleton()); @@ -2025,7 +1968,7 @@ class ConstraintTest scope.push_back(vC.getId()); // 10 11 scope.push_back(vD.getId()); // 10 11, 10 11 scope.push_back(vE.getId()); // 10 11, 10 11, 10 11 -> false: three vars but only two values - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(!bothVar.getDerivedDomain().getSingletonValue()); @@ -2039,7 +1982,7 @@ class ConstraintTest scope.push_back(vB.getId()); // 1 10, 11 27, -1 2 scope.push_back(vC.getId()); // 1 10, 11 27, -1 2, 10 11 scope.push_back(vD.getId()); // 1 10, 11 27, -1 2, 10 11, 10 11 - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); // 10 could be removed from v0 and 11 from vA, but current @@ -2070,7 +2013,7 @@ class ConstraintTest scope.push_back(vO.getId()); // 6 10, 1, 2, 6 27, 6 27, 6 27, 0, 11 27, -1, 10 11, 3, 10 12, 4, 6 7, 6 8, 9, 6 13, 5, 6 15, -2 6 scope.push_back(vP.getId()); // 10, 1, 2, 14 27, 14 27, 14 27, 0, 14 27, -1, 11, 3, 12, 4, 7, 8, 9, 13, 5, 14 15, 6, -2 scope.push_back(vQ.getId()); // 10, 1, 2, 16 27, 16 27, 16 27, 0, 16 27, -1, 11, 3, 12, 4, 7, 8, 9, 13, 5, 14, 6, -2, 15 - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v0.getDerivedDomain() == IntervalIntDomain(10)); @@ -2101,7 +2044,7 @@ class ConstraintTest scope.push_back(falseVar.getId()); scope.push_back(v6.getId()); // 0 scope.push_back(v7.getId()); // 0 - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v6.getDerivedDomain().getSingletonValue() == 0); @@ -2112,7 +2055,7 @@ class ConstraintTest scope.push_back(falseVar.getId()); scope.push_back(v3.getId()); // 0 27 scope.push_back(v4.getId()); // 0 27 - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v3.getDerivedDomain() == IntervalIntDomain(0, 27)); @@ -2125,7 +2068,7 @@ class ConstraintTest scope.push_back(vF.getId()); // 0 3 scope.push_back(vI.getId()); // 0 7 scope.push_back(vC.getId()); // 10 11 - CondAllDiffConstraint c0(LabelStr("CondAllDiffConstraint"), LabelStr("Default"), ENGINE, scope); + CondAllDiffConstraint c0("CondAllDiffConstraint", "Default", ENGINE, scope); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); // Only vF and vI overlap, so they have to be equal. @@ -2145,9 +2088,9 @@ class ConstraintTest Variable v2(ENGINE, IntervalIntDomain(10, 100)); Variable v3(ENGINE, IntervalIntDomain()); - ConstraintId c0 = (new EqualConstraint(LabelStr("eq"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())))->getId(); - ConstraintId c1 = (new EqualConstraint(LabelStr("eq"), LabelStr("Default"), ENGINE, makeScope(v1.getId(), v2.getId())))->getId(); - ConstraintId c2 = (new EqualConstraint(LabelStr("eq"), LabelStr("Default"), ENGINE, makeScope(v2.getId(), v3.getId())))->getId(); + ConstraintId c0 = (new EqualConstraint("eq", "Default", ENGINE, makeScope(v0.getId(), v1.getId())))->getId(); + ConstraintId c1 = (new EqualConstraint("eq", "Default", ENGINE, makeScope(v1.getId(), v2.getId())))->getId(); + ConstraintId c2 = (new EqualConstraint("eq", "Default", ENGINE, makeScope(v2.getId(), v3.getId())))->getId(); // Force an inconsistency v0.specify(1); @@ -2157,14 +2100,14 @@ class ConstraintTest // Reset, and delete constraint, but it should not matter v1.reset(); - delete (Constraint*) c2; + delete static_cast(c2); // Confirm still inconsistent res = ENGINE->propagate(); CPPUNIT_ASSERT(!res); - delete (Constraint*) c0; - delete (Constraint*) c1; + delete static_cast(c0); + delete static_cast(c1); return true; } @@ -2173,15 +2116,16 @@ class ConstraintTest * comparing the propagated domains with the expected output domains. */ static bool testArbitraryConstraints() { - CETestEngine testEngine; + CETestEngine testEngine; - ConstraintEngineId ce = ((ConstraintEngine*)testEngine.getComponent("ConstraintEngine"))->getId(); + ConstraintEngineId ce = + boost::polymorphic_cast(testEngine.getComponent("ConstraintEngine"))->getId(); // Input to this test: a list of constraint calls and expected output domains. std::list tests; // This kind of information can also be read from a file, as below. - std::string constraintName("Equal"); + std::string constraintName("eq"); std::list domains; domains.push_back(new IntervalIntDomain(1, 10)); // first input domain domains.push_back(new IntervalIntDomain(2, 10)); // expected value of first output domain @@ -2199,11 +2143,11 @@ class ConstraintTest // "CLibTestCases". // For each file, try twice with different relative paths since we don't know what // the current working directory is. - CPPUNIT_ASSERT(readTestCases(ce,getTestLoadLibraryPath() + std::string("/NewTestCases.xml"), tests) || - readTestCases(ce,std::string("ConstraintEngine/test/NewTestCases.xml"), tests)); + CPPUNIT_ASSERT(readTestCases(ce,getTestLoadLibraryPath() + "/NewTestCases.xml", tests) || + readTestCases(ce,"ConstraintEngine/test/NewTestCases.xml", tests)); - CPPUNIT_ASSERT(readTestCases(ce,getTestLoadLibraryPath() + std::string("/CLibTestCases.xml"), tests) || - readTestCases(ce,std::string("ConstraintEngine/test/CLibTestCases.xml"), tests)); + CPPUNIT_ASSERT(readTestCases(ce,getTestLoadLibraryPath() + "/CLibTestCases.xml", tests) || + readTestCases(ce,"ConstraintEngine/test/CLibTestCases.xml", tests)); bool retval = false; try { @@ -2239,7 +2183,7 @@ class ConstraintTest Variable v1(ENGINE, lockDomain); // Post constraint, and ensure it is propagated to equality with lock domain - LockConstraint c0(LabelStr("Lock"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + LockConstraint c0("Lock", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); CPPUNIT_ASSERT(ENGINE->propagate()); CPPUNIT_ASSERT(v0.getDerivedDomain() == lockDomain); @@ -2261,7 +2205,7 @@ class ConstraintTest static bool testNegateConstraint() { Variable v0(ENGINE, IntervalIntDomain()); Variable v1(ENGINE, IntervalIntDomain(MINUS_INFINITY, eint(0))); - NegateConstraint c0(LabelStr("NegateConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + NegateConstraint c0("NegateConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(ENGINE->constraintConsistent()); CPPUNIT_ASSERT(v0.getDerivedDomain() == IntervalIntDomain(0, PLUS_INFINITY)); @@ -2281,11 +2225,11 @@ class ConstraintTest static bool testUnaryQuery() { Variable v0(ENGINE, IntervalIntDomain()); Variable v1(ENGINE, IntervalIntDomain()); - NegateConstraint c0(LabelStr("NegateConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v1.getId())); + NegateConstraint c0("NegateConstraint", "Default", ENGINE, makeScope(v0.getId(), v1.getId())); CPPUNIT_ASSERT(!c0.isUnary()); Variable v2(ENGINE, IntervalIntDomain(1)); - NegateConstraint c1(LabelStr("NegateConstraint"), LabelStr("Default"), ENGINE, makeScope(v0.getId(), v2.getId())); + NegateConstraint c1("NegateConstraint", "Default", ENGINE, makeScope(v0.getId(), v2.getId())); CPPUNIT_ASSERT(c1.isUnary()); return true; @@ -2303,8 +2247,8 @@ class ConstraintTest Variable test(ENGINE, BoolDomain()); Variable arg1(ENGINE, baseDomain); Variable arg2(ENGINE, baseDomain); - TestEQ c1(LabelStr("TestEq"), - LabelStr("Default"), + TestEQ c1("TestEq", + "Default", ENGINE, makeScope(test.getId(), arg1.getId(), arg2.getId())); assert(ENGINE->propagate()); @@ -2330,7 +2274,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, IntervalIntDomain(5)); Variable v2(ENGINE, IntervalIntDomain(5)); - TestEQ c0(LabelStr("TestEQ"), LabelStr("Default"), + TestEQ c0("TestEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().isTrue()); @@ -2339,7 +2283,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, IntervalIntDomain(5)); Variable v2(ENGINE, IntervalIntDomain(6)); - TestEQ c0(LabelStr("TestEQ"), LabelStr("Default"), + TestEQ c0("TestEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().isFalse()); @@ -2348,7 +2292,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, IntervalIntDomain(5,10)); Variable v2(ENGINE, IntervalIntDomain(5, 20)); - TestEQ c0(LabelStr("TestEQ"), LabelStr("Default"), + TestEQ c0("TestEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(!v0.getDerivedDomain().isSingleton()); @@ -2373,7 +2317,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, LabelSet(LabelStr("C"))); Variable v2(ENGINE, LabelSet(LabelStr("E"))); - TestEQ c0(LabelStr("TestEQ"), LabelStr("Default"), + TestEQ c0("TestEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().isFalse()); @@ -2386,7 +2330,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, IntervalIntDomain(5)); Variable v2(ENGINE, IntervalIntDomain(6)); - TestLessThan c0(LabelStr("TestLessThan"), LabelStr("Default"), + TestLessThan c0("TestLessThan", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().isTrue()); @@ -2396,7 +2340,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, IntervalIntDomain(5)); Variable v2(ENGINE, IntervalIntDomain(5)); - TestLessThan c0(LabelStr("TestLessThan"), LabelStr("Default"), + TestLessThan c0("TestLessThan", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().isFalse()); @@ -2406,7 +2350,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, IntervalIntDomain(5, 10)); Variable v2(ENGINE, IntervalIntDomain(5)); - TestLessThan c0(LabelStr("TestLessThan"), LabelStr("Default"), + TestLessThan c0("TestLessThan", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().isFalse()); @@ -2416,7 +2360,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, IntervalIntDomain(4, 10)); Variable v2(ENGINE, IntervalIntDomain(11, 20)); - TestLessThan c0(LabelStr("TestLessThan"), LabelStr("Default"), + TestLessThan c0("TestLessThan", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().isTrue()); @@ -2426,7 +2370,7 @@ class ConstraintTest Variable v0(ENGINE, BoolDomain()); Variable v1(ENGINE, IntervalIntDomain(4, 10)); Variable v2(ENGINE, IntervalIntDomain(8, 20)); - TestLessThan c0(LabelStr("TestLessThan"), LabelStr("Default"), + TestLessThan c0("TestLessThan", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); CPPUNIT_ASSERT(!v0.getDerivedDomain().isSingleton()); @@ -2441,7 +2385,7 @@ class ConstraintTest Variable v1(ENGINE, IntervalIntDomain(5)); Variable v2(ENGINE, IntervalIntDomain(5)); - TestLEQ c0(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c0("TestLEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); @@ -2453,7 +2397,7 @@ class ConstraintTest Variable v1(ENGINE, IntervalIntDomain(5)); Variable v2(ENGINE, IntervalIntDomain(4)); - TestLEQ c0(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c0("TestLEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); ENGINE->propagate(); @@ -2465,7 +2409,7 @@ class ConstraintTest Variable v1(ENGINE, IntervalIntDomain(4)); Variable v2(ENGINE, IntervalIntDomain(6)); - TestLEQ c0(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c0("TestLEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); CPPUNIT_ASSERT(ENGINE->propagate()); CPPUNIT_ASSERT(v0.getDerivedDomain().isTrue()); @@ -2476,7 +2420,7 @@ class ConstraintTest Variable v1(ENGINE, IntervalIntDomain(0, 10)); Variable v2(ENGINE, IntervalIntDomain(0, 10)); - TestLEQ c0(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c0("TestLEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); CPPUNIT_ASSERT(ENGINE->propagate()); @@ -2489,7 +2433,7 @@ class ConstraintTest Variable v1(ENGINE, IntervalIntDomain(0, 10)); Variable v2(ENGINE, IntervalIntDomain(11, 20)); - TestLEQ c0(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c0("TestLEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); CPPUNIT_ASSERT(!ENGINE->propagate()); @@ -2500,7 +2444,7 @@ class ConstraintTest Variable v1(ENGINE, IntervalIntDomain(5, 10)); Variable v2(ENGINE, IntervalIntDomain(2, 4)); - TestLEQ c0(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c0("TestLEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); CPPUNIT_ASSERT(!ENGINE->propagate()); @@ -2511,7 +2455,7 @@ class ConstraintTest Variable v1(ENGINE, IntervalIntDomain(0, 10)); Variable v2(ENGINE, IntervalIntDomain(11, 20)); - TestLEQ c0(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c0("TestLEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); CPPUNIT_ASSERT(ENGINE->propagate()); @@ -2523,7 +2467,7 @@ class ConstraintTest Variable v1(ENGINE, IntervalIntDomain(10, 20)); Variable v2(ENGINE, IntervalIntDomain(0, 9)); - TestLEQ c0(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c0("TestLEQ", "Default", ENGINE, makeScope(v0.getId(), v1.getId(), v2.getId())); CPPUNIT_ASSERT(ENGINE->propagate()); @@ -2547,32 +2491,32 @@ class ConstraintTest Variable start_x(ENGINE, IntervalDomain()); Variable start_y(ENGINE, IntervalDomain()); - AddEqualConstraint c0(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, + AddEqualConstraint c0("AddEqualConstraint", "Default", ENGINE, makeScope(goalBox_leftBottomX.getId(), goalBoxTolerance.getId(), goalX.getId())); - AddEqualConstraint c1(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, + AddEqualConstraint c1("AddEqualConstraint", "Default", ENGINE, makeScope(goalBox_leftBottomY.getId(), goalBoxTolerance.getId(), goalY.getId())); - AddEqualConstraint c2(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, + AddEqualConstraint c2("AddEqualConstraint", "Default", ENGINE, makeScope(goalX.getId(), goalBoxTolerance.getId(), goalBox_rightTopX.getId())); - AddEqualConstraint c3(LabelStr("AddEqualConstraint"), LabelStr("Default"), ENGINE, + AddEqualConstraint c3("AddEqualConstraint", "Default", ENGINE, makeScope(goalY.getId(), goalBoxTolerance.getId(), goalBox_rightTopY.getId())); Variable right_of_goalBox_left(ENGINE, BoolDomain()); - TestLEQ c4(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c4("TestLEQ", "Default", ENGINE, makeScope(right_of_goalBox_left.getId(), goalBox_leftBottomX.getId(), start_x.getId())); Variable left_of_goalBox_right(ENGINE, BoolDomain()); - TestLEQ c5(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c5("TestLEQ", "Default", ENGINE, makeScope(left_of_goalBox_right.getId(), start_x.getId(), goalBox_rightTopX.getId())); Variable over_goalBox_bottom(ENGINE, BoolDomain()); - TestLEQ c6(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c6("TestLEQ", "Default", ENGINE, makeScope(over_goalBox_bottom.getId(), start_y.getId(), goalBox_leftBottomY.getId())); Variable under_goalBox_bottom(ENGINE, BoolDomain()); - TestLEQ c7(LabelStr("TestLEQ"), LabelStr("Default"), + TestLEQ c7("TestLEQ", "Default", ENGINE, makeScope(under_goalBox_bottom.getId(), start_y.getId(), goalBox_rightTopY.getId())); assert(ENGINE->propagate()); @@ -2592,7 +2536,8 @@ class ConstraintTypeTest private: static bool testAllocation(){ CETestEngine testEngine; - const ConstraintEngineId& ce=((ConstraintEngine*)testEngine.getComponent("ConstraintEngine"))->getId(); + const ConstraintEngineId ce= + boost::polymorphic_cast(testEngine.getComponent("ConstraintEngine"))->getId(); std::vector variables; // v0 == v1 @@ -2600,10 +2545,10 @@ class ConstraintTypeTest variables.push_back(v0.getId()); Variable v1(ce, IntervalIntDomain(1, 1)); variables.push_back(v1.getId()); - ConstraintId c0 = ce->createConstraint(LabelStr("Equal"), variables); + ConstraintId c0 = ce->createConstraint("eq", variables); ce->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().getSingletonValue() == 1); - delete (Constraint*) c0; + delete static_cast(c0); return true; } }; @@ -2733,10 +2678,11 @@ class EquivalenceClassTest{ } static bool testEqualityConstraintPropagator(){ - CETestEngine engine; - ConstraintEngineId ce = ((ConstraintEngine*)engine.getComponent("ConstraintEngine"))->getId(); + CETestEngine engine; + ConstraintEngineId ce = + boost::polymorphic_cast(engine.getComponent("ConstraintEngine"))->getId(); - new EqualityConstraintPropagator(LabelStr("EquivalenceClass"), ce); + new EqualityConstraintPropagator("EquivalenceClass", ce); { std::vector variables; // v0 == v1 @@ -2744,7 +2690,7 @@ class EquivalenceClassTest{ variables.push_back(v0.getId()); Variable v1(ce, IntervalIntDomain(-100, 100)); variables.push_back(v1.getId()); - EqualConstraint c0(LabelStr("EqualConstraint"), LabelStr("EquivalenceClass"), ce, variables); + EqualConstraint c0("EqualConstraint", "EquivalenceClass", ce, variables); ce->propagate(); variables.clear(); @@ -2752,7 +2698,7 @@ class EquivalenceClassTest{ variables.push_back(v2.getId()); Variable v3(ce, IntervalIntDomain(10, 200)); variables.push_back(v3.getId()); - EqualConstraint c1(LabelStr("EqualConstraint"), LabelStr("EquivalenceClass"), ce, variables); + EqualConstraint c1("EqualConstraint", "EquivalenceClass", ce, variables); ce->propagate(); CPPUNIT_ASSERT(v0.getDerivedDomain().getUpperBound() == 10); @@ -2761,7 +2707,7 @@ class EquivalenceClassTest{ variables.clear(); variables.push_back(v3.getId()); variables.push_back(v1.getId()); - EqualConstraint c2(LabelStr("EqualConstraint"), LabelStr("EquivalenceClass"), ce, variables); + EqualConstraint c2("EqualConstraint", "EquivalenceClass", ce, variables); ce->propagate(); CPPUNIT_ASSERT(ce->constraintConsistent()); @@ -2771,11 +2717,11 @@ class EquivalenceClassTest{ Variable v4(ce, IntervalIntDomain(1, 9)); variables.push_back(v3.getId()); variables.push_back(v4.getId()); - ConstraintId c3((new EqualConstraint(LabelStr("EqualConstraint"), LabelStr("EquivalenceClass"), ce, variables))->getId()); + ConstraintId c3((new EqualConstraint("EqualConstraint", "EquivalenceClass", ce, variables))->getId()); ce->propagate(); CPPUNIT_ASSERT(ce->provenInconsistent()); - delete (Constraint*) c3; + delete static_cast(c3); CPPUNIT_ASSERT(ce->pending()); ce->propagate(); CPPUNIT_ASSERT(ce->constraintConsistent()); @@ -2785,6 +2731,119 @@ class EquivalenceClassTest{ } }; +#include "ConstraintTypeChecking.hh" + +namespace { +class DummyConstraint : public Constraint { + public: + DummyConstraint(const std::string& name, const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& scope) + : Constraint(name, propagatorName, constraintEngine, scope) {} + void handleExecute() {} +}; + +class DummyDT : public DataType { + public: + DummyDT() : DataType(DummyDT::NAME().c_str()) { + m_minDelta = 0.5; + m_baseDomain = NULL;//new DummyDomain(getId()); + } + virtual ~DummyDT() {} + + bool isNumeric() const {return true;} + bool isBool() const {return false;} + bool isString() const {return false;} + + edouble createValue(const std::string& ) const {return 1.0;} + + static const std::string& NAME() { + static std::string sl_name("DummyDT"); + return sl_name; + } + + static const DataTypeId instance() { + + return sl_instance.getId(); + } + static DummyDT sl_instance; +}; +DummyDT DummyDT::sl_instance; +} +class TypeCheckingTests { + public: + static bool test() { + testNArgs(); + testAtLeastNArgs(); + testAllNumeric(); + testTwoNumericArgs(); + return true; + } + private: + static bool testNArgs() { + typedef DataTypeCheck > TwoArgs; + TwoArgs checker("TwoArgs", "Default"); + std::vector argTypes; + for(int i = 0; i < 4; ++i) { + if(i == 2) { + CPPUNIT_ASSERT_NO_THROW(checker.checkArgTypes(argTypes)); + } + else { + CPPUNIT_ASSERT_THROW(checker.checkArgTypes(argTypes), std::string); + } + argTypes.push_back(DummyDT::instance()); + } + return true; + } + static bool testAtLeastNArgs() { + typedef DataTypeCheck > TwoArgs; + TwoArgs checker("TwoArgs", "Default"); + std::vector argTypes; + for(int i = 0; i < 4; ++i) { + if(i >= 2) { + CPPUNIT_ASSERT_NO_THROW(checker.checkArgTypes(argTypes)); + } + else { + CPPUNIT_ASSERT_THROW(checker.checkArgTypes(argTypes), std::string); + } + argTypes.push_back(DummyDT::instance()); + } + return true; + } + static bool testAllNumeric() { + typedef DataTypeCheck > AllNumeric; + AllNumeric checker("AllNumeric", "Default"); + std::vector argTypes; + CPPUNIT_ASSERT_NO_THROW(checker.checkArgTypes(argTypes)); + argTypes.push_back(FloatDT::instance()); + CPPUNIT_ASSERT_NO_THROW(checker.checkArgTypes(argTypes)); + argTypes.push_back(IntDT::instance()); + CPPUNIT_ASSERT_NO_THROW(checker.checkArgTypes(argTypes)); + argTypes.push_back(BoolDT::instance()); //Is this right? ~MJI + CPPUNIT_ASSERT_NO_THROW(checker.checkArgTypes(argTypes)); + argTypes.push_back(StringDT::instance()); + CPPUNIT_ASSERT_THROW(checker.checkArgTypes(argTypes), std::string); + return true; + } + static bool testTwoNumericArgs() { + typedef DataTypeCheck, All > > AllNumeric; + AllNumeric checker("AllNumeric", "Default"); + std::vector argTypes; + CPPUNIT_ASSERT_THROW(checker.checkArgTypes(argTypes), std::string); + argTypes.push_back(FloatDT::instance()); + CPPUNIT_ASSERT_THROW(checker.checkArgTypes(argTypes), std::string); + argTypes.push_back(IntDT::instance()); + CPPUNIT_ASSERT_NO_THROW(checker.checkArgTypes(argTypes)); + argTypes.push_back(IntDT::instance()); //Is this right? ~MJI + CPPUNIT_ASSERT_THROW(checker.checkArgTypes(argTypes), std::string); + argTypes.pop_back(); + argTypes.pop_back(); + argTypes.push_back(StringDT::instance()); + CPPUNIT_ASSERT_THROW(checker.checkArgTypes(argTypes), std::string); + return true; + } +}; + void ConstraintEngineModuleTests::cppSetup(void) { setTestLoadLibraryPath("."); @@ -2830,3 +2889,51 @@ void ConstraintEngineModuleTests::equivalenceClassTests(void) EquivalenceClassTest::test(); } +void ConstraintEngineModuleTests::typeCheckingTests(void) { + TypeCheckingTests::test(); +} + +class ConfigAllowViolationTestEngine : public EngineBase { + public: + ConfigAllowViolationTestEngine(const std::string& configFile); + virtual ~ConfigAllowViolationTestEngine(); + const ConstraintEngineId getConstraintEngine() const; + protected: + void createModules(); +}; + +ConfigAllowViolationTestEngine::ConfigAllowViolationTestEngine(const std::string& configFile) { + CPPUNIT_ASSERT(getConfig()->readFromXML(configFile.c_str(), true) == 1); + createModules(); + doStart(); +} + +ConfigAllowViolationTestEngine::~ConfigAllowViolationTestEngine() { + doShutdown(); +} + +void ConfigAllowViolationTestEngine::createModules() { + addModule((new ModuleConstraintEngine())->getId()); + addModule((new ModuleConstraintLibrary())->getId()); + +} + +const ConstraintEngineId ConfigAllowViolationTestEngine::getConstraintEngine() const { + return (boost::polymorphic_cast(getComponent("ConstraintEngine")))->getId(); +} + +class ConfigAllowViolationsTest { + public: + static bool test() { + ConfigAllowViolationTestEngine allowed(getTestLoadLibraryPath() + "/violations-allowed.xml"); + ConfigAllowViolationTestEngine unallowed(getTestLoadLibraryPath() + "/violations-unallowed.xml"); + ConfigAllowViolationTestEngine none(getTestLoadLibraryPath() + "/violations-missing.xml"); + CPPUNIT_ASSERT(allowed.getConstraintEngine()->getAllowViolations()); + CPPUNIT_ASSERT(!unallowed.getConstraintEngine()->getAllowViolations()); + CPPUNIT_ASSERT(!none.getConstraintEngine()->getAllowViolations()); + return true; + } +}; +void ConstraintEngineModuleTests::configAllowViolationsTest() { + ConfigAllowViolationsTest::test(); +} diff --git a/src/PLASMA/ConstraintEngine/test/ce-test-module.hh b/src/PLASMA/ConstraintEngine/test/ce-test-module.hh index 88de9328a..95e7e361f 100644 --- a/src/PLASMA/ConstraintEngine/test/ce-test-module.hh +++ b/src/PLASMA/ConstraintEngine/test/ce-test-module.hh @@ -17,6 +17,8 @@ class ConstraintEngineModuleTests : public CppUnit::TestFixture { CPPUNIT_TEST(constraintTests); CPPUNIT_TEST(constraintFactoryTests); CPPUNIT_TEST(equivalenceClassTests); + CPPUNIT_TEST(typeCheckingTests); + CPPUNIT_TEST(configAllowViolationsTest); CPPUNIT_TEST_SUITE_END(); public: @@ -39,6 +41,8 @@ public: void constraintTests(); void constraintFactoryTests(); void equivalenceClassTests(); + void typeCheckingTests(); + void configAllowViolationsTest(); }; #endif /* H_CE_MODULE_TESTS */ diff --git a/src/PLASMA/ConstraintEngine/test/domain-tests.cc b/src/PLASMA/ConstraintEngine/test/domain-tests.cc index 97c31c0f8..708fc5fba 100644 --- a/src/PLASMA/ConstraintEngine/test/domain-tests.cc +++ b/src/PLASMA/ConstraintEngine/test/domain-tests.cc @@ -2,12 +2,136 @@ #include "LabelStr.hh" #include "Domains.hh" #include "DomainListener.hh" +#include "TestUtils.hh" #include "module-tests.hh" #include #include namespace EUROPA { +namespace { +class DummyDT : public DataType { + public: + DummyDT(); + virtual ~DummyDT() {} + + bool isNumeric() const {return true;} + bool isBool() const {return false;} + bool isString() const {return false;} + + edouble createValue(const std::string& ) const {return 1.0;} + + static const std::string& NAME() { + static std::string sl_name("DummyDT"); + return sl_name; + } + static const DataTypeId instance(); + +}; +} + +class DummyDomain : public Domain { + public: + DummyDomain(const DataTypeId id = DummyDT::instance()) : Domain(id, false, true) {} + bool isEmpty() const {return false;} + bool isFinite() const {return true;} + bool isSingleton() const {return true;} + size_type getSize() const {return 1;} + edouble getUpperBound() const {return 1.0;} + edouble getLowerBound() const {return 1.0;} + bool getBounds(edouble& lb, edouble& ub) const {lb = getLowerBound(); ub = getUpperBound(); return false;} + void getValues(std::list& results) const {results.clear(); results.push_back(1.0);} + edouble getSingletonValue() const {return 1.0;} + void empty() {} + void set(edouble) {} + void reset(const Domain&) {} + void relax(const Domain&) {} + void relax(edouble ) {} + void insert(edouble ) {} + void insert(const std::list& ) {} + void remove(edouble ) {} + bool intersect(const Domain& ) {return false;} + bool intersect(const edouble , const edouble ) {return false;} + bool difference(const Domain& ) {return false;} + bool equate(Domain& ) {return false;} + bool isMember(edouble value) const {return value == 1.0;} + bool isSubsetOf(const Domain& dom) const {return dom.isMember(1.0);} + bool intersects(const Domain& dom) const {return isSubsetOf(dom);} + Domain* copy() const; + bool convertToMemberValue(const std::string& , edouble& ) const { + return false; + } + void testPrecision(const edouble& ) const {} + private: +}; + +Domain* DummyDomain::copy() const {return new DummyDomain(DummyDT::instance());} + +const DataTypeId DummyDT::instance() { + static DummyDT sl_instance; + return sl_instance.getId(); +} + +DummyDT::DummyDT() : DataType(DummyDT::NAME().c_str()) { + m_minDelta = 0.5; + m_baseDomain = new DummyDomain(getId()); +} + +class IntrinsicsTest { + public: + static bool test() { + unused(DataTypeId dt) = DummyDT::instance(); + EUROPA_runTest(lessThanTest); + EUROPA_runTest(equalTest); + EUROPA_runTest(lessThanOrEqualTest); + return true; + }; + static bool lessThanTest() { + DummyDomain dom; + CPPUNIT_ASSERT(dom.minDelta() == 0.5); + CPPUNIT_ASSERT(dom.lt(0.0, 0.5)); + CPPUNIT_ASSERT(!dom.lt(0.0, 0.4)); + CPPUNIT_ASSERT(dom.lt(0.0, 0.6)); + CPPUNIT_ASSERT(!dom.lt(0.0, 0.0)); + + CPPUNIT_ASSERT(dom.lt(1.0, 1.5)); + CPPUNIT_ASSERT(!dom.lt(1.0, 1.4)); + CPPUNIT_ASSERT(dom.lt(1.0, 1.6)); + CPPUNIT_ASSERT(!dom.lt(1.0, 1.0)); + + return true; + } + + static bool equalTest() { + DummyDomain dom; + CPPUNIT_ASSERT(dom.eq(0.0, 0.0)); + CPPUNIT_ASSERT(!dom.eq(0.0, 0.5)); + CPPUNIT_ASSERT(dom.eq(0.0, 0.4)); + CPPUNIT_ASSERT(!dom.eq(0.0, 0.6)); + + CPPUNIT_ASSERT(dom.eq(1.0, 1.0)); + CPPUNIT_ASSERT(!dom.eq(1.0, 1.5)); + CPPUNIT_ASSERT(dom.eq(1.0, 1.4)); + CPPUNIT_ASSERT(!dom.eq(1.0, 1.6)); + return true; + } + static bool lessThanOrEqualTest() { + DummyDomain dom; + CPPUNIT_ASSERT(dom.leq(0.0, 0.5)); + CPPUNIT_ASSERT(dom.leq(0.0, 0.4)); + CPPUNIT_ASSERT(dom.leq(0.0, 0.6)); + CPPUNIT_ASSERT(dom.leq(0.0, 0.0)); + CPPUNIT_ASSERT(!dom.leq(0.5, 0.0)); + + CPPUNIT_ASSERT(dom.leq(1.0, 1.5)); + CPPUNIT_ASSERT(dom.leq(1.0, 1.4)); + CPPUNIT_ASSERT(dom.leq(1.0, 1.6)); + CPPUNIT_ASSERT(dom.leq(1.0, 1.0)); + CPPUNIT_ASSERT(!dom.leq(1.5, 1.0)); + return true; + } +}; + class ChangeListener : public DomainListener { public: ChangeListener() @@ -62,7 +186,8 @@ namespace EUROPA { IntervalDomain realDomain(10.2 ,20.4); CPPUNIT_ASSERT(!realDomain.isEmpty()); CPPUNIT_ASSERT(!realDomain.isFinite()); - CPPUNIT_ASSERT_EQUAL((Domain::size_type) cast_int(PLUS_INFINITY), realDomain.getSize()); + CPPUNIT_ASSERT_EQUAL(static_cast(cast_int(PLUS_INFINITY)), + realDomain.getSize()); IntervalIntDomain intDomain(10, 20); CPPUNIT_ASSERT(intDomain.isFinite()); @@ -842,7 +967,7 @@ namespace EUROPA { } static bool testBasicLabelOperations() { - int initialCount = EUROPA::LabelStr::getSize(); + unsigned long initialCount = EUROPA::LabelStr::getSize(); EUROPA::LabelStr dt_l1("DT_L1"); EUROPA::LabelStr dt_l2("DT_L2"); EUROPA::LabelStr dt_l3("DT_L3"); @@ -1257,7 +1382,7 @@ namespace EUROPA { EUROPA_runTest(testIntersection); EUROPA_runTest(testSubset); EUROPA_runTest(testIntDomain); - EUROPA_runTest(testDomainComparatorConfiguration); + // EUROPA_runTest(testDomainComparatorConfiguration); EUROPA_runTest(testCopying); EUROPA_runTest(testSymbolicVsNumeric); return(true); @@ -1429,7 +1554,7 @@ namespace EUROPA { copyPtr = customDom.copy(); CPPUNIT_ASSERT(copyPtr->isBool()); - CPPUNIT_ASSERT(copyPtr->getTypeName().toString() == BoolDT::NAME()); + CPPUNIT_ASSERT(copyPtr->getTypeName() == BoolDT::NAME()); CPPUNIT_ASSERT((dynamic_cast(copyPtr))->isTrue()); CPPUNIT_ASSERT(!(dynamic_cast(copyPtr))->isFalse()); delete copyPtr; @@ -1456,7 +1581,7 @@ namespace EUROPA { NumericDomain oneDom(2.7); // Singletn copyPtr = emptyOpen.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName() == LabelStr("float")); + CPPUNIT_ASSERT(copyPtr->getTypeName() == "float"); CPPUNIT_ASSERT(copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isNumeric()); CPPUNIT_ASSERT(copyPtr->isEnumerated()); @@ -1468,7 +1593,7 @@ namespace EUROPA { delete copyPtr; copyPtr = fourDom.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName() == LabelStr("float")); + CPPUNIT_ASSERT(copyPtr->getTypeName() == "float"); CPPUNIT_ASSERT(copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isEnumerated()); copyPtr->close(); @@ -1477,7 +1602,7 @@ namespace EUROPA { delete copyPtr; copyPtr = fiveDom.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName() == LabelStr("float")); + CPPUNIT_ASSERT(copyPtr->getTypeName() == "float"); CPPUNIT_ASSERT(!copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isEnumerated()); CPPUNIT_ASSERT(copyPtr->getSize() == 5); @@ -1485,7 +1610,7 @@ namespace EUROPA { delete copyPtr; copyPtr = oneDom.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName() == LabelStr("float")); + CPPUNIT_ASSERT(copyPtr->getTypeName() == "float"); CPPUNIT_ASSERT(!copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isEnumerated()); CPPUNIT_ASSERT(copyPtr->isSingleton()); @@ -1510,7 +1635,7 @@ namespace EUROPA { // Domains containing infinities should also be tested. copyPtr = empty.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName() == LabelStr("float")); + CPPUNIT_ASSERT(copyPtr->getTypeName() == "float"); CPPUNIT_ASSERT(!copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isNumeric()); CPPUNIT_ASSERT(!copyPtr->isEnumerated()); @@ -1531,7 +1656,7 @@ namespace EUROPA { delete copyPtr; copyPtr = one2ten.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName() == LabelStr("float")); + CPPUNIT_ASSERT(copyPtr->getTypeName() == "float"); CPPUNIT_ASSERT(!copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isNumeric()); CPPUNIT_ASSERT(!copyPtr->isEnumerated()); @@ -1550,7 +1675,7 @@ namespace EUROPA { delete copyPtr; copyPtr = four.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName().toString() == IntDT::NAME()); + CPPUNIT_ASSERT(copyPtr->getTypeName() == IntDT::NAME()); CPPUNIT_ASSERT(!copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isNumeric()); CPPUNIT_ASSERT(!copyPtr->isEnumerated()); @@ -1584,7 +1709,7 @@ namespace EUROPA { // domains containing infinities should also be tested copyPtr = empty.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName() == LabelStr("int")); + CPPUNIT_ASSERT(copyPtr->getTypeName() == "int"); CPPUNIT_ASSERT(!copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isNumeric()); CPPUNIT_ASSERT(!copyPtr->isEnumerated()); @@ -1605,7 +1730,7 @@ namespace EUROPA { delete copyPtr; copyPtr = one2ten.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName() == LabelStr("int")); + CPPUNIT_ASSERT(copyPtr->getTypeName() == "int"); CPPUNIT_ASSERT(!copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isNumeric()); CPPUNIT_ASSERT(!copyPtr->isEnumerated()); @@ -1626,7 +1751,7 @@ namespace EUROPA { delete copyPtr; copyPtr = four.copy(); - CPPUNIT_ASSERT(copyPtr->getTypeName().toString() == IntDT::NAME()); + CPPUNIT_ASSERT(copyPtr->getTypeName() == IntDT::NAME()); CPPUNIT_ASSERT(!copyPtr->isOpen()); CPPUNIT_ASSERT(copyPtr->isNumeric()); CPPUNIT_ASSERT(!copyPtr->isEnumerated()); @@ -1656,7 +1781,7 @@ namespace EUROPA { public: BogusComparator(): DomainComparator(){} - bool canCompare(const Domain& domx, const Domain& domy) const { + bool canCompare(const Domain& , const Domain&) const { return false; } @@ -1813,6 +1938,7 @@ bool DomainTests::test() { /*runTestSuite(EUROPA::IntervalDomainTest::test); runTestSuite(EUROPA::EnumeratedDomainTest::test); runTestSuite(EUROPA::MixedTypeTest::test);*/ + EUROPA::IntrinsicsTest::test(); EUROPA::IntervalDomainTest::test(); EUROPA::EnumeratedDomainTest::test(); EUROPA::MixedTypeTest::test(); diff --git a/src/PLASMA/ConstraintEngine/test/domain-tests.hh b/src/PLASMA/ConstraintEngine/test/domain-tests.hh index 51334c3fe..848f05f62 100644 --- a/src/PLASMA/ConstraintEngine/test/domain-tests.hh +++ b/src/PLASMA/ConstraintEngine/test/domain-tests.hh @@ -1,5 +1,5 @@ -#ifndef _H_DomainTests -#define _H_DomainTests +#ifndef H_DomainTests +#define H_DomainTests class DomainTests { public: diff --git a/src/PLASMA/ConstraintEngine/test/module-tests.cc b/src/PLASMA/ConstraintEngine/test/module-tests.cc index 76b9d4b2d..865c2b488 100644 --- a/src/PLASMA/ConstraintEngine/test/module-tests.cc +++ b/src/PLASMA/ConstraintEngine/test/module-tests.cc @@ -1,22 +1,22 @@ -#include "ce-test-module.hh" +#include "ce-test-module.hh" #include "module-tests.hh" -#include "DataTypes.hh" -#include "CppUnitUtils.hh" - -CPPUNIT_TEST_SUITE_REGISTRATION( ConstraintEngineModuleTests ); - -using namespace EUROPA; - -int main( int argc, char **argv) -{ - // Init data types so that id counts don't fail - VoidDT::instance(); - BoolDT::instance(); - IntDT::instance(); - FloatDT::instance(); - StringDT::instance(); - SymbolDT::instance(); - - RUN_CPP_UNIT_MODULE(true); -} +#include "DataTypes.hh" +#include "CppUnitUtils.hh" + +CPPUNIT_TEST_SUITE_REGISTRATION( ConstraintEngineModuleTests ); + +using namespace EUROPA; + +int main( int, char **) +{ + // Init data types so that id counts don't fail + VoidDT::instance(); + BoolDT::instance(); + IntDT::instance(); + FloatDT::instance(); + StringDT::instance(); + SymbolDT::instance(); + + RUN_CPP_UNIT_MODULE(true); +} diff --git a/src/PLASMA/ConstraintEngine/test/module-tests.hh b/src/PLASMA/ConstraintEngine/test/module-tests.hh index 448ba6de5..b61da44e1 100644 --- a/src/PLASMA/ConstraintEngine/test/module-tests.hh +++ b/src/PLASMA/ConstraintEngine/test/module-tests.hh @@ -1,5 +1,5 @@ -#ifndef _H_ModuleTests -#define _H_ModuleTests +#ifndef H_ModuleTests +#define H_ModuleTests #include #include diff --git a/src/PLASMA/ConstraintEngine/test/violations-allowed.xml b/src/PLASMA/ConstraintEngine/test/violations-allowed.xml new file mode 100644 index 000000000..145dd12af --- /dev/null +++ b/src/PLASMA/ConstraintEngine/test/violations-allowed.xml @@ -0,0 +1,5 @@ + + + true + + diff --git a/src/PLASMA/ConstraintEngine/test/violations-missing.xml b/src/PLASMA/ConstraintEngine/test/violations-missing.xml new file mode 100644 index 000000000..5fe71ae4e --- /dev/null +++ b/src/PLASMA/ConstraintEngine/test/violations-missing.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/PLASMA/ConstraintEngine/test/violations-unallowed.xml b/src/PLASMA/ConstraintEngine/test/violations-unallowed.xml new file mode 100644 index 000000000..2e65db167 --- /dev/null +++ b/src/PLASMA/ConstraintEngine/test/violations-unallowed.xml @@ -0,0 +1,5 @@ + + + false + + diff --git a/src/PLASMA/NDDL/CMakeLists.txt b/src/PLASMA/NDDL/CMakeLists.txt index b9af9f3dd..4b25b229d 100644 --- a/src/PLASMA/NDDL/CMakeLists.txt +++ b/src/PLASMA/NDDL/CMakeLists.txt @@ -1,31 +1,78 @@ include(EuropaModule) +set(ANTLR_FIND_REQUIRED TRUE) +include(FindANTLR) +if(NOT ANTLR_FOUND) + message(FATAL_ERROR "ANTLR not found!") +endif(NOT ANTLR_FOUND) + +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) + set(nddl_parser_sources NDDL3.tokens NDDL3Lexer.cpp NDDL3Lexer.h NDDL3Parser.cpp NDDL3Parser.h) set(nddl_tree_sources NDDL3Tree.cpp NDDL3Tree.h NDDL3Tree.tokens) +set(antlr_generated_parser_files + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3.tokens + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Lexer.c + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Lexer.h + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Parser.c + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Parser.h) +set(antlr_generated_tree_files + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Tree.c + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Tree.h + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Tree.tokens + ) +set(antlr_generated_source_files + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Lexer.c + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Parser.c + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Tree.c) + +set_property(SOURCE ${antlr_generated_source_files} PROPERTY LANGUAGE CXX) #TEMPORARY -set(ANTLR3_JAR /opt/local/share/java/antlr.jar) +#set(ANTLR3_JAR /opt/local/share/java/antlr.jar) +set(nddl_parser_sources_path + #${CMAKE_CURRENT_BINARY_DIR}/NDDL3.tokens + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Lexer.c + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Lexer.h + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Parser.c + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Parser.h) +set(nddl_tree_sources_path + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Tree.c + ${CMAKE_CURRENT_BINARY_DIR}/NDDL3Tree.h + #${CMAKE_CURRENT_BINARY_DIR}/NDDL3Tree.tokens + ) -add_custom_command(OUTPUT ${nddl_parser_sources} - COMMAND ${JAVA} -cp ${ANTLR3_JAR} ${JREFLAGS} org.antlr.Tool -fo ${CMAKE_CURRENT_SOURCE_DIR}/base antlr/NDDL3.g - DEPENDS antlr/NDDL3.g) -add_custom_command(OUTPUT ${nddl_tree_sources} - COMMAND ${JAVA} -cp ${ANTLR3_JAR} ${JREFLAGS} org.antlr.Tool -fo ${CMAKE_CURRENT_SOURCE_DIR}/base antlr/NDDL3Tree.g - DEPENDS antlr/NDDL3Tree.g) +# add_custom_command(OUTPUT ${nddl_parser_sources} +add_custom_command(OUTPUT ${antlr_generated_parser_files} + COMMAND ${Java_JAVA_EXECUTABLE} -cp ${ANTLR_JAR} ${JREFLAGS} org.antlr.Tool -fo ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/base/antlr/NDDL3.g + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/base/antlr/NDDL3.g) +add_custom_command(OUTPUT ${antlr_generated_tree_files} + COMMAND ${Java_JAVA_EXECUTABLE} -cp ${ANTLR_JAR} ${JREFLAGS} org.antlr.Tool -fo ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/base/antlr/NDDL3Tree.g + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/base/antlr/NDDL3Tree.g + ${antlr_generated_parser_files}) -set(internal_dependencies RulesEngine TemporalNetwork PlanDatabase ConstraintEngine Utils TinyXml) + +set(internal_dependencies RulesEngine PlanDatabase TemporalNetwork ConstraintEngine Utils) set(root_sources ModuleNddl.cc) -set(base_sources ${nddl_parser_sources} ${nddl_tree_sources} NddlRules.cc NddlToken.cc NddlUtils.cc) +set(base_sources NddlRules.cc NddlToken.cc NddlUtils.cc) set(component_sources Interpreter.cc NddlInterpreter.cc NddlTestEngine.cc) set(test_sources module-tests.cc nddl-test-module.cc) common_module_prepends("${base_sources}" "${component_sources}" "${test_sources}" base_sources component_sources test_sources) - +list(APPEND base_sources ${antlr_generated_source_files}) declare_module(NDDL "${root_sources}" "${base_sources}" "${component_sources}" "${test_sources}" "${internal_dependencies}" "") #setup ANTLR link/headers? -target_link_libraries("NDDL${EUROPA_SUFFIX}" antlr3c) -target_link_libraries("NDDL-test${EUROPA_SUFFIX}" antlr3c) +append_target_property("NDDL${EUROPA_SUFFIX}" INCLUDE_DIRECTORIES ";${ANTLR_INCLUDE_DIR}") +append_target_property("NDDL${EUROPA_SUFFIX}" INCLUDE_DIRECTORIES ";${CMAKE_CURRENT_BINARY_DIR}") +target_link_libraries("NDDL${EUROPA_SUFFIX}" ${ANTLR_LIBRARIES}) +target_link_libraries("NDDL-test${EUROPA_SUFFIX}" ${ANTLR_LIBRARIES}) + + file(COPY test/ErrorCheckingTests.txt DESTINATION .) file(COPY test/nddl DESTINATION .) file(COPY test/parser DESTINATION .) diff --git a/src/PLASMA/NDDL/ModuleNddl.hh b/src/PLASMA/NDDL/ModuleNddl.hh index 1b76180de..bee991cb4 100644 --- a/src/PLASMA/NDDL/ModuleNddl.hh +++ b/src/PLASMA/NDDL/ModuleNddl.hh @@ -1,6 +1,6 @@ -#ifndef _H_ModuleNddl -#define _H_ModuleNddl +#ifndef H_ModuleNddl +#define H_ModuleNddl #include "Module.hh" @@ -29,4 +29,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_ModuleNddl */ +#endif /* #ifndef H_ModuleNddl */ diff --git a/src/PLASMA/NDDL/NddlDefs.hh b/src/PLASMA/NDDL/NddlDefs.hh index b64db8bde..92dc07bdb 100644 --- a/src/PLASMA/NDDL/NddlDefs.hh +++ b/src/PLASMA/NDDL/NddlDefs.hh @@ -3,20 +3,19 @@ #include "RulesEngineDefs.hh" -using namespace EUROPA; +namespace EUROPA { +class ObjectFilterConstraint; +typedef Id ObjectFilterConstraintId; -namespace NDDL { - - class NddlToken; - typedef Id NddlTokenId; +class ObjectFilterCondition; +typedef Id ObjectFilterConditionId; +} - class ObjectFilterConstraint; - typedef Id ObjectFilterConstraintId; +namespace NDDL { - class ObjectFilterCondition; - typedef Id ObjectFilterConditionId; +class NddlToken; +typedef EUROPA::Id NddlTokenId; - #define inf PLUS_INFINITY } // namespace NDDL diff --git a/src/PLASMA/NDDL/base/NDDL3.tokens b/src/PLASMA/NDDL/base/NDDL3.tokens deleted file mode 100644 index b2c30d6d8..000000000 --- a/src/PLASMA/NDDL/base/NDDL3.tokens +++ /dev/null @@ -1,182 +0,0 @@ -EXPONENT=28 -FLOAT_SUFFIX=29 -CONSTRUCTOR_INVOCATION=6 -OCTAL_ESC=24 -T__93=93 -T__94=94 -T__91=91 -T__92=92 -T__90=90 -INCLUDE=21 -PREDICATE_INSTANCE=9 -COMMENT=30 -T__99=99 -T__98=98 -T__97=97 -T__96=96 -T__95=95 -T__80=80 -T__81=81 -T__82=82 -T__83=83 -LINE_COMMENT=31 -INT=17 -T__85=85 -T__84=84 -T__87=87 -METHOD_CALL=7 -T__86=86 -T__89=89 -T__88=88 -WS=20 -T__71=71 -T__72=72 -VARIABLE=11 -T__70=70 -T__76=76 -T__75=75 -FUNCTION_CALL=14 -T__74=74 -T__73=73 -CONSTRUCTOR=5 -T__79=79 -T__78=78 -T__77=77 -T__68=68 -T__69=69 -T__66=66 -T__67=67 -T__64=64 -T__65=65 -INT_SUFFIX=27 -T__62=62 -T__63=63 -FLOAT=18 -TOKEN_RELATION=10 -T__61=61 -T__60=60 -EXPRESSION_ENFORCE=12 -T__55=55 -ESCAPE_SEQUENCE=22 -T__56=56 -T__57=57 -T__58=58 -T__51=51 -T__52=52 -T__53=53 -T__54=54 -T__107=107 -T__108=108 -T__59=59 -T__103=103 -T__104=104 -T__105=105 -T__106=106 -IDENT=16 -DIGIT=26 -T__50=50 -T__42=42 -T__43=43 -T__40=40 -T__41=41 -T__46=46 -T__47=47 -T__44=44 -T__45=45 -T__48=48 -T__49=49 -UNICODE_ESC=23 -HEX_DIGIT=25 -T__102=102 -T__101=101 -T__100=100 -T__32=32 -T__33=33 -T__34=34 -T__35=35 -EXPRESSION_RETURN=13 -CLOSE=15 -T__36=36 -T__37=37 -T__38=38 -NDDL=8 -T__39=39 -CONSTRAINT_INSTANTIATION=4 -STRING=19 -'>='=70 -'contained_by'=82 -'paralleled_by'=96 -'=='=66 -'string'=56 -'enforce'=63 -'fact'=59 -'parallels'=95 -'>'=69 -'||'=64 -'this'=45 -'&&'=65 -';'=37 -'typedef'=36 -'ends_after'=87 -'+'=72 -'.'=46 -'starts'=97 -'rejectable'=57 -'contains'=83 -'true'=102 -'contains_end'=84 -'equals'=92 -'else'=77 -'condition'=60 -'starts_after'=98 -'extends'=49 -'action'=51 -'{'=33 -'-inf'=106 -'equal'=91 -'goal'=58 -'int'=53 -'if'=76 -'('=41 -':'=62 -'-'=73 -','=34 -'inf'=104 -'in'=47 -'starts_during'=101 -']'=39 -'enum'=32 -'foreach'=78 -'filter'=40 -'class'=48 -'new'=44 -'ends'=86 -'effect'=61 -'meets'=93 -'-inff'=107 -'='=43 -'::'=52 -'ends_after_start'=88 -'bool'=55 -')'=42 -'ends_before'=89 -'predicate'=50 -'super'=75 -'any'=80 -'after'=79 -'starts_before_end'=100 -'float'=54 -'contains_start'=85 -'}'=35 -'met_by'=94 -'inff'=105 -'close'=108 -'before'=81 -'<='=71 -'!='=67 -'false'=103 -'ends_during'=90 -'<'=68 -'starts_before'=99 -'['=38 -'*'=74 diff --git a/src/PLASMA/NDDL/base/NDDL3Lexer.cpp b/src/PLASMA/NDDL/base/NDDL3Lexer.cpp deleted file mode 100644 index 3ebaf287f..000000000 --- a/src/PLASMA/NDDL/base/NDDL3Lexer.cpp +++ /dev/null @@ -1,8207 +0,0 @@ -/** \file - * This C source file was generated by $ANTLR version 3.1.2 - * - * - From the grammar source file : NDDL/base/antlr/NDDL3.g - * - On : 2011-08-29 18:06:03 - * - for the lexer : NDDL3LexerLexer * - * Editing it, at least manually, is not wise. - * - * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. - * - * -*/ -// [The "BSD licence"] -// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC -// http://www.temporal-wave.com -// http://www.linkedin.com/in/jimidle -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* ----------------------------------------- - * Include the ANTLR3 generated header file. - */ -#include "NDDL3Lexer.h" -/* ----------------------------------------- */ - - -/** String literals used by NDDL3Lexer that we must do things like MATCHS() with. - * C will normally just lay down 8 bit characters, and you can use L"xxx" to - * get wchar_t, but wchar_t is 16 bits on Windows, which is not UTF32 and so - * we perform this little trick of defining the literals as arrays of UINT32 - * and passing in the address of these. - */ -static ANTLR3_UCHAR lit_1[] = { 0x65, 0x6E, 0x75, 0x6D, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_2[] = { 0x74, 0x79, 0x70, 0x65, 0x64, 0x65, 0x66, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_3[] = { 0x66, 0x69, 0x6C, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_4[] = { 0x6E, 0x65, 0x77, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_5[] = { 0x74, 0x68, 0x69, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_6[] = { 0x69, 0x6E, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_7[] = { 0x63, 0x6C, 0x61, 0x73, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_8[] = { 0x65, 0x78, 0x74, 0x65, 0x6E, 0x64, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_9[] = { 0x70, 0x72, 0x65, 0x64, 0x69, 0x63, 0x61, 0x74, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_10[] = { 0x61, 0x63, 0x74, 0x69, 0x6F, 0x6E, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_11[] = { 0x3A, 0x3A, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_12[] = { 0x69, 0x6E, 0x74, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_13[] = { 0x66, 0x6C, 0x6F, 0x61, 0x74, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_14[] = { 0x62, 0x6F, 0x6F, 0x6C, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_15[] = { 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_16[] = { 0x72, 0x65, 0x6A, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6C, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_17[] = { 0x67, 0x6F, 0x61, 0x6C, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_18[] = { 0x66, 0x61, 0x63, 0x74, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_19[] = { 0x63, 0x6F, 0x6E, 0x64, 0x69, 0x74, 0x69, 0x6F, 0x6E, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_20[] = { 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_21[] = { 0x65, 0x6E, 0x66, 0x6F, 0x72, 0x63, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_22[] = { 0x7C, 0x7C, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_23[] = { 0x26, 0x26, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_24[] = { 0x3D, 0x3D, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_25[] = { 0x21, 0x3D, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_26[] = { 0x3E, 0x3D, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_27[] = { 0x3C, 0x3D, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_28[] = { 0x73, 0x75, 0x70, 0x65, 0x72, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_29[] = { 0x69, 0x66, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_30[] = { 0x65, 0x6C, 0x73, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_31[] = { 0x66, 0x6F, 0x72, 0x65, 0x61, 0x63, 0x68, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_32[] = { 0x61, 0x66, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_33[] = { 0x61, 0x6E, 0x79, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_34[] = { 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_35[] = { 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x65, 0x64, 0x5F, 0x62, 0x79, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_36[] = { 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_37[] = { 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, 0x5F, 0x65, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_38[] = { 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, 0x5F, 0x73, 0x74, 0x61, 0x72, 0x74, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_39[] = { 0x65, 0x6E, 0x64, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_40[] = { 0x65, 0x6E, 0x64, 0x73, 0x5F, 0x61, 0x66, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_41[] = { 0x65, 0x6E, 0x64, 0x73, 0x5F, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5F, 0x73, 0x74, 0x61, 0x72, 0x74, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_42[] = { 0x65, 0x6E, 0x64, 0x73, 0x5F, 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_43[] = { 0x65, 0x6E, 0x64, 0x73, 0x5F, 0x64, 0x75, 0x72, 0x69, 0x6E, 0x67, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_44[] = { 0x65, 0x71, 0x75, 0x61, 0x6C, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_45[] = { 0x65, 0x71, 0x75, 0x61, 0x6C, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_46[] = { 0x6D, 0x65, 0x65, 0x74, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_47[] = { 0x6D, 0x65, 0x74, 0x5F, 0x62, 0x79, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_48[] = { 0x70, 0x61, 0x72, 0x61, 0x6C, 0x6C, 0x65, 0x6C, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_49[] = { 0x70, 0x61, 0x72, 0x61, 0x6C, 0x6C, 0x65, 0x6C, 0x65, 0x64, 0x5F, 0x62, 0x79, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_50[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_51[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x5F, 0x61, 0x66, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_52[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x5F, 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_53[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x5F, 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, 0x5F, 0x65, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_54[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x5F, 0x64, 0x75, 0x72, 0x69, 0x6E, 0x67, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_55[] = { 0x74, 0x72, 0x75, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_56[] = { 0x66, 0x61, 0x6C, 0x73, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_57[] = { 0x69, 0x6E, 0x66, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_58[] = { 0x69, 0x6E, 0x66, 0x66, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_59[] = { 0x2D, 0x69, 0x6E, 0x66, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_60[] = { 0x2D, 0x69, 0x6E, 0x66, 0x66, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_61[] = { 0x63, 0x6C, 0x6F, 0x73, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_62[] = { 0x23, 0x69, 0x6E, 0x63, 0x6C, 0x75, 0x64, 0x65, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_63[] = { 0x2F, 0x2A, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_64[] = { 0x2A, 0x2F, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_65[] = { 0x2F, 0x2F, ANTLR3_STRING_TERMINATOR}; - - - - -/* MACROS that hide the C interface implementations from the - * generated code, which makes it a little more understandable to the human eye. - * I am very much against using C pre-processor macros for function calls and bits - * of code as you cannot see what is happening when single stepping in debuggers - * and so on. The exception (in my book at least) is for generated code, where you are - * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() - * hides some indirect calls, but is always referring to the input stream. This is - * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig - * the runtime interfaces without changing the generated code too often, without - * confusing the reader of the generated output, who may not wish to know the gory - * details of the interface inheritance. - */ - -#define CTX ctx - -/* Aids in accessing scopes for grammar programmers - */ -#undef SCOPE_TYPE -#undef SCOPE_STACK -#undef SCOPE_TOP -#define SCOPE_TYPE(scope) pNDDL3Lexer_##scope##_SCOPE -#define SCOPE_STACK(scope) pNDDL3Lexer_##scope##Stack -#define SCOPE_TOP(scope) ctx->pNDDL3Lexer_##scope##Top -#define SCOPE_SIZE(scope) (ctx->SCOPE_STACK(scope)->size(ctx->SCOPE_STACK(scope))) -#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) - - -/* Macros for accessing things in a lexer - */ -#undef LEXER -#undef RECOGNIZER -#undef RULEMEMO -#undef GETCHARINDEX -#undef GETLINE -#undef GETCHARPOSITIONINLINE -#undef EMIT -#undef EMITNEW -#undef MATCHC -#undef MATCHS -#undef MATCHRANGE -#undef LTOKEN -#undef HASFAILED -#undef FAILEDFLAG -#undef INPUT -#undef STRSTREAM -#undef LA -#undef HASEXCEPTION -#undef EXCEPTION -#undef CONSTRUCTEX -#undef CONSUME -#undef LRECOVER -#undef MARK -#undef REWIND -#undef REWINDLAST -#undef BACKTRACKING -#undef MATCHANY -#undef MEMOIZE -#undef HAVEPARSEDRULE -#undef GETTEXT -#undef INDEX -#undef SEEK -#undef PUSHSTREAM -#undef POPSTREAM -#undef SETTEXT -#undef SETTEXT8 - -#define LEXER ctx->pLexer -#define RECOGNIZER LEXER->rec -#define LEXSTATE RECOGNIZER->state -#define TOKSOURCE LEXSTATE->tokSource -#define GETCHARINDEX() LEXER->getCharIndex(LEXER) -#define GETLINE() LEXER->getLine(LEXER) -#define GETTEXT() LEXER->getText(LEXER) -#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER) -#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER) -#define EMITNEW(t) LEXER->emitNew(LEXER, t) -#define MATCHC(c) LEXER->matchc(LEXER, c) -#define MATCHS(s) LEXER->matchs(LEXER, s) -#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2) -#define MATCHANY() LEXER->matchAny(LEXER) -#define LTOKEN LEXSTATE->token -#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE) -#define BACKTRACKING LEXSTATE->backtracking -#define FAILEDFLAG LEXSTATE->failed -#define INPUT LEXER->input -#define STRSTREAM INPUT -#define ISTREAM INPUT->istream -#define INDEX() ISTREAM->index(ISTREAM) -#define SEEK(n) ISTREAM->seek(ISTREAM, n) -#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken) -#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE) -#define EXCEPTION LEXSTATE->exception -#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) -#define LRECOVER() LEXER->recover(LEXER) -#define MARK() ISTREAM->mark(ISTREAM) -#define REWIND(m) ISTREAM->rewind(ISTREAM, m) -#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) -#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) -#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) -#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str) -#define POPSTREAM() LEXER->popCharStream(LEXER) -#define SETTEXT(str) LEXSTATE->text = str -#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken) -#define USER1 LEXSTATE->user1 -#define USER2 LEXSTATE->user2 -#define USER3 LEXSTATE->user3 -#define CUSTOM LEXSTATE->custom -#define RULEMEMO LEXSTATE->ruleMemo -#define DBG RECOGNIZER->debugger - -/* If we have been told we can rely on the standard 8 bit or 16 bit input - * stream, then we can define our macros to use the direct pointers - * in the input object, which is much faster than indirect calls. This - * is really only significant to lexers with a lot of fragment rules (which - * do not place LA(1) in a temporary at the moment) and even then - * only if there is a lot of input (order of say 1M or so). - */ -#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16) - -# ifdef ANTLR3_INLINE_INPUT_ASCII - -/* 8 bit "ASCII" (actually any 8 bit character set) */ - -# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar)) -# define DATAP ((pANTLR3_UINT8)(INPUT->data)) - -# else - -# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar)) -# define DATAP ((pANTLR3_UINT16)(INPUT->data)) - -# endif - -# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1))) -# define CONSUME() \ -{ \ - if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \ - { \ - INPUT->charPositionInLine++; \ - if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \ - { \ - INPUT->line++; \ - INPUT->charPositionInLine = 0; \ - INPUT->currentLine = (void *)(NEXTCHAR + 1); \ - } \ - INPUT->nextChar = (void *)(NEXTCHAR + 1); \ - } \ -} - -#else - -// Pick up the input character by calling the input stream implementation. -// -#define CONSUME() INPUT->istream->consume(INPUT->istream) -#define LA(n) INPUT->istream->_LA(INPUT->istream, n) - -#endif -#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt - -/* The 4 tokens defined below may well clash with your own #defines or token types. If so - * then for the present you must use different names for your defines as these are hard coded - * in the code generator. It would be better not to use such names internally, and maybe - * we can change this in a forthcoming release. I deliberately do not #undef these - * here as this will at least give you a redefined error somewhere if they clash. - */ -#define UP ANTLR3_TOKEN_UP -#define DOWN ANTLR3_TOKEN_DOWN -#define EOR ANTLR3_TOKEN_EOR -#define INVALID ANTLR3_TOKEN_INVALID - - -/* ============================================================================= - * Functions to create and destroy scopes. First come the rule scopes, followed - * by the global declared scopes. - */ - - - -/* ============================================================================= */ - -/* ============================================================================= - * Start of recognizer - */ - - -/* Forward declare the locally static matching functions we have generated and any predicate functions. - */ -static ANTLR3_INLINE void mT__32 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__33 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__34 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__35 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__36 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__37 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__38 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__39 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__40 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__41 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__42 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__43 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__44 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__45 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__46 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__47 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__48 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__49 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__50 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__51 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__52 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__53 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__54 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__55 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__56 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__57 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__58 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__59 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__60 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__61 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__62 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__63 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__64 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__65 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__66 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__67 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__68 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__69 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__70 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__71 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__72 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__73 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__74 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__75 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__76 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__77 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__78 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__79 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__80 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__81 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__82 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__83 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__84 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__85 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__86 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__87 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__88 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__89 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__90 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__91 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__92 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__93 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__94 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__95 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__96 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__97 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__98 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__99 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__100 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__101 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__102 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__103 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__104 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__105 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__106 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__107 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mT__108 (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mINCLUDE (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mIDENT (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mSTRING (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mESCAPE_SEQUENCE (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mOCTAL_ESC (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mUNICODE_ESC (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mHEX_DIGIT (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mDIGIT (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mINT (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mINT_SUFFIX (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mFLOAT (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mEXPONENT (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mFLOAT_SUFFIX (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mCOMMENT (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mLINE_COMMENT (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mWS (pNDDL3Lexer ctx); -static ANTLR3_INLINE void mTokens (pNDDL3Lexer ctx); -static void NDDL3LexerFree(pNDDL3Lexer ctx); - -/* ========================================================================= - * Lexer matching rules end. - * ========================================================================= - */ - - - -static void newNDDL3LexerFree(pNDDL3Lexer ctx) { - delete ctx->lexerErrors; - NDDL3LexerFree(ctx); -} - - -static void -NDDL3LexerFree (pNDDL3Lexer ctx) -{ - LEXER->free(LEXER); - - ANTLR3_FREE(ctx); -} - -/** \brief Name of the grammar file that generated this code - */ -static const char fileName[] = "NDDL/base/antlr/NDDL3.g"; - -/** \brief Return the name of the grammar file that generated this code. - */ -static const char * getGrammarFileName() -{ - return fileName; -} - -/** \brief Create a new lexer called NDDL3Lexer - * - * \param[in] instream Pointer to an initialized input stream - * \return - * - Success pNDDL3Lexer initialized for the lex start - * - Fail NULL - */ -ANTLR3_API pNDDL3Lexer NDDL3LexerNew -(pANTLR3_INPUT_STREAM instream) -{ - // See if we can create a new lexer with the standard constructor - // - return NDDL3LexerNewSSD(instream, NULL); -} - -/** \brief Create a new lexer called NDDL3Lexer - * - * \param[in] instream Pointer to an initialized input stream - * \param[state] state Previously created shared recognizer stat - * \return - * - Success pNDDL3Lexer initialized for the lex start - * - Fail NULL - */ -ANTLR3_API pNDDL3Lexer NDDL3LexerNewSSD -(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) -{ - pNDDL3Lexer ctx; // Context structure we will build and return - - ctx = (pNDDL3Lexer) ANTLR3_CALLOC(1, sizeof(NDDL3Lexer)); - - if (ctx == NULL) - { - // Failed to allocate memory for lexer context - return NULL; - } - - /* ------------------------------------------------------------------- - * Memory for basic structure is allocated, now to fill in - * in base ANTLR3 structures. We initialize the function pointers - * for the standard ANTLR3 lexer function set, but upon return - * from here, the programmer may set the pointers to provide custom - * implementations of each function. - * - * We don't use the macros defined in NDDL3Lexer.h here so you can get a sense - * of what goes where. - */ - - /* Create a base lexer, using the supplied input stream - */ - ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state); - - /* Check that we allocated the memory correctly - */ - if (ctx->pLexer == NULL) - { - ANTLR3_FREE(ctx); - return NULL; - } - /* Install the implementation of our NDDL3Lexer interface - */ - ctx->mT__32 = mT__32; - ctx->mT__33 = mT__33; - ctx->mT__34 = mT__34; - ctx->mT__35 = mT__35; - ctx->mT__36 = mT__36; - ctx->mT__37 = mT__37; - ctx->mT__38 = mT__38; - ctx->mT__39 = mT__39; - ctx->mT__40 = mT__40; - ctx->mT__41 = mT__41; - ctx->mT__42 = mT__42; - ctx->mT__43 = mT__43; - ctx->mT__44 = mT__44; - ctx->mT__45 = mT__45; - ctx->mT__46 = mT__46; - ctx->mT__47 = mT__47; - ctx->mT__48 = mT__48; - ctx->mT__49 = mT__49; - ctx->mT__50 = mT__50; - ctx->mT__51 = mT__51; - ctx->mT__52 = mT__52; - ctx->mT__53 = mT__53; - ctx->mT__54 = mT__54; - ctx->mT__55 = mT__55; - ctx->mT__56 = mT__56; - ctx->mT__57 = mT__57; - ctx->mT__58 = mT__58; - ctx->mT__59 = mT__59; - ctx->mT__60 = mT__60; - ctx->mT__61 = mT__61; - ctx->mT__62 = mT__62; - ctx->mT__63 = mT__63; - ctx->mT__64 = mT__64; - ctx->mT__65 = mT__65; - ctx->mT__66 = mT__66; - ctx->mT__67 = mT__67; - ctx->mT__68 = mT__68; - ctx->mT__69 = mT__69; - ctx->mT__70 = mT__70; - ctx->mT__71 = mT__71; - ctx->mT__72 = mT__72; - ctx->mT__73 = mT__73; - ctx->mT__74 = mT__74; - ctx->mT__75 = mT__75; - ctx->mT__76 = mT__76; - ctx->mT__77 = mT__77; - ctx->mT__78 = mT__78; - ctx->mT__79 = mT__79; - ctx->mT__80 = mT__80; - ctx->mT__81 = mT__81; - ctx->mT__82 = mT__82; - ctx->mT__83 = mT__83; - ctx->mT__84 = mT__84; - ctx->mT__85 = mT__85; - ctx->mT__86 = mT__86; - ctx->mT__87 = mT__87; - ctx->mT__88 = mT__88; - ctx->mT__89 = mT__89; - ctx->mT__90 = mT__90; - ctx->mT__91 = mT__91; - ctx->mT__92 = mT__92; - ctx->mT__93 = mT__93; - ctx->mT__94 = mT__94; - ctx->mT__95 = mT__95; - ctx->mT__96 = mT__96; - ctx->mT__97 = mT__97; - ctx->mT__98 = mT__98; - ctx->mT__99 = mT__99; - ctx->mT__100 = mT__100; - ctx->mT__101 = mT__101; - ctx->mT__102 = mT__102; - ctx->mT__103 = mT__103; - ctx->mT__104 = mT__104; - ctx->mT__105 = mT__105; - ctx->mT__106 = mT__106; - ctx->mT__107 = mT__107; - ctx->mT__108 = mT__108; - ctx->mINCLUDE = mINCLUDE; - ctx->mIDENT = mIDENT; - ctx->mSTRING = mSTRING; - ctx->mESCAPE_SEQUENCE = mESCAPE_SEQUENCE; - ctx->mOCTAL_ESC = mOCTAL_ESC; - ctx->mUNICODE_ESC = mUNICODE_ESC; - ctx->mHEX_DIGIT = mHEX_DIGIT; - ctx->mDIGIT = mDIGIT; - ctx->mINT = mINT; - ctx->mINT_SUFFIX = mINT_SUFFIX; - ctx->mFLOAT = mFLOAT; - ctx->mEXPONENT = mEXPONENT; - ctx->mFLOAT_SUFFIX = mFLOAT_SUFFIX; - ctx->mCOMMENT = mCOMMENT; - ctx->mLINE_COMMENT = mLINE_COMMENT; - ctx->mWS = mWS; - ctx->mTokens = mTokens; - - /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE - * it will call mTokens() in this generated code, and will pass it the ctx - * pointer of this lexer, not the context of the base lexer, so store that now. - */ - ctx->pLexer->ctx = ctx; - - /**Install the token matching function - */ - ctx->pLexer->mTokens = (void (*) (void *))(mTokens); - - ctx->getGrammarFileName = getGrammarFileName; - ctx->free = NDDL3LexerFree; - - - - - RECOGNIZER->displayRecognitionError = reportLexerError; - ctx->lexerErrors = new std::vector; - ctx->free = newNDDL3LexerFree; - - - /* Return the newly built lexer to the caller - */ - return ctx; -} - -/* ========================================================================= - * DFA tables for the lexer - */ -/** Static dfa state tables for Cyclic dfa: - * 551:1: FLOAT : ( ( '+' | '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? ( FLOAT_SUFFIX )? | '.' ( '0' .. '9' )+ ( EXPONENT )? ( FLOAT_SUFFIX )? | ( '0' .. '9' )+ EXPONENT ( FLOAT_SUFFIX )? | ( '0' .. '9' )+ FLOAT_SUFFIX ); - */ -static const ANTLR3_INT32 dfa21_eot[6] = - { - -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa21_eof[6] = - { - -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa21_min[6] = - { - 43, -1, 46, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa21_max[6] = - { - 57, -1, 102, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa21_accept[6] = - { - -1, 1, -1, 2, 4, 3 - }; -static const ANTLR3_INT32 dfa21_special[6] = - { - -1, -1, -1, -1, -1, -1 - }; - -/** Used when there is no transition table entry for a particular state */ -#define dfa21_T_empty NULL - -static const ANTLR3_INT32 dfa21_T0[] = - { - 1, -1, 1, 3, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 - };static const ANTLR3_INT32 dfa21_T1[] = - { - 1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 4, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 5, 4 - }; - -/* Transition tables are a table of sub tables, with some tables - * reused for efficiency. - */ -static const ANTLR3_INT32 * const dfa21_transitions[] = -{ - dfa21_T0, dfa21_T_empty, dfa21_T1, dfa21_T_empty, dfa21_T_empty, dfa21_T_empty -}; - - -/* Declare tracking structure for Cyclic DFA 21 - */ -static -ANTLR3_CYCLIC_DFA cdfa21 - = { - 21, /* Decision number of this dfa */ - /* Which decision this represents: */ - (const pANTLR3_UCHAR)"551:1: FLOAT : ( ( '+' | '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? ( FLOAT_SUFFIX )? | '.' ( '0' .. '9' )+ ( EXPONENT )? ( FLOAT_SUFFIX )? | ( '0' .. '9' )+ EXPONENT ( FLOAT_SUFFIX )? | ( '0' .. '9' )+ FLOAT_SUFFIX );", - (CDFA_SPECIAL_FUNC) antlr3dfaspecialStateTransition, /* Default special state transition function */ - antlr3dfaspecialTransition, /* DFA specialTransition is currently just a default function in the runtime */ - antlr3dfapredict, /* DFA simulator function is in the runtime */ - dfa21_eot, /* EOT table */ - dfa21_eof, /* EOF table */ - dfa21_min, /* Minimum tokens for each state */ - dfa21_max, /* Maximum tokens for each state */ - dfa21_accept, /* Accept table */ - dfa21_special, /* Special transition states */ - dfa21_transitions /* Table of transition tables */ - - }; -/* End of Cyclic DFA 21 - * --------------------- - *//** Static dfa state tables for Cyclic dfa: - * 1:1: Tokens : ( T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | T__47 | T__48 | T__49 | T__50 | T__51 | T__52 | T__53 | T__54 | T__55 | T__56 | T__57 | T__58 | T__59 | T__60 | T__61 | T__62 | T__63 | T__64 | T__65 | T__66 | T__67 | T__68 | T__69 | T__70 | T__71 | T__72 | T__73 | T__74 | T__75 | T__76 | T__77 | T__78 | T__79 | T__80 | T__81 | T__82 | T__83 | T__84 | T__85 | T__86 | T__87 | T__88 | T__89 | T__90 | T__91 | T__92 | T__93 | T__94 | T__95 | T__96 | T__97 | T__98 | T__99 | T__100 | T__101 | T__102 | T__103 | T__104 | T__105 | T__106 | T__107 | T__108 | INCLUDE | IDENT | STRING | INT | FLOAT | COMMENT | LINE_COMMENT | WS ); - */ -static const ANTLR3_INT32 dfa27_eot[338] = - { - -1, 34, -1, -1, -1, 34, -1, -1, -1, 34, -1, -1, 53, 34, 55, 34, 34, 34, - 34, 67, 34, 34, 34, 34, -1, -1, -1, 75, 77, 80, 82, -1, 34, -1, -1, -1, - 84, 84, -1, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, -1, -1, - 34, -1, -1, 106, 107, 34, 34, 34, 34, 34, 34, 34, -1, -1, 34, 34, 34, 34, - 34, 34, -1, -1, -1, -1, 84, 84, -1, -1, -1, 34, -1, 84, -1, -1, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 142, 143, 145, -1, - -1, 34, 34, 34, 34, 34, 34, 34, 154, 34, 34, 34, 34, 34, 34, 34, 84, -1, - 34, 34, 165, 34, 168, 34, 34, 171, 34, 34, 174, 175, 34, 34, 178, 34, 34, - -1, -1, 181, -1, 34, 34, 34, 34, 34, 34, 34, 34, -1, 190, 34, 34, 34, 34, - 34, 196, 198, 34, 34, -1, 34, 34, -1, 34, 34, -1, 208, 34, -1, -1, 34, - 211, -1, 212, 34, -1, 214, 215, 34, 34, 34, 34, 34, 221, -1, 34, 34, 34, - 225, 34, -1, -1, -1, 227, 34, 34, 34, 34, 34, 34, 234, 235, -1, 34, 237, - -1, -1, 34, -1, -1, 34, 34, 34, 34, 243, -1, 244, 245, 247, -1, 34, -1, - 249, 250, 34, 34, 34, 254, -1, -1, 255, -1, 256, 34, 34, 34, 34, -1, -1, - -1, 34, -1, 34, -1, -1, 34, 34, 34, -1, -1, -1, 34, 34, 272, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 283, 34, 34, -1, 287, 288, 34, 34, 34, 34, 34, - 295, 34, 34, -1, 34, 34, 34, -1, -1, 34, 34, 34, 34, 305, 34, -1, 307, - 308, 34, 34, 34, 34, 34, 34, 34, -1, 34, -1, -1, 317, 318, 34, 34, 321, - 34, 34, 34, -1, -1, 34, 326, -1, 328, 329, 34, 331, -1, 34, -1, -1, 34, - -1, 34, 335, 34, -1, 337, -1 - }; -static const ANTLR3_INT32 dfa27_eof[338] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa27_min[338] = - { - 9, 102, -1, -1, -1, 104, -1, -1, -1, 97, -1, -1, 61, 101, 48, 102, 108, - 97, 99, 58, 101, 116, 101, 111, -1, -1, -1, 61, 61, 48, 48, -1, 101, -1, - -1, -1, 46, 46, 42, -1, 100, 116, 102, 115, 117, 112, 105, 117, 108, 111, - 99, 114, -1, -1, 119, -1, -1, 36, 36, 97, 110, 101, 114, 116, 116, 121, - -1, -1, 111, 102, 97, 112, 106, 97, -1, -1, -1, -1, 46, 46, -1, 110, -1, - 101, -1, 46, -1, -1, 109, 111, 115, 101, 101, 101, 97, 101, 115, 101, 116, - 97, 116, 115, 101, 36, 36, 36, -1, -1, 115, 115, 100, 100, 97, 105, 101, - 36, 108, 111, 105, 114, 101, 101, 108, 46, 102, 116, 95, 36, 114, 36, 110, - 99, 36, 108, 100, 36, 36, 101, 116, 36, 101, 97, -1, -1, 36, -1, 115, 101, - 105, 97, 105, 108, 111, 114, -1, 36, 114, 110, 116, 114, 99, 36, 102, 115, - 98, -1, 99, 97, -1, 100, 116, -1, 36, 101, -1, -1, 114, 36, -1, 36, 99, - -1, 36, 36, 116, 105, 99, 108, 110, 36, -1, 101, 103, 115, 36, 116, -1, - -1, -1, 36, 121, 101, 102, 101, 117, 115, 36, 36, -1, 102, 36, -1, -1, - 104, -1, -1, 105, 110, 97, 101, 36, -1, 36, 36, 36, -1, 97, -1, 36, 36, - 116, 102, 114, 36, -1, -1, 36, -1, 36, 111, 101, 116, 108, -1, -1, -1, - 97, -1, 98, -1, -1, 101, 111, 105, -1, -1, -1, 110, 100, 36, 101, 101, - 102, 101, 117, 108, 114, 114, 110, 36, 95, 101, -1, 36, 36, 100, 116, 102, - 114, 101, 36, 101, 103, -1, 98, 110, 116, -1, -1, 95, 101, 111, 105, 36, - 115, -1, 36, 36, 121, 100, 97, 98, 114, 114, 110, -1, 116, -1, -1, 36, - 36, 114, 121, 36, 101, 103, 97, -1, -1, 116, 36, -1, 36, 36, 114, 36, -1, - 101, -1, -1, 116, -1, 110, 36, 100, -1, 36, -1 - }; -static const ANTLR3_INT32 dfa27_max[338] = - { - 125, 120, -1, -1, -1, 121, -1, -1, -1, 111, -1, -1, 61, 101, 57, 110, 111, - 114, 110, 58, 111, 117, 101, 111, -1, -1, -1, 61, 61, 57, 105, -1, 101, - -1, -1, -1, 102, 102, 47, -1, 117, 116, 102, 115, 117, 112, 105, 117, 108, - 111, 108, 114, -1, -1, 119, -1, -1, 122, 122, 111, 110, 101, 114, 116, - 116, 121, -1, -1, 111, 102, 114, 112, 106, 97, -1, -1, -1, -1, 57, 57, - -1, 110, -1, 116, -1, 102, -1, -1, 109, 111, 115, 101, 101, 101, 97, 101, - 115, 101, 116, 97, 116, 115, 101, 122, 122, 122, -1, -1, 115, 115, 116, - 100, 97, 105, 101, 122, 108, 111, 105, 114, 101, 101, 108, 57, 102, 116, - 95, 122, 114, 122, 110, 99, 122, 108, 100, 122, 122, 101, 116, 122, 101, - 97, -1, -1, 122, -1, 115, 101, 105, 97, 105, 108, 111, 114, -1, 122, 114, - 110, 116, 114, 99, 122, 102, 115, 98, -1, 99, 100, -1, 100, 116, -1, 122, - 101, -1, -1, 114, 122, -1, 122, 99, -1, 122, 122, 116, 105, 99, 108, 110, - 122, -1, 101, 103, 115, 122, 116, -1, -1, -1, 122, 121, 101, 102, 101, - 117, 115, 122, 122, -1, 102, 122, -1, -1, 104, -1, -1, 105, 110, 97, 101, - 122, -1, 122, 122, 122, -1, 97, -1, 122, 122, 116, 102, 114, 122, -1, -1, - 122, -1, 122, 111, 115, 116, 108, -1, -1, -1, 100, -1, 98, -1, -1, 101, - 111, 105, -1, -1, -1, 110, 100, 122, 101, 115, 102, 101, 117, 108, 114, - 114, 110, 122, 95, 115, -1, 122, 122, 100, 116, 102, 114, 101, 122, 101, - 103, -1, 98, 110, 116, -1, -1, 95, 101, 111, 105, 122, 115, -1, 122, 122, - 121, 100, 97, 98, 114, 114, 110, -1, 116, -1, -1, 122, 122, 114, 121, 122, - 101, 103, 97, -1, -1, 116, 122, -1, 122, 122, 114, 122, -1, 101, -1, -1, - 116, -1, 110, 122, 100, -1, 122, -1 - }; -static const ANTLR3_INT32 dfa27_accept[338] = - { - -1, -1, 2, 3, 4, -1, 6, 7, 8, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 33, 34, 36, -1, -1, -1, -1, 43, -1, 78, 79, 80, -1, -1, - -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, 12, -1, 15, - 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, 31, -1, -1, -1, -1, -1, -1, - 40, 37, 39, 38, -1, -1, 41, -1, 42, -1, 81, -1, 83, 84, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 45, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 22, -1, 73, - -1, -1, -1, -1, -1, -1, -1, -1, 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 1, -1, -1, 55, -1, -1, 46, -1, -1, 14, 71, -1, -1, 28, -1, -1, 74, - -1, -1, -1, -1, -1, -1, -1, -1, 24, -1, -1, -1, -1, -1, 27, 76, 75, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 60, -1, -1, 23, 72, -1, 17, 77, -1, -1, - -1, -1, -1, 48, -1, -1, -1, 44, -1, 62, -1, -1, -1, -1, -1, -1, 30, 61, - -1, 9, -1, -1, -1, -1, -1, 20, 50, 25, -1, 66, -1, 63, 32, -1, -1, -1, - 18, 5, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 52, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, 19, 64, -1, - -1, -1, -1, -1, -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, -1, 58, - 59, -1, -1, -1, -1, -1, -1, -1, -1, 51, 53, -1, -1, 67, -1, -1, -1, -1, - 65, -1, 68, 70, -1, 54, -1, -1, -1, 57, -1, 69 - }; -static const ANTLR3_INT32 dfa27_special[338] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }; - -/** Used when there is no transition table entry for a particular state */ -#define dfa27_T_empty NULL - -static const ANTLR3_INT32 dfa27_T0[] = - { - 78, 79, 79, 79, 79, 79, 79, 79, 79, 79 - };static const ANTLR3_INT32 dfa27_T1[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 34, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T2[] = - { - 56, -1, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123 - };static const ANTLR3_INT32 dfa27_T3[] = - { - 202, 203, -1, 204 - };static const ANTLR3_INT32 dfa27_T4[] = - { - 228 - };static const ANTLR3_INT32 dfa27_T5[] = - { - 127 - };static const ANTLR3_INT32 dfa27_T6[] = - { - 200 - };static const ANTLR3_INT32 dfa27_T7[] = - { - 42, -1, -1, -1, -1, -1, 43, -1, 40, -1, -1, 44, -1, -1, -1, -1, -1, -1, - 41 - };static const ANTLR3_INT32 dfa27_T8[] = - { - 164 - };static const ANTLR3_INT32 dfa27_T9[] = - { - 199 - };static const ANTLR3_INT32 dfa27_T10[] = - { - 163 - };static const ANTLR3_INT32 dfa27_T11[] = - { - 66 - };static const ANTLR3_INT32 dfa27_T12[] = - { - 312 - };static const ANTLR3_INT32 dfa27_T13[] = - { - 124 - };static const ANTLR3_INT32 dfa27_T14[] = - { - 301 - };static const ANTLR3_INT32 dfa27_T15[] = - { - 162 - };static const ANTLR3_INT32 dfa27_T16[] = - { - 320 - };static const ANTLR3_INT32 dfa27_T17[] = - { - 62, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 61 - };static const ANTLR3_INT32 dfa27_T18[] = - { - 289 - };static const ANTLR3_INT32 dfa27_T19[] = - { - 280 - };static const ANTLR3_INT32 dfa27_T20[] = - { - 276 - };static const ANTLR3_INT32 dfa27_T21[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 34, -1, 34, 34, 34, 34, 34, 144, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T22[] = - { - 313 - };static const ANTLR3_INT32 dfa27_T23[] = - { - 137 - };static const ANTLR3_INT32 dfa27_T24[] = - { - 176 - };static const ANTLR3_INT32 dfa27_T25[] = - { - 290 - };static const ANTLR3_INT32 dfa27_T26[] = - { - 210 - };static const ANTLR3_INT32 dfa27_T27[] = - { - 302 - };static const ANTLR3_INT32 dfa27_T28[] = - { - 98 - };static const ANTLR3_INT32 dfa27_T29[] = - { - 103 - };static const ANTLR3_INT32 dfa27_T30[] = - { - 56, -1, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56 - };static const ANTLR3_INT32 dfa27_T31[] = - { - 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 118 - };static const ANTLR3_INT32 dfa27_T32[] = - { - 100, -1, -1, -1, -1, -1, -1, -1, -1, 101 - };static const ANTLR3_INT32 dfa27_T33[] = - { - 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, -1, -1, -1, -1, -1, -1, 45 - };static const ANTLR3_INT32 dfa27_T34[] = - { - 292 - };static const ANTLR3_INT32 dfa27_T35[] = - { - 278 - };static const ANTLR3_INT32 dfa27_T36[] = - { - 334 - };static const ANTLR3_INT32 dfa27_T37[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 294, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T38[] = - { - 332 - };static const ANTLR3_INT32 dfa27_T39[] = - { - 230 - };static const ANTLR3_INT32 dfa27_T40[] = - { - 236 - };static const ANTLR3_INT32 dfa27_T41[] = - { - 336 - };static const ANTLR3_INT32 dfa27_T42[] = - { - 209 - };static const ANTLR3_INT32 dfa27_T43[] = - { - 173 - };static const ANTLR3_INT32 dfa27_T44[] = - { - 266 - };static const ANTLR3_INT32 dfa27_T45[] = - { - 134 - };static const ANTLR3_INT32 dfa27_T46[] = - { - 95 - };static const ANTLR3_INT32 dfa27_T47[] = - { - 251 - };static const ANTLR3_INT32 dfa27_T48[] = - { - 270 - };static const ANTLR3_INT32 dfa27_T49[] = - { - 69, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68 - };static const ANTLR3_INT32 dfa27_T50[] = - { - 309 - };static const ANTLR3_INT32 dfa27_T51[] = - { - 298 - };static const ANTLR3_INT32 dfa27_T52[] = - { - 284 - };static const ANTLR3_INT32 dfa27_T53[] = - { - 262, 263, -1, 264 - };static const ANTLR3_INT32 dfa27_T54[] = - { - 310 - };static const ANTLR3_INT32 dfa27_T55[] = - { - 299 - };static const ANTLR3_INT32 dfa27_T56[] = - { - 129 - };static const ANTLR3_INT32 dfa27_T57[] = - { - 108, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109 - };static const ANTLR3_INT32 dfa27_T58[] = - { - 319 - };static const ANTLR3_INT32 dfa27_T59[] = - { - 63, -1, -1, 64, -1, -1, -1, -1, -1, -1, -1, 65 - };static const ANTLR3_INT32 dfa27_T60[] = - { - 325 - };static const ANTLR3_INT32 dfa27_T61[] = - { - 300 - };static const ANTLR3_INT32 dfa27_T62[] = - { - 311 - };static const ANTLR3_INT32 dfa27_T63[] = - { - 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 286 - };static const ANTLR3_INT32 dfa27_T64[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 271, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T65[] = - { - 110 - };static const ANTLR3_INT32 dfa27_T66[] = - { - 148, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 149 - };static const ANTLR3_INT32 dfa27_T67[] = - { - 78, 79, 79, 79, 79, 79, 79, 79, 79, 79, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 81 - };static const ANTLR3_INT32 dfa27_T68[] = - { - 83 - };static const ANTLR3_INT32 dfa27_T69[] = - { - 197 - };static const ANTLR3_INT32 dfa27_T70[] = - { - 90, -1, 89, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 88 - };static const ANTLR3_INT32 dfa27_T71[] = - { - 86, -1, -1, -1, -1, 87 - };static const ANTLR3_INT32 dfa27_T72[] = - { - 324 - };static const ANTLR3_INT32 dfa27_T73[] = - { - 330 - };static const ANTLR3_INT32 dfa27_T74[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 327, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T75[] = - { - 306 - };static const ANTLR3_INT32 dfa27_T76[] = - { - 316 - };static const ANTLR3_INT32 dfa27_T77[] = - { - 333 - };static const ANTLR3_INT32 dfa27_T78[] = - { - 52 - };static const ANTLR3_INT32 dfa27_T79[] = - { - 252 - };static const ANTLR3_INT32 dfa27_T80[] = - { - 231 - };static const ANTLR3_INT32 dfa27_T81[] = - { - 281 - };static const ANTLR3_INT32 dfa27_T82[] = - { - 267 - };static const ANTLR3_INT32 dfa27_T83[] = - { - 54 - };static const ANTLR3_INT32 dfa27_T84[] = - { - 296 - };static const ANTLR3_INT32 dfa27_T85[] = - { - 232 - };static const ANTLR3_INT32 dfa27_T86[] = - { - 253 - };static const ANTLR3_INT32 dfa27_T87[] = - { - 268 - };static const ANTLR3_INT32 dfa27_T88[] = - { - 282 - };static const ANTLR3_INT32 dfa27_T89[] = - { - 297 - };static const ANTLR3_INT32 dfa27_T90[] = - { - 50, -1, -1, -1, -1, -1, -1, -1, 48, -1, -1, 49, -1, -1, 51 - };static const ANTLR3_INT32 dfa27_T91[] = - { - 193 - };static const ANTLR3_INT32 dfa27_T92[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 167, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T93[] = - { - 158 - };static const ANTLR3_INT32 dfa27_T94[] = - { - 229 - };static const ANTLR3_INT32 dfa27_T95[] = - { - 128 - };static const ANTLR3_INT32 dfa27_T96[] = - { - 201 - };static const ANTLR3_INT32 dfa27_T97[] = - { - 166 - };static const ANTLR3_INT32 dfa27_T98[] = - { - 76 - };static const ANTLR3_INT32 dfa27_T99[] = - { - 277 - };static const ANTLR3_INT32 dfa27_T100[] = - { - 74 - };static const ANTLR3_INT32 dfa27_T101[] = - { - 291 - };static const ANTLR3_INT32 dfa27_T102[] = - { - 131 - };static const ANTLR3_INT32 dfa27_T103[] = - { - 303 - };static const ANTLR3_INT32 dfa27_T104[] = - { - 170 - };static const ANTLR3_INT32 dfa27_T105[] = - { - 206 - };static const ANTLR3_INT32 dfa27_T106[] = - { - 314 - };static const ANTLR3_INT32 dfa27_T107[] = - { - 322 - };static const ANTLR3_INT32 dfa27_T108[] = - { - 92 - };static const ANTLR3_INT32 dfa27_T109[] = - { - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56 - };static const ANTLR3_INT32 dfa27_T110[] = - { - 56, -1, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 56, 56, 56, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 56, 56, 56 - };static const ANTLR3_INT32 dfa27_T111[] = - { - 217 - };static const ANTLR3_INT32 dfa27_T112[] = - { - 59, -1, -1, 60 - };static const ANTLR3_INT32 dfa27_T113[] = - { - 185 - };static const ANTLR3_INT32 dfa27_T114[] = - { - 58, -1, -1, -1, -1, -1, -1, -1, 57 - };static const ANTLR3_INT32 dfa27_T115[] = - { - 258, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 259 - };static const ANTLR3_INT32 dfa27_T116[] = - { - 240 - };static const ANTLR3_INT32 dfa27_T117[] = - { - 93 - };static const ANTLR3_INT32 dfa27_T118[] = - { - 132 - };static const ANTLR3_INT32 dfa27_T119[] = - { - 72 - };static const ANTLR3_INT32 dfa27_T120[] = - { - 120 - };static const ANTLR3_INT32 dfa27_T121[] = - { - 159 - };static const ANTLR3_INT32 dfa27_T122[] = - { - 194 - };static const ANTLR3_INT32 dfa27_T123[] = - { - 73 - };static const ANTLR3_INT32 dfa27_T124[] = - { - 222 - };static const ANTLR3_INT32 dfa27_T125[] = - { - 191 - };static const ANTLR3_INT32 dfa27_T126[] = - { - 156 - };static const ANTLR3_INT32 dfa27_T127[] = - { - 117 - };static const ANTLR3_INT32 dfa27_T128[] = - { - 115 - };static const ANTLR3_INT32 dfa27_T129[] = - { - 114 - };static const ANTLR3_INT32 dfa27_T130[] = - { - 153 - };static const ANTLR3_INT32 dfa27_T131[] = - { - 189 - };static const ANTLR3_INT32 dfa27_T132[] = - { - 180 - };static const ANTLR3_INT32 dfa27_T133[] = - { - 213 - };static const ANTLR3_INT32 dfa27_T134[] = - { - 102 - };static const ANTLR3_INT32 dfa27_T135[] = - { - 141 - };static const ANTLR3_INT32 dfa27_T136[] = - { - 224 - };static const ANTLR3_INT32 dfa27_T137[] = - { - 238 - };static const ANTLR3_INT32 dfa27_T138[] = - { - 182 - };static const ANTLR3_INT32 dfa27_T139[] = - { - 275, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 274 - };static const ANTLR3_INT32 dfa27_T140[] = - { - 146 - };static const ANTLR3_INT32 dfa27_T141[] = - { - 169 - };static const ANTLR3_INT32 dfa27_T142[] = - { - 187 - };static const ANTLR3_INT32 dfa27_T143[] = - { - 205 - };static const ANTLR3_INT32 dfa27_T144[] = - { - 233 - };static const ANTLR3_INT32 dfa27_T145[] = - { - 219 - };static const ANTLR3_INT32 dfa27_T146[] = - { - 242 - };static const ANTLR3_INT32 dfa27_T147[] = - { - 91 - };static const ANTLR3_INT32 dfa27_T148[] = - { - 261 - };static const ANTLR3_INT32 dfa27_T149[] = - { - 130 - };static const ANTLR3_INT32 dfa27_T150[] = - { - 112 - };static const ANTLR3_INT32 dfa27_T151[] = - { - 135 - };static const ANTLR3_INT32 dfa27_T152[] = - { - 151 - };static const ANTLR3_INT32 dfa27_T153[] = - { - 96 - };static const ANTLR3_INT32 dfa27_T154[] = - { - 70, 71 - };static const ANTLR3_INT32 dfa27_T155[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 34, -1, 34, 34, 34, 34, 34, 105, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 104, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T156[] = - { - 188 - };static const ANTLR3_INT32 dfa27_T157[] = - { - 220 - };static const ANTLR3_INT32 dfa27_T158[] = - { - 113 - };static const ANTLR3_INT32 dfa27_T159[] = - { - 152 - };static const ANTLR3_INT32 dfa27_T160[] = - { - 218 - };static const ANTLR3_INT32 dfa27_T161[] = - { - 186 - };static const ANTLR3_INT32 dfa27_T162[] = - { - 150 - };static const ANTLR3_INT32 dfa27_T163[] = - { - 111 - };static const ANTLR3_INT32 dfa27_T164[] = - { - 273 - };static const ANTLR3_INT32 dfa27_T165[] = - { - 260 - };static const ANTLR3_INT32 dfa27_T166[] = - { - 241 - };static const ANTLR3_INT32 dfa27_T167[] = - { - 157 - };static const ANTLR3_INT32 dfa27_T168[] = - { - 192 - };static const ANTLR3_INT32 dfa27_T169[] = - { - 223 - };static const ANTLR3_INT32 dfa27_T170[] = - { - 121 - };static const ANTLR3_INT32 dfa27_T171[] = - { - 160 - };static const ANTLR3_INT32 dfa27_T172[] = - { - 147 - };static const ANTLR3_INT32 dfa27_T173[] = - { - 195 - };static const ANTLR3_INT32 dfa27_T174[] = - { - 226 - };static const ANTLR3_INT32 dfa27_T175[] = - { - 183 - };static const ANTLR3_INT32 dfa27_T176[] = - { - 39, 39, -1, 39, 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 39, 26, 35, 33, 34, -1, 25, -1, 10, 11, 31, 29, 3, - 30, 14, 38, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 19, 6, 27, 12, 28, - -1, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 7, -1, 8, -1, 34, -1, 18, 20, 16, - 34, 1, 9, 23, 34, 15, 34, 34, 34, 32, 13, 34, 17, 34, 22, 21, 5, 34, 34, - 34, 34, 34, 34, 2, 24, 4 - };static const ANTLR3_INT32 dfa27_T177[] = - { - 56, -1, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 56, 56, 56, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 56, 56, 56 - };static const ANTLR3_INT32 dfa27_T178[] = - { - 138 - };static const ANTLR3_INT32 dfa27_T179[] = - { - 172 - };static const ANTLR3_INT32 dfa27_T180[] = - { - 99 - };static const ANTLR3_INT32 dfa27_T181[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 246, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T182[] = - { - 177 - };static const ANTLR3_INT32 dfa27_T183[] = - { - 94 - };static const ANTLR3_INT32 dfa27_T184[] = - { - 133 - };static const ANTLR3_INT32 dfa27_T185[] = - { - 155 - };static const ANTLR3_INT32 dfa27_T186[] = - { - 116 - };static const ANTLR3_INT32 dfa27_T187[] = - { - 139 - };static const ANTLR3_INT32 dfa27_T188[] = - { - 140 - };static const ANTLR3_INT32 dfa27_T189[] = - { - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, -1, -1, -1, -1, -1, -1, -1, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, -1, -1, -1, -1, 34, -1, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 207, 34, 34, 34, 34, 34, 34, 34 - };static const ANTLR3_INT32 dfa27_T190[] = - { - 216 - };static const ANTLR3_INT32 dfa27_T191[] = - { - 239 - };static const ANTLR3_INT32 dfa27_T192[] = - { - 179 - };static const ANTLR3_INT32 dfa27_T193[] = - { - 184 - };static const ANTLR3_INT32 dfa27_T194[] = - { - 257 - };static const ANTLR3_INT32 dfa27_T195[] = - { - 269 - };static const ANTLR3_INT32 dfa27_T196[] = - { - 293 - };static const ANTLR3_INT32 dfa27_T197[] = - { - 136 - };static const ANTLR3_INT32 dfa27_T198[] = - { - 279 - };static const ANTLR3_INT32 dfa27_T199[] = - { - 97 - };static const ANTLR3_INT32 dfa27_T200[] = - { - 265 - };static const ANTLR3_INT32 dfa27_T201[] = - { - 248 - };static const ANTLR3_INT32 dfa27_T202[] = - { - 315 - };static const ANTLR3_INT32 dfa27_T203[] = - { - 125, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 126 - };static const ANTLR3_INT32 dfa27_T204[] = - { - 304 - };static const ANTLR3_INT32 dfa27_T205[] = - { - 161 - };static const ANTLR3_INT32 dfa27_T206[] = - { - 122 - };static const ANTLR3_INT32 dfa27_T207[] = - { - 323 - }; - -/* Transition tables are a table of sub tables, with some tables - * reused for efficiency. - */ -static const ANTLR3_INT32 * const dfa27_transitions[] = -{ - dfa27_T176, dfa27_T7, dfa27_T_empty, dfa27_T_empty, dfa27_T_empty, dfa27_T33, - dfa27_T_empty, dfa27_T_empty, dfa27_T_empty, dfa27_T90, dfa27_T_empty, - dfa27_T_empty, dfa27_T78, dfa27_T83, dfa27_T109, dfa27_T114, dfa27_T112, - dfa27_T17, dfa27_T59, dfa27_T11, dfa27_T49, dfa27_T154, dfa27_T119, - dfa27_T123, dfa27_T_empty, dfa27_T_empty, dfa27_T_empty, dfa27_T100, - dfa27_T98, dfa27_T0, dfa27_T67, dfa27_T_empty, dfa27_T68, dfa27_T_empty, - dfa27_T_empty, dfa27_T_empty, dfa27_T177, dfa27_T110, dfa27_T71, dfa27_T_empty, - dfa27_T70, dfa27_T147, dfa27_T108, dfa27_T117, dfa27_T183, dfa27_T46, - dfa27_T153, dfa27_T199, dfa27_T28, dfa27_T180, dfa27_T32, dfa27_T134, - dfa27_T_empty, dfa27_T_empty, dfa27_T29, dfa27_T_empty, dfa27_T_empty, - dfa27_T155, dfa27_T1, dfa27_T57, dfa27_T65, dfa27_T163, dfa27_T150, - dfa27_T158, dfa27_T129, dfa27_T128, dfa27_T_empty, dfa27_T_empty, dfa27_T186, - dfa27_T127, dfa27_T31, dfa27_T120, dfa27_T170, dfa27_T206, dfa27_T_empty, - dfa27_T_empty, dfa27_T_empty, dfa27_T_empty, dfa27_T30, dfa27_T2, dfa27_T_empty, - dfa27_T13, dfa27_T_empty, dfa27_T203, dfa27_T_empty, dfa27_T110, dfa27_T_empty, - dfa27_T_empty, dfa27_T5, dfa27_T95, dfa27_T56, dfa27_T149, dfa27_T102, - dfa27_T118, dfa27_T184, dfa27_T45, dfa27_T151, dfa27_T197, dfa27_T23, - dfa27_T178, dfa27_T187, dfa27_T188, dfa27_T135, dfa27_T1, dfa27_T1, - dfa27_T21, dfa27_T_empty, dfa27_T_empty, dfa27_T140, dfa27_T172, dfa27_T66, - dfa27_T162, dfa27_T152, dfa27_T159, dfa27_T130, dfa27_T1, dfa27_T185, - dfa27_T126, dfa27_T167, dfa27_T93, dfa27_T121, dfa27_T171, dfa27_T205, - dfa27_T2, dfa27_T15, dfa27_T10, dfa27_T8, dfa27_T1, dfa27_T97, dfa27_T92, - dfa27_T141, dfa27_T104, dfa27_T1, dfa27_T179, dfa27_T43, dfa27_T1, dfa27_T1, - dfa27_T24, dfa27_T182, dfa27_T1, dfa27_T192, dfa27_T132, dfa27_T_empty, - dfa27_T_empty, dfa27_T1, dfa27_T_empty, dfa27_T138, dfa27_T175, dfa27_T193, - dfa27_T113, dfa27_T161, dfa27_T142, dfa27_T156, dfa27_T131, dfa27_T_empty, - dfa27_T1, dfa27_T125, dfa27_T168, dfa27_T91, dfa27_T122, dfa27_T173, - dfa27_T1, dfa27_T69, dfa27_T9, dfa27_T6, dfa27_T_empty, dfa27_T96, dfa27_T3, - dfa27_T_empty, dfa27_T143, dfa27_T105, dfa27_T_empty, dfa27_T189, dfa27_T42, - dfa27_T_empty, dfa27_T_empty, dfa27_T26, dfa27_T1, dfa27_T_empty, dfa27_T1, - dfa27_T133, dfa27_T_empty, dfa27_T1, dfa27_T1, dfa27_T190, dfa27_T111, - dfa27_T160, dfa27_T145, dfa27_T157, dfa27_T1, dfa27_T_empty, dfa27_T124, - dfa27_T169, dfa27_T136, dfa27_T1, dfa27_T174, dfa27_T_empty, dfa27_T_empty, - dfa27_T_empty, dfa27_T1, dfa27_T4, dfa27_T94, dfa27_T39, dfa27_T80, - dfa27_T85, dfa27_T144, dfa27_T1, dfa27_T1, dfa27_T_empty, dfa27_T40, - dfa27_T1, dfa27_T_empty, dfa27_T_empty, dfa27_T137, dfa27_T_empty, dfa27_T_empty, - dfa27_T191, dfa27_T116, dfa27_T166, dfa27_T146, dfa27_T1, dfa27_T_empty, - dfa27_T1, dfa27_T1, dfa27_T181, dfa27_T_empty, dfa27_T201, dfa27_T_empty, - dfa27_T1, dfa27_T1, dfa27_T47, dfa27_T79, dfa27_T86, dfa27_T1, dfa27_T_empty, - dfa27_T_empty, dfa27_T1, dfa27_T_empty, dfa27_T1, dfa27_T194, dfa27_T115, - dfa27_T165, dfa27_T148, dfa27_T_empty, dfa27_T_empty, dfa27_T_empty, - dfa27_T53, dfa27_T_empty, dfa27_T200, dfa27_T_empty, dfa27_T_empty, - dfa27_T44, dfa27_T82, dfa27_T87, dfa27_T_empty, dfa27_T_empty, dfa27_T_empty, - dfa27_T195, dfa27_T48, dfa27_T64, dfa27_T164, dfa27_T139, dfa27_T20, - dfa27_T99, dfa27_T35, dfa27_T198, dfa27_T19, dfa27_T81, dfa27_T88, dfa27_T1, - dfa27_T52, dfa27_T63, dfa27_T_empty, dfa27_T1, dfa27_T1, dfa27_T18, - dfa27_T25, dfa27_T101, dfa27_T34, dfa27_T196, dfa27_T37, dfa27_T84, - dfa27_T89, dfa27_T_empty, dfa27_T51, dfa27_T55, dfa27_T61, dfa27_T_empty, - dfa27_T_empty, dfa27_T14, dfa27_T27, dfa27_T103, dfa27_T204, dfa27_T1, - dfa27_T75, dfa27_T_empty, dfa27_T1, dfa27_T1, dfa27_T50, dfa27_T54, - dfa27_T62, dfa27_T12, dfa27_T22, dfa27_T106, dfa27_T202, dfa27_T_empty, - dfa27_T76, dfa27_T_empty, dfa27_T_empty, dfa27_T1, dfa27_T1, dfa27_T58, - dfa27_T16, dfa27_T1, dfa27_T107, dfa27_T207, dfa27_T72, dfa27_T_empty, - dfa27_T_empty, dfa27_T60, dfa27_T1, dfa27_T_empty, dfa27_T74, dfa27_T1, - dfa27_T73, dfa27_T1, dfa27_T_empty, dfa27_T38, dfa27_T_empty, dfa27_T_empty, - dfa27_T77, dfa27_T_empty, dfa27_T36, dfa27_T1, dfa27_T41, dfa27_T_empty, - dfa27_T1, dfa27_T_empty -}; - - -/* Declare tracking structure for Cyclic DFA 27 - */ -static -ANTLR3_CYCLIC_DFA cdfa27 - = { - 27, /* Decision number of this dfa */ - /* Which decision this represents: */ - (const pANTLR3_UCHAR)"1:1: Tokens : ( T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | T__47 | T__48 | T__49 | T__50 | T__51 | T__52 | T__53 | T__54 | T__55 | T__56 | T__57 | T__58 | T__59 | T__60 | T__61 | T__62 | T__63 | T__64 | T__65 | T__66 | T__67 | T__68 | T__69 | T__70 | T__71 | T__72 | T__73 | T__74 | T__75 | T__76 | T__77 | T__78 | T__79 | T__80 | T__81 | T__82 | T__83 | T__84 | T__85 | T__86 | T__87 | T__88 | T__89 | T__90 | T__91 | T__92 | T__93 | T__94 | T__95 | T__96 | T__97 | T__98 | T__99 | T__100 | T__101 | T__102 | T__103 | T__104 | T__105 | T__106 | T__107 | T__108 | INCLUDE | IDENT | STRING | INT | FLOAT | COMMENT | LINE_COMMENT | WS );", - (CDFA_SPECIAL_FUNC) antlr3dfaspecialStateTransition, /* Default special state transition function */ - antlr3dfaspecialTransition, /* DFA specialTransition is currently just a default function in the runtime */ - antlr3dfapredict, /* DFA simulator function is in the runtime */ - dfa27_eot, /* EOT table */ - dfa27_eof, /* EOF table */ - dfa27_min, /* Minimum tokens for each state */ - dfa27_max, /* Maximum tokens for each state */ - dfa27_accept, /* Accept table */ - dfa27_special, /* Special transition states */ - dfa27_transitions /* Table of transition tables */ - - }; -/* End of Cyclic DFA 27 - * --------------------- - */ -/* ========================================================================= - * End of DFA tables for the lexer - */ - -/* ========================================================================= - * Functions to match the lexer grammar defined tokens from the input stream - */ - -// Comes from: 32:7: ( 'enum' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__32 - * - * Looks to match the characters the constitute the token T__32 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__32(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__32; - - - // NDDL/base/antlr/NDDL3.g:32:7: ( 'enum' ) - // NDDL/base/antlr/NDDL3.g:32:9: 'enum' - { - MATCHS(lit_1); - if (HASEXCEPTION()) - { - goto ruleT__32Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__32Ex; /* Prevent compiler warnings */ - ruleT__32Ex: ; - -} -// $ANTLR end T__32 - -// Comes from: 33:7: ( '{' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__33 - * - * Looks to match the characters the constitute the token T__33 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__33(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__33; - - - // NDDL/base/antlr/NDDL3.g:33:7: ( '{' ) - // NDDL/base/antlr/NDDL3.g:33:9: '{' - { - MATCHC('{'); - if (HASEXCEPTION()) - { - goto ruleT__33Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__33Ex; /* Prevent compiler warnings */ - ruleT__33Ex: ; - -} -// $ANTLR end T__33 - -// Comes from: 34:7: ( ',' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__34 - * - * Looks to match the characters the constitute the token T__34 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__34(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__34; - - - // NDDL/base/antlr/NDDL3.g:34:7: ( ',' ) - // NDDL/base/antlr/NDDL3.g:34:9: ',' - { - MATCHC(','); - if (HASEXCEPTION()) - { - goto ruleT__34Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__34Ex; /* Prevent compiler warnings */ - ruleT__34Ex: ; - -} -// $ANTLR end T__34 - -// Comes from: 35:7: ( '}' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__35 - * - * Looks to match the characters the constitute the token T__35 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__35(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__35; - - - // NDDL/base/antlr/NDDL3.g:35:7: ( '}' ) - // NDDL/base/antlr/NDDL3.g:35:9: '}' - { - MATCHC('}'); - if (HASEXCEPTION()) - { - goto ruleT__35Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__35Ex; /* Prevent compiler warnings */ - ruleT__35Ex: ; - -} -// $ANTLR end T__35 - -// Comes from: 36:7: ( 'typedef' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__36 - * - * Looks to match the characters the constitute the token T__36 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__36(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__36; - - - // NDDL/base/antlr/NDDL3.g:36:7: ( 'typedef' ) - // NDDL/base/antlr/NDDL3.g:36:9: 'typedef' - { - MATCHS(lit_2); - if (HASEXCEPTION()) - { - goto ruleT__36Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__36Ex; /* Prevent compiler warnings */ - ruleT__36Ex: ; - -} -// $ANTLR end T__36 - -// Comes from: 37:7: ( ';' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__37 - * - * Looks to match the characters the constitute the token T__37 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__37(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__37; - - - // NDDL/base/antlr/NDDL3.g:37:7: ( ';' ) - // NDDL/base/antlr/NDDL3.g:37:9: ';' - { - MATCHC(';'); - if (HASEXCEPTION()) - { - goto ruleT__37Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__37Ex; /* Prevent compiler warnings */ - ruleT__37Ex: ; - -} -// $ANTLR end T__37 - -// Comes from: 38:7: ( '[' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__38 - * - * Looks to match the characters the constitute the token T__38 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__38(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__38; - - - // NDDL/base/antlr/NDDL3.g:38:7: ( '[' ) - // NDDL/base/antlr/NDDL3.g:38:9: '[' - { - MATCHC('['); - if (HASEXCEPTION()) - { - goto ruleT__38Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__38Ex; /* Prevent compiler warnings */ - ruleT__38Ex: ; - -} -// $ANTLR end T__38 - -// Comes from: 39:7: ( ']' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__39 - * - * Looks to match the characters the constitute the token T__39 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__39(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__39; - - - // NDDL/base/antlr/NDDL3.g:39:7: ( ']' ) - // NDDL/base/antlr/NDDL3.g:39:9: ']' - { - MATCHC(']'); - if (HASEXCEPTION()) - { - goto ruleT__39Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__39Ex; /* Prevent compiler warnings */ - ruleT__39Ex: ; - -} -// $ANTLR end T__39 - -// Comes from: 40:7: ( 'filter' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__40 - * - * Looks to match the characters the constitute the token T__40 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__40(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__40; - - - // NDDL/base/antlr/NDDL3.g:40:7: ( 'filter' ) - // NDDL/base/antlr/NDDL3.g:40:9: 'filter' - { - MATCHS(lit_3); - if (HASEXCEPTION()) - { - goto ruleT__40Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__40Ex; /* Prevent compiler warnings */ - ruleT__40Ex: ; - -} -// $ANTLR end T__40 - -// Comes from: 41:7: ( '(' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__41 - * - * Looks to match the characters the constitute the token T__41 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__41(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__41; - - - // NDDL/base/antlr/NDDL3.g:41:7: ( '(' ) - // NDDL/base/antlr/NDDL3.g:41:9: '(' - { - MATCHC('('); - if (HASEXCEPTION()) - { - goto ruleT__41Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__41Ex; /* Prevent compiler warnings */ - ruleT__41Ex: ; - -} -// $ANTLR end T__41 - -// Comes from: 42:7: ( ')' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__42 - * - * Looks to match the characters the constitute the token T__42 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__42(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__42; - - - // NDDL/base/antlr/NDDL3.g:42:7: ( ')' ) - // NDDL/base/antlr/NDDL3.g:42:9: ')' - { - MATCHC(')'); - if (HASEXCEPTION()) - { - goto ruleT__42Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__42Ex; /* Prevent compiler warnings */ - ruleT__42Ex: ; - -} -// $ANTLR end T__42 - -// Comes from: 43:7: ( '=' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__43 - * - * Looks to match the characters the constitute the token T__43 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__43(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__43; - - - // NDDL/base/antlr/NDDL3.g:43:7: ( '=' ) - // NDDL/base/antlr/NDDL3.g:43:9: '=' - { - MATCHC('='); - if (HASEXCEPTION()) - { - goto ruleT__43Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__43Ex; /* Prevent compiler warnings */ - ruleT__43Ex: ; - -} -// $ANTLR end T__43 - -// Comes from: 44:7: ( 'new' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__44 - * - * Looks to match the characters the constitute the token T__44 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__44(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__44; - - - // NDDL/base/antlr/NDDL3.g:44:7: ( 'new' ) - // NDDL/base/antlr/NDDL3.g:44:9: 'new' - { - MATCHS(lit_4); - if (HASEXCEPTION()) - { - goto ruleT__44Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__44Ex; /* Prevent compiler warnings */ - ruleT__44Ex: ; - -} -// $ANTLR end T__44 - -// Comes from: 45:7: ( 'this' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__45 - * - * Looks to match the characters the constitute the token T__45 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__45(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__45; - - - // NDDL/base/antlr/NDDL3.g:45:7: ( 'this' ) - // NDDL/base/antlr/NDDL3.g:45:9: 'this' - { - MATCHS(lit_5); - if (HASEXCEPTION()) - { - goto ruleT__45Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__45Ex; /* Prevent compiler warnings */ - ruleT__45Ex: ; - -} -// $ANTLR end T__45 - -// Comes from: 46:7: ( '.' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__46 - * - * Looks to match the characters the constitute the token T__46 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__46(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__46; - - - // NDDL/base/antlr/NDDL3.g:46:7: ( '.' ) - // NDDL/base/antlr/NDDL3.g:46:9: '.' - { - MATCHC('.'); - if (HASEXCEPTION()) - { - goto ruleT__46Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__46Ex; /* Prevent compiler warnings */ - ruleT__46Ex: ; - -} -// $ANTLR end T__46 - -// Comes from: 47:7: ( 'in' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__47 - * - * Looks to match the characters the constitute the token T__47 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__47(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__47; - - - // NDDL/base/antlr/NDDL3.g:47:7: ( 'in' ) - // NDDL/base/antlr/NDDL3.g:47:9: 'in' - { - MATCHS(lit_6); - if (HASEXCEPTION()) - { - goto ruleT__47Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__47Ex; /* Prevent compiler warnings */ - ruleT__47Ex: ; - -} -// $ANTLR end T__47 - -// Comes from: 48:7: ( 'class' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__48 - * - * Looks to match the characters the constitute the token T__48 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__48(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__48; - - - // NDDL/base/antlr/NDDL3.g:48:7: ( 'class' ) - // NDDL/base/antlr/NDDL3.g:48:9: 'class' - { - MATCHS(lit_7); - if (HASEXCEPTION()) - { - goto ruleT__48Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__48Ex; /* Prevent compiler warnings */ - ruleT__48Ex: ; - -} -// $ANTLR end T__48 - -// Comes from: 49:7: ( 'extends' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__49 - * - * Looks to match the characters the constitute the token T__49 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__49(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__49; - - - // NDDL/base/antlr/NDDL3.g:49:7: ( 'extends' ) - // NDDL/base/antlr/NDDL3.g:49:9: 'extends' - { - MATCHS(lit_8); - if (HASEXCEPTION()) - { - goto ruleT__49Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__49Ex; /* Prevent compiler warnings */ - ruleT__49Ex: ; - -} -// $ANTLR end T__49 - -// Comes from: 50:7: ( 'predicate' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__50 - * - * Looks to match the characters the constitute the token T__50 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__50(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__50; - - - // NDDL/base/antlr/NDDL3.g:50:7: ( 'predicate' ) - // NDDL/base/antlr/NDDL3.g:50:9: 'predicate' - { - MATCHS(lit_9); - if (HASEXCEPTION()) - { - goto ruleT__50Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__50Ex; /* Prevent compiler warnings */ - ruleT__50Ex: ; - -} -// $ANTLR end T__50 - -// Comes from: 51:7: ( 'action' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__51 - * - * Looks to match the characters the constitute the token T__51 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__51(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__51; - - - // NDDL/base/antlr/NDDL3.g:51:7: ( 'action' ) - // NDDL/base/antlr/NDDL3.g:51:9: 'action' - { - MATCHS(lit_10); - if (HASEXCEPTION()) - { - goto ruleT__51Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__51Ex; /* Prevent compiler warnings */ - ruleT__51Ex: ; - -} -// $ANTLR end T__51 - -// Comes from: 52:7: ( '::' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__52 - * - * Looks to match the characters the constitute the token T__52 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__52(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__52; - - - // NDDL/base/antlr/NDDL3.g:52:7: ( '::' ) - // NDDL/base/antlr/NDDL3.g:52:9: '::' - { - MATCHS(lit_11); - if (HASEXCEPTION()) - { - goto ruleT__52Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__52Ex; /* Prevent compiler warnings */ - ruleT__52Ex: ; - -} -// $ANTLR end T__52 - -// Comes from: 53:7: ( 'int' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__53 - * - * Looks to match the characters the constitute the token T__53 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__53(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__53; - - - // NDDL/base/antlr/NDDL3.g:53:7: ( 'int' ) - // NDDL/base/antlr/NDDL3.g:53:9: 'int' - { - MATCHS(lit_12); - if (HASEXCEPTION()) - { - goto ruleT__53Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__53Ex; /* Prevent compiler warnings */ - ruleT__53Ex: ; - -} -// $ANTLR end T__53 - -// Comes from: 54:7: ( 'float' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__54 - * - * Looks to match the characters the constitute the token T__54 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__54(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__54; - - - // NDDL/base/antlr/NDDL3.g:54:7: ( 'float' ) - // NDDL/base/antlr/NDDL3.g:54:9: 'float' - { - MATCHS(lit_13); - if (HASEXCEPTION()) - { - goto ruleT__54Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__54Ex; /* Prevent compiler warnings */ - ruleT__54Ex: ; - -} -// $ANTLR end T__54 - -// Comes from: 55:7: ( 'bool' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__55 - * - * Looks to match the characters the constitute the token T__55 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__55(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__55; - - - // NDDL/base/antlr/NDDL3.g:55:7: ( 'bool' ) - // NDDL/base/antlr/NDDL3.g:55:9: 'bool' - { - MATCHS(lit_14); - if (HASEXCEPTION()) - { - goto ruleT__55Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__55Ex; /* Prevent compiler warnings */ - ruleT__55Ex: ; - -} -// $ANTLR end T__55 - -// Comes from: 56:7: ( 'string' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__56 - * - * Looks to match the characters the constitute the token T__56 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__56(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__56; - - - // NDDL/base/antlr/NDDL3.g:56:7: ( 'string' ) - // NDDL/base/antlr/NDDL3.g:56:9: 'string' - { - MATCHS(lit_15); - if (HASEXCEPTION()) - { - goto ruleT__56Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__56Ex; /* Prevent compiler warnings */ - ruleT__56Ex: ; - -} -// $ANTLR end T__56 - -// Comes from: 57:7: ( 'rejectable' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__57 - * - * Looks to match the characters the constitute the token T__57 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__57(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__57; - - - // NDDL/base/antlr/NDDL3.g:57:7: ( 'rejectable' ) - // NDDL/base/antlr/NDDL3.g:57:9: 'rejectable' - { - MATCHS(lit_16); - if (HASEXCEPTION()) - { - goto ruleT__57Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__57Ex; /* Prevent compiler warnings */ - ruleT__57Ex: ; - -} -// $ANTLR end T__57 - -// Comes from: 58:7: ( 'goal' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__58 - * - * Looks to match the characters the constitute the token T__58 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__58(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__58; - - - // NDDL/base/antlr/NDDL3.g:58:7: ( 'goal' ) - // NDDL/base/antlr/NDDL3.g:58:9: 'goal' - { - MATCHS(lit_17); - if (HASEXCEPTION()) - { - goto ruleT__58Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__58Ex; /* Prevent compiler warnings */ - ruleT__58Ex: ; - -} -// $ANTLR end T__58 - -// Comes from: 59:7: ( 'fact' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__59 - * - * Looks to match the characters the constitute the token T__59 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__59(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__59; - - - // NDDL/base/antlr/NDDL3.g:59:7: ( 'fact' ) - // NDDL/base/antlr/NDDL3.g:59:9: 'fact' - { - MATCHS(lit_18); - if (HASEXCEPTION()) - { - goto ruleT__59Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__59Ex; /* Prevent compiler warnings */ - ruleT__59Ex: ; - -} -// $ANTLR end T__59 - -// Comes from: 60:7: ( 'condition' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__60 - * - * Looks to match the characters the constitute the token T__60 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__60(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__60; - - - // NDDL/base/antlr/NDDL3.g:60:7: ( 'condition' ) - // NDDL/base/antlr/NDDL3.g:60:9: 'condition' - { - MATCHS(lit_19); - if (HASEXCEPTION()) - { - goto ruleT__60Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__60Ex; /* Prevent compiler warnings */ - ruleT__60Ex: ; - -} -// $ANTLR end T__60 - -// Comes from: 61:7: ( 'effect' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__61 - * - * Looks to match the characters the constitute the token T__61 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__61(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__61; - - - // NDDL/base/antlr/NDDL3.g:61:7: ( 'effect' ) - // NDDL/base/antlr/NDDL3.g:61:9: 'effect' - { - MATCHS(lit_20); - if (HASEXCEPTION()) - { - goto ruleT__61Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__61Ex; /* Prevent compiler warnings */ - ruleT__61Ex: ; - -} -// $ANTLR end T__61 - -// Comes from: 62:7: ( ':' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__62 - * - * Looks to match the characters the constitute the token T__62 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__62(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__62; - - - // NDDL/base/antlr/NDDL3.g:62:7: ( ':' ) - // NDDL/base/antlr/NDDL3.g:62:9: ':' - { - MATCHC(':'); - if (HASEXCEPTION()) - { - goto ruleT__62Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__62Ex; /* Prevent compiler warnings */ - ruleT__62Ex: ; - -} -// $ANTLR end T__62 - -// Comes from: 63:7: ( 'enforce' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__63 - * - * Looks to match the characters the constitute the token T__63 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__63(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__63; - - - // NDDL/base/antlr/NDDL3.g:63:7: ( 'enforce' ) - // NDDL/base/antlr/NDDL3.g:63:9: 'enforce' - { - MATCHS(lit_21); - if (HASEXCEPTION()) - { - goto ruleT__63Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__63Ex; /* Prevent compiler warnings */ - ruleT__63Ex: ; - -} -// $ANTLR end T__63 - -// Comes from: 64:7: ( '||' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__64 - * - * Looks to match the characters the constitute the token T__64 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__64(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__64; - - - // NDDL/base/antlr/NDDL3.g:64:7: ( '||' ) - // NDDL/base/antlr/NDDL3.g:64:9: '||' - { - MATCHS(lit_22); - if (HASEXCEPTION()) - { - goto ruleT__64Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__64Ex; /* Prevent compiler warnings */ - ruleT__64Ex: ; - -} -// $ANTLR end T__64 - -// Comes from: 65:7: ( '&&' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__65 - * - * Looks to match the characters the constitute the token T__65 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__65(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__65; - - - // NDDL/base/antlr/NDDL3.g:65:7: ( '&&' ) - // NDDL/base/antlr/NDDL3.g:65:9: '&&' - { - MATCHS(lit_23); - if (HASEXCEPTION()) - { - goto ruleT__65Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__65Ex; /* Prevent compiler warnings */ - ruleT__65Ex: ; - -} -// $ANTLR end T__65 - -// Comes from: 66:7: ( '==' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__66 - * - * Looks to match the characters the constitute the token T__66 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__66(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__66; - - - // NDDL/base/antlr/NDDL3.g:66:7: ( '==' ) - // NDDL/base/antlr/NDDL3.g:66:9: '==' - { - MATCHS(lit_24); - if (HASEXCEPTION()) - { - goto ruleT__66Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__66Ex; /* Prevent compiler warnings */ - ruleT__66Ex: ; - -} -// $ANTLR end T__66 - -// Comes from: 67:7: ( '!=' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__67 - * - * Looks to match the characters the constitute the token T__67 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__67(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__67; - - - // NDDL/base/antlr/NDDL3.g:67:7: ( '!=' ) - // NDDL/base/antlr/NDDL3.g:67:9: '!=' - { - MATCHS(lit_25); - if (HASEXCEPTION()) - { - goto ruleT__67Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__67Ex; /* Prevent compiler warnings */ - ruleT__67Ex: ; - -} -// $ANTLR end T__67 - -// Comes from: 68:7: ( '<' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__68 - * - * Looks to match the characters the constitute the token T__68 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__68(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__68; - - - // NDDL/base/antlr/NDDL3.g:68:7: ( '<' ) - // NDDL/base/antlr/NDDL3.g:68:9: '<' - { - MATCHC('<'); - if (HASEXCEPTION()) - { - goto ruleT__68Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__68Ex; /* Prevent compiler warnings */ - ruleT__68Ex: ; - -} -// $ANTLR end T__68 - -// Comes from: 69:7: ( '>' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__69 - * - * Looks to match the characters the constitute the token T__69 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__69(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__69; - - - // NDDL/base/antlr/NDDL3.g:69:7: ( '>' ) - // NDDL/base/antlr/NDDL3.g:69:9: '>' - { - MATCHC('>'); - if (HASEXCEPTION()) - { - goto ruleT__69Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__69Ex; /* Prevent compiler warnings */ - ruleT__69Ex: ; - -} -// $ANTLR end T__69 - -// Comes from: 70:7: ( '>=' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__70 - * - * Looks to match the characters the constitute the token T__70 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__70(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__70; - - - // NDDL/base/antlr/NDDL3.g:70:7: ( '>=' ) - // NDDL/base/antlr/NDDL3.g:70:9: '>=' - { - MATCHS(lit_26); - if (HASEXCEPTION()) - { - goto ruleT__70Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__70Ex; /* Prevent compiler warnings */ - ruleT__70Ex: ; - -} -// $ANTLR end T__70 - -// Comes from: 71:7: ( '<=' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__71 - * - * Looks to match the characters the constitute the token T__71 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__71(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__71; - - - // NDDL/base/antlr/NDDL3.g:71:7: ( '<=' ) - // NDDL/base/antlr/NDDL3.g:71:9: '<=' - { - MATCHS(lit_27); - if (HASEXCEPTION()) - { - goto ruleT__71Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__71Ex; /* Prevent compiler warnings */ - ruleT__71Ex: ; - -} -// $ANTLR end T__71 - -// Comes from: 72:7: ( '+' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__72 - * - * Looks to match the characters the constitute the token T__72 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__72(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__72; - - - // NDDL/base/antlr/NDDL3.g:72:7: ( '+' ) - // NDDL/base/antlr/NDDL3.g:72:9: '+' - { - MATCHC('+'); - if (HASEXCEPTION()) - { - goto ruleT__72Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__72Ex; /* Prevent compiler warnings */ - ruleT__72Ex: ; - -} -// $ANTLR end T__72 - -// Comes from: 73:7: ( '-' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__73 - * - * Looks to match the characters the constitute the token T__73 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__73(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__73; - - - // NDDL/base/antlr/NDDL3.g:73:7: ( '-' ) - // NDDL/base/antlr/NDDL3.g:73:9: '-' - { - MATCHC('-'); - if (HASEXCEPTION()) - { - goto ruleT__73Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__73Ex; /* Prevent compiler warnings */ - ruleT__73Ex: ; - -} -// $ANTLR end T__73 - -// Comes from: 74:7: ( '*' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__74 - * - * Looks to match the characters the constitute the token T__74 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__74(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__74; - - - // NDDL/base/antlr/NDDL3.g:74:7: ( '*' ) - // NDDL/base/antlr/NDDL3.g:74:9: '*' - { - MATCHC('*'); - if (HASEXCEPTION()) - { - goto ruleT__74Ex; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__74Ex; /* Prevent compiler warnings */ - ruleT__74Ex: ; - -} -// $ANTLR end T__74 - -// Comes from: 75:7: ( 'super' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__75 - * - * Looks to match the characters the constitute the token T__75 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__75(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__75; - - - // NDDL/base/antlr/NDDL3.g:75:7: ( 'super' ) - // NDDL/base/antlr/NDDL3.g:75:9: 'super' - { - MATCHS(lit_28); - if (HASEXCEPTION()) - { - goto ruleT__75Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__75Ex; /* Prevent compiler warnings */ - ruleT__75Ex: ; - -} -// $ANTLR end T__75 - -// Comes from: 76:7: ( 'if' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__76 - * - * Looks to match the characters the constitute the token T__76 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__76(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__76; - - - // NDDL/base/antlr/NDDL3.g:76:7: ( 'if' ) - // NDDL/base/antlr/NDDL3.g:76:9: 'if' - { - MATCHS(lit_29); - if (HASEXCEPTION()) - { - goto ruleT__76Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__76Ex; /* Prevent compiler warnings */ - ruleT__76Ex: ; - -} -// $ANTLR end T__76 - -// Comes from: 77:7: ( 'else' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__77 - * - * Looks to match the characters the constitute the token T__77 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__77(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__77; - - - // NDDL/base/antlr/NDDL3.g:77:7: ( 'else' ) - // NDDL/base/antlr/NDDL3.g:77:9: 'else' - { - MATCHS(lit_30); - if (HASEXCEPTION()) - { - goto ruleT__77Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__77Ex; /* Prevent compiler warnings */ - ruleT__77Ex: ; - -} -// $ANTLR end T__77 - -// Comes from: 78:7: ( 'foreach' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__78 - * - * Looks to match the characters the constitute the token T__78 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__78(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__78; - - - // NDDL/base/antlr/NDDL3.g:78:7: ( 'foreach' ) - // NDDL/base/antlr/NDDL3.g:78:9: 'foreach' - { - MATCHS(lit_31); - if (HASEXCEPTION()) - { - goto ruleT__78Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__78Ex; /* Prevent compiler warnings */ - ruleT__78Ex: ; - -} -// $ANTLR end T__78 - -// Comes from: 79:7: ( 'after' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__79 - * - * Looks to match the characters the constitute the token T__79 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__79(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__79; - - - // NDDL/base/antlr/NDDL3.g:79:7: ( 'after' ) - // NDDL/base/antlr/NDDL3.g:79:9: 'after' - { - MATCHS(lit_32); - if (HASEXCEPTION()) - { - goto ruleT__79Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__79Ex; /* Prevent compiler warnings */ - ruleT__79Ex: ; - -} -// $ANTLR end T__79 - -// Comes from: 80:7: ( 'any' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__80 - * - * Looks to match the characters the constitute the token T__80 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__80(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__80; - - - // NDDL/base/antlr/NDDL3.g:80:7: ( 'any' ) - // NDDL/base/antlr/NDDL3.g:80:9: 'any' - { - MATCHS(lit_33); - if (HASEXCEPTION()) - { - goto ruleT__80Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__80Ex; /* Prevent compiler warnings */ - ruleT__80Ex: ; - -} -// $ANTLR end T__80 - -// Comes from: 81:7: ( 'before' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__81 - * - * Looks to match the characters the constitute the token T__81 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__81(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__81; - - - // NDDL/base/antlr/NDDL3.g:81:7: ( 'before' ) - // NDDL/base/antlr/NDDL3.g:81:9: 'before' - { - MATCHS(lit_34); - if (HASEXCEPTION()) - { - goto ruleT__81Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__81Ex; /* Prevent compiler warnings */ - ruleT__81Ex: ; - -} -// $ANTLR end T__81 - -// Comes from: 82:7: ( 'contained_by' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__82 - * - * Looks to match the characters the constitute the token T__82 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__82(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__82; - - - // NDDL/base/antlr/NDDL3.g:82:7: ( 'contained_by' ) - // NDDL/base/antlr/NDDL3.g:82:9: 'contained_by' - { - MATCHS(lit_35); - if (HASEXCEPTION()) - { - goto ruleT__82Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__82Ex; /* Prevent compiler warnings */ - ruleT__82Ex: ; - -} -// $ANTLR end T__82 - -// Comes from: 83:7: ( 'contains' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__83 - * - * Looks to match the characters the constitute the token T__83 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__83(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__83; - - - // NDDL/base/antlr/NDDL3.g:83:7: ( 'contains' ) - // NDDL/base/antlr/NDDL3.g:83:9: 'contains' - { - MATCHS(lit_36); - if (HASEXCEPTION()) - { - goto ruleT__83Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__83Ex; /* Prevent compiler warnings */ - ruleT__83Ex: ; - -} -// $ANTLR end T__83 - -// Comes from: 84:7: ( 'contains_end' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__84 - * - * Looks to match the characters the constitute the token T__84 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__84(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__84; - - - // NDDL/base/antlr/NDDL3.g:84:7: ( 'contains_end' ) - // NDDL/base/antlr/NDDL3.g:84:9: 'contains_end' - { - MATCHS(lit_37); - if (HASEXCEPTION()) - { - goto ruleT__84Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__84Ex; /* Prevent compiler warnings */ - ruleT__84Ex: ; - -} -// $ANTLR end T__84 - -// Comes from: 85:7: ( 'contains_start' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__85 - * - * Looks to match the characters the constitute the token T__85 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__85(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__85; - - - // NDDL/base/antlr/NDDL3.g:85:7: ( 'contains_start' ) - // NDDL/base/antlr/NDDL3.g:85:9: 'contains_start' - { - MATCHS(lit_38); - if (HASEXCEPTION()) - { - goto ruleT__85Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__85Ex; /* Prevent compiler warnings */ - ruleT__85Ex: ; - -} -// $ANTLR end T__85 - -// Comes from: 86:7: ( 'ends' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__86 - * - * Looks to match the characters the constitute the token T__86 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__86(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__86; - - - // NDDL/base/antlr/NDDL3.g:86:7: ( 'ends' ) - // NDDL/base/antlr/NDDL3.g:86:9: 'ends' - { - MATCHS(lit_39); - if (HASEXCEPTION()) - { - goto ruleT__86Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__86Ex; /* Prevent compiler warnings */ - ruleT__86Ex: ; - -} -// $ANTLR end T__86 - -// Comes from: 87:7: ( 'ends_after' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__87 - * - * Looks to match the characters the constitute the token T__87 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__87(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__87; - - - // NDDL/base/antlr/NDDL3.g:87:7: ( 'ends_after' ) - // NDDL/base/antlr/NDDL3.g:87:9: 'ends_after' - { - MATCHS(lit_40); - if (HASEXCEPTION()) - { - goto ruleT__87Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__87Ex; /* Prevent compiler warnings */ - ruleT__87Ex: ; - -} -// $ANTLR end T__87 - -// Comes from: 88:7: ( 'ends_after_start' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__88 - * - * Looks to match the characters the constitute the token T__88 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__88(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__88; - - - // NDDL/base/antlr/NDDL3.g:88:7: ( 'ends_after_start' ) - // NDDL/base/antlr/NDDL3.g:88:9: 'ends_after_start' - { - MATCHS(lit_41); - if (HASEXCEPTION()) - { - goto ruleT__88Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__88Ex; /* Prevent compiler warnings */ - ruleT__88Ex: ; - -} -// $ANTLR end T__88 - -// Comes from: 89:7: ( 'ends_before' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__89 - * - * Looks to match the characters the constitute the token T__89 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__89(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__89; - - - // NDDL/base/antlr/NDDL3.g:89:7: ( 'ends_before' ) - // NDDL/base/antlr/NDDL3.g:89:9: 'ends_before' - { - MATCHS(lit_42); - if (HASEXCEPTION()) - { - goto ruleT__89Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__89Ex; /* Prevent compiler warnings */ - ruleT__89Ex: ; - -} -// $ANTLR end T__89 - -// Comes from: 90:7: ( 'ends_during' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__90 - * - * Looks to match the characters the constitute the token T__90 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__90(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__90; - - - // NDDL/base/antlr/NDDL3.g:90:7: ( 'ends_during' ) - // NDDL/base/antlr/NDDL3.g:90:9: 'ends_during' - { - MATCHS(lit_43); - if (HASEXCEPTION()) - { - goto ruleT__90Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__90Ex; /* Prevent compiler warnings */ - ruleT__90Ex: ; - -} -// $ANTLR end T__90 - -// Comes from: 91:7: ( 'equal' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__91 - * - * Looks to match the characters the constitute the token T__91 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__91(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__91; - - - // NDDL/base/antlr/NDDL3.g:91:7: ( 'equal' ) - // NDDL/base/antlr/NDDL3.g:91:9: 'equal' - { - MATCHS(lit_44); - if (HASEXCEPTION()) - { - goto ruleT__91Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__91Ex; /* Prevent compiler warnings */ - ruleT__91Ex: ; - -} -// $ANTLR end T__91 - -// Comes from: 92:7: ( 'equals' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__92 - * - * Looks to match the characters the constitute the token T__92 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__92(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__92; - - - // NDDL/base/antlr/NDDL3.g:92:7: ( 'equals' ) - // NDDL/base/antlr/NDDL3.g:92:9: 'equals' - { - MATCHS(lit_45); - if (HASEXCEPTION()) - { - goto ruleT__92Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__92Ex; /* Prevent compiler warnings */ - ruleT__92Ex: ; - -} -// $ANTLR end T__92 - -// Comes from: 93:7: ( 'meets' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__93 - * - * Looks to match the characters the constitute the token T__93 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__93(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__93; - - - // NDDL/base/antlr/NDDL3.g:93:7: ( 'meets' ) - // NDDL/base/antlr/NDDL3.g:93:9: 'meets' - { - MATCHS(lit_46); - if (HASEXCEPTION()) - { - goto ruleT__93Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__93Ex; /* Prevent compiler warnings */ - ruleT__93Ex: ; - -} -// $ANTLR end T__93 - -// Comes from: 94:7: ( 'met_by' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__94 - * - * Looks to match the characters the constitute the token T__94 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__94(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__94; - - - // NDDL/base/antlr/NDDL3.g:94:7: ( 'met_by' ) - // NDDL/base/antlr/NDDL3.g:94:9: 'met_by' - { - MATCHS(lit_47); - if (HASEXCEPTION()) - { - goto ruleT__94Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__94Ex; /* Prevent compiler warnings */ - ruleT__94Ex: ; - -} -// $ANTLR end T__94 - -// Comes from: 95:7: ( 'parallels' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__95 - * - * Looks to match the characters the constitute the token T__95 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__95(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__95; - - - // NDDL/base/antlr/NDDL3.g:95:7: ( 'parallels' ) - // NDDL/base/antlr/NDDL3.g:95:9: 'parallels' - { - MATCHS(lit_48); - if (HASEXCEPTION()) - { - goto ruleT__95Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__95Ex; /* Prevent compiler warnings */ - ruleT__95Ex: ; - -} -// $ANTLR end T__95 - -// Comes from: 96:7: ( 'paralleled_by' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__96 - * - * Looks to match the characters the constitute the token T__96 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__96(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__96; - - - // NDDL/base/antlr/NDDL3.g:96:7: ( 'paralleled_by' ) - // NDDL/base/antlr/NDDL3.g:96:9: 'paralleled_by' - { - MATCHS(lit_49); - if (HASEXCEPTION()) - { - goto ruleT__96Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__96Ex; /* Prevent compiler warnings */ - ruleT__96Ex: ; - -} -// $ANTLR end T__96 - -// Comes from: 97:7: ( 'starts' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__97 - * - * Looks to match the characters the constitute the token T__97 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__97(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__97; - - - // NDDL/base/antlr/NDDL3.g:97:7: ( 'starts' ) - // NDDL/base/antlr/NDDL3.g:97:9: 'starts' - { - MATCHS(lit_50); - if (HASEXCEPTION()) - { - goto ruleT__97Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__97Ex; /* Prevent compiler warnings */ - ruleT__97Ex: ; - -} -// $ANTLR end T__97 - -// Comes from: 98:7: ( 'starts_after' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__98 - * - * Looks to match the characters the constitute the token T__98 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__98(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__98; - - - // NDDL/base/antlr/NDDL3.g:98:7: ( 'starts_after' ) - // NDDL/base/antlr/NDDL3.g:98:9: 'starts_after' - { - MATCHS(lit_51); - if (HASEXCEPTION()) - { - goto ruleT__98Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__98Ex; /* Prevent compiler warnings */ - ruleT__98Ex: ; - -} -// $ANTLR end T__98 - -// Comes from: 99:7: ( 'starts_before' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__99 - * - * Looks to match the characters the constitute the token T__99 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__99(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__99; - - - // NDDL/base/antlr/NDDL3.g:99:7: ( 'starts_before' ) - // NDDL/base/antlr/NDDL3.g:99:9: 'starts_before' - { - MATCHS(lit_52); - if (HASEXCEPTION()) - { - goto ruleT__99Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__99Ex; /* Prevent compiler warnings */ - ruleT__99Ex: ; - -} -// $ANTLR end T__99 - -// Comes from: 100:8: ( 'starts_before_end' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__100 - * - * Looks to match the characters the constitute the token T__100 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__100(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__100; - - - // NDDL/base/antlr/NDDL3.g:100:8: ( 'starts_before_end' ) - // NDDL/base/antlr/NDDL3.g:100:10: 'starts_before_end' - { - MATCHS(lit_53); - if (HASEXCEPTION()) - { - goto ruleT__100Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__100Ex; /* Prevent compiler warnings */ - ruleT__100Ex: ; - -} -// $ANTLR end T__100 - -// Comes from: 101:8: ( 'starts_during' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__101 - * - * Looks to match the characters the constitute the token T__101 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__101(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__101; - - - // NDDL/base/antlr/NDDL3.g:101:8: ( 'starts_during' ) - // NDDL/base/antlr/NDDL3.g:101:10: 'starts_during' - { - MATCHS(lit_54); - if (HASEXCEPTION()) - { - goto ruleT__101Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__101Ex; /* Prevent compiler warnings */ - ruleT__101Ex: ; - -} -// $ANTLR end T__101 - -// Comes from: 102:8: ( 'true' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__102 - * - * Looks to match the characters the constitute the token T__102 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__102(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__102; - - - // NDDL/base/antlr/NDDL3.g:102:8: ( 'true' ) - // NDDL/base/antlr/NDDL3.g:102:10: 'true' - { - MATCHS(lit_55); - if (HASEXCEPTION()) - { - goto ruleT__102Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__102Ex; /* Prevent compiler warnings */ - ruleT__102Ex: ; - -} -// $ANTLR end T__102 - -// Comes from: 103:8: ( 'false' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__103 - * - * Looks to match the characters the constitute the token T__103 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__103(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__103; - - - // NDDL/base/antlr/NDDL3.g:103:8: ( 'false' ) - // NDDL/base/antlr/NDDL3.g:103:10: 'false' - { - MATCHS(lit_56); - if (HASEXCEPTION()) - { - goto ruleT__103Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__103Ex; /* Prevent compiler warnings */ - ruleT__103Ex: ; - -} -// $ANTLR end T__103 - -// Comes from: 104:8: ( 'inf' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__104 - * - * Looks to match the characters the constitute the token T__104 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__104(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__104; - - - // NDDL/base/antlr/NDDL3.g:104:8: ( 'inf' ) - // NDDL/base/antlr/NDDL3.g:104:10: 'inf' - { - MATCHS(lit_57); - if (HASEXCEPTION()) - { - goto ruleT__104Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__104Ex; /* Prevent compiler warnings */ - ruleT__104Ex: ; - -} -// $ANTLR end T__104 - -// Comes from: 105:8: ( 'inff' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__105 - * - * Looks to match the characters the constitute the token T__105 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__105(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__105; - - - // NDDL/base/antlr/NDDL3.g:105:8: ( 'inff' ) - // NDDL/base/antlr/NDDL3.g:105:10: 'inff' - { - MATCHS(lit_58); - if (HASEXCEPTION()) - { - goto ruleT__105Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__105Ex; /* Prevent compiler warnings */ - ruleT__105Ex: ; - -} -// $ANTLR end T__105 - -// Comes from: 106:8: ( '-inf' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__106 - * - * Looks to match the characters the constitute the token T__106 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__106(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__106; - - - // NDDL/base/antlr/NDDL3.g:106:8: ( '-inf' ) - // NDDL/base/antlr/NDDL3.g:106:10: '-inf' - { - MATCHS(lit_59); - if (HASEXCEPTION()) - { - goto ruleT__106Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__106Ex; /* Prevent compiler warnings */ - ruleT__106Ex: ; - -} -// $ANTLR end T__106 - -// Comes from: 107:8: ( '-inff' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__107 - * - * Looks to match the characters the constitute the token T__107 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__107(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__107; - - - // NDDL/base/antlr/NDDL3.g:107:8: ( '-inff' ) - // NDDL/base/antlr/NDDL3.g:107:10: '-inff' - { - MATCHS(lit_60); - if (HASEXCEPTION()) - { - goto ruleT__107Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__107Ex; /* Prevent compiler warnings */ - ruleT__107Ex: ; - -} -// $ANTLR end T__107 - -// Comes from: 108:8: ( 'close' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__108 - * - * Looks to match the characters the constitute the token T__108 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__108(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__108; - - - // NDDL/base/antlr/NDDL3.g:108:8: ( 'close' ) - // NDDL/base/antlr/NDDL3.g:108:10: 'close' - { - MATCHS(lit_61); - if (HASEXCEPTION()) - { - goto ruleT__108Ex; - } - - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleT__108Ex; /* Prevent compiler warnings */ - ruleT__108Ex: ; - -} -// $ANTLR end T__108 - -// Comes from: 463:9: ( '#include' ( WS )+ file= STRING ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start INCLUDE - * - * Looks to match the characters the constitute the token INCLUDE - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mINCLUDE(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - pANTLR3_COMMON_TOKEN file; - - - file = NULL; - - _type = INCLUDE; - - - // NDDL/base/antlr/NDDL3.g:463:9: ( '#include' ( WS )+ file= STRING ) - // NDDL/base/antlr/NDDL3.g:463:11: '#include' ( WS )+ file= STRING - { - MATCHS(lit_62); - if (HASEXCEPTION()) - { - goto ruleINCLUDEEx; - } - - - // NDDL/base/antlr/NDDL3.g:463:22: ( WS )+ - { - int cnt1=0; - - for (;;) - { - int alt1=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA1_0 = LA(1); - if ( (((LA1_0 >= '\t') && (LA1_0 <= '\n')) || ((LA1_0 >= '\f') && (LA1_0 <= '\r')) || LA1_0 == ' ') ) - { - alt1=1; - } - - } - switch (alt1) - { - case 1: - // NDDL/base/antlr/NDDL3.g:463:22: WS - { - /* 463:22: WS */ - mWS(ctx ); - if (HASEXCEPTION()) - { - goto ruleINCLUDEEx; - } - - - } - break; - - default: - - if ( cnt1 >= 1 ) - { - goto loop1; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleINCLUDEEx; - } - cnt1++; - } - loop1: ; /* Jump to here if this rule does not match */ - } - /* 463:11: '#include' ( WS )+ file= STRING */ - { - ANTLR3_MARKER fileStart670 = GETCHARINDEX(); - mSTRING(ctx ); - if (HASEXCEPTION()) - { - goto ruleINCLUDEEx; - } - - file = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory); - file->setType(file, ANTLR3_TOKEN_INVALID); - file->setStartIndex(file, fileStart670); - file->setStopIndex(file, GETCHARINDEX()-1); - file->input = INPUT; - } - { - - std::string fullName = std::string((const char*)((file->getText(file))->chars)); - - // Look for the included file in include path - fullName = CTX->parserObj->getFilename(fullName); - - // TODO: if we couldn't find it, look in the same dir as the current file - - if (fullName.length() == 0) { - std::string path = ""; - std::vector parserPath = CTX->parserObj->getIncludePath(); - for (unsigned int i=0; istate->errorCount++; - std::string message = ("File not found: " + std::string((const char*)(file->getText(file))->chars) - + ", search path \"" + path + "\""); - EXCEPTION->message = (void*) strdup(message.c_str()); - EXCEPTION->token = file; - return; // generated code has GOTO to the end - // reportLexerError(RECOGNIZER, NULL); //Note: the second argument does not appear to be used for anything. - // check_runtime_error(false, std::string("ERROR!: couldn't find file: " + std::string((const char*)(file->getText(file))->chars) - // + ", search path \"" + path + "\"").c_str()); - } - - if (!CTX->parserObj->queryIncludeGuard(fullName)) { - CTX->parserObj->addInclude(fullName); - - // Create a new input stream and take advantage of built in stream stacking - // in C target runtime. - - pANTLR3_STRING_FACTORY factory = antlr3StringFactoryNew(); - pANTLR3_STRING fName = factory->newStr(factory,(ANTLR3_UINT8 *)fullName.c_str()); - - pANTLR3_INPUT_STREAM in = antlr3AsciiFileStreamNew(fName->chars); - PUSHSTREAM(in); - CTX->parserObj->addInputStream(in); - factory->destroy(factory,fName); - factory->close(factory); - } else { - //std::cout << "Ignoring already included file " << fullName << std::endl; - } - - LEXSTATE->channel=HIDDEN; - - } - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleINCLUDEEx; /* Prevent compiler warnings */ - ruleINCLUDEEx: ; - - file = NULL; - -} -// $ANTLR end INCLUDE - -// Comes from: 514:7: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '$' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '$' )* ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start IDENT - * - * Looks to match the characters the constitute the token IDENT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mIDENT(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = IDENT; - - - // NDDL/base/antlr/NDDL3.g:514:7: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '$' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '$' )* ) - // NDDL/base/antlr/NDDL3.g:514:10: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '$' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '$' )* - { - if ( LA(1) == '$' || ((LA(1) >= 'A') && (LA(1) <= 'Z')) || LA(1) == '_' || ((LA(1) >= 'a') && (LA(1) <= 'z')) ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleIDENTEx; - } - - - // NDDL/base/antlr/NDDL3.g:514:38: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '$' )* - - for (;;) - { - int alt2=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA2_0 = LA(1); - if ( (LA2_0 == '$' || ((LA2_0 >= '0') && (LA2_0 <= '9')) || ((LA2_0 >= 'A') && (LA2_0 <= 'Z')) || LA2_0 == '_' || ((LA2_0 >= 'a') && (LA2_0 <= 'z'))) ) - { - alt2=1; - } - - } - switch (alt2) - { - case 1: - // NDDL/base/antlr/NDDL3.g: - { - if ( LA(1) == '$' || ((LA(1) >= '0') && (LA(1) <= '9')) || ((LA(1) >= 'A') && (LA(1) <= 'Z')) || LA(1) == '_' || ((LA(1) >= 'a') && (LA(1) <= 'z')) ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleIDENTEx; - } - - - } - break; - - default: - goto loop2; /* break out of the loop */ - break; - } - } - loop2: ; /* Jump out to here if this rule does not match */ - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleIDENTEx; /* Prevent compiler warnings */ - ruleIDENTEx: ; - -} -// $ANTLR end IDENT - -// Comes from: 517:8: ( '\"' (~ ( '\\\\' | '\"' ) | ESCAPE_SEQUENCE )* '\"' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start STRING - * - * Looks to match the characters the constitute the token STRING - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mSTRING(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = STRING; - - - // NDDL/base/antlr/NDDL3.g:517:8: ( '\"' (~ ( '\\\\' | '\"' ) | ESCAPE_SEQUENCE )* '\"' ) - // NDDL/base/antlr/NDDL3.g:517:10: '\"' (~ ( '\\\\' | '\"' ) | ESCAPE_SEQUENCE )* '\"' - { - MATCHC('"'); - if (HASEXCEPTION()) - { - goto ruleSTRINGEx; - } - - - // NDDL/base/antlr/NDDL3.g:517:14: (~ ( '\\\\' | '\"' ) | ESCAPE_SEQUENCE )* - - for (;;) - { - int alt3=3; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA3_0 = LA(1); - if ( (((LA3_0 >= 0x0000) && (LA3_0 <= '!')) || ((LA3_0 >= '#') && (LA3_0 <= '[')) || ((LA3_0 >= ']') && (LA3_0 <= 0xFFFF))) ) - { - alt3=1; - } - else if ( (LA3_0 == '\\') ) - { - alt3=2; - } - - } - switch (alt3) - { - case 1: - // NDDL/base/antlr/NDDL3.g:517:15: ~ ( '\\\\' | '\"' ) - { - if ( ((LA(1) >= 0x0000) && (LA(1) <= '!')) || ((LA(1) >= '#') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleSTRINGEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:517:29: ESCAPE_SEQUENCE - { - /* 517:29: ESCAPE_SEQUENCE */ - mESCAPE_SEQUENCE(ctx ); - if (HASEXCEPTION()) - { - goto ruleSTRINGEx; - } - - - } - break; - - default: - goto loop3; /* break out of the loop */ - break; - } - } - loop3: ; /* Jump out to here if this rule does not match */ - - MATCHC('"'); - if (HASEXCEPTION()) - { - goto ruleSTRINGEx; - } - - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleSTRINGEx; /* Prevent compiler warnings */ - ruleSTRINGEx: ; - -} -// $ANTLR end STRING - -// Comes from: 521:2: ( '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | UNICODE_ESC | OCTAL_ESC ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start ESCAPE_SEQUENCE - * - * Looks to match the characters the constitute the token ESCAPE_SEQUENCE - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mESCAPE_SEQUENCE(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - - { - // NDDL/base/antlr/NDDL3.g:521:2: ( '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | UNICODE_ESC | OCTAL_ESC ) - - ANTLR3_UINT32 alt4; - - alt4=3; - - - { - int LA4_0 = LA(1); - if ( (LA4_0 == '\\') ) - { - switch ( LA(2) ) - { - case '"': - case '\'': - case '\\': - case 'b': - case 'f': - case 'n': - case 'r': - case 't': - { - alt4=1; - } - break; - case 'u': - { - alt4=2; - } - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - alt4=3; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 4; - EXCEPTION->state = 1; - - - goto ruleESCAPE_SEQUENCEEx; - } - - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 4; - EXCEPTION->state = 0; - - - goto ruleESCAPE_SEQUENCEEx; - } - } - switch (alt4) - { - case 1: - // NDDL/base/antlr/NDDL3.g:521:4: '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) - { - MATCHC('\\'); - if (HASEXCEPTION()) - { - goto ruleESCAPE_SEQUENCEEx; - } - - if ( LA(1) == '"' || LA(1) == '\'' || LA(1) == '\\' || LA(1) == 'b' || LA(1) == 'f' || LA(1) == 'n' || LA(1) == 'r' || LA(1) == 't' ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleESCAPE_SEQUENCEEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:522:4: UNICODE_ESC - { - /* 522:4: UNICODE_ESC */ - mUNICODE_ESC(ctx ); - if (HASEXCEPTION()) - { - goto ruleESCAPE_SEQUENCEEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:523:4: OCTAL_ESC - { - /* 523:4: OCTAL_ESC */ - mOCTAL_ESC(ctx ); - if (HASEXCEPTION()) - { - goto ruleESCAPE_SEQUENCEEx; - } - - - } - break; - - } - } - - - // This is where rules clean up and exit - // - goto ruleESCAPE_SEQUENCEEx; /* Prevent compiler warnings */ - ruleESCAPE_SEQUENCEEx: ; - -} -// $ANTLR end ESCAPE_SEQUENCE - -// Comes from: 527:2: ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start OCTAL_ESC - * - * Looks to match the characters the constitute the token OCTAL_ESC - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mOCTAL_ESC(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - - { - // NDDL/base/antlr/NDDL3.g:527:2: ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ) - - ANTLR3_UINT32 alt5; - - alt5=3; - - - { - int LA5_0 = LA(1); - if ( (LA5_0 == '\\') ) - { - - { - int LA5_1 = LA(2); - if ( (((LA5_1 >= '0') && (LA5_1 <= '3'))) ) - { - - { - int LA5_2 = LA(3); - if ( (((LA5_2 >= '0') && (LA5_2 <= '7'))) ) - { - - { - int LA5_4 = LA(4); - if ( (((LA5_4 >= '0') && (LA5_4 <= '7'))) ) - { - alt5=1; - } - else - { - alt5=2; } - } - } - else - { - alt5=3; } - } - } - else if ( (((LA5_1 >= '4') && (LA5_1 <= '7'))) ) - { - - { - int LA5_3 = LA(3); - if ( (((LA5_3 >= '0') && (LA5_3 <= '7'))) ) - { - alt5=2; - } - else - { - alt5=3; } - } - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 5; - EXCEPTION->state = 1; - - - goto ruleOCTAL_ESCEx; - } - } - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 5; - EXCEPTION->state = 0; - - - goto ruleOCTAL_ESCEx; - } - } - switch (alt5) - { - case 1: - // NDDL/base/antlr/NDDL3.g:527:4: '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) - { - MATCHC('\\'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - // NDDL/base/antlr/NDDL3.g:527:9: ( '0' .. '3' ) - // NDDL/base/antlr/NDDL3.g:527:10: '0' .. '3' - { - MATCHRANGE('0', '3'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - - } - - // NDDL/base/antlr/NDDL3.g:527:20: ( '0' .. '7' ) - // NDDL/base/antlr/NDDL3.g:527:21: '0' .. '7' - { - MATCHRANGE('0', '7'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - - } - - // NDDL/base/antlr/NDDL3.g:527:31: ( '0' .. '7' ) - // NDDL/base/antlr/NDDL3.g:527:32: '0' .. '7' - { - MATCHRANGE('0', '7'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:528:4: '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) - { - MATCHC('\\'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - // NDDL/base/antlr/NDDL3.g:528:9: ( '0' .. '7' ) - // NDDL/base/antlr/NDDL3.g:528:10: '0' .. '7' - { - MATCHRANGE('0', '7'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - - } - - // NDDL/base/antlr/NDDL3.g:528:20: ( '0' .. '7' ) - // NDDL/base/antlr/NDDL3.g:528:21: '0' .. '7' - { - MATCHRANGE('0', '7'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:529:4: '\\\\' ( '0' .. '7' ) - { - MATCHC('\\'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - // NDDL/base/antlr/NDDL3.g:529:9: ( '0' .. '7' ) - // NDDL/base/antlr/NDDL3.g:529:10: '0' .. '7' - { - MATCHRANGE('0', '7'); - if (HASEXCEPTION()) - { - goto ruleOCTAL_ESCEx; - } - - - } - - - } - break; - - } - } - - - // This is where rules clean up and exit - // - goto ruleOCTAL_ESCEx; /* Prevent compiler warnings */ - ruleOCTAL_ESCEx: ; - -} -// $ANTLR end OCTAL_ESC - -// Comes from: 533:2: ( '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start UNICODE_ESC - * - * Looks to match the characters the constitute the token UNICODE_ESC - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mUNICODE_ESC(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - - // NDDL/base/antlr/NDDL3.g:533:2: ( '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT ) - // NDDL/base/antlr/NDDL3.g:533:4: '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - { - MATCHC('\\'); - if (HASEXCEPTION()) - { - goto ruleUNICODE_ESCEx; - } - - MATCHC('u'); - if (HASEXCEPTION()) - { - goto ruleUNICODE_ESCEx; - } - - /* 533:4: '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT */ - mHEX_DIGIT(ctx ); - if (HASEXCEPTION()) - { - goto ruleUNICODE_ESCEx; - } - - /* 533:4: '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT */ - mHEX_DIGIT(ctx ); - if (HASEXCEPTION()) - { - goto ruleUNICODE_ESCEx; - } - - /* 533:4: '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT */ - mHEX_DIGIT(ctx ); - if (HASEXCEPTION()) - { - goto ruleUNICODE_ESCEx; - } - - /* 533:4: '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT */ - mHEX_DIGIT(ctx ); - if (HASEXCEPTION()) - { - goto ruleUNICODE_ESCEx; - } - - - } - - - - // This is where rules clean up and exit - // - goto ruleUNICODE_ESCEx; /* Prevent compiler warnings */ - ruleUNICODE_ESCEx: ; - -} -// $ANTLR end UNICODE_ESC - -// Comes from: 537:2: ( ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start HEX_DIGIT - * - * Looks to match the characters the constitute the token HEX_DIGIT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mHEX_DIGIT(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - - // NDDL/base/antlr/NDDL3.g:537:2: ( ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) ) - // NDDL/base/antlr/NDDL3.g:537:4: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) - { - if ( ((LA(1) >= '0') && (LA(1) <= '9')) || ((LA(1) >= 'A') && (LA(1) <= 'F')) || ((LA(1) >= 'a') && (LA(1) <= 'f')) ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleHEX_DIGITEx; - } - - - } - - - - // This is where rules clean up and exit - // - goto ruleHEX_DIGITEx; /* Prevent compiler warnings */ - ruleHEX_DIGITEx: ; - -} -// $ANTLR end HEX_DIGIT - -// Comes from: 541:2: ( ( '0' .. '9' ) ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start DIGIT - * - * Looks to match the characters the constitute the token DIGIT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mDIGIT(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - - // NDDL/base/antlr/NDDL3.g:541:2: ( ( '0' .. '9' ) ) - // NDDL/base/antlr/NDDL3.g:541:4: ( '0' .. '9' ) - { - // NDDL/base/antlr/NDDL3.g:541:4: ( '0' .. '9' ) - // NDDL/base/antlr/NDDL3.g:541:5: '0' .. '9' - { - MATCHRANGE('0', '9'); - if (HASEXCEPTION()) - { - goto ruleDIGITEx; - } - - - } - - - } - - - - // This is where rules clean up and exit - // - goto ruleDIGITEx; /* Prevent compiler warnings */ - ruleDIGITEx: ; - -} -// $ANTLR end DIGIT - -// Comes from: 544:5: ( ( '+' | '-' )? ( '0' | '1' .. '9' ( '0' .. '9' )* ) ( INT_SUFFIX )? ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start INT - * - * Looks to match the characters the constitute the token INT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mINT(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = INT; - - - // NDDL/base/antlr/NDDL3.g:544:5: ( ( '+' | '-' )? ( '0' | '1' .. '9' ( '0' .. '9' )* ) ( INT_SUFFIX )? ) - // NDDL/base/antlr/NDDL3.g:544:7: ( '+' | '-' )? ( '0' | '1' .. '9' ( '0' .. '9' )* ) ( INT_SUFFIX )? - { - - // NDDL/base/antlr/NDDL3.g:544:7: ( '+' | '-' )? - { - int alt6=2; - { - int LA6_0 = LA(1); - if ( (LA6_0 == '+' || LA6_0 == '-') ) - { - alt6=1; - } - } - switch (alt6) - { - case 1: - // NDDL/base/antlr/NDDL3.g: - { - if ( LA(1) == '+' || LA(1) == '-' ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleINTEx; - } - - - } - break; - - } - } - - // NDDL/base/antlr/NDDL3.g:544:20: ( '0' | '1' .. '9' ( '0' .. '9' )* ) - { - int alt8=2; - - { - int LA8_0 = LA(1); - if ( (LA8_0 == '0') ) - { - alt8=1; - } - else if ( (((LA8_0 >= '1') && (LA8_0 <= '9'))) ) - { - alt8=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 8; - EXCEPTION->state = 0; - - - goto ruleINTEx; - } - } - switch (alt8) - { - case 1: - // NDDL/base/antlr/NDDL3.g:544:21: '0' - { - MATCHC('0'); - if (HASEXCEPTION()) - { - goto ruleINTEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:544:27: '1' .. '9' ( '0' .. '9' )* - { - MATCHRANGE('1', '9'); - if (HASEXCEPTION()) - { - goto ruleINTEx; - } - - - // NDDL/base/antlr/NDDL3.g:544:36: ( '0' .. '9' )* - - for (;;) - { - int alt7=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA7_0 = LA(1); - if ( (((LA7_0 >= '0') && (LA7_0 <= '9'))) ) - { - alt7=1; - } - - } - switch (alt7) - { - case 1: - // NDDL/base/antlr/NDDL3.g:544:36: '0' .. '9' - { - MATCHRANGE('0', '9'); - if (HASEXCEPTION()) - { - goto ruleINTEx; - } - - - } - break; - - default: - goto loop7; /* break out of the loop */ - break; - } - } - loop7: ; /* Jump out to here if this rule does not match */ - - - } - break; - - } - } - - // NDDL/base/antlr/NDDL3.g:544:47: ( INT_SUFFIX )? - { - int alt9=2; - { - int LA9_0 = LA(1); - if ( (LA9_0 == 'L' || LA9_0 == 'l') ) - { - alt9=1; - } - } - switch (alt9) - { - case 1: - // NDDL/base/antlr/NDDL3.g:544:47: INT_SUFFIX - { - /* 544:47: INT_SUFFIX */ - mINT_SUFFIX(ctx ); - if (HASEXCEPTION()) - { - goto ruleINTEx; - } - - - } - break; - - } - } - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleINTEx; /* Prevent compiler warnings */ - ruleINTEx: ; - -} -// $ANTLR end INT - -// Comes from: 548:2: ( ( 'l' | 'L' ) ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start INT_SUFFIX - * - * Looks to match the characters the constitute the token INT_SUFFIX - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mINT_SUFFIX(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - - // NDDL/base/antlr/NDDL3.g:548:2: ( ( 'l' | 'L' ) ) - // NDDL/base/antlr/NDDL3.g:548:4: ( 'l' | 'L' ) - { - if ( LA(1) == 'L' || LA(1) == 'l' ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleINT_SUFFIXEx; - } - - - } - - - - // This is where rules clean up and exit - // - goto ruleINT_SUFFIXEx; /* Prevent compiler warnings */ - ruleINT_SUFFIXEx: ; - -} -// $ANTLR end INT_SUFFIX - -// Comes from: 551:7: ( ( '+' | '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? ( FLOAT_SUFFIX )? | '.' ( '0' .. '9' )+ ( EXPONENT )? ( FLOAT_SUFFIX )? | ( '0' .. '9' )+ EXPONENT ( FLOAT_SUFFIX )? | ( '0' .. '9' )+ FLOAT_SUFFIX ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start FLOAT - * - * Looks to match the characters the constitute the token FLOAT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mFLOAT(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = FLOAT; - - - { - // NDDL/base/antlr/NDDL3.g:551:7: ( ( '+' | '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? ( FLOAT_SUFFIX )? | '.' ( '0' .. '9' )+ ( EXPONENT )? ( FLOAT_SUFFIX )? | ( '0' .. '9' )+ EXPONENT ( FLOAT_SUFFIX )? | ( '0' .. '9' )+ FLOAT_SUFFIX ) - - ANTLR3_UINT32 alt21; - - alt21=4; - - alt21 = cdfa21.predict(ctx, RECOGNIZER, ISTREAM, &cdfa21); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - switch (alt21) - { - case 1: - // NDDL/base/antlr/NDDL3.g:551:9: ( '+' | '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? ( FLOAT_SUFFIX )? - { - - // NDDL/base/antlr/NDDL3.g:551:9: ( '+' | '-' )? - { - int alt10=2; - { - int LA10_0 = LA(1); - if ( (LA10_0 == '+' || LA10_0 == '-') ) - { - alt10=1; - } - } - switch (alt10) - { - case 1: - // NDDL/base/antlr/NDDL3.g: - { - if ( LA(1) == '+' || LA(1) == '-' ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleFLOATEx; - } - - - } - break; - - } - } - // NDDL/base/antlr/NDDL3.g:551:22: ( '0' .. '9' )+ - { - int cnt11=0; - - for (;;) - { - int alt11=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA11_0 = LA(1); - if ( (((LA11_0 >= '0') && (LA11_0 <= '9'))) ) - { - alt11=1; - } - - } - switch (alt11) - { - case 1: - // NDDL/base/antlr/NDDL3.g:551:23: '0' .. '9' - { - MATCHRANGE('0', '9'); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - default: - - if ( cnt11 >= 1 ) - { - goto loop11; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleFLOATEx; - } - cnt11++; - } - loop11: ; /* Jump to here if this rule does not match */ - } - MATCHC('.'); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - // NDDL/base/antlr/NDDL3.g:551:38: ( '0' .. '9' )* - - for (;;) - { - int alt12=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA12_0 = LA(1); - if ( (((LA12_0 >= '0') && (LA12_0 <= '9'))) ) - { - alt12=1; - } - - } - switch (alt12) - { - case 1: - // NDDL/base/antlr/NDDL3.g:551:39: '0' .. '9' - { - MATCHRANGE('0', '9'); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - default: - goto loop12; /* break out of the loop */ - break; - } - } - loop12: ; /* Jump out to here if this rule does not match */ - - - // NDDL/base/antlr/NDDL3.g:551:50: ( EXPONENT )? - { - int alt13=2; - { - int LA13_0 = LA(1); - if ( (LA13_0 == 'E' || LA13_0 == 'e') ) - { - alt13=1; - } - } - switch (alt13) - { - case 1: - // NDDL/base/antlr/NDDL3.g:551:50: EXPONENT - { - /* 551:50: EXPONENT */ - mEXPONENT(ctx ); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - } - } - - // NDDL/base/antlr/NDDL3.g:551:60: ( FLOAT_SUFFIX )? - { - int alt14=2; - { - int LA14_0 = LA(1); - if ( (LA14_0 == 'D' || LA14_0 == 'F' || LA14_0 == 'd' || LA14_0 == 'f') ) - { - alt14=1; - } - } - switch (alt14) - { - case 1: - // NDDL/base/antlr/NDDL3.g:551:60: FLOAT_SUFFIX - { - /* 551:60: FLOAT_SUFFIX */ - mFLOAT_SUFFIX(ctx ); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - } - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:552:4: '.' ( '0' .. '9' )+ ( EXPONENT )? ( FLOAT_SUFFIX )? - { - MATCHC('.'); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - // NDDL/base/antlr/NDDL3.g:552:8: ( '0' .. '9' )+ - { - int cnt15=0; - - for (;;) - { - int alt15=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA15_0 = LA(1); - if ( (((LA15_0 >= '0') && (LA15_0 <= '9'))) ) - { - alt15=1; - } - - } - switch (alt15) - { - case 1: - // NDDL/base/antlr/NDDL3.g:552:9: '0' .. '9' - { - MATCHRANGE('0', '9'); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - default: - - if ( cnt15 >= 1 ) - { - goto loop15; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleFLOATEx; - } - cnt15++; - } - loop15: ; /* Jump to here if this rule does not match */ - } - - // NDDL/base/antlr/NDDL3.g:552:20: ( EXPONENT )? - { - int alt16=2; - { - int LA16_0 = LA(1); - if ( (LA16_0 == 'E' || LA16_0 == 'e') ) - { - alt16=1; - } - } - switch (alt16) - { - case 1: - // NDDL/base/antlr/NDDL3.g:552:20: EXPONENT - { - /* 552:20: EXPONENT */ - mEXPONENT(ctx ); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - } - } - - // NDDL/base/antlr/NDDL3.g:552:30: ( FLOAT_SUFFIX )? - { - int alt17=2; - { - int LA17_0 = LA(1); - if ( (LA17_0 == 'D' || LA17_0 == 'F' || LA17_0 == 'd' || LA17_0 == 'f') ) - { - alt17=1; - } - } - switch (alt17) - { - case 1: - // NDDL/base/antlr/NDDL3.g:552:30: FLOAT_SUFFIX - { - /* 552:30: FLOAT_SUFFIX */ - mFLOAT_SUFFIX(ctx ); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - } - } - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:553:4: ( '0' .. '9' )+ EXPONENT ( FLOAT_SUFFIX )? - { - // NDDL/base/antlr/NDDL3.g:553:4: ( '0' .. '9' )+ - { - int cnt18=0; - - for (;;) - { - int alt18=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA18_0 = LA(1); - if ( (((LA18_0 >= '0') && (LA18_0 <= '9'))) ) - { - alt18=1; - } - - } - switch (alt18) - { - case 1: - // NDDL/base/antlr/NDDL3.g:553:5: '0' .. '9' - { - MATCHRANGE('0', '9'); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - default: - - if ( cnt18 >= 1 ) - { - goto loop18; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleFLOATEx; - } - cnt18++; - } - loop18: ; /* Jump to here if this rule does not match */ - } - /* 553:4: ( '0' .. '9' )+ EXPONENT ( FLOAT_SUFFIX )? */ - mEXPONENT(ctx ); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - // NDDL/base/antlr/NDDL3.g:553:25: ( FLOAT_SUFFIX )? - { - int alt19=2; - { - int LA19_0 = LA(1); - if ( (LA19_0 == 'D' || LA19_0 == 'F' || LA19_0 == 'd' || LA19_0 == 'f') ) - { - alt19=1; - } - } - switch (alt19) - { - case 1: - // NDDL/base/antlr/NDDL3.g:553:25: FLOAT_SUFFIX - { - /* 553:25: FLOAT_SUFFIX */ - mFLOAT_SUFFIX(ctx ); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - } - } - - } - break; - case 4: - // NDDL/base/antlr/NDDL3.g:554:4: ( '0' .. '9' )+ FLOAT_SUFFIX - { - // NDDL/base/antlr/NDDL3.g:554:4: ( '0' .. '9' )+ - { - int cnt20=0; - - for (;;) - { - int alt20=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA20_0 = LA(1); - if ( (((LA20_0 >= '0') && (LA20_0 <= '9'))) ) - { - alt20=1; - } - - } - switch (alt20) - { - case 1: - // NDDL/base/antlr/NDDL3.g:554:5: '0' .. '9' - { - MATCHRANGE('0', '9'); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - default: - - if ( cnt20 >= 1 ) - { - goto loop20; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleFLOATEx; - } - cnt20++; - } - loop20: ; /* Jump to here if this rule does not match */ - } - /* 554:4: ( '0' .. '9' )+ FLOAT_SUFFIX */ - mFLOAT_SUFFIX(ctx ); - if (HASEXCEPTION()) - { - goto ruleFLOATEx; - } - - - } - break; - - } - } - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleFLOATEx; /* Prevent compiler warnings */ - ruleFLOATEx: ; - -} -// $ANTLR end FLOAT - -// Comes from: 558:2: ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start EXPONENT - * - * Looks to match the characters the constitute the token EXPONENT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mEXPONENT(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - - // NDDL/base/antlr/NDDL3.g:558:2: ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ ) - // NDDL/base/antlr/NDDL3.g:558:4: ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ - { - if ( LA(1) == 'E' || LA(1) == 'e' ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleEXPONENTEx; - } - - - // NDDL/base/antlr/NDDL3.g:558:14: ( '+' | '-' )? - { - int alt22=2; - { - int LA22_0 = LA(1); - if ( (LA22_0 == '+' || LA22_0 == '-') ) - { - alt22=1; - } - } - switch (alt22) - { - case 1: - // NDDL/base/antlr/NDDL3.g: - { - if ( LA(1) == '+' || LA(1) == '-' ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleEXPONENTEx; - } - - - } - break; - - } - } - // NDDL/base/antlr/NDDL3.g:558:25: ( '0' .. '9' )+ - { - int cnt23=0; - - for (;;) - { - int alt23=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA23_0 = LA(1); - if ( (((LA23_0 >= '0') && (LA23_0 <= '9'))) ) - { - alt23=1; - } - - } - switch (alt23) - { - case 1: - // NDDL/base/antlr/NDDL3.g:558:26: '0' .. '9' - { - MATCHRANGE('0', '9'); - if (HASEXCEPTION()) - { - goto ruleEXPONENTEx; - } - - - } - break; - - default: - - if ( cnt23 >= 1 ) - { - goto loop23; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleEXPONENTEx; - } - cnt23++; - } - loop23: ; /* Jump to here if this rule does not match */ - } - - } - - - - // This is where rules clean up and exit - // - goto ruleEXPONENTEx; /* Prevent compiler warnings */ - ruleEXPONENTEx: ; - -} -// $ANTLR end EXPONENT - -// Comes from: 562:2: ( ( 'f' | 'F' | 'd' | 'D' ) ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start FLOAT_SUFFIX - * - * Looks to match the characters the constitute the token FLOAT_SUFFIX - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mFLOAT_SUFFIX(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - - // NDDL/base/antlr/NDDL3.g:562:2: ( ( 'f' | 'F' | 'd' | 'D' ) ) - // NDDL/base/antlr/NDDL3.g:562:4: ( 'f' | 'F' | 'd' | 'D' ) - { - if ( LA(1) == 'D' || LA(1) == 'F' || LA(1) == 'd' || LA(1) == 'f' ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleFLOAT_SUFFIXEx; - } - - - } - - - - // This is where rules clean up and exit - // - goto ruleFLOAT_SUFFIXEx; /* Prevent compiler warnings */ - ruleFLOAT_SUFFIXEx: ; - -} -// $ANTLR end FLOAT_SUFFIX - -// Comes from: 565:9: ( '/*' ( options {greedy=false; } : . )* '*/' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start COMMENT - * - * Looks to match the characters the constitute the token COMMENT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mCOMMENT(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = COMMENT; - - - // NDDL/base/antlr/NDDL3.g:565:9: ( '/*' ( options {greedy=false; } : . )* '*/' ) - // NDDL/base/antlr/NDDL3.g:565:11: '/*' ( options {greedy=false; } : . )* '*/' - { - MATCHS(lit_63); - if (HASEXCEPTION()) - { - goto ruleCOMMENTEx; - } - - - - // NDDL/base/antlr/NDDL3.g:565:16: ( options {greedy=false; } : . )* - - for (;;) - { - int alt24=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA24_0 = LA(1); - if ( (LA24_0 == '*') ) - { - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA24_1 = LA(2); - if ( (LA24_1 == '/') ) - { - alt24=2; - } - else if ( (((LA24_1 >= 0x0000) && (LA24_1 <= '.')) || ((LA24_1 >= '0') && (LA24_1 <= 0xFFFF))) ) - { - alt24=1; - } - - } - } - else if ( (((LA24_0 >= 0x0000) && (LA24_0 <= ')')) || ((LA24_0 >= '+') && (LA24_0 <= 0xFFFF))) ) - { - alt24=1; - } - - } - switch (alt24) - { - case 1: - // NDDL/base/antlr/NDDL3.g:565:44: . - { - MATCHANY(); - if (HASEXCEPTION()) - { - goto ruleCOMMENTEx; - } - - - } - break; - - default: - goto loop24; /* break out of the loop */ - break; - } - } - loop24: ; /* Jump out to here if this rule does not match */ - - MATCHS(lit_64); - if (HASEXCEPTION()) - { - goto ruleCOMMENTEx; - } - - - { - LEXSTATE->channel=HIDDEN; - } - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleCOMMENTEx; /* Prevent compiler warnings */ - ruleCOMMENTEx: ; - -} -// $ANTLR end COMMENT - -// Comes from: 569:2: ( '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start LINE_COMMENT - * - * Looks to match the characters the constitute the token LINE_COMMENT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mLINE_COMMENT(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = LINE_COMMENT; - - - // NDDL/base/antlr/NDDL3.g:569:2: ( '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' ) - // NDDL/base/antlr/NDDL3.g:569:4: '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' - { - MATCHS(lit_65); - if (HASEXCEPTION()) - { - goto ruleLINE_COMMENTEx; - } - - - - // NDDL/base/antlr/NDDL3.g:569:9: (~ ( '\\n' | '\\r' ) )* - - for (;;) - { - int alt25=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA25_0 = LA(1); - if ( (((LA25_0 >= 0x0000) && (LA25_0 <= '\t')) || ((LA25_0 >= 0x000B) && (LA25_0 <= '\f')) || ((LA25_0 >= 0x000E) && (LA25_0 <= 0xFFFF))) ) - { - alt25=1; - } - - } - switch (alt25) - { - case 1: - // NDDL/base/antlr/NDDL3.g:569:9: ~ ( '\\n' | '\\r' ) - { - if ( ((LA(1) >= 0x0000) && (LA(1) <= '\t')) || ((LA(1) >= 0x000B) && (LA(1) <= '\f')) || ((LA(1) >= 0x000E) && (LA(1) <= 0xFFFF)) ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleLINE_COMMENTEx; - } - - - } - break; - - default: - goto loop25; /* break out of the loop */ - break; - } - } - loop25: ; /* Jump out to here if this rule does not match */ - - - // NDDL/base/antlr/NDDL3.g:569:23: ( '\\r' )? - { - int alt26=2; - { - int LA26_0 = LA(1); - if ( (LA26_0 == '\r') ) - { - alt26=1; - } - } - switch (alt26) - { - case 1: - // NDDL/base/antlr/NDDL3.g:569:23: '\\r' - { - MATCHC('\r'); - if (HASEXCEPTION()) - { - goto ruleLINE_COMMENTEx; - } - - - } - break; - - } - } - MATCHC('\n'); - if (HASEXCEPTION()) - { - goto ruleLINE_COMMENTEx; - } - - { - LEXSTATE->channel=HIDDEN; - } - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleLINE_COMMENTEx; /* Prevent compiler warnings */ - ruleLINE_COMMENTEx: ; - -} -// $ANTLR end LINE_COMMENT - -// Comes from: 572:4: ( ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start WS - * - * Looks to match the characters the constitute the token WS - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mWS(pNDDL3Lexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = WS; - - - // NDDL/base/antlr/NDDL3.g:572:4: ( ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) ) - // NDDL/base/antlr/NDDL3.g:572:6: ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) - { - if ( ((LA(1) >= '\t') && (LA(1) <= '\n')) || ((LA(1) >= '\f') && (LA(1) <= '\r')) || LA(1) == ' ' ) - { - CONSUME(); - - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); goto ruleWSEx; - } - - { - LEXSTATE->channel=HIDDEN; - } - - } - - LEXSTATE->type = _type; - - // This is where rules clean up and exit - // - goto ruleWSEx; /* Prevent compiler warnings */ - ruleWSEx: ; - -} -// $ANTLR end WS - -/** This is the entry point in to the lexer from an object that - * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM - */ -static void -mTokens(pNDDL3Lexer ctx) -{ - { - // NDDL/base/antlr/NDDL3.g:1:8: ( T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | T__47 | T__48 | T__49 | T__50 | T__51 | T__52 | T__53 | T__54 | T__55 | T__56 | T__57 | T__58 | T__59 | T__60 | T__61 | T__62 | T__63 | T__64 | T__65 | T__66 | T__67 | T__68 | T__69 | T__70 | T__71 | T__72 | T__73 | T__74 | T__75 | T__76 | T__77 | T__78 | T__79 | T__80 | T__81 | T__82 | T__83 | T__84 | T__85 | T__86 | T__87 | T__88 | T__89 | T__90 | T__91 | T__92 | T__93 | T__94 | T__95 | T__96 | T__97 | T__98 | T__99 | T__100 | T__101 | T__102 | T__103 | T__104 | T__105 | T__106 | T__107 | T__108 | INCLUDE | IDENT | STRING | INT | FLOAT | COMMENT | LINE_COMMENT | WS ) - - ANTLR3_UINT32 alt27; - - alt27=85; - - alt27 = cdfa27.predict(ctx, RECOGNIZER, ISTREAM, &cdfa27); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - switch (alt27) - { - case 1: - // NDDL/base/antlr/NDDL3.g:1:10: T__32 - { - /* 1:10: T__32 */ - mT__32(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:1:16: T__33 - { - /* 1:16: T__33 */ - mT__33(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:1:22: T__34 - { - /* 1:22: T__34 */ - mT__34(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 4: - // NDDL/base/antlr/NDDL3.g:1:28: T__35 - { - /* 1:28: T__35 */ - mT__35(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 5: - // NDDL/base/antlr/NDDL3.g:1:34: T__36 - { - /* 1:34: T__36 */ - mT__36(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 6: - // NDDL/base/antlr/NDDL3.g:1:40: T__37 - { - /* 1:40: T__37 */ - mT__37(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 7: - // NDDL/base/antlr/NDDL3.g:1:46: T__38 - { - /* 1:46: T__38 */ - mT__38(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 8: - // NDDL/base/antlr/NDDL3.g:1:52: T__39 - { - /* 1:52: T__39 */ - mT__39(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 9: - // NDDL/base/antlr/NDDL3.g:1:58: T__40 - { - /* 1:58: T__40 */ - mT__40(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 10: - // NDDL/base/antlr/NDDL3.g:1:64: T__41 - { - /* 1:64: T__41 */ - mT__41(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 11: - // NDDL/base/antlr/NDDL3.g:1:70: T__42 - { - /* 1:70: T__42 */ - mT__42(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 12: - // NDDL/base/antlr/NDDL3.g:1:76: T__43 - { - /* 1:76: T__43 */ - mT__43(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 13: - // NDDL/base/antlr/NDDL3.g:1:82: T__44 - { - /* 1:82: T__44 */ - mT__44(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 14: - // NDDL/base/antlr/NDDL3.g:1:88: T__45 - { - /* 1:88: T__45 */ - mT__45(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 15: - // NDDL/base/antlr/NDDL3.g:1:94: T__46 - { - /* 1:94: T__46 */ - mT__46(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 16: - // NDDL/base/antlr/NDDL3.g:1:100: T__47 - { - /* 1:100: T__47 */ - mT__47(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 17: - // NDDL/base/antlr/NDDL3.g:1:106: T__48 - { - /* 1:106: T__48 */ - mT__48(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 18: - // NDDL/base/antlr/NDDL3.g:1:112: T__49 - { - /* 1:112: T__49 */ - mT__49(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 19: - // NDDL/base/antlr/NDDL3.g:1:118: T__50 - { - /* 1:118: T__50 */ - mT__50(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 20: - // NDDL/base/antlr/NDDL3.g:1:124: T__51 - { - /* 1:124: T__51 */ - mT__51(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 21: - // NDDL/base/antlr/NDDL3.g:1:130: T__52 - { - /* 1:130: T__52 */ - mT__52(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 22: - // NDDL/base/antlr/NDDL3.g:1:136: T__53 - { - /* 1:136: T__53 */ - mT__53(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 23: - // NDDL/base/antlr/NDDL3.g:1:142: T__54 - { - /* 1:142: T__54 */ - mT__54(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 24: - // NDDL/base/antlr/NDDL3.g:1:148: T__55 - { - /* 1:148: T__55 */ - mT__55(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 25: - // NDDL/base/antlr/NDDL3.g:1:154: T__56 - { - /* 1:154: T__56 */ - mT__56(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 26: - // NDDL/base/antlr/NDDL3.g:1:160: T__57 - { - /* 1:160: T__57 */ - mT__57(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 27: - // NDDL/base/antlr/NDDL3.g:1:166: T__58 - { - /* 1:166: T__58 */ - mT__58(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 28: - // NDDL/base/antlr/NDDL3.g:1:172: T__59 - { - /* 1:172: T__59 */ - mT__59(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 29: - // NDDL/base/antlr/NDDL3.g:1:178: T__60 - { - /* 1:178: T__60 */ - mT__60(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 30: - // NDDL/base/antlr/NDDL3.g:1:184: T__61 - { - /* 1:184: T__61 */ - mT__61(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 31: - // NDDL/base/antlr/NDDL3.g:1:190: T__62 - { - /* 1:190: T__62 */ - mT__62(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 32: - // NDDL/base/antlr/NDDL3.g:1:196: T__63 - { - /* 1:196: T__63 */ - mT__63(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 33: - // NDDL/base/antlr/NDDL3.g:1:202: T__64 - { - /* 1:202: T__64 */ - mT__64(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 34: - // NDDL/base/antlr/NDDL3.g:1:208: T__65 - { - /* 1:208: T__65 */ - mT__65(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 35: - // NDDL/base/antlr/NDDL3.g:1:214: T__66 - { - /* 1:214: T__66 */ - mT__66(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 36: - // NDDL/base/antlr/NDDL3.g:1:220: T__67 - { - /* 1:220: T__67 */ - mT__67(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 37: - // NDDL/base/antlr/NDDL3.g:1:226: T__68 - { - /* 1:226: T__68 */ - mT__68(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 38: - // NDDL/base/antlr/NDDL3.g:1:232: T__69 - { - /* 1:232: T__69 */ - mT__69(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 39: - // NDDL/base/antlr/NDDL3.g:1:238: T__70 - { - /* 1:238: T__70 */ - mT__70(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 40: - // NDDL/base/antlr/NDDL3.g:1:244: T__71 - { - /* 1:244: T__71 */ - mT__71(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 41: - // NDDL/base/antlr/NDDL3.g:1:250: T__72 - { - /* 1:250: T__72 */ - mT__72(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 42: - // NDDL/base/antlr/NDDL3.g:1:256: T__73 - { - /* 1:256: T__73 */ - mT__73(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 43: - // NDDL/base/antlr/NDDL3.g:1:262: T__74 - { - /* 1:262: T__74 */ - mT__74(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 44: - // NDDL/base/antlr/NDDL3.g:1:268: T__75 - { - /* 1:268: T__75 */ - mT__75(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 45: - // NDDL/base/antlr/NDDL3.g:1:274: T__76 - { - /* 1:274: T__76 */ - mT__76(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 46: - // NDDL/base/antlr/NDDL3.g:1:280: T__77 - { - /* 1:280: T__77 */ - mT__77(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 47: - // NDDL/base/antlr/NDDL3.g:1:286: T__78 - { - /* 1:286: T__78 */ - mT__78(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 48: - // NDDL/base/antlr/NDDL3.g:1:292: T__79 - { - /* 1:292: T__79 */ - mT__79(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 49: - // NDDL/base/antlr/NDDL3.g:1:298: T__80 - { - /* 1:298: T__80 */ - mT__80(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 50: - // NDDL/base/antlr/NDDL3.g:1:304: T__81 - { - /* 1:304: T__81 */ - mT__81(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 51: - // NDDL/base/antlr/NDDL3.g:1:310: T__82 - { - /* 1:310: T__82 */ - mT__82(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 52: - // NDDL/base/antlr/NDDL3.g:1:316: T__83 - { - /* 1:316: T__83 */ - mT__83(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 53: - // NDDL/base/antlr/NDDL3.g:1:322: T__84 - { - /* 1:322: T__84 */ - mT__84(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 54: - // NDDL/base/antlr/NDDL3.g:1:328: T__85 - { - /* 1:328: T__85 */ - mT__85(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 55: - // NDDL/base/antlr/NDDL3.g:1:334: T__86 - { - /* 1:334: T__86 */ - mT__86(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 56: - // NDDL/base/antlr/NDDL3.g:1:340: T__87 - { - /* 1:340: T__87 */ - mT__87(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 57: - // NDDL/base/antlr/NDDL3.g:1:346: T__88 - { - /* 1:346: T__88 */ - mT__88(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 58: - // NDDL/base/antlr/NDDL3.g:1:352: T__89 - { - /* 1:352: T__89 */ - mT__89(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 59: - // NDDL/base/antlr/NDDL3.g:1:358: T__90 - { - /* 1:358: T__90 */ - mT__90(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 60: - // NDDL/base/antlr/NDDL3.g:1:364: T__91 - { - /* 1:364: T__91 */ - mT__91(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 61: - // NDDL/base/antlr/NDDL3.g:1:370: T__92 - { - /* 1:370: T__92 */ - mT__92(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 62: - // NDDL/base/antlr/NDDL3.g:1:376: T__93 - { - /* 1:376: T__93 */ - mT__93(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 63: - // NDDL/base/antlr/NDDL3.g:1:382: T__94 - { - /* 1:382: T__94 */ - mT__94(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 64: - // NDDL/base/antlr/NDDL3.g:1:388: T__95 - { - /* 1:388: T__95 */ - mT__95(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 65: - // NDDL/base/antlr/NDDL3.g:1:394: T__96 - { - /* 1:394: T__96 */ - mT__96(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 66: - // NDDL/base/antlr/NDDL3.g:1:400: T__97 - { - /* 1:400: T__97 */ - mT__97(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 67: - // NDDL/base/antlr/NDDL3.g:1:406: T__98 - { - /* 1:406: T__98 */ - mT__98(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 68: - // NDDL/base/antlr/NDDL3.g:1:412: T__99 - { - /* 1:412: T__99 */ - mT__99(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 69: - // NDDL/base/antlr/NDDL3.g:1:418: T__100 - { - /* 1:418: T__100 */ - mT__100(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 70: - // NDDL/base/antlr/NDDL3.g:1:425: T__101 - { - /* 1:425: T__101 */ - mT__101(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 71: - // NDDL/base/antlr/NDDL3.g:1:432: T__102 - { - /* 1:432: T__102 */ - mT__102(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 72: - // NDDL/base/antlr/NDDL3.g:1:439: T__103 - { - /* 1:439: T__103 */ - mT__103(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 73: - // NDDL/base/antlr/NDDL3.g:1:446: T__104 - { - /* 1:446: T__104 */ - mT__104(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 74: - // NDDL/base/antlr/NDDL3.g:1:453: T__105 - { - /* 1:453: T__105 */ - mT__105(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 75: - // NDDL/base/antlr/NDDL3.g:1:460: T__106 - { - /* 1:460: T__106 */ - mT__106(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 76: - // NDDL/base/antlr/NDDL3.g:1:467: T__107 - { - /* 1:467: T__107 */ - mT__107(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 77: - // NDDL/base/antlr/NDDL3.g:1:474: T__108 - { - /* 1:474: T__108 */ - mT__108(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 78: - // NDDL/base/antlr/NDDL3.g:1:481: INCLUDE - { - /* 1:481: INCLUDE */ - mINCLUDE(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 79: - // NDDL/base/antlr/NDDL3.g:1:489: IDENT - { - /* 1:489: IDENT */ - mIDENT(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 80: - // NDDL/base/antlr/NDDL3.g:1:495: STRING - { - /* 1:495: STRING */ - mSTRING(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 81: - // NDDL/base/antlr/NDDL3.g:1:502: INT - { - /* 1:502: INT */ - mINT(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 82: - // NDDL/base/antlr/NDDL3.g:1:506: FLOAT - { - /* 1:506: FLOAT */ - mFLOAT(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 83: - // NDDL/base/antlr/NDDL3.g:1:512: COMMENT - { - /* 1:512: COMMENT */ - mCOMMENT(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 84: - // NDDL/base/antlr/NDDL3.g:1:520: LINE_COMMENT - { - /* 1:520: LINE_COMMENT */ - mLINE_COMMENT(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - case 85: - // NDDL/base/antlr/NDDL3.g:1:533: WS - { - /* 1:533: WS */ - mWS(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - } - break; - - } - } - - - goto ruleTokensEx; /* Prevent compiler warnings */ -ruleTokensEx: ; -} - -/* ========================================================================= - * Lexer matching rules end. - * ========================================================================= - */ -/* End of Lexer code - * ================================================ - * ================================================ - */ - - -/* End of code - * ============================================================================= - */ diff --git a/src/PLASMA/NDDL/base/NDDL3Lexer.h b/src/PLASMA/NDDL/base/NDDL3Lexer.h deleted file mode 100644 index 3cc218ad7..000000000 --- a/src/PLASMA/NDDL/base/NDDL3Lexer.h +++ /dev/null @@ -1,468 +0,0 @@ -/** \file - * This C header file was generated by $ANTLR version 3.1.2 - * - * - From the grammar source file : NDDL/base/antlr/NDDL3.g - * - On : 2011-08-29 18:06:03 - * - for the lexer : NDDL3LexerLexer * - * Editing it, at least manually, is not wise. - * - * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. - * - * - * The lexer NDDL3Lexer has the callable functions (rules) shown below, - * which will invoke the code for the associated rule in the source grammar - * assuming that the input stream is pointing to a token/text stream that could begin - * this rule. - * - * For instance if you call the first (topmost) rule in a parser grammar, you will - * get the results of a full parse, but calling a rule half way through the grammar will - * allow you to pass part of a full token stream to the parser, such as for syntax checking - * in editors and so on. - * - * The parser entry points are called indirectly (by function pointer to function) via - * a parser context typedef pNDDL3Lexer, which is returned from a call to NDDL3LexerNew(). - * - * As this is a generated lexer, it is unlikely you will call it 'manually'. However - * the methods are provided anyway. - * * The methods in pNDDL3Lexer are as follows: - * - * - void pNDDL3Lexer->T__32(pNDDL3Lexer) - * - void pNDDL3Lexer->T__33(pNDDL3Lexer) - * - void pNDDL3Lexer->T__34(pNDDL3Lexer) - * - void pNDDL3Lexer->T__35(pNDDL3Lexer) - * - void pNDDL3Lexer->T__36(pNDDL3Lexer) - * - void pNDDL3Lexer->T__37(pNDDL3Lexer) - * - void pNDDL3Lexer->T__38(pNDDL3Lexer) - * - void pNDDL3Lexer->T__39(pNDDL3Lexer) - * - void pNDDL3Lexer->T__40(pNDDL3Lexer) - * - void pNDDL3Lexer->T__41(pNDDL3Lexer) - * - void pNDDL3Lexer->T__42(pNDDL3Lexer) - * - void pNDDL3Lexer->T__43(pNDDL3Lexer) - * - void pNDDL3Lexer->T__44(pNDDL3Lexer) - * - void pNDDL3Lexer->T__45(pNDDL3Lexer) - * - void pNDDL3Lexer->T__46(pNDDL3Lexer) - * - void pNDDL3Lexer->T__47(pNDDL3Lexer) - * - void pNDDL3Lexer->T__48(pNDDL3Lexer) - * - void pNDDL3Lexer->T__49(pNDDL3Lexer) - * - void pNDDL3Lexer->T__50(pNDDL3Lexer) - * - void pNDDL3Lexer->T__51(pNDDL3Lexer) - * - void pNDDL3Lexer->T__52(pNDDL3Lexer) - * - void pNDDL3Lexer->T__53(pNDDL3Lexer) - * - void pNDDL3Lexer->T__54(pNDDL3Lexer) - * - void pNDDL3Lexer->T__55(pNDDL3Lexer) - * - void pNDDL3Lexer->T__56(pNDDL3Lexer) - * - void pNDDL3Lexer->T__57(pNDDL3Lexer) - * - void pNDDL3Lexer->T__58(pNDDL3Lexer) - * - void pNDDL3Lexer->T__59(pNDDL3Lexer) - * - void pNDDL3Lexer->T__60(pNDDL3Lexer) - * - void pNDDL3Lexer->T__61(pNDDL3Lexer) - * - void pNDDL3Lexer->T__62(pNDDL3Lexer) - * - void pNDDL3Lexer->T__63(pNDDL3Lexer) - * - void pNDDL3Lexer->T__64(pNDDL3Lexer) - * - void pNDDL3Lexer->T__65(pNDDL3Lexer) - * - void pNDDL3Lexer->T__66(pNDDL3Lexer) - * - void pNDDL3Lexer->T__67(pNDDL3Lexer) - * - void pNDDL3Lexer->T__68(pNDDL3Lexer) - * - void pNDDL3Lexer->T__69(pNDDL3Lexer) - * - void pNDDL3Lexer->T__70(pNDDL3Lexer) - * - void pNDDL3Lexer->T__71(pNDDL3Lexer) - * - void pNDDL3Lexer->T__72(pNDDL3Lexer) - * - void pNDDL3Lexer->T__73(pNDDL3Lexer) - * - void pNDDL3Lexer->T__74(pNDDL3Lexer) - * - void pNDDL3Lexer->T__75(pNDDL3Lexer) - * - void pNDDL3Lexer->T__76(pNDDL3Lexer) - * - void pNDDL3Lexer->T__77(pNDDL3Lexer) - * - void pNDDL3Lexer->T__78(pNDDL3Lexer) - * - void pNDDL3Lexer->T__79(pNDDL3Lexer) - * - void pNDDL3Lexer->T__80(pNDDL3Lexer) - * - void pNDDL3Lexer->T__81(pNDDL3Lexer) - * - void pNDDL3Lexer->T__82(pNDDL3Lexer) - * - void pNDDL3Lexer->T__83(pNDDL3Lexer) - * - void pNDDL3Lexer->T__84(pNDDL3Lexer) - * - void pNDDL3Lexer->T__85(pNDDL3Lexer) - * - void pNDDL3Lexer->T__86(pNDDL3Lexer) - * - void pNDDL3Lexer->T__87(pNDDL3Lexer) - * - void pNDDL3Lexer->T__88(pNDDL3Lexer) - * - void pNDDL3Lexer->T__89(pNDDL3Lexer) - * - void pNDDL3Lexer->T__90(pNDDL3Lexer) - * - void pNDDL3Lexer->T__91(pNDDL3Lexer) - * - void pNDDL3Lexer->T__92(pNDDL3Lexer) - * - void pNDDL3Lexer->T__93(pNDDL3Lexer) - * - void pNDDL3Lexer->T__94(pNDDL3Lexer) - * - void pNDDL3Lexer->T__95(pNDDL3Lexer) - * - void pNDDL3Lexer->T__96(pNDDL3Lexer) - * - void pNDDL3Lexer->T__97(pNDDL3Lexer) - * - void pNDDL3Lexer->T__98(pNDDL3Lexer) - * - void pNDDL3Lexer->T__99(pNDDL3Lexer) - * - void pNDDL3Lexer->T__100(pNDDL3Lexer) - * - void pNDDL3Lexer->T__101(pNDDL3Lexer) - * - void pNDDL3Lexer->T__102(pNDDL3Lexer) - * - void pNDDL3Lexer->T__103(pNDDL3Lexer) - * - void pNDDL3Lexer->T__104(pNDDL3Lexer) - * - void pNDDL3Lexer->T__105(pNDDL3Lexer) - * - void pNDDL3Lexer->T__106(pNDDL3Lexer) - * - void pNDDL3Lexer->T__107(pNDDL3Lexer) - * - void pNDDL3Lexer->T__108(pNDDL3Lexer) - * - void pNDDL3Lexer->INCLUDE(pNDDL3Lexer) - * - void pNDDL3Lexer->IDENT(pNDDL3Lexer) - * - void pNDDL3Lexer->STRING(pNDDL3Lexer) - * - void pNDDL3Lexer->ESCAPE_SEQUENCE(pNDDL3Lexer) - * - void pNDDL3Lexer->OCTAL_ESC(pNDDL3Lexer) - * - void pNDDL3Lexer->UNICODE_ESC(pNDDL3Lexer) - * - void pNDDL3Lexer->HEX_DIGIT(pNDDL3Lexer) - * - void pNDDL3Lexer->DIGIT(pNDDL3Lexer) - * - void pNDDL3Lexer->INT(pNDDL3Lexer) - * - void pNDDL3Lexer->INT_SUFFIX(pNDDL3Lexer) - * - void pNDDL3Lexer->FLOAT(pNDDL3Lexer) - * - void pNDDL3Lexer->EXPONENT(pNDDL3Lexer) - * - void pNDDL3Lexer->FLOAT_SUFFIX(pNDDL3Lexer) - * - void pNDDL3Lexer->COMMENT(pNDDL3Lexer) - * - void pNDDL3Lexer->LINE_COMMENT(pNDDL3Lexer) - * - void pNDDL3Lexer->WS(pNDDL3Lexer) - * - void pNDDL3Lexer->Tokens(pNDDL3Lexer) - * - * The return type for any particular rule is of course determined by the source - * grammar file. - */ -// [The "BSD licence"] -// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC -// http://www.temporal-wave.com -// http://www.linkedin.com/in/jimidle -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef _NDDL3Lexer_H -#define _NDDL3Lexer_H -/* ============================================================================= - * Standard antlr3 C runtime definitions - */ -#include - -/* End of standard antlr 3 runtime definitions - * ============================================================================= - */ - -#include "NddlInterpreter.hh" - -using namespace EUROPA; - -// Forward declaration so that we can use this function in apifuncs -typedef struct NDDL3Lexer_Ctx_struct NDDL3Lexer, * pNDDL3Lexer; -static void newNDDL3LexerFree(pNDDL3Lexer ctx); - - -#ifdef __cplusplus -extern "C" { -#endif - -// Forward declare the context typedef so that we can use it before it is -// properly defined. Delegators and delegates (from import statements) are -// interdependent and their context structures contain pointers to each other -// C only allows such things to be declared if you pre-declare the typedef. -// -typedef struct NDDL3Lexer_Ctx_struct NDDL3Lexer, * pNDDL3Lexer; - - - -#ifdef ANTLR3_WINDOWS -// Disable: Unreferenced parameter, - Rules with parameters that are not used -// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) -// initialized but unused variable - tree rewrite variables declared but not needed -// Unreferenced local variable - lexer rule declares but does not always use _type -// potentially unitialized variable used - retval always returned from a rule -// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns -// -// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at -// and the codegen must generate some of these warnings by necessity, apart from 4100, which is -// usually generated when a parser rule is given a parameter that it does not use. Mostly though -// this is a matter of orthogonality hence I disable that one. -// -#pragma warning( disable : 4100 ) -#pragma warning( disable : 4101 ) -#pragma warning( disable : 4127 ) -#pragma warning( disable : 4189 ) -#pragma warning( disable : 4505 ) -#pragma warning( disable : 4701 ) -#endif - -/** Context tracking structure for NDDL3Lexer - */ -struct NDDL3Lexer_Ctx_struct -{ - /** Built in ANTLR3 context tracker contains all the generic elements - * required for context tracking. - */ - pANTLR3_LEXER pLexer; - - - void (*mT__32) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__33) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__34) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__35) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__36) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__37) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__38) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__39) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__40) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__41) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__42) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__43) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__44) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__45) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__46) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__47) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__48) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__49) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__50) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__51) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__52) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__53) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__54) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__55) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__56) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__57) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__58) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__59) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__60) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__61) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__62) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__63) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__64) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__65) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__66) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__67) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__68) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__69) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__70) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__71) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__72) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__73) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__74) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__75) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__76) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__77) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__78) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__79) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__80) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__81) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__82) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__83) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__84) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__85) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__86) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__87) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__88) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__89) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__90) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__91) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__92) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__93) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__94) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__95) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__96) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__97) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__98) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__99) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__100) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__101) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__102) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__103) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__104) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__105) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__106) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__107) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mT__108) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mINCLUDE) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mIDENT) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mSTRING) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mESCAPE_SEQUENCE) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mOCTAL_ESC) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mUNICODE_ESC) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mHEX_DIGIT) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mDIGIT) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mINT) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mINT_SUFFIX) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mFLOAT) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mEXPONENT) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mFLOAT_SUFFIX) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mCOMMENT) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mLINE_COMMENT) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mWS) (struct NDDL3Lexer_Ctx_struct * ctx); - void (*mTokens) (struct NDDL3Lexer_Ctx_struct * ctx); const char * (*getGrammarFileName)(); - void (*free) (struct NDDL3Lexer_Ctx_struct * ctx); - - - NddlInterpreter* parserObj; - std::vector* lexerErrors; - -}; - -// Function protoypes for the constructor functions that external translation units -// such as delegators and delegates may wish to call. -// -ANTLR3_API pNDDL3Lexer NDDL3LexerNew (pANTLR3_INPUT_STREAM instream); -ANTLR3_API pNDDL3Lexer NDDL3LexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); - -/** Symbolic definitions of all the tokens that the lexer will work with. - * \{ - * - * Antlr will define EOF, but we can't use that as it it is too common in - * in C header files and that would be confusing. There is no way to filter this out at the moment - * so we just undef it here for now. That isn't the value we get back from C recognizers - * anyway. We are looking for ANTLR3_TOKEN_EOF. - */ -#ifdef EOF -#undef EOF -#endif -#ifdef Tokens -#undef Tokens -#endif -#define EXPONENT 28 -#define FLOAT_SUFFIX 29 -#define CONSTRUCTOR_INVOCATION 6 -#define OCTAL_ESC 24 -#define EOF -1 -#define T__93 93 -#define T__94 94 -#define T__91 91 -#define T__92 92 -#define T__90 90 -#define INCLUDE 21 -#define PREDICATE_INSTANCE 9 -#define COMMENT 30 -#define T__99 99 -#define T__98 98 -#define T__97 97 -#define T__96 96 -#define T__95 95 -#define T__80 80 -#define T__81 81 -#define T__82 82 -#define T__83 83 -#define LINE_COMMENT 31 -#define INT 17 -#define T__85 85 -#define T__84 84 -#define METHOD_CALL 7 -#define T__87 87 -#define T__86 86 -#define T__89 89 -#define T__88 88 -#define T__71 71 -#define WS 20 -#define T__72 72 -#define VARIABLE 11 -#define T__70 70 -#define T__76 76 -#define FUNCTION_CALL 14 -#define T__75 75 -#define T__74 74 -#define T__73 73 -#define CONSTRUCTOR 5 -#define T__79 79 -#define T__78 78 -#define T__77 77 -#define T__68 68 -#define T__69 69 -#define T__66 66 -#define T__67 67 -#define T__64 64 -#define T__65 65 -#define INT_SUFFIX 27 -#define T__62 62 -#define T__63 63 -#define FLOAT 18 -#define TOKEN_RELATION 10 -#define T__61 61 -#define T__60 60 -#define EXPRESSION_ENFORCE 12 -#define T__55 55 -#define ESCAPE_SEQUENCE 22 -#define T__56 56 -#define T__57 57 -#define T__58 58 -#define T__51 51 -#define T__52 52 -#define T__53 53 -#define T__54 54 -#define T__107 107 -#define T__108 108 -#define T__59 59 -#define T__103 103 -#define T__104 104 -#define T__105 105 -#define T__106 106 -#define IDENT 16 -#define DIGIT 26 -#define T__50 50 -#define T__42 42 -#define T__43 43 -#define T__40 40 -#define T__41 41 -#define T__46 46 -#define T__47 47 -#define T__44 44 -#define T__45 45 -#define T__48 48 -#define T__49 49 -#define UNICODE_ESC 23 -#define HEX_DIGIT 25 -#define T__102 102 -#define T__101 101 -#define T__100 100 -#define T__32 32 -#define T__33 33 -#define T__34 34 -#define EXPRESSION_RETURN 13 -#define T__35 35 -#define T__36 36 -#define CLOSE 15 -#define T__37 37 -#define NDDL 8 -#define T__38 38 -#define T__39 39 -#define CONSTRAINT_INSTANTIATION 4 -#define STRING 19 -#ifdef EOF -#undef EOF -#define EOF ANTLR3_TOKEN_EOF -#endif - -#ifndef TOKENSOURCE -#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource -#endif - -/* End of token definitions for NDDL3Lexer - * ============================================================================= - */ -/** \} */ - -#ifdef __cplusplus -} -#endif - -#endif - -/* END - Note:Keep extra line feed to satisfy UNIX systems */ diff --git a/src/PLASMA/NDDL/base/NDDL3Parser.cpp b/src/PLASMA/NDDL/base/NDDL3Parser.cpp deleted file mode 100644 index 8d05895fa..000000000 --- a/src/PLASMA/NDDL/base/NDDL3Parser.cpp +++ /dev/null @@ -1,14236 +0,0 @@ -/** \file - * This C source file was generated by $ANTLR version 3.1.2 - * - * - From the grammar source file : NDDL/base/antlr/NDDL3.g - * - On : 2011-08-29 18:06:01 - * - for the parser : NDDL3ParserParser * - * Editing it, at least manually, is not wise. - * - * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. - * - * -*/ -// [The "BSD licence"] -// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC -// http://www.temporal-wave.com -// http://www.linkedin.com/in/jimidle -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* ----------------------------------------- - * Include the ANTLR3 generated header file. - */ -#include "NDDL3Parser.h" -/* ----------------------------------------- */ - - - - - -/* MACROS that hide the C interface implementations from the - * generated code, which makes it a little more understandable to the human eye. - * I am very much against using C pre-processor macros for function calls and bits - * of code as you cannot see what is happening when single stepping in debuggers - * and so on. The exception (in my book at least) is for generated code, where you are - * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() - * hides some indirect calls, but is always referring to the input stream. This is - * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig - * the runtime interfaces without changing the generated code too often, without - * confusing the reader of the generated output, who may not wish to know the gory - * details of the interface inheritance. - */ - -#define CTX ctx - -/* Aids in accessing scopes for grammar programmers - */ -#undef SCOPE_TYPE -#undef SCOPE_STACK -#undef SCOPE_TOP -#define SCOPE_TYPE(scope) pNDDL3Parser_##scope##_SCOPE -#define SCOPE_STACK(scope) pNDDL3Parser_##scope##Stack -#define SCOPE_TOP(scope) ctx->pNDDL3Parser_##scope##Top -#define SCOPE_SIZE(scope) (ctx->SCOPE_STACK(scope)->size(ctx->SCOPE_STACK(scope))) -#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) - -/* Macros for accessing things in the parser - */ - -#undef PARSER -#undef RECOGNIZER -#undef HAVEPARSEDRULE -#undef MEMOIZE -#undef INPUT -#undef STRSTREAM -#undef HASEXCEPTION -#undef EXCEPTION -#undef MATCHT -#undef MATCHANYT -#undef FOLLOWSTACK -#undef FOLLOWPUSH -#undef FOLLOWPOP -#undef PRECOVER -#undef PREPORTERROR -#undef LA -#undef LT -#undef CONSTRUCTEX -#undef CONSUME -#undef MARK -#undef REWIND -#undef REWINDLAST -#undef PERRORRECOVERY -#undef HASFAILED -#undef FAILEDFLAG -#undef RECOVERFROMMISMATCHEDSET -#undef RECOVERFROMMISMATCHEDELEMENT -#undef INDEX -#undef ADAPTOR -#undef SEEK -#undef RULEMEMO -#undef DBG - -#define PARSER ctx->pParser -#define RECOGNIZER PARSER->rec -#define PSRSTATE RECOGNIZER->state -#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) -#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) -#define INPUT PARSER->tstream -#define STRSTREAM INPUT -#define ISTREAM INPUT->istream -#define INDEX() ISTREAM->index(INPUT->istream) -#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) -#define EXCEPTION PSRSTATE->exception -#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) -#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) -#define FOLLOWSTACK PSRSTATE->following -#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) -#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) -#define PRECOVER() RECOGNIZER->recover(RECOGNIZER) -#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) -#define LA(n) INPUT->istream->_LA(ISTREAM, n) -#define LT(n) INPUT->_LT(INPUT, n) -#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) -#define CONSUME() ISTREAM->consume(ISTREAM) -#define MARK() ISTREAM->mark(ISTREAM) -#define REWIND(m) ISTREAM->rewind(ISTREAM, m) -#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) -#define SEEK(n) ISTREAM->seek(ISTREAM, n) -#define PERRORRECOVERY PSRSTATE->errorRecovery -#define FAILEDFLAG PSRSTATE->failed -#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) -#define BACKTRACKING PSRSTATE->backtracking -#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) -#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) -#define ADAPTOR ctx->adaptor -#define RULEMEMO PSRSTATE->ruleMemo -#define DBG RECOGNIZER->debugger - -#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt - -/* The 4 tokens defined below may well clash with your own #defines or token types. If so - * then for the present you must use different names for your defines as these are hard coded - * in the code generator. It would be better not to use such names internally, and maybe - * we can change this in a forthcoming release. I deliberately do not #undef these - * here as this will at least give you a redefined error somewhere if they clash. - */ -#define UP ANTLR3_TOKEN_UP -#define DOWN ANTLR3_TOKEN_DOWN -#define EOR ANTLR3_TOKEN_EOR -#define INVALID ANTLR3_TOKEN_INVALID - - -/* ============================================================================= - * Functions to create and destroy scopes. First come the rule scopes, followed - * by the global declared scopes. - */ - - - -/* ============================================================================= */ - -/* ============================================================================= - * Start of recognizer - */ - - - -/** \brief Table of all token names in symbolic order, mainly used for - * error reporting. - */ -pANTLR3_UINT8 NDDL3ParserTokenNames[105+4] - = { - (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ - (pANTLR3_UINT8) "", - (pANTLR3_UINT8) "", - (pANTLR3_UINT8) "", - (pANTLR3_UINT8) "CONSTRAINT_INSTANTIATION", - (pANTLR3_UINT8) "CONSTRUCTOR", - (pANTLR3_UINT8) "CONSTRUCTOR_INVOCATION", - (pANTLR3_UINT8) "METHOD_CALL", - (pANTLR3_UINT8) "NDDL", - (pANTLR3_UINT8) "PREDICATE_INSTANCE", - (pANTLR3_UINT8) "TOKEN_RELATION", - (pANTLR3_UINT8) "VARIABLE", - (pANTLR3_UINT8) "EXPRESSION_ENFORCE", - (pANTLR3_UINT8) "EXPRESSION_RETURN", - (pANTLR3_UINT8) "FUNCTION_CALL", - (pANTLR3_UINT8) "CLOSE", - (pANTLR3_UINT8) "IDENT", - (pANTLR3_UINT8) "INT", - (pANTLR3_UINT8) "FLOAT", - (pANTLR3_UINT8) "STRING", - (pANTLR3_UINT8) "WS", - (pANTLR3_UINT8) "INCLUDE", - (pANTLR3_UINT8) "ESCAPE_SEQUENCE", - (pANTLR3_UINT8) "UNICODE_ESC", - (pANTLR3_UINT8) "OCTAL_ESC", - (pANTLR3_UINT8) "HEX_DIGIT", - (pANTLR3_UINT8) "DIGIT", - (pANTLR3_UINT8) "INT_SUFFIX", - (pANTLR3_UINT8) "EXPONENT", - (pANTLR3_UINT8) "FLOAT_SUFFIX", - (pANTLR3_UINT8) "COMMENT", - (pANTLR3_UINT8) "LINE_COMMENT", - (pANTLR3_UINT8) "'enum'", - (pANTLR3_UINT8) "'{'", - (pANTLR3_UINT8) "','", - (pANTLR3_UINT8) "'}'", - (pANTLR3_UINT8) "'typedef'", - (pANTLR3_UINT8) "';'", - (pANTLR3_UINT8) "'['", - (pANTLR3_UINT8) "']'", - (pANTLR3_UINT8) "'filter'", - (pANTLR3_UINT8) "'('", - (pANTLR3_UINT8) "')'", - (pANTLR3_UINT8) "'='", - (pANTLR3_UINT8) "'new'", - (pANTLR3_UINT8) "'this'", - (pANTLR3_UINT8) "'.'", - (pANTLR3_UINT8) "'in'", - (pANTLR3_UINT8) "'class'", - (pANTLR3_UINT8) "'extends'", - (pANTLR3_UINT8) "'predicate'", - (pANTLR3_UINT8) "'action'", - (pANTLR3_UINT8) "'::'", - (pANTLR3_UINT8) "'int'", - (pANTLR3_UINT8) "'float'", - (pANTLR3_UINT8) "'bool'", - (pANTLR3_UINT8) "'string'", - (pANTLR3_UINT8) "'rejectable'", - (pANTLR3_UINT8) "'goal'", - (pANTLR3_UINT8) "'fact'", - (pANTLR3_UINT8) "'condition'", - (pANTLR3_UINT8) "'effect'", - (pANTLR3_UINT8) "':'", - (pANTLR3_UINT8) "'enforce'", - (pANTLR3_UINT8) "'||'", - (pANTLR3_UINT8) "'&&'", - (pANTLR3_UINT8) "'=='", - (pANTLR3_UINT8) "'!='", - (pANTLR3_UINT8) "'<'", - (pANTLR3_UINT8) "'>'", - (pANTLR3_UINT8) "'>='", - (pANTLR3_UINT8) "'<='", - (pANTLR3_UINT8) "'+'", - (pANTLR3_UINT8) "'-'", - (pANTLR3_UINT8) "'*'", - (pANTLR3_UINT8) "'super'", - (pANTLR3_UINT8) "'if'", - (pANTLR3_UINT8) "'else'", - (pANTLR3_UINT8) "'foreach'", - (pANTLR3_UINT8) "'after'", - (pANTLR3_UINT8) "'any'", - (pANTLR3_UINT8) "'before'", - (pANTLR3_UINT8) "'contained_by'", - (pANTLR3_UINT8) "'contains'", - (pANTLR3_UINT8) "'contains_end'", - (pANTLR3_UINT8) "'contains_start'", - (pANTLR3_UINT8) "'ends'", - (pANTLR3_UINT8) "'ends_after'", - (pANTLR3_UINT8) "'ends_after_start'", - (pANTLR3_UINT8) "'ends_before'", - (pANTLR3_UINT8) "'ends_during'", - (pANTLR3_UINT8) "'equal'", - (pANTLR3_UINT8) "'equals'", - (pANTLR3_UINT8) "'meets'", - (pANTLR3_UINT8) "'met_by'", - (pANTLR3_UINT8) "'parallels'", - (pANTLR3_UINT8) "'paralleled_by'", - (pANTLR3_UINT8) "'starts'", - (pANTLR3_UINT8) "'starts_after'", - (pANTLR3_UINT8) "'starts_before'", - (pANTLR3_UINT8) "'starts_before_end'", - (pANTLR3_UINT8) "'starts_during'", - (pANTLR3_UINT8) "'true'", - (pANTLR3_UINT8) "'false'", - (pANTLR3_UINT8) "'inf'", - (pANTLR3_UINT8) "'inff'", - (pANTLR3_UINT8) "'-inf'", - (pANTLR3_UINT8) "'-inff'", - (pANTLR3_UINT8) "'close'" - }; - - - -// Forward declare the locally static matching functions we have generated. -// -static NDDL3Parser_nddl_return nddl (pNDDL3Parser ctx); -static NDDL3Parser_nddlStatement_return nddlStatement (pNDDL3Parser ctx); -static NDDL3Parser_enumDefinition_return enumDefinition (pNDDL3Parser ctx); -static NDDL3Parser_enumValues_return enumValues (pNDDL3Parser ctx); -static NDDL3Parser_typeDefinition_return typeDefinition (pNDDL3Parser ctx); -static NDDL3Parser_baseDomain_return baseDomain (pNDDL3Parser ctx); -static NDDL3Parser_intervalBaseDomain_return intervalBaseDomain (pNDDL3Parser ctx); -static NDDL3Parser_enumeratedBaseDomain_return enumeratedBaseDomain (pNDDL3Parser ctx); -static NDDL3Parser_baseDomainValue_return baseDomainValue (pNDDL3Parser ctx); -static NDDL3Parser_variableDeclarations_return variableDeclarations (pNDDL3Parser ctx); -static NDDL3Parser_nameWithBaseDomain_return nameWithBaseDomain (pNDDL3Parser ctx); -static NDDL3Parser_anyValue_return anyValue (pNDDL3Parser ctx); -static NDDL3Parser_allocation_return allocation (pNDDL3Parser ctx); -static NDDL3Parser_constructorInvocation_return constructorInvocation (pNDDL3Parser ctx); -static NDDL3Parser_qualified_return qualified (pNDDL3Parser ctx); -static NDDL3Parser_assignment_return assignment (pNDDL3Parser ctx); -static NDDL3Parser_initializer_return initializer (pNDDL3Parser ctx); -static NDDL3Parser_classDeclaration_return classDeclaration (pNDDL3Parser ctx); -static NDDL3Parser_classBlock_return classBlock (pNDDL3Parser ctx); -static NDDL3Parser_classStatement_return classStatement (pNDDL3Parser ctx); -static NDDL3Parser_constructor_return constructor (pNDDL3Parser ctx); -static NDDL3Parser_constructorBlock_return constructorBlock (pNDDL3Parser ctx); -static NDDL3Parser_constructorStatement_return constructorStatement (pNDDL3Parser ctx); -static NDDL3Parser_constructorParameterList_return constructorParameterList (pNDDL3Parser ctx); -static NDDL3Parser_constructorParameters_return constructorParameters (pNDDL3Parser ctx); -static NDDL3Parser_constructorParameter_return constructorParameter (pNDDL3Parser ctx); -static NDDL3Parser_tokenType_return tokenType (pNDDL3Parser ctx); -static NDDL3Parser_tokenBlock_return tokenBlock (pNDDL3Parser ctx); -static NDDL3Parser_tokenStatement_return tokenStatement (pNDDL3Parser ctx); -static NDDL3Parser_rule_return rule (pNDDL3Parser ctx); -static NDDL3Parser_ruleBlock_return ruleBlock (pNDDL3Parser ctx); -static NDDL3Parser_ruleStatement_return ruleStatement (pNDDL3Parser ctx); -static NDDL3Parser_type_return type (pNDDL3Parser ctx); -static NDDL3Parser_relation_return relation (pNDDL3Parser ctx); -static NDDL3Parser_problemStmt_return problemStmt (pNDDL3Parser ctx); -static NDDL3Parser_tokenInstanceList_return tokenInstanceList (pNDDL3Parser ctx); -static NDDL3Parser_tokenVarRef_return tokenVarRef (pNDDL3Parser ctx); -static NDDL3Parser_tokenInstances_return tokenInstances (pNDDL3Parser ctx); -static NDDL3Parser_tokenInstance_return tokenInstance (pNDDL3Parser ctx); -static NDDL3Parser_tokenAnnotation_return tokenAnnotation (pNDDL3Parser ctx); -static NDDL3Parser_constraintInstantiation_return constraintInstantiation (pNDDL3Parser ctx); -static NDDL3Parser_enforceStatement_return enforceStatement (pNDDL3Parser ctx); -static NDDL3Parser_violationMsg_return violationMsg (pNDDL3Parser ctx); -static NDDL3Parser_cexpression_return cexpression (pNDDL3Parser ctx); -static NDDL3Parser_cbooleanOrExpression_return cbooleanOrExpression (pNDDL3Parser ctx); -static NDDL3Parser_cbooleanAndExpression_return cbooleanAndExpression (pNDDL3Parser ctx); -static NDDL3Parser_crelationalExpression_return crelationalExpression (pNDDL3Parser ctx); -static NDDL3Parser_cadditiveExpression_return cadditiveExpression (pNDDL3Parser ctx); -static NDDL3Parser_cmultiplicativeExpression_return cmultiplicativeExpression (pNDDL3Parser ctx); -static NDDL3Parser_cprimary_return cprimary (pNDDL3Parser ctx); -static NDDL3Parser_cexpressionList_return cexpressionList (pNDDL3Parser ctx); -static NDDL3Parser_superInvocation_return superInvocation (pNDDL3Parser ctx); -static NDDL3Parser_variableArgumentList_return variableArgumentList (pNDDL3Parser ctx); -static NDDL3Parser_variableArguments_return variableArguments (pNDDL3Parser ctx); -static NDDL3Parser_variableArgument_return variableArgument (pNDDL3Parser ctx); -static NDDL3Parser_typeArgumentList_return typeArgumentList (pNDDL3Parser ctx); -static NDDL3Parser_typeArguments_return typeArguments (pNDDL3Parser ctx); -static NDDL3Parser_typeArgument_return typeArgument (pNDDL3Parser ctx); -static NDDL3Parser_flowControl_return flowControl (pNDDL3Parser ctx); -static NDDL3Parser_guardExpression_return guardExpression (pNDDL3Parser ctx); -static NDDL3Parser_allocationStmt_return allocationStmt (pNDDL3Parser ctx); -static NDDL3Parser_temporalRelation_return temporalRelation (pNDDL3Parser ctx); -static NDDL3Parser_literalValue_return literalValue (pNDDL3Parser ctx); -static NDDL3Parser_booleanLiteral_return booleanLiteral (pNDDL3Parser ctx); -static NDDL3Parser_numericLiteral_return numericLiteral (pNDDL3Parser ctx); -static NDDL3Parser_stringLiteral_return stringLiteral (pNDDL3Parser ctx); -static NDDL3Parser_methodInvocation_return methodInvocation (pNDDL3Parser ctx); -static NDDL3Parser_methodName_return methodName (pNDDL3Parser ctx); -static NDDL3Parser_noopstatement_return noopstatement (pNDDL3Parser ctx); -static ANTLR3_BOOLEAN synpred1_NDDL3 (pNDDL3Parser ctx); -static ANTLR3_BOOLEAN synpred2_NDDL3 (pNDDL3Parser ctx); -static void NDDL3ParserFree(pNDDL3Parser ctx); -/* For use in tree output where we are accumulating rule labels via label += ruleRef - * we need a function that knows how to free a return scope when the list is destroyed. - * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. - */ -static void ANTLR3_CDECL freeScope(void * scope) -{ - ANTLR3_FREE(scope); -} - -/** \brief Name of the grammar file that generated this code - */ -static const char fileName[] = "NDDL/base/antlr/NDDL3.g"; - -/** \brief Return the name of the grammar file that generated this code. - */ -static const char * getGrammarFileName() -{ - return fileName; -} -/** \brief Create a new NDDL3Parser parser and return a context for it. - * - * \param[in] instream Pointer to an input stream interface. - * - * \return Pointer to new parser context upon success. - */ -ANTLR3_API pNDDL3Parser -NDDL3ParserNew (pANTLR3_COMMON_TOKEN_STREAM instream) -{ - // See if we can create a new parser with the standard constructor - // - return NDDL3ParserNewSSD(instream, NULL); -} - -/** \brief Create a new NDDL3Parser parser and return a context for it. - * - * \param[in] instream Pointer to an input stream interface. - * - * \return Pointer to new parser context upon success. - */ -ANTLR3_API pNDDL3Parser -NDDL3ParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) -{ - pNDDL3Parser ctx; /* Context structure we will build and return */ - - ctx = (pNDDL3Parser) ANTLR3_CALLOC(1, sizeof(NDDL3Parser)); - - if (ctx == NULL) - { - // Failed to allocate memory for parser context - // - return NULL; - } - - /* ------------------------------------------------------------------- - * Memory for basic structure is allocated, now to fill in - * the base ANTLR3 structures. We initialize the function pointers - * for the standard ANTLR3 parser function set, but upon return - * from here, the programmer may set the pointers to provide custom - * implementations of each function. - * - * We don't use the macros defined in NDDL3Parser.h here, in order that you can get a sense - * of what goes where. - */ - - /* Create a base parser/recognizer, using the supplied token stream - */ - ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state); - /* Install the implementation of our NDDL3Parser interface - */ - ctx->nddl = nddl; - ctx->nddlStatement = nddlStatement; - ctx->enumDefinition = enumDefinition; - ctx->enumValues = enumValues; - ctx->typeDefinition = typeDefinition; - ctx->baseDomain = baseDomain; - ctx->intervalBaseDomain = intervalBaseDomain; - ctx->enumeratedBaseDomain = enumeratedBaseDomain; - ctx->baseDomainValue = baseDomainValue; - ctx->variableDeclarations = variableDeclarations; - ctx->nameWithBaseDomain = nameWithBaseDomain; - ctx->anyValue = anyValue; - ctx->allocation = allocation; - ctx->constructorInvocation = constructorInvocation; - ctx->qualified = qualified; - ctx->assignment = assignment; - ctx->initializer = initializer; - ctx->classDeclaration = classDeclaration; - ctx->classBlock = classBlock; - ctx->classStatement = classStatement; - ctx->constructor = constructor; - ctx->constructorBlock = constructorBlock; - ctx->constructorStatement = constructorStatement; - ctx->constructorParameterList = constructorParameterList; - ctx->constructorParameters = constructorParameters; - ctx->constructorParameter = constructorParameter; - ctx->tokenType = tokenType; - ctx->tokenBlock = tokenBlock; - ctx->tokenStatement = tokenStatement; - ctx->rule = rule; - ctx->ruleBlock = ruleBlock; - ctx->ruleStatement = ruleStatement; - ctx->type = type; - ctx->relation = relation; - ctx->problemStmt = problemStmt; - ctx->tokenInstanceList = tokenInstanceList; - ctx->tokenVarRef = tokenVarRef; - ctx->tokenInstances = tokenInstances; - ctx->tokenInstance = tokenInstance; - ctx->tokenAnnotation = tokenAnnotation; - ctx->constraintInstantiation = constraintInstantiation; - ctx->enforceStatement = enforceStatement; - ctx->violationMsg = violationMsg; - ctx->cexpression = cexpression; - ctx->cbooleanOrExpression = cbooleanOrExpression; - ctx->cbooleanAndExpression = cbooleanAndExpression; - ctx->crelationalExpression = crelationalExpression; - ctx->cadditiveExpression = cadditiveExpression; - ctx->cmultiplicativeExpression = cmultiplicativeExpression; - ctx->cprimary = cprimary; - ctx->cexpressionList = cexpressionList; - ctx->superInvocation = superInvocation; - ctx->variableArgumentList = variableArgumentList; - ctx->variableArguments = variableArguments; - ctx->variableArgument = variableArgument; - ctx->typeArgumentList = typeArgumentList; - ctx->typeArguments = typeArguments; - ctx->typeArgument = typeArgument; - ctx->flowControl = flowControl; - ctx->guardExpression = guardExpression; - ctx->allocationStmt = allocationStmt; - ctx->temporalRelation = temporalRelation; - ctx->literalValue = literalValue; - ctx->booleanLiteral = booleanLiteral; - ctx->numericLiteral = numericLiteral; - ctx->stringLiteral = stringLiteral; - ctx->methodInvocation = methodInvocation; - ctx->methodName = methodName; - ctx->noopstatement = noopstatement; - ctx->synpred1_NDDL3 = synpred1_NDDL3; - ctx->synpred2_NDDL3 = synpred2_NDDL3; - ctx->free = NDDL3ParserFree; - ctx->getGrammarFileName = getGrammarFileName; - - /* Install the scope pushing methods. - */ - ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory); - ctx->vectors = antlr3VectorFactoryNew(0); - - - RECOGNIZER->displayRecognitionError = reportParserError; - ctx->parserErrors = new std::vector; - ctx->free = newNDDL3ParserFree; - // This is needed so that we can get to the CTX from reportParseError - // Thanks to http://www.antlr.org/pipermail/antlr-interest/2009-May/034567.html - // for the tip - PARSER->super = (void *)ctx; - - - /* Install the token table - */ - PSRSTATE->tokenNames = NDDL3ParserTokenNames; - - - /* Return the newly built parser to the caller - */ - return ctx; -} - -/** Free the parser resources - */ - static void - NDDL3ParserFree(pNDDL3Parser ctx) - { - /* Free any scope memory - */ - - ctx->vectors->close(ctx->vectors); - /* We created the adaptor so we must free it - */ - ADAPTOR->free(ADAPTOR); - // Free this parser - // - ctx->pParser->free(ctx->pParser); - ANTLR3_FREE(ctx); - - /* Everything is released, so we can return - */ - return; - } - -/** Return token names used by this parser - * - * The returned pointer is used as an index into the token names table (using the token - * number as the index). - * - * \return Pointer to first char * in the table. - */ -static pANTLR3_UINT8 *getTokenNames() -{ - return NDDL3ParserTokenNames; -} - - - // Declare it in members, so that we can refer to the original Free - static void newNDDL3ParserFree(pNDDL3Parser ctx) { - delete ctx->parserErrors; - NDDL3ParserFree(ctx); - } - - -/* Declare the bitsets - */ - -/** Bitset defining follow set for error recovery in rule state: FOLLOW_nddlStatement_in_nddl184 */ -static ANTLR3_BITWORD FOLLOW_nddlStatement_in_nddl184_bits[] = { ANTLR3_UINT64_LIT(0x8FE13373000F0002), ANTLR3_UINT64_LIT(0x00001FFFFFFF8100) }; -static ANTLR3_BITSET_LIST FOLLOW_nddlStatement_in_nddl184 = { FOLLOW_nddlStatement_in_nddl184_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_typeDefinition_in_nddlStatement221 */ -static ANTLR3_BITWORD FOLLOW_typeDefinition_in_nddlStatement221_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_typeDefinition_in_nddlStatement221 = { FOLLOW_typeDefinition_in_nddlStatement221_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enumDefinition_in_nddlStatement231 */ -static ANTLR3_BITWORD FOLLOW_enumDefinition_in_nddlStatement231_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_enumDefinition_in_nddlStatement231 = { FOLLOW_enumDefinition_in_nddlStatement231_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableDeclarations_in_nddlStatement241 */ -static ANTLR3_BITWORD FOLLOW_variableDeclarations_in_nddlStatement241_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableDeclarations_in_nddlStatement241 = { FOLLOW_variableDeclarations_in_nddlStatement241_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_assignment_in_nddlStatement251 */ -static ANTLR3_BITWORD FOLLOW_assignment_in_nddlStatement251_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_assignment_in_nddlStatement251 = { FOLLOW_assignment_in_nddlStatement251_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constraintInstantiation_in_nddlStatement261 */ -static ANTLR3_BITWORD FOLLOW_constraintInstantiation_in_nddlStatement261_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constraintInstantiation_in_nddlStatement261 = { FOLLOW_constraintInstantiation_in_nddlStatement261_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_classDeclaration_in_nddlStatement271 */ -static ANTLR3_BITWORD FOLLOW_classDeclaration_in_nddlStatement271_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_classDeclaration_in_nddlStatement271 = { FOLLOW_classDeclaration_in_nddlStatement271_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_allocationStmt_in_nddlStatement281 */ -static ANTLR3_BITWORD FOLLOW_allocationStmt_in_nddlStatement281_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_allocationStmt_in_nddlStatement281 = { FOLLOW_allocationStmt_in_nddlStatement281_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_rule_in_nddlStatement291 */ -static ANTLR3_BITWORD FOLLOW_rule_in_nddlStatement291_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_rule_in_nddlStatement291 = { FOLLOW_rule_in_nddlStatement291_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_problemStmt_in_nddlStatement301 */ -static ANTLR3_BITWORD FOLLOW_problemStmt_in_nddlStatement301_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_problemStmt_in_nddlStatement301 = { FOLLOW_problemStmt_in_nddlStatement301_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_relation_in_nddlStatement311 */ -static ANTLR3_BITWORD FOLLOW_relation_in_nddlStatement311_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_relation_in_nddlStatement311 = { FOLLOW_relation_in_nddlStatement311_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_methodInvocation_in_nddlStatement321 */ -static ANTLR3_BITWORD FOLLOW_methodInvocation_in_nddlStatement321_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_methodInvocation_in_nddlStatement321 = { FOLLOW_methodInvocation_in_nddlStatement321_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_noopstatement_in_nddlStatement331 */ -static ANTLR3_BITWORD FOLLOW_noopstatement_in_nddlStatement331_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_noopstatement_in_nddlStatement331 = { FOLLOW_noopstatement_in_nddlStatement331_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_32_in_enumDefinition348 */ -static ANTLR3_BITWORD FOLLOW_32_in_enumDefinition348_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_32_in_enumDefinition348 = { FOLLOW_32_in_enumDefinition348_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_enumDefinition351 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_enumDefinition351_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_enumDefinition351 = { FOLLOW_IDENT_in_enumDefinition351_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enumValues_in_enumDefinition353 */ -static ANTLR3_BITWORD FOLLOW_enumValues_in_enumDefinition353_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_enumValues_in_enumDefinition353 = { FOLLOW_enumValues_in_enumDefinition353_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_enumValues373 */ -static ANTLR3_BITWORD FOLLOW_33_in_enumValues373_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_enumValues373 = { FOLLOW_33_in_enumValues373_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_enumValues376 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_enumValues376_bits[] = { ANTLR3_UINT64_LIT(0x0000000C00000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_enumValues376 = { FOLLOW_IDENT_in_enumValues376_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_enumValues379 */ -static ANTLR3_BITWORD FOLLOW_34_in_enumValues379_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_enumValues379 = { FOLLOW_34_in_enumValues379_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_enumValues382 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_enumValues382_bits[] = { ANTLR3_UINT64_LIT(0x0000000C00000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_enumValues382 = { FOLLOW_IDENT_in_enumValues382_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_35_in_enumValues386 */ -static ANTLR3_BITWORD FOLLOW_35_in_enumValues386_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_35_in_enumValues386 = { FOLLOW_35_in_enumValues386_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_36_in_typeDefinition417 */ -static ANTLR3_BITWORD FOLLOW_36_in_typeDefinition417_bits[] = { ANTLR3_UINT64_LIT(0x01E0010000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_36_in_typeDefinition417 = { FOLLOW_36_in_typeDefinition417_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_type_in_typeDefinition419 */ -static ANTLR3_BITWORD FOLLOW_type_in_typeDefinition419_bits[] = { ANTLR3_UINT64_LIT(0x0000004200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_type_in_typeDefinition419 = { FOLLOW_type_in_typeDefinition419_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_baseDomain_in_typeDefinition421 */ -static ANTLR3_BITWORD FOLLOW_baseDomain_in_typeDefinition421_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_baseDomain_in_typeDefinition421 = { FOLLOW_baseDomain_in_typeDefinition421_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_typeDefinition423 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_typeDefinition423_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_typeDefinition423 = { FOLLOW_IDENT_in_typeDefinition423_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_typeDefinition425 */ -static ANTLR3_BITWORD FOLLOW_37_in_typeDefinition425_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_typeDefinition425 = { FOLLOW_37_in_typeDefinition425_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_intervalBaseDomain_in_baseDomain463 */ -static ANTLR3_BITWORD FOLLOW_intervalBaseDomain_in_baseDomain463_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_intervalBaseDomain_in_baseDomain463 = { FOLLOW_intervalBaseDomain_in_baseDomain463_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enumeratedBaseDomain_in_baseDomain473 */ -static ANTLR3_BITWORD FOLLOW_enumeratedBaseDomain_in_baseDomain473_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_enumeratedBaseDomain_in_baseDomain473 = { FOLLOW_enumeratedBaseDomain_in_baseDomain473_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_38_in_intervalBaseDomain492 */ -static ANTLR3_BITWORD FOLLOW_38_in_intervalBaseDomain492_bits[] = { ANTLR3_UINT64_LIT(0x0000000000060000), ANTLR3_UINT64_LIT(0x00000F0000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_38_in_intervalBaseDomain492 = { FOLLOW_38_in_intervalBaseDomain492_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_numericLiteral_in_intervalBaseDomain495 */ -static ANTLR3_BITWORD FOLLOW_numericLiteral_in_intervalBaseDomain495_bits[] = { ANTLR3_UINT64_LIT(0x0000000400060000), ANTLR3_UINT64_LIT(0x00000F0000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_numericLiteral_in_intervalBaseDomain495 = { FOLLOW_numericLiteral_in_intervalBaseDomain495_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_intervalBaseDomain498 */ -static ANTLR3_BITWORD FOLLOW_34_in_intervalBaseDomain498_bits[] = { ANTLR3_UINT64_LIT(0x0000000000060000), ANTLR3_UINT64_LIT(0x00000F0000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_intervalBaseDomain498 = { FOLLOW_34_in_intervalBaseDomain498_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_numericLiteral_in_intervalBaseDomain503 */ -static ANTLR3_BITWORD FOLLOW_numericLiteral_in_intervalBaseDomain503_bits[] = { ANTLR3_UINT64_LIT(0x0000008000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_numericLiteral_in_intervalBaseDomain503 = { FOLLOW_numericLiteral_in_intervalBaseDomain503_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_39_in_intervalBaseDomain505 */ -static ANTLR3_BITWORD FOLLOW_39_in_intervalBaseDomain505_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_39_in_intervalBaseDomain505 = { FOLLOW_39_in_intervalBaseDomain505_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_enumeratedBaseDomain525 */ -static ANTLR3_BITWORD FOLLOW_33_in_enumeratedBaseDomain525_bits[] = { ANTLR3_UINT64_LIT(0x00002000000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_enumeratedBaseDomain525 = { FOLLOW_33_in_enumeratedBaseDomain525_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_baseDomainValue_in_enumeratedBaseDomain528 */ -static ANTLR3_BITWORD FOLLOW_baseDomainValue_in_enumeratedBaseDomain528_bits[] = { ANTLR3_UINT64_LIT(0x0000000C00000000) }; -static ANTLR3_BITSET_LIST FOLLOW_baseDomainValue_in_enumeratedBaseDomain528 = { FOLLOW_baseDomainValue_in_enumeratedBaseDomain528_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_enumeratedBaseDomain531 */ -static ANTLR3_BITWORD FOLLOW_34_in_enumeratedBaseDomain531_bits[] = { ANTLR3_UINT64_LIT(0x00002000000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_enumeratedBaseDomain531 = { FOLLOW_34_in_enumeratedBaseDomain531_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_baseDomainValue_in_enumeratedBaseDomain534 */ -static ANTLR3_BITWORD FOLLOW_baseDomainValue_in_enumeratedBaseDomain534_bits[] = { ANTLR3_UINT64_LIT(0x0000000C00000000) }; -static ANTLR3_BITSET_LIST FOLLOW_baseDomainValue_in_enumeratedBaseDomain534 = { FOLLOW_baseDomainValue_in_enumeratedBaseDomain534_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_35_in_enumeratedBaseDomain538 */ -static ANTLR3_BITWORD FOLLOW_35_in_enumeratedBaseDomain538_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_35_in_enumeratedBaseDomain538 = { FOLLOW_35_in_enumeratedBaseDomain538_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_literalValue_in_baseDomainValue563 */ -static ANTLR3_BITWORD FOLLOW_literalValue_in_baseDomainValue563_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_literalValue_in_baseDomainValue563 = { FOLLOW_literalValue_in_baseDomainValue563_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_baseDomainValue571 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_baseDomainValue571_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_baseDomainValue571 = { FOLLOW_qualified_in_baseDomainValue571_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_40_in_variableDeclarations609 */ -static ANTLR3_BITWORD FOLLOW_40_in_variableDeclarations609_bits[] = { ANTLR3_UINT64_LIT(0x01E0010000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_40_in_variableDeclarations609 = { FOLLOW_40_in_variableDeclarations609_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_type_in_variableDeclarations613 */ -static ANTLR3_BITWORD FOLLOW_type_in_variableDeclarations613_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_type_in_variableDeclarations613 = { FOLLOW_type_in_variableDeclarations613_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_nameWithBaseDomain_in_variableDeclarations615 */ -static ANTLR3_BITWORD FOLLOW_nameWithBaseDomain_in_variableDeclarations615_bits[] = { ANTLR3_UINT64_LIT(0x0000002400000000) }; -static ANTLR3_BITSET_LIST FOLLOW_nameWithBaseDomain_in_variableDeclarations615 = { FOLLOW_nameWithBaseDomain_in_variableDeclarations615_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_variableDeclarations618 */ -static ANTLR3_BITWORD FOLLOW_34_in_variableDeclarations618_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_variableDeclarations618 = { FOLLOW_34_in_variableDeclarations618_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_nameWithBaseDomain_in_variableDeclarations620 */ -static ANTLR3_BITWORD FOLLOW_nameWithBaseDomain_in_variableDeclarations620_bits[] = { ANTLR3_UINT64_LIT(0x0000002400000000) }; -static ANTLR3_BITSET_LIST FOLLOW_nameWithBaseDomain_in_variableDeclarations620 = { FOLLOW_nameWithBaseDomain_in_variableDeclarations620_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_variableDeclarations624 */ -static ANTLR3_BITWORD FOLLOW_37_in_variableDeclarations624_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_variableDeclarations624 = { FOLLOW_37_in_variableDeclarations624_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_nameWithBaseDomain676 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_nameWithBaseDomain676_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_nameWithBaseDomain676 = { FOLLOW_IDENT_in_nameWithBaseDomain676_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_nameWithBaseDomain679 */ -static ANTLR3_BITWORD FOLLOW_41_in_nameWithBaseDomain679_bits[] = { ANTLR3_UINT64_LIT(0x00003042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_nameWithBaseDomain679 = { FOLLOW_41_in_nameWithBaseDomain679_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_initializer_in_nameWithBaseDomain684 */ -static ANTLR3_BITWORD FOLLOW_initializer_in_nameWithBaseDomain684_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_initializer_in_nameWithBaseDomain684 = { FOLLOW_initializer_in_nameWithBaseDomain684_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_nameWithBaseDomain686 */ -static ANTLR3_BITWORD FOLLOW_42_in_nameWithBaseDomain686_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_nameWithBaseDomain686 = { FOLLOW_42_in_nameWithBaseDomain686_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_nameWithBaseDomain706 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_nameWithBaseDomain706_bits[] = { ANTLR3_UINT64_LIT(0x0000080000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_nameWithBaseDomain706 = { FOLLOW_IDENT_in_nameWithBaseDomain706_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_43_in_nameWithBaseDomain708 */ -static ANTLR3_BITWORD FOLLOW_43_in_nameWithBaseDomain708_bits[] = { ANTLR3_UINT64_LIT(0x00003042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_43_in_nameWithBaseDomain708 = { FOLLOW_43_in_nameWithBaseDomain708_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_initializer_in_nameWithBaseDomain713 */ -static ANTLR3_BITWORD FOLLOW_initializer_in_nameWithBaseDomain713_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_initializer_in_nameWithBaseDomain713 = { FOLLOW_initializer_in_nameWithBaseDomain713_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_literalValue_in_anyValue742 */ -static ANTLR3_BITWORD FOLLOW_literalValue_in_anyValue742_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_literalValue_in_anyValue742 = { FOLLOW_literalValue_in_anyValue742_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_baseDomain_in_anyValue752 */ -static ANTLR3_BITWORD FOLLOW_baseDomain_in_anyValue752_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_baseDomain_in_anyValue752 = { FOLLOW_baseDomain_in_anyValue752_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_anyValue762 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_anyValue762_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_anyValue762 = { FOLLOW_qualified_in_anyValue762_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_44_in_allocation781 */ -static ANTLR3_BITWORD FOLLOW_44_in_allocation781_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_44_in_allocation781 = { FOLLOW_44_in_allocation781_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorInvocation_in_allocation784 */ -static ANTLR3_BITWORD FOLLOW_constructorInvocation_in_allocation784_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorInvocation_in_allocation784 = { FOLLOW_constructorInvocation_in_allocation784_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_constructorInvocation803 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_constructorInvocation803_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_constructorInvocation803 = { FOLLOW_IDENT_in_constructorInvocation803_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_constructorInvocation805 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_constructorInvocation805_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_constructorInvocation805 = { FOLLOW_variableArgumentList_in_constructorInvocation805_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_qualified846 */ -static ANTLR3_BITWORD FOLLOW_set_in_qualified846_bits[] = { ANTLR3_UINT64_LIT(0x0000400000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_qualified846 = { FOLLOW_set_in_qualified846_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_46_in_qualified855 */ -static ANTLR3_BITWORD FOLLOW_46_in_qualified855_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_46_in_qualified855 = { FOLLOW_46_in_qualified855_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_qualified858 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_qualified858_bits[] = { ANTLR3_UINT64_LIT(0x0000400000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_qualified858 = { FOLLOW_IDENT_in_qualified858_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_assignment879 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_assignment879_bits[] = { ANTLR3_UINT64_LIT(0x0000880000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_assignment879 = { FOLLOW_qualified_in_assignment879_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_47_in_assignment882 */ -static ANTLR3_BITWORD FOLLOW_47_in_assignment882_bits[] = { ANTLR3_UINT64_LIT(0x00003042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_47_in_assignment882 = { FOLLOW_47_in_assignment882_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_43_in_assignment886 */ -static ANTLR3_BITWORD FOLLOW_43_in_assignment886_bits[] = { ANTLR3_UINT64_LIT(0x00003042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_43_in_assignment886 = { FOLLOW_43_in_assignment886_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_initializer_in_assignment889 */ -static ANTLR3_BITWORD FOLLOW_initializer_in_assignment889_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_initializer_in_assignment889 = { FOLLOW_initializer_in_assignment889_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_assignment891 */ -static ANTLR3_BITWORD FOLLOW_37_in_assignment891_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_assignment891 = { FOLLOW_37_in_assignment891_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_initializer924 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_initializer924_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_initializer924 = { FOLLOW_anyValue_in_initializer924_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_allocation_in_initializer934 */ -static ANTLR3_BITWORD FOLLOW_allocation_in_initializer934_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_allocation_in_initializer934 = { FOLLOW_allocation_in_initializer934_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_48_in_classDeclaration956 */ -static ANTLR3_BITWORD FOLLOW_48_in_classDeclaration956_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_48_in_classDeclaration956 = { FOLLOW_48_in_classDeclaration956_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_classDeclaration960 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_classDeclaration960_bits[] = { ANTLR3_UINT64_LIT(0x0002002200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_classDeclaration960 = { FOLLOW_IDENT_in_classDeclaration960_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_49_in_classDeclaration968 */ -static ANTLR3_BITWORD FOLLOW_49_in_classDeclaration968_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_49_in_classDeclaration968 = { FOLLOW_49_in_classDeclaration968_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_classDeclaration972 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_classDeclaration972_bits[] = { ANTLR3_UINT64_LIT(0x0002000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_classDeclaration972 = { FOLLOW_IDENT_in_classDeclaration972_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_classBlock_in_classDeclaration976 */ -static ANTLR3_BITWORD FOLLOW_classBlock_in_classDeclaration976_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_classBlock_in_classDeclaration976 = { FOLLOW_classBlock_in_classDeclaration976_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_classDeclaration1012 */ -static ANTLR3_BITWORD FOLLOW_37_in_classDeclaration1012_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_classDeclaration1012 = { FOLLOW_37_in_classDeclaration1012_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_classBlock1055 */ -static ANTLR3_BITWORD FOLLOW_33_in_classBlock1055_bits[] = { ANTLR3_UINT64_LIT(0x8FED337B000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFF8100) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_classBlock1055 = { FOLLOW_33_in_classBlock1055_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_classStatement_in_classBlock1058 */ -static ANTLR3_BITWORD FOLLOW_classStatement_in_classBlock1058_bits[] = { ANTLR3_UINT64_LIT(0x8FED337B000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFF8100) }; -static ANTLR3_BITSET_LIST FOLLOW_classStatement_in_classBlock1058 = { FOLLOW_classStatement_in_classBlock1058_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_35_in_classBlock1061 */ -static ANTLR3_BITWORD FOLLOW_35_in_classBlock1061_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_35_in_classBlock1061 = { FOLLOW_35_in_classBlock1061_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableDeclarations_in_classStatement1073 */ -static ANTLR3_BITWORD FOLLOW_variableDeclarations_in_classStatement1073_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableDeclarations_in_classStatement1073 = { FOLLOW_variableDeclarations_in_classStatement1073_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructor_in_classStatement1078 */ -static ANTLR3_BITWORD FOLLOW_constructor_in_classStatement1078_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constructor_in_classStatement1078 = { FOLLOW_constructor_in_classStatement1078_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenType_in_classStatement1083 */ -static ANTLR3_BITWORD FOLLOW_tokenType_in_classStatement1083_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenType_in_classStatement1083 = { FOLLOW_tokenType_in_classStatement1083_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_noopstatement_in_classStatement1088 */ -static ANTLR3_BITWORD FOLLOW_noopstatement_in_classStatement1088_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_noopstatement_in_classStatement1088 = { FOLLOW_noopstatement_in_classStatement1088_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_constructor1099 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_constructor1099_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_constructor1099 = { FOLLOW_IDENT_in_constructor1099_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorParameterList_in_constructor1101 */ -static ANTLR3_BITWORD FOLLOW_constructorParameterList_in_constructor1101_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorParameterList_in_constructor1101 = { FOLLOW_constructorParameterList_in_constructor1101_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorBlock_in_constructor1103 */ -static ANTLR3_BITWORD FOLLOW_constructorBlock_in_constructor1103_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorBlock_in_constructor1103 = { FOLLOW_constructorBlock_in_constructor1103_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_constructorBlock1129 */ -static ANTLR3_BITWORD FOLLOW_33_in_constructorBlock1129_bits[] = { ANTLR3_UINT64_LIT(0x8FE1337B000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFF8900) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_constructorBlock1129 = { FOLLOW_33_in_constructorBlock1129_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorStatement_in_constructorBlock1132 */ -static ANTLR3_BITWORD FOLLOW_constructorStatement_in_constructorBlock1132_bits[] = { ANTLR3_UINT64_LIT(0x8FE1337B000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFF8900) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorStatement_in_constructorBlock1132 = { FOLLOW_constructorStatement_in_constructorBlock1132_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_35_in_constructorBlock1135 */ -static ANTLR3_BITWORD FOLLOW_35_in_constructorBlock1135_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_35_in_constructorBlock1135 = { FOLLOW_35_in_constructorBlock1135_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_assignment_in_constructorStatement1147 */ -static ANTLR3_BITWORD FOLLOW_assignment_in_constructorStatement1147_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_assignment_in_constructorStatement1147 = { FOLLOW_assignment_in_constructorStatement1147_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_superInvocation_in_constructorStatement1152 */ -static ANTLR3_BITWORD FOLLOW_superInvocation_in_constructorStatement1152_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_superInvocation_in_constructorStatement1152 = { FOLLOW_superInvocation_in_constructorStatement1152_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_noopstatement_in_constructorStatement1157 */ -static ANTLR3_BITWORD FOLLOW_noopstatement_in_constructorStatement1157_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_noopstatement_in_constructorStatement1157 = { FOLLOW_noopstatement_in_constructorStatement1157_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_constructorParameterList1168 */ -static ANTLR3_BITWORD FOLLOW_41_in_constructorParameterList1168_bits[] = { ANTLR3_UINT64_LIT(0x01E0050000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_constructorParameterList1168 = { FOLLOW_41_in_constructorParameterList1168_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorParameters_in_constructorParameterList1171 */ -static ANTLR3_BITWORD FOLLOW_constructorParameters_in_constructorParameterList1171_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorParameters_in_constructorParameterList1171 = { FOLLOW_constructorParameters_in_constructorParameterList1171_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_constructorParameterList1174 */ -static ANTLR3_BITWORD FOLLOW_42_in_constructorParameterList1174_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_constructorParameterList1174 = { FOLLOW_42_in_constructorParameterList1174_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorParameter_in_constructorParameters1186 */ -static ANTLR3_BITWORD FOLLOW_constructorParameter_in_constructorParameters1186_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorParameter_in_constructorParameters1186 = { FOLLOW_constructorParameter_in_constructorParameters1186_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_constructorParameters1190 */ -static ANTLR3_BITWORD FOLLOW_34_in_constructorParameters1190_bits[] = { ANTLR3_UINT64_LIT(0x01E0010000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_constructorParameters1190 = { FOLLOW_34_in_constructorParameters1190_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorParameters_in_constructorParameters1193 */ -static ANTLR3_BITWORD FOLLOW_constructorParameters_in_constructorParameters1193_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorParameters_in_constructorParameters1193 = { FOLLOW_constructorParameters_in_constructorParameters1193_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_type_in_constructorParameter1206 */ -static ANTLR3_BITWORD FOLLOW_type_in_constructorParameter1206_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_type_in_constructorParameter1206 = { FOLLOW_type_in_constructorParameter1206_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_constructorParameter1208 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_constructorParameter1208_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_constructorParameter1208 = { FOLLOW_IDENT_in_constructorParameter1208_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_tokenType1232 */ -static ANTLR3_BITWORD FOLLOW_set_in_tokenType1232_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_tokenType1232 = { FOLLOW_set_in_tokenType1232_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_tokenType1241 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_tokenType1241_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_tokenType1241 = { FOLLOW_IDENT_in_tokenType1241_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenBlock_in_tokenType1243 */ -static ANTLR3_BITWORD FOLLOW_tokenBlock_in_tokenType1243_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenBlock_in_tokenType1243 = { FOLLOW_tokenBlock_in_tokenType1243_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_tokenBlock1255 */ -static ANTLR3_BITWORD FOLLOW_33_in_tokenBlock1255_bits[] = { ANTLR3_UINT64_LIT(0x81E0234A000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_tokenBlock1255 = { FOLLOW_33_in_tokenBlock1255_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenStatement_in_tokenBlock1258 */ -static ANTLR3_BITWORD FOLLOW_tokenStatement_in_tokenBlock1258_bits[] = { ANTLR3_UINT64_LIT(0x81E0234A000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenStatement_in_tokenBlock1258 = { FOLLOW_tokenStatement_in_tokenBlock1258_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_35_in_tokenBlock1261 */ -static ANTLR3_BITWORD FOLLOW_35_in_tokenBlock1261_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_35_in_tokenBlock1261 = { FOLLOW_35_in_tokenBlock1261_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableDeclarations_in_tokenStatement1274 */ -static ANTLR3_BITWORD FOLLOW_variableDeclarations_in_tokenStatement1274_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableDeclarations_in_tokenStatement1274 = { FOLLOW_variableDeclarations_in_tokenStatement1274_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constraintInstantiation_in_tokenStatement1279 */ -static ANTLR3_BITWORD FOLLOW_constraintInstantiation_in_tokenStatement1279_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constraintInstantiation_in_tokenStatement1279 = { FOLLOW_constraintInstantiation_in_tokenStatement1279_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_assignment_in_tokenStatement1284 */ -static ANTLR3_BITWORD FOLLOW_assignment_in_tokenStatement1284_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_assignment_in_tokenStatement1284 = { FOLLOW_assignment_in_tokenStatement1284_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_rule1298 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_rule1298_bits[] = { ANTLR3_UINT64_LIT(0x0010000000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_rule1298 = { FOLLOW_IDENT_in_rule1298_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_52_in_rule1300 */ -static ANTLR3_BITWORD FOLLOW_52_in_rule1300_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_52_in_rule1300 = { FOLLOW_52_in_rule1300_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_rule1303 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_rule1303_bits[] = { ANTLR3_UINT64_LIT(0x8FE13373000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFFD100) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_rule1303 = { FOLLOW_IDENT_in_rule1303_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleBlock_in_rule1305 */ -static ANTLR3_BITWORD FOLLOW_ruleBlock_in_rule1305_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleBlock_in_rule1305 = { FOLLOW_ruleBlock_in_rule1305_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_ruleBlock1316 */ -static ANTLR3_BITWORD FOLLOW_33_in_ruleBlock1316_bits[] = { ANTLR3_UINT64_LIT(0x8FE1337B000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFFD100) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_ruleBlock1316 = { FOLLOW_33_in_ruleBlock1316_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleStatement_in_ruleBlock1319 */ -static ANTLR3_BITWORD FOLLOW_ruleStatement_in_ruleBlock1319_bits[] = { ANTLR3_UINT64_LIT(0x8FE1337B000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFFD100) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleStatement_in_ruleBlock1319 = { FOLLOW_ruleStatement_in_ruleBlock1319_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_35_in_ruleBlock1322 */ -static ANTLR3_BITWORD FOLLOW_35_in_ruleBlock1322_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_35_in_ruleBlock1322 = { FOLLOW_35_in_ruleBlock1322_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleStatement_in_ruleBlock1328 */ -static ANTLR3_BITWORD FOLLOW_ruleStatement_in_ruleBlock1328_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleStatement_in_ruleBlock1328 = { FOLLOW_ruleStatement_in_ruleBlock1328_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_relation_in_ruleStatement1347 */ -static ANTLR3_BITWORD FOLLOW_relation_in_ruleStatement1347_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_relation_in_ruleStatement1347 = { FOLLOW_relation_in_ruleStatement1347_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableDeclarations_in_ruleStatement1352 */ -static ANTLR3_BITWORD FOLLOW_variableDeclarations_in_ruleStatement1352_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableDeclarations_in_ruleStatement1352 = { FOLLOW_variableDeclarations_in_ruleStatement1352_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constraintInstantiation_in_ruleStatement1357 */ -static ANTLR3_BITWORD FOLLOW_constraintInstantiation_in_ruleStatement1357_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constraintInstantiation_in_ruleStatement1357 = { FOLLOW_constraintInstantiation_in_ruleStatement1357_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_flowControl_in_ruleStatement1362 */ -static ANTLR3_BITWORD FOLLOW_flowControl_in_ruleStatement1362_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_flowControl_in_ruleStatement1362 = { FOLLOW_flowControl_in_ruleStatement1362_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_noopstatement_in_ruleStatement1367 */ -static ANTLR3_BITWORD FOLLOW_noopstatement_in_ruleStatement1367_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_noopstatement_in_ruleStatement1367 = { FOLLOW_noopstatement_in_ruleStatement1367_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_type0 */ -static ANTLR3_BITWORD FOLLOW_set_in_type0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_type0 = { FOLLOW_set_in_type0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenVarRef_in_relation1418 */ -static ANTLR3_BITWORD FOLLOW_tokenVarRef_in_relation1418_bits[] = { ANTLR3_UINT64_LIT(0x0000200000010000), ANTLR3_UINT64_LIT(0x0000003FFFFF8000) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenVarRef_in_relation1418 = { FOLLOW_tokenVarRef_in_relation1418_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_temporalRelation_in_relation1421 */ -static ANTLR3_BITWORD FOLLOW_temporalRelation_in_relation1421_bits[] = { ANTLR3_UINT64_LIT(0x0000220000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_temporalRelation_in_relation1421 = { FOLLOW_temporalRelation_in_relation1421_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenInstanceList_in_relation1423 */ -static ANTLR3_BITWORD FOLLOW_tokenInstanceList_in_relation1423_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenInstanceList_in_relation1423 = { FOLLOW_tokenInstanceList_in_relation1423_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_relation1425 */ -static ANTLR3_BITWORD FOLLOW_37_in_relation1425_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_relation1425 = { FOLLOW_37_in_relation1425_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_57_in_problemStmt1460 */ -static ANTLR3_BITWORD FOLLOW_57_in_problemStmt1460_bits[] = { ANTLR3_UINT64_LIT(0x0000220000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_57_in_problemStmt1460 = { FOLLOW_57_in_problemStmt1460_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_58_in_problemStmt1465 */ -static ANTLR3_BITWORD FOLLOW_58_in_problemStmt1465_bits[] = { ANTLR3_UINT64_LIT(0x0000220000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_58_in_problemStmt1465 = { FOLLOW_58_in_problemStmt1465_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_59_in_problemStmt1470 */ -static ANTLR3_BITWORD FOLLOW_59_in_problemStmt1470_bits[] = { ANTLR3_UINT64_LIT(0x0000220000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_59_in_problemStmt1470 = { FOLLOW_59_in_problemStmt1470_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenInstanceList_in_problemStmt1474 */ -static ANTLR3_BITWORD FOLLOW_tokenInstanceList_in_problemStmt1474_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenInstanceList_in_problemStmt1474 = { FOLLOW_tokenInstanceList_in_problemStmt1474_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_problemStmt1476 */ -static ANTLR3_BITWORD FOLLOW_37_in_problemStmt1476_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_problemStmt1476 = { FOLLOW_37_in_problemStmt1476_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenVarRef_in_tokenInstanceList1496 */ -static ANTLR3_BITWORD FOLLOW_tokenVarRef_in_tokenInstanceList1496_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenVarRef_in_tokenInstanceList1496 = { FOLLOW_tokenVarRef_in_tokenInstanceList1496_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_tokenInstanceList1501 */ -static ANTLR3_BITWORD FOLLOW_41_in_tokenInstanceList1501_bits[] = { ANTLR3_UINT64_LIT(0x3000240000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_tokenInstanceList1501 = { FOLLOW_41_in_tokenInstanceList1501_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenInstances_in_tokenInstanceList1504 */ -static ANTLR3_BITWORD FOLLOW_tokenInstances_in_tokenInstanceList1504_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenInstances_in_tokenInstanceList1504 = { FOLLOW_tokenInstances_in_tokenInstanceList1504_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_tokenInstanceList1507 */ -static ANTLR3_BITWORD FOLLOW_42_in_tokenInstanceList1507_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_tokenInstanceList1507 = { FOLLOW_42_in_tokenInstanceList1507_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_tokenVarRef0 */ -static ANTLR3_BITWORD FOLLOW_set_in_tokenVarRef0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_tokenVarRef0 = { FOLLOW_set_in_tokenVarRef0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenInstance_in_tokenInstances1536 */ -static ANTLR3_BITWORD FOLLOW_tokenInstance_in_tokenInstances1536_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenInstance_in_tokenInstances1536 = { FOLLOW_tokenInstance_in_tokenInstances1536_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_tokenInstances1539 */ -static ANTLR3_BITWORD FOLLOW_34_in_tokenInstances1539_bits[] = { ANTLR3_UINT64_LIT(0x3000200000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_tokenInstances1539 = { FOLLOW_34_in_tokenInstances1539_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenInstance_in_tokenInstances1542 */ -static ANTLR3_BITWORD FOLLOW_tokenInstance_in_tokenInstances1542_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenInstance_in_tokenInstances1542 = { FOLLOW_tokenInstance_in_tokenInstances1542_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenAnnotation_in_tokenInstance1555 */ -static ANTLR3_BITWORD FOLLOW_tokenAnnotation_in_tokenInstance1555_bits[] = { ANTLR3_UINT64_LIT(0x0000200000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenAnnotation_in_tokenInstance1555 = { FOLLOW_tokenAnnotation_in_tokenInstance1555_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_tokenInstance1558 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_tokenInstance1558_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010002) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_tokenInstance1558 = { FOLLOW_qualified_in_tokenInstance1558_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_tokenInstance1560 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_tokenInstance1560_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_tokenInstance1560 = { FOLLOW_IDENT_in_tokenInstance1560_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_tokenAnnotation0 */ -static ANTLR3_BITWORD FOLLOW_set_in_tokenAnnotation0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_tokenAnnotation0 = { FOLLOW_set_in_tokenAnnotation0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_constraintInstantiation1626 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_constraintInstantiation1626_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_constraintInstantiation1626 = { FOLLOW_IDENT_in_constraintInstantiation1626_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_constraintInstantiation1628 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_constraintInstantiation1628_bits[] = { ANTLR3_UINT64_LIT(0x4000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_constraintInstantiation1628 = { FOLLOW_variableArgumentList_in_constraintInstantiation1628_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_62_in_constraintInstantiation1631 */ -static ANTLR3_BITWORD FOLLOW_62_in_constraintInstantiation1631_bits[] = { ANTLR3_UINT64_LIT(0x00000000000E0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_62_in_constraintInstantiation1631 = { FOLLOW_62_in_constraintInstantiation1631_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_violationMsg_in_constraintInstantiation1633 */ -static ANTLR3_BITWORD FOLLOW_violationMsg_in_constraintInstantiation1633_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_violationMsg_in_constraintInstantiation1633 = { FOLLOW_violationMsg_in_constraintInstantiation1633_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_constraintInstantiation1637 */ -static ANTLR3_BITWORD FOLLOW_37_in_constraintInstantiation1637_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_constraintInstantiation1637 = { FOLLOW_37_in_constraintInstantiation1637_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enforceStatement_in_constraintInstantiation1660 */ -static ANTLR3_BITWORD FOLLOW_enforceStatement_in_constraintInstantiation1660_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_enforceStatement_in_constraintInstantiation1660 = { FOLLOW_enforceStatement_in_constraintInstantiation1660_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_63_in_enforceStatement1675 */ -static ANTLR3_BITWORD FOLLOW_63_in_enforceStatement1675_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_63_in_enforceStatement1675 = { FOLLOW_63_in_enforceStatement1675_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_enforceStatement1680 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_enforceStatement1680_bits[] = { ANTLR3_UINT64_LIT(0x4000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_enforceStatement1680 = { FOLLOW_cexpression_in_enforceStatement1680_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_62_in_enforceStatement1683 */ -static ANTLR3_BITWORD FOLLOW_62_in_enforceStatement1683_bits[] = { ANTLR3_UINT64_LIT(0x00000000000E0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_62_in_enforceStatement1683 = { FOLLOW_62_in_enforceStatement1683_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_violationMsg_in_enforceStatement1687 */ -static ANTLR3_BITWORD FOLLOW_violationMsg_in_enforceStatement1687_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_violationMsg_in_enforceStatement1687 = { FOLLOW_violationMsg_in_enforceStatement1687_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_enforceStatement1691 */ -static ANTLR3_BITWORD FOLLOW_37_in_enforceStatement1691_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_enforceStatement1691 = { FOLLOW_37_in_enforceStatement1691_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_stringLiteral_in_violationMsg1721 */ -static ANTLR3_BITWORD FOLLOW_stringLiteral_in_violationMsg1721_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_stringLiteral_in_violationMsg1721 = { FOLLOW_stringLiteral_in_violationMsg1721_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cbooleanOrExpression_in_cexpression1734 */ -static ANTLR3_BITWORD FOLLOW_cbooleanOrExpression_in_cexpression1734_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_cbooleanOrExpression_in_cexpression1734 = { FOLLOW_cbooleanOrExpression_in_cexpression1734_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1746 */ -static ANTLR3_BITWORD FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1746_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000000001) }; -static ANTLR3_BITSET_LIST FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1746 = { FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1746_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_64_in_cbooleanOrExpression1749 */ -static ANTLR3_BITWORD FOLLOW_64_in_cbooleanOrExpression1749_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_64_in_cbooleanOrExpression1749 = { FOLLOW_64_in_cbooleanOrExpression1749_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1752 */ -static ANTLR3_BITWORD FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1752_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000000001) }; -static ANTLR3_BITSET_LIST FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1752 = { FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1752_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_crelationalExpression_in_cbooleanAndExpression1768 */ -static ANTLR3_BITWORD FOLLOW_crelationalExpression_in_cbooleanAndExpression1768_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_crelationalExpression_in_cbooleanAndExpression1768 = { FOLLOW_crelationalExpression_in_cbooleanAndExpression1768_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_65_in_cbooleanAndExpression1771 */ -static ANTLR3_BITWORD FOLLOW_65_in_cbooleanAndExpression1771_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_65_in_cbooleanAndExpression1771 = { FOLLOW_65_in_cbooleanAndExpression1771_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_crelationalExpression_in_cbooleanAndExpression1776 */ -static ANTLR3_BITWORD FOLLOW_crelationalExpression_in_cbooleanAndExpression1776_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_crelationalExpression_in_cbooleanAndExpression1776 = { FOLLOW_crelationalExpression_in_cbooleanAndExpression1776_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cadditiveExpression_in_crelationalExpression1800 */ -static ANTLR3_BITWORD FOLLOW_cadditiveExpression_in_crelationalExpression1800_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x00000000000000FC) }; -static ANTLR3_BITSET_LIST FOLLOW_cadditiveExpression_in_crelationalExpression1800 = { FOLLOW_cadditiveExpression_in_crelationalExpression1800_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_crelationalExpression1803 */ -static ANTLR3_BITWORD FOLLOW_set_in_crelationalExpression1803_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_crelationalExpression1803 = { FOLLOW_set_in_crelationalExpression1803_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cadditiveExpression_in_crelationalExpression1828 */ -static ANTLR3_BITWORD FOLLOW_cadditiveExpression_in_crelationalExpression1828_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x00000000000000FC) }; -static ANTLR3_BITSET_LIST FOLLOW_cadditiveExpression_in_crelationalExpression1828 = { FOLLOW_cadditiveExpression_in_crelationalExpression1828_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1851 */ -static ANTLR3_BITWORD FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1851_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000000300) }; -static ANTLR3_BITSET_LIST FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1851 = { FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1851_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_cadditiveExpression1854 */ -static ANTLR3_BITWORD FOLLOW_set_in_cadditiveExpression1854_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_cadditiveExpression1854 = { FOLLOW_set_in_cadditiveExpression1854_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1863 */ -static ANTLR3_BITWORD FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1863_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000000300) }; -static ANTLR3_BITSET_LIST FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1863 = { FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1863_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cprimary_in_cmultiplicativeExpression1880 */ -static ANTLR3_BITWORD FOLLOW_cprimary_in_cmultiplicativeExpression1880_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000000400) }; -static ANTLR3_BITSET_LIST FOLLOW_cprimary_in_cmultiplicativeExpression1880 = { FOLLOW_cprimary_in_cmultiplicativeExpression1880_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_74_in_cmultiplicativeExpression1883 */ -static ANTLR3_BITWORD FOLLOW_74_in_cmultiplicativeExpression1883_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_74_in_cmultiplicativeExpression1883 = { FOLLOW_74_in_cmultiplicativeExpression1883_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cprimary_in_cmultiplicativeExpression1886 */ -static ANTLR3_BITWORD FOLLOW_cprimary_in_cmultiplicativeExpression1886_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000000400) }; -static ANTLR3_BITSET_LIST FOLLOW_cprimary_in_cmultiplicativeExpression1886 = { FOLLOW_cprimary_in_cmultiplicativeExpression1886_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_cprimary1900 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_cprimary1900_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_cprimary1900 = { FOLLOW_anyValue_in_cprimary1900_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_cprimary1908 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_cprimary1908_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_cprimary1908 = { FOLLOW_IDENT_in_cprimary1908_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_cprimary1910 */ -static ANTLR3_BITWORD FOLLOW_41_in_cprimary1910_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_cprimary1910 = { FOLLOW_41_in_cprimary1910_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpressionList_in_cprimary1914 */ -static ANTLR3_BITWORD FOLLOW_cexpressionList_in_cprimary1914_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpressionList_in_cprimary1914 = { FOLLOW_cexpressionList_in_cprimary1914_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_cprimary1916 */ -static ANTLR3_BITWORD FOLLOW_42_in_cprimary1916_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_cprimary1916 = { FOLLOW_42_in_cprimary1916_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_cprimary1936 */ -static ANTLR3_BITWORD FOLLOW_41_in_cprimary1936_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_cprimary1936 = { FOLLOW_41_in_cprimary1936_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cbooleanOrExpression_in_cprimary1939 */ -static ANTLR3_BITWORD FOLLOW_cbooleanOrExpression_in_cprimary1939_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_cbooleanOrExpression_in_cprimary1939 = { FOLLOW_cbooleanOrExpression_in_cprimary1939_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_cprimary1941 */ -static ANTLR3_BITWORD FOLLOW_42_in_cprimary1941_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_cprimary1941 = { FOLLOW_42_in_cprimary1941_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_cexpressionList1954 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_cexpressionList1954_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_cexpressionList1954 = { FOLLOW_cexpression_in_cexpressionList1954_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_cexpressionList1957 */ -static ANTLR3_BITWORD FOLLOW_34_in_cexpressionList1957_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_cexpressionList1957 = { FOLLOW_34_in_cexpressionList1957_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_cexpressionList1960 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_cexpressionList1960_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_cexpressionList1960 = { FOLLOW_cexpression_in_cexpressionList1960_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_75_in_superInvocation1975 */ -static ANTLR3_BITWORD FOLLOW_75_in_superInvocation1975_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_75_in_superInvocation1975 = { FOLLOW_75_in_superInvocation1975_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_superInvocation1978 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_superInvocation1978_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_superInvocation1978 = { FOLLOW_variableArgumentList_in_superInvocation1978_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_superInvocation1980 */ -static ANTLR3_BITWORD FOLLOW_37_in_superInvocation1980_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_superInvocation1980 = { FOLLOW_37_in_superInvocation1980_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_variableArgumentList1992 */ -static ANTLR3_BITWORD FOLLOW_41_in_variableArgumentList1992_bits[] = { ANTLR3_UINT64_LIT(0x00002442000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_variableArgumentList1992 = { FOLLOW_41_in_variableArgumentList1992_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArguments_in_variableArgumentList1995 */ -static ANTLR3_BITWORD FOLLOW_variableArguments_in_variableArgumentList1995_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArguments_in_variableArgumentList1995 = { FOLLOW_variableArguments_in_variableArgumentList1995_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_variableArgumentList1998 */ -static ANTLR3_BITWORD FOLLOW_42_in_variableArgumentList1998_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_variableArgumentList1998 = { FOLLOW_42_in_variableArgumentList1998_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgument_in_variableArguments2010 */ -static ANTLR3_BITWORD FOLLOW_variableArgument_in_variableArguments2010_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgument_in_variableArguments2010 = { FOLLOW_variableArgument_in_variableArguments2010_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_variableArguments2013 */ -static ANTLR3_BITWORD FOLLOW_34_in_variableArguments2013_bits[] = { ANTLR3_UINT64_LIT(0x00002042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_variableArguments2013 = { FOLLOW_34_in_variableArguments2013_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgument_in_variableArguments2016 */ -static ANTLR3_BITWORD FOLLOW_variableArgument_in_variableArguments2016_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgument_in_variableArguments2016 = { FOLLOW_variableArgument_in_variableArguments2016_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_variableArgument2029 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_variableArgument2029_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_variableArgument2029 = { FOLLOW_anyValue_in_variableArgument2029_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_typeArgumentList2040 */ -static ANTLR3_BITWORD FOLLOW_41_in_typeArgumentList2040_bits[] = { ANTLR3_UINT64_LIT(0x0000040000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_typeArgumentList2040 = { FOLLOW_41_in_typeArgumentList2040_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_typeArguments_in_typeArgumentList2043 */ -static ANTLR3_BITWORD FOLLOW_typeArguments_in_typeArgumentList2043_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_typeArguments_in_typeArgumentList2043 = { FOLLOW_typeArguments_in_typeArgumentList2043_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_typeArgumentList2046 */ -static ANTLR3_BITWORD FOLLOW_42_in_typeArgumentList2046_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_typeArgumentList2046 = { FOLLOW_42_in_typeArgumentList2046_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_typeArgument_in_typeArguments2058 */ -static ANTLR3_BITWORD FOLLOW_typeArgument_in_typeArguments2058_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_typeArgument_in_typeArguments2058 = { FOLLOW_typeArgument_in_typeArguments2058_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_34_in_typeArguments2061 */ -static ANTLR3_BITWORD FOLLOW_34_in_typeArguments2061_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_34_in_typeArguments2061 = { FOLLOW_34_in_typeArguments2061_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_typeArgument_in_typeArguments2064 */ -static ANTLR3_BITWORD FOLLOW_typeArgument_in_typeArguments2064_bits[] = { ANTLR3_UINT64_LIT(0x0000000400000002) }; -static ANTLR3_BITSET_LIST FOLLOW_typeArgument_in_typeArguments2064 = { FOLLOW_typeArgument_in_typeArguments2064_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_typeArgument2077 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_typeArgument2077_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_typeArgument2077 = { FOLLOW_IDENT_in_typeArgument2077_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_76_in_flowControl2097 */ -static ANTLR3_BITWORD FOLLOW_76_in_flowControl2097_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_76_in_flowControl2097 = { FOLLOW_76_in_flowControl2097_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_flowControl2099 */ -static ANTLR3_BITWORD FOLLOW_41_in_flowControl2099_bits[] = { ANTLR3_UINT64_LIT(0x80002242000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_flowControl2099 = { FOLLOW_41_in_flowControl2099_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_flowControl2103 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_flowControl2103_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_flowControl2103 = { FOLLOW_cexpression_in_flowControl2103_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_flowControl2105 */ -static ANTLR3_BITWORD FOLLOW_42_in_flowControl2105_bits[] = { ANTLR3_UINT64_LIT(0x8FE13373000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFFD100) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_flowControl2105 = { FOLLOW_42_in_flowControl2105_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleBlock_in_flowControl2109 */ -static ANTLR3_BITWORD FOLLOW_ruleBlock_in_flowControl2109_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002), ANTLR3_UINT64_LIT(0x0000000000002000) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleBlock_in_flowControl2109 = { FOLLOW_ruleBlock_in_flowControl2109_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_77_in_flowControl2117 */ -static ANTLR3_BITWORD FOLLOW_77_in_flowControl2117_bits[] = { ANTLR3_UINT64_LIT(0x8FE13373000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFFD100) }; -static ANTLR3_BITSET_LIST FOLLOW_77_in_flowControl2117 = { FOLLOW_77_in_flowControl2117_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleBlock_in_flowControl2121 */ -static ANTLR3_BITWORD FOLLOW_ruleBlock_in_flowControl2121_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleBlock_in_flowControl2121 = { FOLLOW_ruleBlock_in_flowControl2121_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_78_in_flowControl2186 */ -static ANTLR3_BITWORD FOLLOW_78_in_flowControl2186_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_78_in_flowControl2186 = { FOLLOW_78_in_flowControl2186_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_flowControl2189 */ -static ANTLR3_BITWORD FOLLOW_41_in_flowControl2189_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_flowControl2189 = { FOLLOW_41_in_flowControl2189_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_flowControl2192 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_flowControl2192_bits[] = { ANTLR3_UINT64_LIT(0x0000800000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_flowControl2192 = { FOLLOW_IDENT_in_flowControl2192_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_47_in_flowControl2194 */ -static ANTLR3_BITWORD FOLLOW_47_in_flowControl2194_bits[] = { ANTLR3_UINT64_LIT(0x0000200000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_47_in_flowControl2194 = { FOLLOW_47_in_flowControl2194_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_flowControl2197 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_flowControl2197_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_flowControl2197 = { FOLLOW_qualified_in_flowControl2197_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_flowControl2199 */ -static ANTLR3_BITWORD FOLLOW_42_in_flowControl2199_bits[] = { ANTLR3_UINT64_LIT(0x8FE13373000F0000), ANTLR3_UINT64_LIT(0x00001FFFFFFFD100) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_flowControl2199 = { FOLLOW_42_in_flowControl2199_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleBlock_in_flowControl2202 */ -static ANTLR3_BITWORD FOLLOW_ruleBlock_in_flowControl2202_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleBlock_in_flowControl2202 = { FOLLOW_ruleBlock_in_flowControl2202_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_guardExpression2214 */ -static ANTLR3_BITWORD FOLLOW_41_in_guardExpression2214_bits[] = { ANTLR3_UINT64_LIT(0x00002042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_guardExpression2214 = { FOLLOW_41_in_guardExpression2214_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_guardExpression2217 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_guardExpression2217_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000), ANTLR3_UINT64_LIT(0x000000000000000C) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_guardExpression2217 = { FOLLOW_anyValue_in_guardExpression2217_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_66_in_guardExpression2221 */ -static ANTLR3_BITWORD FOLLOW_66_in_guardExpression2221_bits[] = { ANTLR3_UINT64_LIT(0x00002042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_66_in_guardExpression2221 = { FOLLOW_66_in_guardExpression2221_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_67_in_guardExpression2226 */ -static ANTLR3_BITWORD FOLLOW_67_in_guardExpression2226_bits[] = { ANTLR3_UINT64_LIT(0x00002042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_67_in_guardExpression2226 = { FOLLOW_67_in_guardExpression2226_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_guardExpression2230 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_guardExpression2230_bits[] = { ANTLR3_UINT64_LIT(0x0000040000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_guardExpression2230 = { FOLLOW_anyValue_in_guardExpression2230_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_42_in_guardExpression2234 */ -static ANTLR3_BITWORD FOLLOW_42_in_guardExpression2234_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_42_in_guardExpression2234 = { FOLLOW_42_in_guardExpression2234_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_allocation_in_allocationStmt2256 */ -static ANTLR3_BITWORD FOLLOW_allocation_in_allocationStmt2256_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_allocation_in_allocationStmt2256 = { FOLLOW_allocation_in_allocationStmt2256_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_allocationStmt2258 */ -static ANTLR3_BITWORD FOLLOW_37_in_allocationStmt2258_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_allocationStmt2258 = { FOLLOW_37_in_allocationStmt2258_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_temporalRelation0 */ -static ANTLR3_BITWORD FOLLOW_set_in_temporalRelation0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_temporalRelation0 = { FOLLOW_set_in_temporalRelation0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_booleanLiteral_in_literalValue2511 */ -static ANTLR3_BITWORD FOLLOW_booleanLiteral_in_literalValue2511_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_booleanLiteral_in_literalValue2511 = { FOLLOW_booleanLiteral_in_literalValue2511_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_numericLiteral_in_literalValue2521 */ -static ANTLR3_BITWORD FOLLOW_numericLiteral_in_literalValue2521_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_numericLiteral_in_literalValue2521 = { FOLLOW_numericLiteral_in_literalValue2521_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_stringLiteral_in_literalValue2531 */ -static ANTLR3_BITWORD FOLLOW_stringLiteral_in_literalValue2531_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_stringLiteral_in_literalValue2531 = { FOLLOW_stringLiteral_in_literalValue2531_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_booleanLiteral0 */ -static ANTLR3_BITWORD FOLLOW_set_in_booleanLiteral0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_booleanLiteral0 = { FOLLOW_set_in_booleanLiteral0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_numericLiteral2579 */ -static ANTLR3_BITWORD FOLLOW_INT_in_numericLiteral2579_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_INT_in_numericLiteral2579 = { FOLLOW_INT_in_numericLiteral2579_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_FLOAT_in_numericLiteral2584 */ -static ANTLR3_BITWORD FOLLOW_FLOAT_in_numericLiteral2584_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_FLOAT_in_numericLiteral2584 = { FOLLOW_FLOAT_in_numericLiteral2584_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_72_in_numericLiteral2590 */ -static ANTLR3_BITWORD FOLLOW_72_in_numericLiteral2590_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000), ANTLR3_UINT64_LIT(0x0000030000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_72_in_numericLiteral2590 = { FOLLOW_72_in_numericLiteral2590_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_numericLiteral2595 */ -static ANTLR3_BITWORD FOLLOW_set_in_numericLiteral2595_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_numericLiteral2595 = { FOLLOW_set_in_numericLiteral2595_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_106_in_numericLiteral2606 */ -static ANTLR3_BITWORD FOLLOW_106_in_numericLiteral2606_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_106_in_numericLiteral2606 = { FOLLOW_106_in_numericLiteral2606_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_107_in_numericLiteral2617 */ -static ANTLR3_BITWORD FOLLOW_107_in_numericLiteral2617_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_107_in_numericLiteral2617 = { FOLLOW_107_in_numericLiteral2617_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_STRING_in_stringLiteral2634 */ -static ANTLR3_BITWORD FOLLOW_STRING_in_stringLiteral2634_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_STRING_in_stringLiteral2634 = { FOLLOW_STRING_in_stringLiteral2634_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_methodInvocation2657 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_methodInvocation2657_bits[] = { ANTLR3_UINT64_LIT(0x0000400000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_methodInvocation2657 = { FOLLOW_qualified_in_methodInvocation2657_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_46_in_methodInvocation2659 */ -static ANTLR3_BITWORD FOLLOW_46_in_methodInvocation2659_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000), ANTLR3_UINT64_LIT(0x0000100000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_46_in_methodInvocation2659 = { FOLLOW_46_in_methodInvocation2659_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_methodName_in_methodInvocation2661 */ -static ANTLR3_BITWORD FOLLOW_methodName_in_methodInvocation2661_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_methodName_in_methodInvocation2661 = { FOLLOW_methodName_in_methodInvocation2661_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_methodInvocation2663 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_methodInvocation2663_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_methodInvocation2663 = { FOLLOW_variableArgumentList_in_methodInvocation2663_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_methodInvocation2665 */ -static ANTLR3_BITWORD FOLLOW_37_in_methodInvocation2665_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_methodInvocation2665 = { FOLLOW_37_in_methodInvocation2665_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_108_in_methodInvocation2694 */ -static ANTLR3_BITWORD FOLLOW_108_in_methodInvocation2694_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_108_in_methodInvocation2694 = { FOLLOW_108_in_methodInvocation2694_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_methodInvocation2696 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_methodInvocation2696_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_methodInvocation2696 = { FOLLOW_variableArgumentList_in_methodInvocation2696_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_methodInvocation2698 */ -static ANTLR3_BITWORD FOLLOW_37_in_methodInvocation2698_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_methodInvocation2698 = { FOLLOW_37_in_methodInvocation2698_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_methodName0 */ -static ANTLR3_BITWORD FOLLOW_set_in_methodName0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_methodName0 = { FOLLOW_set_in_methodName0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_noopstatement2739 */ -static ANTLR3_BITWORD FOLLOW_37_in_noopstatement2739_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_noopstatement2739 = { FOLLOW_37_in_noopstatement2739_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_synpred1_NDDL31612 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_synpred1_NDDL31612_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_synpred1_NDDL31612 = { FOLLOW_IDENT_in_synpred1_NDDL31612_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_synpred1_NDDL31614 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_synpred1_NDDL31614_bits[] = { ANTLR3_UINT64_LIT(0x4000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_synpred1_NDDL31614 = { FOLLOW_variableArgumentList_in_synpred1_NDDL31614_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_62_in_synpred1_NDDL31617 */ -static ANTLR3_BITWORD FOLLOW_62_in_synpred1_NDDL31617_bits[] = { ANTLR3_UINT64_LIT(0x00000000000E0000), ANTLR3_UINT64_LIT(0x00000FC000000100) }; -static ANTLR3_BITSET_LIST FOLLOW_62_in_synpred1_NDDL31617 = { FOLLOW_62_in_synpred1_NDDL31617_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_violationMsg_in_synpred1_NDDL31619 */ -static ANTLR3_BITWORD FOLLOW_violationMsg_in_synpred1_NDDL31619_bits[] = { ANTLR3_UINT64_LIT(0x0000002000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_violationMsg_in_synpred1_NDDL31619 = { FOLLOW_violationMsg_in_synpred1_NDDL31619_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_synpred1_NDDL31623 */ -static ANTLR3_BITWORD FOLLOW_37_in_synpred1_NDDL31623_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_synpred1_NDDL31623 = { FOLLOW_37_in_synpred1_NDDL31623_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_77_in_synpred2_NDDL32113 */ -static ANTLR3_BITWORD FOLLOW_77_in_synpred2_NDDL32113_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_77_in_synpred2_NDDL32113 = { FOLLOW_77_in_synpred2_NDDL32113_bits, 1 }; - - - -/* ========================================================================= - * DFA tables for the parser - */ -/** Static dfa state tables for Cyclic dfa: - * 98:1: nddlStatement : ( typeDefinition | enumDefinition | variableDeclarations | assignment | constraintInstantiation | classDeclaration | allocationStmt | rule | problemStmt | relation | methodInvocation | noopstatement ); - */ -static const ANTLR3_INT32 dfa2_eot[17] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa2_eof[17] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa2_min[17] = - { - 16, -1, -1, -1, 16, 37, -1, -1, -1, -1, -1, -1, -1, -1, 16, -1, 37 - }; -static const ANTLR3_INT32 dfa2_max[17] = - { - 108, -1, -1, -1, 101, 101, -1, -1, -1, -1, -1, -1, -1, -1, 108, -1, 74 - }; -static const ANTLR3_INT32 dfa2_accept[17] = - { - -1, 1, 2, 3, -1, -1, 5, 6, 7, 9, 10, 11, 12, 8, -1, 4, -1 - }; -static const ANTLR3_INT32 dfa2_special[17] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }; - -/** Used when there is no transition table entry for a particular state */ -#define dfa2_T_empty NULL - -static const ANTLR3_INT32 dfa2_T0[] = - { - 6, -1, -1, -1, -1, -1, 15, -1, -1, 14, 15, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 6, -1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -1, - -1, -1, -1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10 - };static const ANTLR3_INT32 dfa2_T1[] = - { - 4, 6, 6, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 6, -1, -1, - 1, 12, 6, -1, 3, 6, -1, -1, 8, 5, -1, -1, 7, -1, -1, -1, -1, 3, 3, 3, 3, - 9, 9, 9, -1, -1, -1, 6, -1, -1, -1, -1, -1, -1, -1, -1, 6, -1, -1, -1, - -1, -1, -1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 11 - };static const ANTLR3_INT32 dfa2_T2[] = - { - 6, -1, -1, -1, 11, -1, 15, -1, -1, 14, 15, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 6, -1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 - };static const ANTLR3_INT32 dfa2_T3[] = - { - 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 6, -1, -1, -1, 6, -1, 15, -1, -1, 14, 15, -1, -1, -1, -1, 13, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, -1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, -1, -1, -1, -1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 - };static const ANTLR3_INT32 dfa2_T4[] = - { - 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 11 - }; - -/* Transition tables are a table of sub tables, with some tables - * reused for efficiency. - */ -static const ANTLR3_INT32 * const dfa2_transitions[] = -{ - dfa2_T1, dfa2_T_empty, dfa2_T_empty, dfa2_T_empty, dfa2_T3, dfa2_T0, - dfa2_T_empty, dfa2_T_empty, dfa2_T_empty, dfa2_T_empty, dfa2_T_empty, - dfa2_T_empty, dfa2_T_empty, dfa2_T_empty, dfa2_T4, dfa2_T_empty, dfa2_T2 -}; - - -/* Declare tracking structure for Cyclic DFA 2 - */ -static -ANTLR3_CYCLIC_DFA cdfa2 - = { - 2, /* Decision number of this dfa */ - /* Which decision this represents: */ - (const pANTLR3_UCHAR)"98:1: nddlStatement : ( typeDefinition | enumDefinition | variableDeclarations | assignment | constraintInstantiation | classDeclaration | allocationStmt | rule | problemStmt | relation | methodInvocation | noopstatement );", - (CDFA_SPECIAL_FUNC) antlr3dfaspecialStateTransition, /* Default special state transition function */ - antlr3dfaspecialTransition, /* DFA specialTransition is currently just a default function in the runtime */ - antlr3dfapredict, /* DFA simulator function is in the runtime */ - dfa2_eot, /* EOT table */ - dfa2_eof, /* EOF table */ - dfa2_min, /* Minimum tokens for each state */ - dfa2_max, /* Maximum tokens for each state */ - dfa2_accept, /* Accept table */ - dfa2_special, /* Special transition states */ - dfa2_transitions /* Table of transition tables */ - - }; -/* End of Cyclic DFA 2 - * --------------------- - *//** Static dfa state tables for Cyclic dfa: - * 240:1: tokenStatement : ( variableDeclarations | constraintInstantiation | assignment ); - */ -static const ANTLR3_INT32 dfa25_eot[8] = - { - -1, -1, -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa25_eof[8] = - { - -1, -1, -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa25_min[8] = - { - 16, -1, 16, -1, 37, 16, -1, 37 - }; -static const ANTLR3_INT32 dfa25_max[8] = - { - 107, -1, 74, -1, 74, 16, -1, 74 - }; -static const ANTLR3_INT32 dfa25_accept[8] = - { - -1, 1, -1, 2, -1, -1, 3, -1 - }; -static const ANTLR3_INT32 dfa25_special[8] = - { - -1, -1, -1, -1, -1, -1, -1, -1 - }; - -/** Used when there is no transition table entry for a particular state */ -#define dfa25_T_empty NULL - -static const ANTLR3_INT32 dfa25_T0[] = - { - 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 3, -1, -1, -1, 3, -1, 6, -1, -1, 5, 6, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, -1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3 - };static const ANTLR3_INT32 dfa25_T1[] = - { - 3, -1, -1, -1, -1, -1, 6, -1, -1, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 3, -1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 - };static const ANTLR3_INT32 dfa25_T2[] = - { - 7 - };static const ANTLR3_INT32 dfa25_T3[] = - { - 2, 3, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, -1, - -1, -1, -1, 3, -1, 1, 3, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, 1, - 1, 1, 1, -1, -1, -1, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, 3, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 3, 3, 3, 3 - }; - -/* Transition tables are a table of sub tables, with some tables - * reused for efficiency. - */ -static const ANTLR3_INT32 * const dfa25_transitions[] = -{ - dfa25_T3, dfa25_T_empty, dfa25_T0, dfa25_T_empty, dfa25_T1, dfa25_T2, - dfa25_T_empty, dfa25_T1 -}; - - -/* Declare tracking structure for Cyclic DFA 25 - */ -static -ANTLR3_CYCLIC_DFA cdfa25 - = { - 25, /* Decision number of this dfa */ - /* Which decision this represents: */ - (const pANTLR3_UCHAR)"240:1: tokenStatement : ( variableDeclarations | constraintInstantiation | assignment );", - (CDFA_SPECIAL_FUNC) antlr3dfaspecialStateTransition, /* Default special state transition function */ - antlr3dfaspecialTransition, /* DFA specialTransition is currently just a default function in the runtime */ - antlr3dfapredict, /* DFA simulator function is in the runtime */ - dfa25_eot, /* EOT table */ - dfa25_eof, /* EOF table */ - dfa25_min, /* Minimum tokens for each state */ - dfa25_max, /* Maximum tokens for each state */ - dfa25_accept, /* Accept table */ - dfa25_special, /* Special transition states */ - dfa25_transitions /* Table of transition tables */ - - }; -/* End of Cyclic DFA 25 - * --------------------- - *//** Static dfa state tables for Cyclic dfa: - * 250:1: ruleBlock : ( '{' ( ruleStatement )* '}' | ruleStatement -> ^( '{' ruleStatement ) ); - */ -static const ANTLR3_INT32 dfa27_eot[16] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa27_eof[16] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa27_min[16] = - { - 16, 16, -1, 34, 34, 34, 104, 34, 34, 34, 34, 16, -1, 34, 16, 34 - }; -static const ANTLR3_INT32 dfa27_max[16] = - { - 107, 107, -1, 74, 74, 74, 105, 74, 74, 74, 74, 101, -1, 101, 16, 74 - }; -static const ANTLR3_INT32 dfa27_accept[16] = - { - -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa27_special[16] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - }; - -/** Used when there is no transition table entry for a particular state */ -#define dfa27_T_empty NULL - -static const ANTLR3_INT32 dfa27_T0[] = - { - 2, 2, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12 - };static const ANTLR3_INT32 dfa27_T1[] = - { - 15 - };static const ANTLR3_INT32 dfa27_T2[] = - { - 11, 4, 5, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1, - 12, -1, 12, 12, -1, 12, 12, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, - 12, 12, 12, 12, -1, -1, -1, -1, -1, -1, 12, -1, -1, -1, -1, -1, -1, -1, - -1, 6, -1, -1, -1, 12, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3, 3, 7, 7, 8, 9 - };static const ANTLR3_INT32 dfa27_T3[] = - { - 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 2, 2, -1, 12, -1, -1, -1, 12, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, -1, -1, -1, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 - };static const ANTLR3_INT32 dfa27_T4[] = - { - 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, - -1, -1, 2, 2, -1, 2, 2, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, 2, 2, - 2, 2, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, - -1, -1, 2, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 - };static const ANTLR3_INT32 dfa27_T5[] = - { - 2, 2, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12 - };static const ANTLR3_INT32 dfa27_T6[] = - { - 7, 7 - };static const ANTLR3_INT32 dfa27_T7[] = - { - 2, 2, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, -1, -1, -1, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 - }; - -/* Transition tables are a table of sub tables, with some tables - * reused for efficiency. - */ -static const ANTLR3_INT32 * const dfa27_transitions[] = -{ - dfa27_T4, dfa27_T2, dfa27_T_empty, dfa27_T0, dfa27_T0, dfa27_T0, dfa27_T6, - dfa27_T0, dfa27_T0, dfa27_T0, dfa27_T0, dfa27_T3, dfa27_T_empty, dfa27_T7, - dfa27_T1, dfa27_T5 -}; - - -/* Declare tracking structure for Cyclic DFA 27 - */ -static -ANTLR3_CYCLIC_DFA cdfa27 - = { - 27, /* Decision number of this dfa */ - /* Which decision this represents: */ - (const pANTLR3_UCHAR)"250:1: ruleBlock : ( '{' ( ruleStatement )* '}' | ruleStatement -> ^( '{' ruleStatement ) );", - (CDFA_SPECIAL_FUNC) antlr3dfaspecialStateTransition, /* Default special state transition function */ - antlr3dfaspecialTransition, /* DFA specialTransition is currently just a default function in the runtime */ - antlr3dfapredict, /* DFA simulator function is in the runtime */ - dfa27_eot, /* EOT table */ - dfa27_eof, /* EOF table */ - dfa27_min, /* Minimum tokens for each state */ - dfa27_max, /* Maximum tokens for each state */ - dfa27_accept, /* Accept table */ - dfa27_special, /* Special transition states */ - dfa27_transitions /* Table of transition tables */ - - }; -/* End of Cyclic DFA 27 - * --------------------- - *//** Static dfa state tables for Cyclic dfa: - * 303:1: constraintInstantiation : ( ( ( IDENT variableArgumentList ( ':' violationMsg )? ';' )=> IDENT variableArgumentList ( ':' violationMsg )? ';' ) -> ^( CONSTRAINT_INSTANTIATION IDENT variableArgumentList ( violationMsg )? ) | enforceStatement ); - */ -static const ANTLR3_INT32 dfa37_eot[114] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa37_eof[114] = - { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa37_min[114] = - { - 16, 37, -1, 16, 34, 34, 34, 104, 34, 34, 34, 34, 17, 16, 34, 34, -1, 16, - 37, 17, 17, 104, 17, 17, 17, 34, 34, 34, 104, 34, 34, 34, 34, 34, 16, 34, - 34, 34, 104, 34, 34, 34, 34, 17, 16, 34, 34, 19, 0, 17, 39, 39, 104, 39, - 39, 39, 16, 34, 16, 34, 17, 17, 104, 17, 17, 17, 34, 34, 34, 104, 34, 34, - 34, 34, 34, 16, 37, 34, 34, 34, 34, 104, 34, 34, 34, 34, 34, 34, 17, 39, - 39, 104, 39, 39, 39, 16, 34, 16, 34, 16, 34, 34, 34, 34, 104, 34, 34, 34, - 34, 34, 34, 34, 16, 34 - }; -static const ANTLR3_INT32 dfa37_max[114] = - { - 107, 74, -1, 107, 74, 74, 74, 105, 74, 74, 74, 74, 107, 107, 74, 74, -1, - 107, 74, 107, 107, 105, 107, 107, 107, 35, 35, 35, 105, 35, 35, 35, 35, - 46, 16, 74, 74, 74, 105, 74, 74, 74, 74, 107, 107, 74, 74, 19, 0, 107, - 39, 39, 105, 39, 39, 39, 107, 74, 16, 74, 107, 107, 105, 107, 107, 107, - 35, 35, 35, 105, 35, 35, 35, 35, 46, 16, 37, 74, 35, 35, 35, 105, 35, 35, - 35, 35, 46, 46, 107, 39, 39, 105, 39, 39, 39, 107, 74, 16, 74, 16, 74, - 35, 35, 35, 105, 35, 35, 35, 35, 46, 46, 46, 16, 46 - }; -static const ANTLR3_INT32 dfa37_accept[114] = - { - -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1 - }; -static const ANTLR3_INT32 dfa37_special[114] = - { - -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1 - }; - -/** Used when there is no transition table entry for a particular state */ -#define dfa37_T_empty NULL - -static const ANTLR3_INT32 dfa37_T0[] = - { - 17, -1, -1, -1, -1, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2 - };static const ANTLR3_INT32 dfa37_T1[] = - { - 17, -1, -1, -1, -1, -1, -1, 2, 18, -1, -1, -1, 75, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2 - };static const ANTLR3_INT32 dfa37_T2[] = - { - 56, 57 - };static const ANTLR3_INT32 dfa37_T3[] = - { - 95, 96 - };static const ANTLR3_INT32 dfa37_T4[] = - { - 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 49, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 52, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 53, 53, 54, - 55 - };static const ANTLR3_INT32 dfa37_T5[] = - { - 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 88, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 91, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 92, 92, 93, - 94 - };static const ANTLR3_INT32 dfa37_T6[] = - { - 74, 67, 68, 73, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 69, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, 66, 70, 70, - 71, 72 - };static const ANTLR3_INT32 dfa37_T7[] = - { - 33, 26, 27, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 25, 29, 29, - 30, 31 - };static const ANTLR3_INT32 dfa37_T8[] = - { - 86, 79, 80, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 81, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 78, 78, 82, 82, - 83, 84 - };static const ANTLR3_INT32 dfa37_T9[] = - { - 109, 102, 103, 108, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 101, 101, 105, - 105, 106, 107 - };static const ANTLR3_INT32 dfa37_T10[] = - { - 2, -1, -1, -1, 3, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 2, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 - };static const ANTLR3_INT32 dfa37_T11[] = - { - 56, 57, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58 - };static const ANTLR3_INT32 dfa37_T12[] = - { - 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 97 - };static const ANTLR3_INT32 dfa37_T13[] = - { - 17, -1, -1, -1, -1, -1, -1, -1, 18, -1, -1, -1, 34, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2 - };static const ANTLR3_INT32 dfa37_T14[] = - { - 77 - };static const ANTLR3_INT32 dfa37_T15[] = - { - 100 - };static const ANTLR3_INT32 dfa37_T16[] = - { - 60, 61, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 62, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 63, 63, 64, - 65 - };static const ANTLR3_INT32 dfa37_T17[] = - { - 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 21, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, 22, 23, - 24 - };static const ANTLR3_INT32 dfa37_T18[] = - { - -1 - };static const ANTLR3_INT32 dfa37_T19[] = - { - 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 52, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 53, 53, 54, - 55 - };static const ANTLR3_INT32 dfa37_T20[] = - { - 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 91, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 92, 92, 93, - 94 - };static const ANTLR3_INT32 dfa37_T21[] = - { - 45, 36, 37, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, - -1, -1, -1, -1, 43, -1, -1, 2, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, 35, 39, 39, - 40, 41 - };static const ANTLR3_INT32 dfa37_T22[] = - { - 17, -1, -1, -1, -1, -1, -1, -1, 18, -1, -1, -1, 75, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2 - };static const ANTLR3_INT32 dfa37_T23[] = - { - 76 - };static const ANTLR3_INT32 dfa37_T24[] = - { - 14, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, - -1, -1, -1, 12, -1, -1, 2, 16, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 4, 8, 8, 9, 10 - };static const ANTLR3_INT32 dfa37_T25[] = - { - 17, -1, -1, -1, -1, -1, -1, 2, 18, -1, -1, -1, 34, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2 - };static const ANTLR3_INT32 dfa37_T26[] = - { - 105, 105 - };static const ANTLR3_INT32 dfa37_T27[] = - { - 39, 39 - };static const ANTLR3_INT32 dfa37_T28[] = - { - 29, 29 - };static const ANTLR3_INT32 dfa37_T29[] = - { - 8, 8 - };static const ANTLR3_INT32 dfa37_T30[] = - { - 22, 22 - };static const ANTLR3_INT32 dfa37_T31[] = - { - 53, 53 - };static const ANTLR3_INT32 dfa37_T32[] = - { - 63, 63 - };static const ANTLR3_INT32 dfa37_T33[] = - { - 70, 70 - };static const ANTLR3_INT32 dfa37_T34[] = - { - 82, 82 - };static const ANTLR3_INT32 dfa37_T35[] = - { - 92, 92 - };static const ANTLR3_INT32 dfa37_T36[] = - { - 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 112 - };static const ANTLR3_INT32 dfa37_T37[] = - { - 56, 57, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 99 - };static const ANTLR3_INT32 dfa37_T38[] = - { - 113 - };static const ANTLR3_INT32 dfa37_T39[] = - { - 111 - };static const ANTLR3_INT32 dfa37_T40[] = - { - 110 - };static const ANTLR3_INT32 dfa37_T41[] = - { - 59 - };static const ANTLR3_INT32 dfa37_T42[] = - { - 87 - };static const ANTLR3_INT32 dfa37_T43[] = - { - 98 - };static const ANTLR3_INT32 dfa37_T44[] = - { - 48, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 47, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 - };static const ANTLR3_INT32 dfa37_T45[] = - { - 48 - };static const ANTLR3_INT32 dfa37_T46[] = - { - 1, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, - -1, -1, -1, 2, -1, -1, 2, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, - 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2 - }; - -/* Transition tables are a table of sub tables, with some tables - * reused for efficiency. - */ -static const ANTLR3_INT32 * const dfa37_transitions[] = -{ - dfa37_T46, dfa37_T10, dfa37_T_empty, dfa37_T24, dfa37_T0, dfa37_T0, - dfa37_T0, dfa37_T29, dfa37_T0, dfa37_T0, dfa37_T0, dfa37_T0, dfa37_T17, - dfa37_T7, dfa37_T25, dfa37_T13, dfa37_T_empty, dfa37_T21, dfa37_T44, - dfa37_T4, dfa37_T4, dfa37_T30, dfa37_T4, dfa37_T4, dfa37_T4, dfa37_T2, - dfa37_T2, dfa37_T2, dfa37_T28, dfa37_T2, dfa37_T2, dfa37_T2, dfa37_T2, - dfa37_T11, dfa37_T41, dfa37_T0, dfa37_T0, dfa37_T0, dfa37_T27, dfa37_T0, - dfa37_T0, dfa37_T0, dfa37_T0, dfa37_T16, dfa37_T6, dfa37_T1, dfa37_T22, - dfa37_T23, dfa37_T18, dfa37_T19, dfa37_T14, dfa37_T14, dfa37_T31, dfa37_T14, - dfa37_T14, dfa37_T14, dfa37_T8, dfa37_T0, dfa37_T42, dfa37_T13, dfa37_T5, - dfa37_T5, dfa37_T32, dfa37_T5, dfa37_T5, dfa37_T5, dfa37_T3, dfa37_T3, - dfa37_T3, dfa37_T33, dfa37_T3, dfa37_T3, dfa37_T3, dfa37_T3, dfa37_T12, - dfa37_T43, dfa37_T45, dfa37_T0, dfa37_T2, dfa37_T2, dfa37_T2, dfa37_T34, - dfa37_T2, dfa37_T2, dfa37_T2, dfa37_T2, dfa37_T37, dfa37_T11, dfa37_T20, - dfa37_T15, dfa37_T15, dfa37_T35, dfa37_T15, dfa37_T15, dfa37_T15, dfa37_T9, - dfa37_T0, dfa37_T40, dfa37_T22, dfa37_T39, dfa37_T0, dfa37_T3, dfa37_T3, - dfa37_T3, dfa37_T26, dfa37_T3, dfa37_T3, dfa37_T3, dfa37_T3, dfa37_T36, - dfa37_T12, dfa37_T37, dfa37_T38, dfa37_T36 -}; - -static ANTLR3_INT32 dfa37_sst(pNDDL3Parser ctx, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, pANTLR3_CYCLIC_DFA dfa, ANTLR3_INT32 s) -{ - ANTLR3_INT32 _s; - - _s = s; - switch (s) - { - case 0: - - { - ANTLR3_UINT32 LA37_48; - - ANTLR3_MARKER index37_48; - - - LA37_48 = LA(1); - - - index37_48 = INDEX(); - - REWINDLAST(); - - s = -1; - if ( (synpred1_NDDL3(ctx)) ) - { - s = 16; - } - - else if ( (ANTLR3_TRUE) ) - { - s = 2; - } - - - SEEK(index37_48); - - if ( s>=0 ) - { - return s; - } - } - break; - case 1: - - { - ANTLR3_UINT32 LA37_3; - - ANTLR3_MARKER index37_3; - - - LA37_3 = LA(1); - - - index37_3 = INDEX(); - - REWINDLAST(); - - s = -1; - if ( (((LA37_3 >= 102) && (LA37_3 <= 103))) ) - { - s = 4; - } - - else if ( (LA37_3 == INT) ) - { - s = 5; - } - - else if ( (LA37_3 == FLOAT) ) - { - s = 6; - } - - else if ( (LA37_3 == 72) ) - { - s = 7; - } - - else if ( (((LA37_3 >= 104) && (LA37_3 <= 105))) ) - { - s = 8; - } - - else if ( (LA37_3 == 106) ) - { - s = 9; - } - - else if ( (LA37_3 == 107) ) - { - s = 10; - } - - else if ( (LA37_3 == STRING) ) - { - s = 11; - } - - else if ( (LA37_3 == 38) ) - { - s = 12; - } - - else if ( (LA37_3 == 33) ) - { - s = 13; - } - - else if ( (LA37_3 == IDENT) ) - { - s = 14; - } - - else if ( (LA37_3 == 45) ) - { - s = 15; - } - - else if ( (LA37_3 == 41) ) - { - s = 2; - } - - else if ( (LA37_3 == 42) && (synpred1_NDDL3(ctx))) - { - s = 16; - } - - - SEEK(index37_3); - - if ( s>=0 ) - { - return s; - } - } - break; - } - if (BACKTRACKING > 0) - { - FAILEDFLAG = ANTLR3_TRUE; - return -1; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)"303:1: constraintInstantiation : ( ( ( IDENT variableArgumentList ( ':' violationMsg )? ';' )=> IDENT variableArgumentList ( ':' violationMsg )? ';' ) -> ^( CONSTRAINT_INSTANTIATION IDENT variableArgumentList ( violationMsg )? ) | enforceStatement );"; - EXCEPTION->decisionNum = 37; - EXCEPTION->state = _s; - return -1; -} - -/* Declare tracking structure for Cyclic DFA 37 - */ -static -ANTLR3_CYCLIC_DFA cdfa37 - = { - 37, /* Decision number of this dfa */ - /* Which decision this represents: */ - (const pANTLR3_UCHAR)"303:1: constraintInstantiation : ( ( ( IDENT variableArgumentList ( ':' violationMsg )? ';' )=> IDENT variableArgumentList ( ':' violationMsg )? ';' ) -> ^( CONSTRAINT_INSTANTIATION IDENT variableArgumentList ( violationMsg )? ) | enforceStatement );", - (CDFA_SPECIAL_FUNC) dfa37_sst, - antlr3dfaspecialTransition, /* DFA specialTransition is currently just a default function in the runtime */ - antlr3dfapredict, /* DFA simulator function is in the runtime */ - dfa37_eot, /* EOT table */ - dfa37_eof, /* EOF table */ - dfa37_min, /* Minimum tokens for each state */ - dfa37_max, /* Maximum tokens for each state */ - dfa37_accept, /* Accept table */ - dfa37_special, /* Special transition states */ - dfa37_transitions /* Table of transition tables */ - - }; -/* End of Cyclic DFA 37 - * --------------------- - */ -/* ========================================================================= - * End of DFA tables for the parser - */ - -/* ============================================== - * Parsing rules - */ -/** - * $ANTLR start nddl - * NDDL/base/antlr/NDDL3.g:93:1: nddl : ( nddlStatement )* -> ^( NDDL ( nddlStatement )* ) ; - */ -static NDDL3Parser_nddl_return -nddl(pNDDL3Parser ctx) -{ - NDDL3Parser_nddl_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_nddlStatement_return nddlStatement1; - #undef RETURN_TYPE_nddlStatement1 - #define RETURN_TYPE_nddlStatement1 NDDL3Parser_nddlStatement_return - - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_nddlStatement; - /* Initialize rule variables - */ - - - root_0 = NULL; - - nddlStatement1.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - stream_nddlStatement = NULL; - #define CREATE_stream_nddlStatement if (stream_nddlStatement == NULL) {stream_nddlStatement = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule nddlStatement"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:94:5: ( ( nddlStatement )* -> ^( NDDL ( nddlStatement )* ) ) - // NDDL/base/antlr/NDDL3.g:94:9: ( nddlStatement )* - { - - // NDDL/base/antlr/NDDL3.g:94:9: ( nddlStatement )* - - for (;;) - { - int alt1=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA1_0 = LA(1); - if ( (((LA1_0 >= IDENT) && (LA1_0 <= STRING)) || ((LA1_0 >= 32) && (LA1_0 <= 33)) || ((LA1_0 >= 36) && (LA1_0 <= 38)) || ((LA1_0 >= 40) && (LA1_0 <= 41)) || ((LA1_0 >= 44) && (LA1_0 <= 45)) || LA1_0 == 48 || ((LA1_0 >= 53) && (LA1_0 <= 59)) || LA1_0 == 63 || LA1_0 == 72 || ((LA1_0 >= 79) && (LA1_0 <= 108))) ) - { - alt1=1; - } - - } - switch (alt1) - { - case 1: - // NDDL/base/antlr/NDDL3.g:94:9: nddlStatement - { - FOLLOWPUSH(FOLLOW_nddlStatement_in_nddl184); - nddlStatement1=nddlStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_nddlStatement; stream_nddlStatement->add(stream_nddlStatement, nddlStatement1.tree, NULL); } - - } - break; - - default: - goto loop1; /* break out of the loop */ - break; - } - } - loop1: ; /* Jump out to here if this rule does not match */ - - - - /* AST REWRITE - * elements : nddlStatement - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 95:9: -> ^( NDDL ( nddlStatement )* ) - { - // NDDL/base/antlr/NDDL3.g:95:12: ^( NDDL ( nddlStatement )* ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, NDDL, (pANTLR3_UINT8)"NDDL"), root_1)); - - // NDDL/base/antlr/NDDL3.g:95:19: ( nddlStatement )* - { - while ( (stream_nddlStatement != NULL && stream_nddlStatement->hasNext(stream_nddlStatement)) ) - { - ADAPTOR->addChild(ADAPTOR, root_1, stream_nddlStatement == NULL ? NULL : stream_nddlStatement->nextTree(stream_nddlStatement)); - - } - if ( stream_nddlStatement != NULL) stream_nddlStatement->reset(stream_nddlStatement); - - } - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto rulenddlEx; /* Prevent compiler warnings */ - rulenddlEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_nddlStatement != NULL) stream_nddlStatement->free(stream_nddlStatement); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end nddl */ - -/** - * $ANTLR start nddlStatement - * NDDL/base/antlr/NDDL3.g:98:1: nddlStatement : ( typeDefinition | enumDefinition | variableDeclarations | assignment | constraintInstantiation | classDeclaration | allocationStmt | rule | problemStmt | relation | methodInvocation | noopstatement ); - */ -static NDDL3Parser_nddlStatement_return -nddlStatement(pNDDL3Parser ctx) -{ - NDDL3Parser_nddlStatement_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_typeDefinition_return typeDefinition2; - #undef RETURN_TYPE_typeDefinition2 - #define RETURN_TYPE_typeDefinition2 NDDL3Parser_typeDefinition_return - - NDDL3Parser_enumDefinition_return enumDefinition3; - #undef RETURN_TYPE_enumDefinition3 - #define RETURN_TYPE_enumDefinition3 NDDL3Parser_enumDefinition_return - - NDDL3Parser_variableDeclarations_return variableDeclarations4; - #undef RETURN_TYPE_variableDeclarations4 - #define RETURN_TYPE_variableDeclarations4 NDDL3Parser_variableDeclarations_return - - NDDL3Parser_assignment_return assignment5; - #undef RETURN_TYPE_assignment5 - #define RETURN_TYPE_assignment5 NDDL3Parser_assignment_return - - NDDL3Parser_constraintInstantiation_return constraintInstantiation6; - #undef RETURN_TYPE_constraintInstantiation6 - #define RETURN_TYPE_constraintInstantiation6 NDDL3Parser_constraintInstantiation_return - - NDDL3Parser_classDeclaration_return classDeclaration7; - #undef RETURN_TYPE_classDeclaration7 - #define RETURN_TYPE_classDeclaration7 NDDL3Parser_classDeclaration_return - - NDDL3Parser_allocationStmt_return allocationStmt8; - #undef RETURN_TYPE_allocationStmt8 - #define RETURN_TYPE_allocationStmt8 NDDL3Parser_allocationStmt_return - - NDDL3Parser_rule_return rule9; - #undef RETURN_TYPE_rule9 - #define RETURN_TYPE_rule9 NDDL3Parser_rule_return - - NDDL3Parser_problemStmt_return problemStmt10; - #undef RETURN_TYPE_problemStmt10 - #define RETURN_TYPE_problemStmt10 NDDL3Parser_problemStmt_return - - NDDL3Parser_relation_return relation11; - #undef RETURN_TYPE_relation11 - #define RETURN_TYPE_relation11 NDDL3Parser_relation_return - - NDDL3Parser_methodInvocation_return methodInvocation12; - #undef RETURN_TYPE_methodInvocation12 - #define RETURN_TYPE_methodInvocation12 NDDL3Parser_methodInvocation_return - - NDDL3Parser_noopstatement_return noopstatement13; - #undef RETURN_TYPE_noopstatement13 - #define RETURN_TYPE_noopstatement13 NDDL3Parser_noopstatement_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - typeDefinition2.tree = NULL; - - enumDefinition3.tree = NULL; - - variableDeclarations4.tree = NULL; - - assignment5.tree = NULL; - - constraintInstantiation6.tree = NULL; - - classDeclaration7.tree = NULL; - - allocationStmt8.tree = NULL; - - rule9.tree = NULL; - - problemStmt10.tree = NULL; - - relation11.tree = NULL; - - methodInvocation12.tree = NULL; - - noopstatement13.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:99:5: ( typeDefinition | enumDefinition | variableDeclarations | assignment | constraintInstantiation | classDeclaration | allocationStmt | rule | problemStmt | relation | methodInvocation | noopstatement ) - - ANTLR3_UINT32 alt2; - - alt2=12; - - alt2 = cdfa2.predict(ctx, RECOGNIZER, ISTREAM, &cdfa2); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - switch (alt2) - { - case 1: - // NDDL/base/antlr/NDDL3.g:99:9: typeDefinition - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_typeDefinition_in_nddlStatement221); - typeDefinition2=typeDefinition(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, typeDefinition2.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:100:9: enumDefinition - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_enumDefinition_in_nddlStatement231); - enumDefinition3=enumDefinition(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, enumDefinition3.tree); - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:101:9: variableDeclarations - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_variableDeclarations_in_nddlStatement241); - variableDeclarations4=variableDeclarations(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, variableDeclarations4.tree); - - } - break; - case 4: - // NDDL/base/antlr/NDDL3.g:102:9: assignment - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_assignment_in_nddlStatement251); - assignment5=assignment(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, assignment5.tree); - - } - break; - case 5: - // NDDL/base/antlr/NDDL3.g:103:9: constraintInstantiation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_constraintInstantiation_in_nddlStatement261); - constraintInstantiation6=constraintInstantiation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constraintInstantiation6.tree); - - } - break; - case 6: - // NDDL/base/antlr/NDDL3.g:104:9: classDeclaration - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_classDeclaration_in_nddlStatement271); - classDeclaration7=classDeclaration(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, classDeclaration7.tree); - - } - break; - case 7: - // NDDL/base/antlr/NDDL3.g:105:9: allocationStmt - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_allocationStmt_in_nddlStatement281); - allocationStmt8=allocationStmt(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, allocationStmt8.tree); - - } - break; - case 8: - // NDDL/base/antlr/NDDL3.g:106:9: rule - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_rule_in_nddlStatement291); - rule9=rule(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, rule9.tree); - - } - break; - case 9: - // NDDL/base/antlr/NDDL3.g:107:9: problemStmt - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_problemStmt_in_nddlStatement301); - problemStmt10=problemStmt(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, problemStmt10.tree); - - } - break; - case 10: - // NDDL/base/antlr/NDDL3.g:108:9: relation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_relation_in_nddlStatement311); - relation11=relation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, relation11.tree); - - } - break; - case 11: - // NDDL/base/antlr/NDDL3.g:109:9: methodInvocation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_methodInvocation_in_nddlStatement321); - methodInvocation12=methodInvocation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, methodInvocation12.tree); - - } - break; - case 12: - // NDDL/base/antlr/NDDL3.g:110:9: noopstatement - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_noopstatement_in_nddlStatement331); - noopstatement13=noopstatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, noopstatement13.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulenddlStatementEx; /* Prevent compiler warnings */ - rulenddlStatementEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end nddlStatement */ - -/** - * $ANTLR start enumDefinition - * NDDL/base/antlr/NDDL3.g:113:1: enumDefinition : 'enum' IDENT enumValues ; - */ -static NDDL3Parser_enumDefinition_return -enumDefinition(pNDDL3Parser ctx) -{ - NDDL3Parser_enumDefinition_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal14; - pANTLR3_COMMON_TOKEN IDENT15; - NDDL3Parser_enumValues_return enumValues16; - #undef RETURN_TYPE_enumValues16 - #define RETURN_TYPE_enumValues16 NDDL3Parser_enumValues_return - - pANTLR3_BASE_TREE string_literal14_tree; - pANTLR3_BASE_TREE IDENT15_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal14 = NULL; - IDENT15 = NULL; - enumValues16.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal14_tree = NULL; - IDENT15_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:114:5: ( 'enum' IDENT enumValues ) - // NDDL/base/antlr/NDDL3.g:114:7: 'enum' IDENT enumValues - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - string_literal14 = (pANTLR3_COMMON_TOKEN) MATCHT(32, &FOLLOW_32_in_enumDefinition348); - if (HASEXCEPTION()) - { - goto ruleenumDefinitionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal14_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal14)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal14_tree, root_0)); - } - IDENT15 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_enumDefinition351); - if (HASEXCEPTION()) - { - goto ruleenumDefinitionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT15_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT15)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT15_tree); - } - FOLLOWPUSH(FOLLOW_enumValues_in_enumDefinition353); - enumValues16=enumValues(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleenumDefinitionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, enumValues16.tree); - - } - - } - - - // This is where rules clean up and exit - // - goto ruleenumDefinitionEx; /* Prevent compiler warnings */ - ruleenumDefinitionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end enumDefinition */ - -/** - * $ANTLR start enumValues - * NDDL/base/antlr/NDDL3.g:117:1: enumValues : '{' IDENT ( ',' IDENT )* '}' ; - */ -static NDDL3Parser_enumValues_return -enumValues(pNDDL3Parser ctx) -{ - NDDL3Parser_enumValues_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal17; - pANTLR3_COMMON_TOKEN IDENT18; - pANTLR3_COMMON_TOKEN char_literal19; - pANTLR3_COMMON_TOKEN IDENT20; - pANTLR3_COMMON_TOKEN char_literal21; - - pANTLR3_BASE_TREE char_literal17_tree; - pANTLR3_BASE_TREE IDENT18_tree; - pANTLR3_BASE_TREE char_literal19_tree; - pANTLR3_BASE_TREE IDENT20_tree; - pANTLR3_BASE_TREE char_literal21_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal17 = NULL; - IDENT18 = NULL; - char_literal19 = NULL; - IDENT20 = NULL; - char_literal21 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - char_literal17_tree = NULL; - IDENT18_tree = NULL; - char_literal19_tree = NULL; - IDENT20_tree = NULL; - char_literal21_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:118:5: ( '{' IDENT ( ',' IDENT )* '}' ) - // NDDL/base/antlr/NDDL3.g:118:7: '{' IDENT ( ',' IDENT )* '}' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal17 = (pANTLR3_COMMON_TOKEN) MATCHT(33, &FOLLOW_33_in_enumValues373); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal17_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal17)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal17_tree, root_0)); - } - IDENT18 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_enumValues376); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT18_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT18)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT18_tree); - } - - // NDDL/base/antlr/NDDL3.g:118:18: ( ',' IDENT )* - - for (;;) - { - int alt3=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA3_0 = LA(1); - if ( (LA3_0 == 34) ) - { - alt3=1; - } - - } - switch (alt3) - { - case 1: - // NDDL/base/antlr/NDDL3.g:118:19: ',' IDENT - { - char_literal19 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_enumValues379); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - if (HASFAILED()) - { - return retval; - } - IDENT20 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_enumValues382); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT20_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT20)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT20_tree); - } - - } - break; - - default: - goto loop3; /* break out of the loop */ - break; - } - } - loop3: ; /* Jump out to here if this rule does not match */ - - char_literal21 = (pANTLR3_COMMON_TOKEN) MATCHT(35, &FOLLOW_35_in_enumValues386); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleenumValuesEx; /* Prevent compiler warnings */ - ruleenumValuesEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end enumValues */ - -/** - * $ANTLR start typeDefinition - * NDDL/base/antlr/NDDL3.g:121:1: typeDefinition : 'typedef' type baseDomain IDENT ';' -> ^( 'typedef' IDENT type baseDomain ) ; - */ -static NDDL3Parser_typeDefinition_return -typeDefinition(pNDDL3Parser ctx) -{ - NDDL3Parser_typeDefinition_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal22; - pANTLR3_COMMON_TOKEN IDENT25; - pANTLR3_COMMON_TOKEN char_literal26; - NDDL3Parser_type_return type23; - #undef RETURN_TYPE_type23 - #define RETURN_TYPE_type23 NDDL3Parser_type_return - - NDDL3Parser_baseDomain_return baseDomain24; - #undef RETURN_TYPE_baseDomain24 - #define RETURN_TYPE_baseDomain24 NDDL3Parser_baseDomain_return - - pANTLR3_BASE_TREE string_literal22_tree; - pANTLR3_BASE_TREE IDENT25_tree; - pANTLR3_BASE_TREE char_literal26_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_IDENT; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_36; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_37; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_baseDomain; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_type; - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal22 = NULL; - IDENT25 = NULL; - char_literal26 = NULL; - type23.tree = NULL; - - baseDomain24.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal22_tree = NULL; - IDENT25_tree = NULL; - char_literal26_tree = NULL; - - stream_IDENT = NULL; - #define CREATE_stream_IDENT if (stream_IDENT == NULL) {stream_IDENT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token IDENT"); } - stream_36 = NULL; - #define CREATE_stream_36 if (stream_36 == NULL) {stream_36 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 36"); } - stream_37 = NULL; - #define CREATE_stream_37 if (stream_37 == NULL) {stream_37 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 37"); } - stream_baseDomain = NULL; - #define CREATE_stream_baseDomain if (stream_baseDomain == NULL) {stream_baseDomain = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule baseDomain"); } - stream_type = NULL; - #define CREATE_stream_type if (stream_type == NULL) {stream_type = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule type"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:122:2: ( 'typedef' type baseDomain IDENT ';' -> ^( 'typedef' IDENT type baseDomain ) ) - // NDDL/base/antlr/NDDL3.g:122:4: 'typedef' type baseDomain IDENT ';' - { - string_literal22 = (pANTLR3_COMMON_TOKEN) MATCHT(36, &FOLLOW_36_in_typeDefinition417); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_36; stream_36->add(stream_36, string_literal22, NULL); } - - FOLLOWPUSH(FOLLOW_type_in_typeDefinition419); - type23=type(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_type; stream_type->add(stream_type, type23.tree, NULL); } - FOLLOWPUSH(FOLLOW_baseDomain_in_typeDefinition421); - baseDomain24=baseDomain(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_baseDomain; stream_baseDomain->add(stream_baseDomain, baseDomain24.tree, NULL); } - IDENT25 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_typeDefinition423); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, IDENT25, NULL); } - - char_literal26 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_typeDefinition425); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal26, NULL); } - - - - /* AST REWRITE - * elements : baseDomain, 36, IDENT, type - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 123:9: -> ^( 'typedef' IDENT type baseDomain ) - { - // NDDL/base/antlr/NDDL3.g:123:12: ^( 'typedef' IDENT type baseDomain ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_36 == NULL ? NULL : stream_36->nextNode(stream_36), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_IDENT == NULL ? NULL : stream_IDENT->nextNode(stream_IDENT)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_type == NULL ? NULL : stream_type->nextTree(stream_type)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_baseDomain == NULL ? NULL : stream_baseDomain->nextTree(stream_baseDomain)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto ruletypeDefinitionEx; /* Prevent compiler warnings */ - ruletypeDefinitionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_IDENT != NULL) stream_IDENT->free(stream_IDENT); - if (stream_36 != NULL) stream_36->free(stream_36); - if (stream_37 != NULL) stream_37->free(stream_37); - if (stream_baseDomain != NULL) stream_baseDomain->free(stream_baseDomain); - if (stream_type != NULL) stream_type->free(stream_type); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end typeDefinition */ - -/** - * $ANTLR start baseDomain - * NDDL/base/antlr/NDDL3.g:126:1: baseDomain : ( intervalBaseDomain | enumeratedBaseDomain ); - */ -static NDDL3Parser_baseDomain_return -baseDomain(pNDDL3Parser ctx) -{ - NDDL3Parser_baseDomain_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_intervalBaseDomain_return intervalBaseDomain27; - #undef RETURN_TYPE_intervalBaseDomain27 - #define RETURN_TYPE_intervalBaseDomain27 NDDL3Parser_intervalBaseDomain_return - - NDDL3Parser_enumeratedBaseDomain_return enumeratedBaseDomain28; - #undef RETURN_TYPE_enumeratedBaseDomain28 - #define RETURN_TYPE_enumeratedBaseDomain28 NDDL3Parser_enumeratedBaseDomain_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - intervalBaseDomain27.tree = NULL; - - enumeratedBaseDomain28.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:127:5: ( intervalBaseDomain | enumeratedBaseDomain ) - - ANTLR3_UINT32 alt4; - - alt4=2; - - - { - int LA4_0 = LA(1); - if ( (LA4_0 == 38) ) - { - alt4=1; - } - else if ( (LA4_0 == 33) ) - { - alt4=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 4; - EXCEPTION->state = 0; - - - goto rulebaseDomainEx; - } - } - switch (alt4) - { - case 1: - // NDDL/base/antlr/NDDL3.g:127:9: intervalBaseDomain - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_intervalBaseDomain_in_baseDomain463); - intervalBaseDomain27=intervalBaseDomain(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulebaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, intervalBaseDomain27.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:128:9: enumeratedBaseDomain - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_enumeratedBaseDomain_in_baseDomain473); - enumeratedBaseDomain28=enumeratedBaseDomain(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulebaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, enumeratedBaseDomain28.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulebaseDomainEx; /* Prevent compiler warnings */ - rulebaseDomainEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end baseDomain */ - -/** - * $ANTLR start intervalBaseDomain - * NDDL/base/antlr/NDDL3.g:131:1: intervalBaseDomain : '[' numericLiteral ( ',' )? numericLiteral ']' ; - */ -static NDDL3Parser_intervalBaseDomain_return -intervalBaseDomain(pNDDL3Parser ctx) -{ - NDDL3Parser_intervalBaseDomain_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal29; - pANTLR3_COMMON_TOKEN char_literal31; - pANTLR3_COMMON_TOKEN char_literal33; - NDDL3Parser_numericLiteral_return numericLiteral30; - #undef RETURN_TYPE_numericLiteral30 - #define RETURN_TYPE_numericLiteral30 NDDL3Parser_numericLiteral_return - - NDDL3Parser_numericLiteral_return numericLiteral32; - #undef RETURN_TYPE_numericLiteral32 - #define RETURN_TYPE_numericLiteral32 NDDL3Parser_numericLiteral_return - - pANTLR3_BASE_TREE char_literal29_tree; - pANTLR3_BASE_TREE char_literal31_tree; - pANTLR3_BASE_TREE char_literal33_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal29 = NULL; - char_literal31 = NULL; - char_literal33 = NULL; - numericLiteral30.tree = NULL; - - numericLiteral32.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal29_tree = NULL; - char_literal31_tree = NULL; - char_literal33_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:132:5: ( '[' numericLiteral ( ',' )? numericLiteral ']' ) - // NDDL/base/antlr/NDDL3.g:132:9: '[' numericLiteral ( ',' )? numericLiteral ']' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal29 = (pANTLR3_COMMON_TOKEN) MATCHT(38, &FOLLOW_38_in_intervalBaseDomain492); - if (HASEXCEPTION()) - { - goto ruleintervalBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal29_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal29)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal29_tree, root_0)); - } - FOLLOWPUSH(FOLLOW_numericLiteral_in_intervalBaseDomain495); - numericLiteral30=numericLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleintervalBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, numericLiteral30.tree); - - // NDDL/base/antlr/NDDL3.g:132:29: ( ',' )? - { - int alt5=2; - { - int LA5_0 = LA(1); - if ( (LA5_0 == 34) ) - { - alt5=1; - } - } - switch (alt5) - { - case 1: - // NDDL/base/antlr/NDDL3.g:132:30: ',' - { - char_literal31 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_intervalBaseDomain498); - if (HASEXCEPTION()) - { - goto ruleintervalBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_numericLiteral_in_intervalBaseDomain503); - numericLiteral32=numericLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleintervalBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, numericLiteral32.tree); - char_literal33 = (pANTLR3_COMMON_TOKEN) MATCHT(39, &FOLLOW_39_in_intervalBaseDomain505); - if (HASEXCEPTION()) - { - goto ruleintervalBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleintervalBaseDomainEx; /* Prevent compiler warnings */ - ruleintervalBaseDomainEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end intervalBaseDomain */ - -/** - * $ANTLR start enumeratedBaseDomain - * NDDL/base/antlr/NDDL3.g:135:1: enumeratedBaseDomain : '{' baseDomainValue ( ',' baseDomainValue )* '}' ; - */ -static NDDL3Parser_enumeratedBaseDomain_return -enumeratedBaseDomain(pNDDL3Parser ctx) -{ - NDDL3Parser_enumeratedBaseDomain_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal34; - pANTLR3_COMMON_TOKEN char_literal36; - pANTLR3_COMMON_TOKEN char_literal38; - NDDL3Parser_baseDomainValue_return baseDomainValue35; - #undef RETURN_TYPE_baseDomainValue35 - #define RETURN_TYPE_baseDomainValue35 NDDL3Parser_baseDomainValue_return - - NDDL3Parser_baseDomainValue_return baseDomainValue37; - #undef RETURN_TYPE_baseDomainValue37 - #define RETURN_TYPE_baseDomainValue37 NDDL3Parser_baseDomainValue_return - - pANTLR3_BASE_TREE char_literal34_tree; - pANTLR3_BASE_TREE char_literal36_tree; - pANTLR3_BASE_TREE char_literal38_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal34 = NULL; - char_literal36 = NULL; - char_literal38 = NULL; - baseDomainValue35.tree = NULL; - - baseDomainValue37.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal34_tree = NULL; - char_literal36_tree = NULL; - char_literal38_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:136:5: ( '{' baseDomainValue ( ',' baseDomainValue )* '}' ) - // NDDL/base/antlr/NDDL3.g:136:9: '{' baseDomainValue ( ',' baseDomainValue )* '}' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal34 = (pANTLR3_COMMON_TOKEN) MATCHT(33, &FOLLOW_33_in_enumeratedBaseDomain525); - if (HASEXCEPTION()) - { - goto ruleenumeratedBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal34_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal34)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal34_tree, root_0)); - } - FOLLOWPUSH(FOLLOW_baseDomainValue_in_enumeratedBaseDomain528); - baseDomainValue35=baseDomainValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleenumeratedBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, baseDomainValue35.tree); - - // NDDL/base/antlr/NDDL3.g:136:30: ( ',' baseDomainValue )* - - for (;;) - { - int alt6=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA6_0 = LA(1); - if ( (LA6_0 == 34) ) - { - alt6=1; - } - - } - switch (alt6) - { - case 1: - // NDDL/base/antlr/NDDL3.g:136:31: ',' baseDomainValue - { - char_literal36 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_enumeratedBaseDomain531); - if (HASEXCEPTION()) - { - goto ruleenumeratedBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_baseDomainValue_in_enumeratedBaseDomain534); - baseDomainValue37=baseDomainValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleenumeratedBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, baseDomainValue37.tree); - - } - break; - - default: - goto loop6; /* break out of the loop */ - break; - } - } - loop6: ; /* Jump out to here if this rule does not match */ - - char_literal38 = (pANTLR3_COMMON_TOKEN) MATCHT(35, &FOLLOW_35_in_enumeratedBaseDomain538); - if (HASEXCEPTION()) - { - goto ruleenumeratedBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleenumeratedBaseDomainEx; /* Prevent compiler warnings */ - ruleenumeratedBaseDomainEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end enumeratedBaseDomain */ - -/** - * $ANTLR start baseDomainValue - * NDDL/base/antlr/NDDL3.g:139:1: baseDomainValue : ( literalValue | qualified ); - */ -static NDDL3Parser_baseDomainValue_return -baseDomainValue(pNDDL3Parser ctx) -{ - NDDL3Parser_baseDomainValue_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_literalValue_return literalValue39; - #undef RETURN_TYPE_literalValue39 - #define RETURN_TYPE_literalValue39 NDDL3Parser_literalValue_return - - NDDL3Parser_qualified_return qualified40; - #undef RETURN_TYPE_qualified40 - #define RETURN_TYPE_qualified40 NDDL3Parser_qualified_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - literalValue39.tree = NULL; - - qualified40.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:140:5: ( literalValue | qualified ) - - ANTLR3_UINT32 alt7; - - alt7=2; - - - { - int LA7_0 = LA(1); - if ( (((LA7_0 >= INT) && (LA7_0 <= STRING)) || LA7_0 == 72 || ((LA7_0 >= 102) && (LA7_0 <= 107))) ) - { - alt7=1; - } - else if ( (LA7_0 == IDENT || LA7_0 == 45) ) - { - alt7=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 7; - EXCEPTION->state = 0; - - - goto rulebaseDomainValueEx; - } - } - switch (alt7) - { - case 1: - // NDDL/base/antlr/NDDL3.g:140:7: literalValue - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_literalValue_in_baseDomainValue563); - literalValue39=literalValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulebaseDomainValueEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, literalValue39.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:141:7: qualified - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_qualified_in_baseDomainValue571); - qualified40=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulebaseDomainValueEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, qualified40.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulebaseDomainValueEx; /* Prevent compiler warnings */ - rulebaseDomainValueEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end baseDomainValue */ - -/** - * $ANTLR start variableDeclarations - * NDDL/base/antlr/NDDL3.g:144:1: variableDeclarations : ( 'filter' )? type nameWithBaseDomain ( ',' nameWithBaseDomain )* ';' -> ^( VARIABLE type nameWithBaseDomain ( nameWithBaseDomain )* ) ; - */ -static NDDL3Parser_variableDeclarations_return -variableDeclarations(pNDDL3Parser ctx) -{ - NDDL3Parser_variableDeclarations_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal41; - pANTLR3_COMMON_TOKEN char_literal44; - pANTLR3_COMMON_TOKEN char_literal46; - NDDL3Parser_type_return type42; - #undef RETURN_TYPE_type42 - #define RETURN_TYPE_type42 NDDL3Parser_type_return - - NDDL3Parser_nameWithBaseDomain_return nameWithBaseDomain43; - #undef RETURN_TYPE_nameWithBaseDomain43 - #define RETURN_TYPE_nameWithBaseDomain43 NDDL3Parser_nameWithBaseDomain_return - - NDDL3Parser_nameWithBaseDomain_return nameWithBaseDomain45; - #undef RETURN_TYPE_nameWithBaseDomain45 - #define RETURN_TYPE_nameWithBaseDomain45 NDDL3Parser_nameWithBaseDomain_return - - pANTLR3_BASE_TREE string_literal41_tree; - pANTLR3_BASE_TREE char_literal44_tree; - pANTLR3_BASE_TREE char_literal46_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_40; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_34; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_37; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_type; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_nameWithBaseDomain; - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal41 = NULL; - char_literal44 = NULL; - char_literal46 = NULL; - type42.tree = NULL; - - nameWithBaseDomain43.tree = NULL; - - nameWithBaseDomain45.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal41_tree = NULL; - char_literal44_tree = NULL; - char_literal46_tree = NULL; - - stream_40 = NULL; - #define CREATE_stream_40 if (stream_40 == NULL) {stream_40 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 40"); } - stream_34 = NULL; - #define CREATE_stream_34 if (stream_34 == NULL) {stream_34 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 34"); } - stream_37 = NULL; - #define CREATE_stream_37 if (stream_37 == NULL) {stream_37 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 37"); } - stream_type = NULL; - #define CREATE_stream_type if (stream_type == NULL) {stream_type = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule type"); } - stream_nameWithBaseDomain = NULL; - #define CREATE_stream_nameWithBaseDomain if (stream_nameWithBaseDomain == NULL) {stream_nameWithBaseDomain = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule nameWithBaseDomain"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:145:5: ( ( 'filter' )? type nameWithBaseDomain ( ',' nameWithBaseDomain )* ';' -> ^( VARIABLE type nameWithBaseDomain ( nameWithBaseDomain )* ) ) - // NDDL/base/antlr/NDDL3.g:145:9: ( 'filter' )? type nameWithBaseDomain ( ',' nameWithBaseDomain )* ';' - { - - // NDDL/base/antlr/NDDL3.g:145:9: ( 'filter' )? - { - int alt8=2; - { - int LA8_0 = LA(1); - if ( (LA8_0 == 40) ) - { - alt8=1; - } - } - switch (alt8) - { - case 1: - // NDDL/base/antlr/NDDL3.g:145:10: 'filter' - { - string_literal41 = (pANTLR3_COMMON_TOKEN) MATCHT(40, &FOLLOW_40_in_variableDeclarations609); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_40; stream_40->add(stream_40, string_literal41, NULL); } - - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_type_in_variableDeclarations613); - type42=type(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_type; stream_type->add(stream_type, type42.tree, NULL); } - FOLLOWPUSH(FOLLOW_nameWithBaseDomain_in_variableDeclarations615); - nameWithBaseDomain43=nameWithBaseDomain(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_nameWithBaseDomain; stream_nameWithBaseDomain->add(stream_nameWithBaseDomain, nameWithBaseDomain43.tree, NULL); } - - // NDDL/base/antlr/NDDL3.g:145:45: ( ',' nameWithBaseDomain )* - - for (;;) - { - int alt9=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA9_0 = LA(1); - if ( (LA9_0 == 34) ) - { - alt9=1; - } - - } - switch (alt9) - { - case 1: - // NDDL/base/antlr/NDDL3.g:145:46: ',' nameWithBaseDomain - { - char_literal44 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_variableDeclarations618); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_34; stream_34->add(stream_34, char_literal44, NULL); } - - FOLLOWPUSH(FOLLOW_nameWithBaseDomain_in_variableDeclarations620); - nameWithBaseDomain45=nameWithBaseDomain(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_nameWithBaseDomain; stream_nameWithBaseDomain->add(stream_nameWithBaseDomain, nameWithBaseDomain45.tree, NULL); } - - } - break; - - default: - goto loop9; /* break out of the loop */ - break; - } - } - loop9: ; /* Jump out to here if this rule does not match */ - - char_literal46 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_variableDeclarations624); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal46, NULL); } - - - - /* AST REWRITE - * elements : nameWithBaseDomain, type, nameWithBaseDomain - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 146:13: -> ^( VARIABLE type nameWithBaseDomain ( nameWithBaseDomain )* ) - { - // NDDL/base/antlr/NDDL3.g:146:16: ^( VARIABLE type nameWithBaseDomain ( nameWithBaseDomain )* ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, VARIABLE, (pANTLR3_UINT8)"VARIABLE"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_type == NULL ? NULL : stream_type->nextTree(stream_type)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_nameWithBaseDomain == NULL ? NULL : stream_nameWithBaseDomain->nextTree(stream_nameWithBaseDomain)); - // NDDL/base/antlr/NDDL3.g:146:51: ( nameWithBaseDomain )* - { - while ( (stream_nameWithBaseDomain != NULL && stream_nameWithBaseDomain->hasNext(stream_nameWithBaseDomain)) ) - { - ADAPTOR->addChild(ADAPTOR, root_1, stream_nameWithBaseDomain == NULL ? NULL : stream_nameWithBaseDomain->nextTree(stream_nameWithBaseDomain)); - - } - if ( stream_nameWithBaseDomain != NULL) stream_nameWithBaseDomain->reset(stream_nameWithBaseDomain); - - } - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto rulevariableDeclarationsEx; /* Prevent compiler warnings */ - rulevariableDeclarationsEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_40 != NULL) stream_40->free(stream_40); - if (stream_34 != NULL) stream_34->free(stream_34); - if (stream_37 != NULL) stream_37->free(stream_37); - if (stream_type != NULL) stream_type->free(stream_type); - if (stream_nameWithBaseDomain != NULL) stream_nameWithBaseDomain->free(stream_nameWithBaseDomain); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end variableDeclarations */ - -/** - * $ANTLR start nameWithBaseDomain - * NDDL/base/antlr/NDDL3.g:149:1: nameWithBaseDomain : (variable= IDENT ( '(' value= initializer ')' )? | variable= IDENT '=' value= initializer ) ; - */ -static NDDL3Parser_nameWithBaseDomain_return -nameWithBaseDomain(pNDDL3Parser ctx) -{ - NDDL3Parser_nameWithBaseDomain_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN variable; - pANTLR3_COMMON_TOKEN char_literal47; - pANTLR3_COMMON_TOKEN char_literal48; - pANTLR3_COMMON_TOKEN char_literal49; - NDDL3Parser_initializer_return value; - #undef RETURN_TYPE_value - #define RETURN_TYPE_value NDDL3Parser_initializer_return - - pANTLR3_BASE_TREE variable_tree; - pANTLR3_BASE_TREE char_literal47_tree; - pANTLR3_BASE_TREE char_literal48_tree; - pANTLR3_BASE_TREE char_literal49_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - variable = NULL; - char_literal47 = NULL; - char_literal48 = NULL; - char_literal49 = NULL; - value.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - variable_tree = NULL; - char_literal47_tree = NULL; - char_literal48_tree = NULL; - char_literal49_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:150:5: ( (variable= IDENT ( '(' value= initializer ')' )? | variable= IDENT '=' value= initializer ) ) - // NDDL/base/antlr/NDDL3.g:150:9: (variable= IDENT ( '(' value= initializer ')' )? | variable= IDENT '=' value= initializer ) - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - - // NDDL/base/antlr/NDDL3.g:150:9: (variable= IDENT ( '(' value= initializer ')' )? | variable= IDENT '=' value= initializer ) - { - int alt11=2; - - { - int LA11_0 = LA(1); - if ( (LA11_0 == IDENT) ) - { - - { - int LA11_1 = LA(2); - if ( (LA11_1 == 43) ) - { - alt11=2; - } - else if ( (LA11_1 == 34 || LA11_1 == 37 || LA11_1 == 41) ) - { - alt11=1; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 11; - EXCEPTION->state = 1; - - - goto rulenameWithBaseDomainEx; - } - } - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 11; - EXCEPTION->state = 0; - - - goto rulenameWithBaseDomainEx; - } - } - switch (alt11) - { - case 1: - // NDDL/base/antlr/NDDL3.g:150:13: variable= IDENT ( '(' value= initializer ')' )? - { - variable = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_nameWithBaseDomain676); - if (HASEXCEPTION()) - { - goto rulenameWithBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - variable_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, variable)); - ADAPTOR->addChild(ADAPTOR, root_0, variable_tree); - } - - // NDDL/base/antlr/NDDL3.g:150:28: ( '(' value= initializer ')' )? - { - int alt10=2; - { - int LA10_0 = LA(1); - if ( (LA10_0 == 41) ) - { - alt10=1; - } - } - switch (alt10) - { - case 1: - // NDDL/base/antlr/NDDL3.g:150:29: '(' value= initializer ')' - { - char_literal47 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_nameWithBaseDomain679); - if (HASEXCEPTION()) - { - goto rulenameWithBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal47_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal47)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal47_tree, root_0)); - } - FOLLOWPUSH(FOLLOW_initializer_in_nameWithBaseDomain684); - value=initializer(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenameWithBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, value.tree); - char_literal48 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_nameWithBaseDomain686); - if (HASEXCEPTION()) - { - goto rulenameWithBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - - } - break; - - } - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:151:13: variable= IDENT '=' value= initializer - { - variable = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_nameWithBaseDomain706); - if (HASEXCEPTION()) - { - goto rulenameWithBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - variable_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, variable)); - ADAPTOR->addChild(ADAPTOR, root_0, variable_tree); - } - char_literal49 = (pANTLR3_COMMON_TOKEN) MATCHT(43, &FOLLOW_43_in_nameWithBaseDomain708); - if (HASEXCEPTION()) - { - goto rulenameWithBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal49_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal49)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal49_tree, root_0)); - } - FOLLOWPUSH(FOLLOW_initializer_in_nameWithBaseDomain713); - value=initializer(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenameWithBaseDomainEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, value.tree); - - } - break; - - } - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulenameWithBaseDomainEx; /* Prevent compiler warnings */ - rulenameWithBaseDomainEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end nameWithBaseDomain */ - -/** - * $ANTLR start anyValue - * NDDL/base/antlr/NDDL3.g:155:1: anyValue : ( literalValue | baseDomain | qualified ); - */ -static NDDL3Parser_anyValue_return -anyValue(pNDDL3Parser ctx) -{ - NDDL3Parser_anyValue_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_literalValue_return literalValue50; - #undef RETURN_TYPE_literalValue50 - #define RETURN_TYPE_literalValue50 NDDL3Parser_literalValue_return - - NDDL3Parser_baseDomain_return baseDomain51; - #undef RETURN_TYPE_baseDomain51 - #define RETURN_TYPE_baseDomain51 NDDL3Parser_baseDomain_return - - NDDL3Parser_qualified_return qualified52; - #undef RETURN_TYPE_qualified52 - #define RETURN_TYPE_qualified52 NDDL3Parser_qualified_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - literalValue50.tree = NULL; - - baseDomain51.tree = NULL; - - qualified52.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:156:5: ( literalValue | baseDomain | qualified ) - - ANTLR3_UINT32 alt12; - - alt12=3; - - switch ( LA(1) ) - { - case INT: - case FLOAT: - case STRING: - case 72: - case 102: - case 103: - case 104: - case 105: - case 106: - case 107: - { - alt12=1; - } - break; - case 33: - case 38: - { - alt12=2; - } - break; - case IDENT: - case 45: - { - alt12=3; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 12; - EXCEPTION->state = 0; - - - goto ruleanyValueEx; - } - - switch (alt12) - { - case 1: - // NDDL/base/antlr/NDDL3.g:156:9: literalValue - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_literalValue_in_anyValue742); - literalValue50=literalValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleanyValueEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, literalValue50.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:157:9: baseDomain - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_baseDomain_in_anyValue752); - baseDomain51=baseDomain(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleanyValueEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, baseDomain51.tree); - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:158:9: qualified - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_qualified_in_anyValue762); - qualified52=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleanyValueEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, qualified52.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleanyValueEx; /* Prevent compiler warnings */ - ruleanyValueEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end anyValue */ - -/** - * $ANTLR start allocation - * NDDL/base/antlr/NDDL3.g:161:1: allocation : 'new' constructorInvocation ; - */ -static NDDL3Parser_allocation_return -allocation(pNDDL3Parser ctx) -{ - NDDL3Parser_allocation_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal53; - NDDL3Parser_constructorInvocation_return constructorInvocation54; - #undef RETURN_TYPE_constructorInvocation54 - #define RETURN_TYPE_constructorInvocation54 NDDL3Parser_constructorInvocation_return - - pANTLR3_BASE_TREE string_literal53_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal53 = NULL; - constructorInvocation54.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal53_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:162:5: ( 'new' constructorInvocation ) - // NDDL/base/antlr/NDDL3.g:162:9: 'new' constructorInvocation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - string_literal53 = (pANTLR3_COMMON_TOKEN) MATCHT(44, &FOLLOW_44_in_allocation781); - if (HASEXCEPTION()) - { - goto ruleallocationEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_constructorInvocation_in_allocation784); - constructorInvocation54=constructorInvocation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleallocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constructorInvocation54.tree); - - } - - } - - - // This is where rules clean up and exit - // - goto ruleallocationEx; /* Prevent compiler warnings */ - ruleallocationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end allocation */ - -/** - * $ANTLR start constructorInvocation - * NDDL/base/antlr/NDDL3.g:165:1: constructorInvocation : IDENT variableArgumentList -> ^( CONSTRUCTOR_INVOCATION IDENT variableArgumentList ) ; - */ -static NDDL3Parser_constructorInvocation_return -constructorInvocation(pNDDL3Parser ctx) -{ - NDDL3Parser_constructorInvocation_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN IDENT55; - NDDL3Parser_variableArgumentList_return variableArgumentList56; - #undef RETURN_TYPE_variableArgumentList56 - #define RETURN_TYPE_variableArgumentList56 NDDL3Parser_variableArgumentList_return - - pANTLR3_BASE_TREE IDENT55_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_IDENT; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_variableArgumentList; - /* Initialize rule variables - */ - - - root_0 = NULL; - - IDENT55 = NULL; - variableArgumentList56.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - IDENT55_tree = NULL; - - stream_IDENT = NULL; - #define CREATE_stream_IDENT if (stream_IDENT == NULL) {stream_IDENT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token IDENT"); } - stream_variableArgumentList = NULL; - #define CREATE_stream_variableArgumentList if (stream_variableArgumentList == NULL) {stream_variableArgumentList = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule variableArgumentList"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:166:5: ( IDENT variableArgumentList -> ^( CONSTRUCTOR_INVOCATION IDENT variableArgumentList ) ) - // NDDL/base/antlr/NDDL3.g:166:9: IDENT variableArgumentList - { - IDENT55 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_constructorInvocation803); - if (HASEXCEPTION()) - { - goto ruleconstructorInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, IDENT55, NULL); } - - FOLLOWPUSH(FOLLOW_variableArgumentList_in_constructorInvocation805); - variableArgumentList56=variableArgumentList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_variableArgumentList; stream_variableArgumentList->add(stream_variableArgumentList, variableArgumentList56.tree, NULL); } - - - /* AST REWRITE - * elements : variableArgumentList, IDENT - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 167:13: -> ^( CONSTRUCTOR_INVOCATION IDENT variableArgumentList ) - { - // NDDL/base/antlr/NDDL3.g:167:16: ^( CONSTRUCTOR_INVOCATION IDENT variableArgumentList ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, CONSTRUCTOR_INVOCATION, (pANTLR3_UINT8)"CONSTRUCTOR_INVOCATION"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_IDENT == NULL ? NULL : stream_IDENT->nextNode(stream_IDENT)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_variableArgumentList == NULL ? NULL : stream_variableArgumentList->nextTree(stream_variableArgumentList)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorInvocationEx; /* Prevent compiler warnings */ - ruleconstructorInvocationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_IDENT != NULL) stream_IDENT->free(stream_IDENT); - if (stream_variableArgumentList != NULL) stream_variableArgumentList->free(stream_variableArgumentList); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end constructorInvocation */ - -/** - * $ANTLR start qualified - * NDDL/base/antlr/NDDL3.g:170:1: qualified : ( 'this' | IDENT ) ( '.' IDENT )* ; - */ -static NDDL3Parser_qualified_return -qualified(pNDDL3Parser ctx) -{ - NDDL3Parser_qualified_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set57; - pANTLR3_COMMON_TOKEN char_literal58; - pANTLR3_COMMON_TOKEN IDENT59; - - pANTLR3_BASE_TREE set57_tree; - pANTLR3_BASE_TREE char_literal58_tree; - pANTLR3_BASE_TREE IDENT59_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set57 = NULL; - char_literal58 = NULL; - IDENT59 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - set57_tree = NULL; - char_literal58_tree = NULL; - IDENT59_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:171:5: ( ( 'this' | IDENT ) ( '.' IDENT )* ) - // NDDL/base/antlr/NDDL3.g:171:9: ( 'this' | IDENT ) ( '.' IDENT )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - set57=(pANTLR3_COMMON_TOKEN)LT(1); - if ( LA(1) == IDENT || LA(1) == 45 ) - { - CONSUME(); - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set57))); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_qualified846; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_qualified846); goto rulequalifiedEx; - } - - - // NDDL/base/antlr/NDDL3.g:171:26: ( '.' IDENT )* - - for (;;) - { - int alt13=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA13_0 = LA(1); - if ( (LA13_0 == 46) ) - { - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA13_2 = LA(2); - if ( (LA13_2 == IDENT) ) - { - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA13_3 = LA(3); - if ( (LA13_3 == IDENT || ((LA13_3 >= 34) && (LA13_3 <= 35)) || LA13_3 == 37 || ((LA13_3 >= 42) && (LA13_3 <= 43)) || ((LA13_3 >= 46) && (LA13_3 <= 47)) || LA13_3 == 62 || ((LA13_3 >= 64) && (LA13_3 <= 74))) ) - { - alt13=1; - } - - } - } - - } - } - - } - switch (alt13) - { - case 1: - // NDDL/base/antlr/NDDL3.g:171:27: '.' IDENT - { - char_literal58 = (pANTLR3_COMMON_TOKEN) MATCHT(46, &FOLLOW_46_in_qualified855); - if (HASEXCEPTION()) - { - goto rulequalifiedEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal58_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal58)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal58_tree, root_0)); - } - IDENT59 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_qualified858); - if (HASEXCEPTION()) - { - goto rulequalifiedEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT59_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT59)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT59_tree); - } - - } - break; - - default: - goto loop13; /* break out of the loop */ - break; - } - } - loop13: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulequalifiedEx; /* Prevent compiler warnings */ - rulequalifiedEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end qualified */ - -/** - * $ANTLR start assignment - * NDDL/base/antlr/NDDL3.g:174:1: assignment : qualified ( 'in' | '=' ) initializer ';' -> ^( '=' qualified initializer ) ; - */ -static NDDL3Parser_assignment_return -assignment(pNDDL3Parser ctx) -{ - NDDL3Parser_assignment_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal61; - pANTLR3_COMMON_TOKEN char_literal62; - pANTLR3_COMMON_TOKEN char_literal64; - NDDL3Parser_qualified_return qualified60; - #undef RETURN_TYPE_qualified60 - #define RETURN_TYPE_qualified60 NDDL3Parser_qualified_return - - NDDL3Parser_initializer_return initializer63; - #undef RETURN_TYPE_initializer63 - #define RETURN_TYPE_initializer63 NDDL3Parser_initializer_return - - pANTLR3_BASE_TREE string_literal61_tree; - pANTLR3_BASE_TREE char_literal62_tree; - pANTLR3_BASE_TREE char_literal64_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_43; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_47; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_37; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_qualified; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_initializer; - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal61 = NULL; - char_literal62 = NULL; - char_literal64 = NULL; - qualified60.tree = NULL; - - initializer63.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal61_tree = NULL; - char_literal62_tree = NULL; - char_literal64_tree = NULL; - - stream_43 = NULL; - #define CREATE_stream_43 if (stream_43 == NULL) {stream_43 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 43"); } - stream_47 = NULL; - #define CREATE_stream_47 if (stream_47 == NULL) {stream_47 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 47"); } - stream_37 = NULL; - #define CREATE_stream_37 if (stream_37 == NULL) {stream_37 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 37"); } - stream_qualified = NULL; - #define CREATE_stream_qualified if (stream_qualified == NULL) {stream_qualified = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule qualified"); } - stream_initializer = NULL; - #define CREATE_stream_initializer if (stream_initializer == NULL) {stream_initializer = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule initializer"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:175:5: ( qualified ( 'in' | '=' ) initializer ';' -> ^( '=' qualified initializer ) ) - // NDDL/base/antlr/NDDL3.g:175:9: qualified ( 'in' | '=' ) initializer ';' - { - FOLLOWPUSH(FOLLOW_qualified_in_assignment879); - qualified60=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_qualified; stream_qualified->add(stream_qualified, qualified60.tree, NULL); } - - // NDDL/base/antlr/NDDL3.g:175:19: ( 'in' | '=' ) - { - int alt14=2; - - { - int LA14_0 = LA(1); - if ( (LA14_0 == 47) ) - { - alt14=1; - } - else if ( (LA14_0 == 43) ) - { - alt14=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 14; - EXCEPTION->state = 0; - - - goto ruleassignmentEx; - } - } - switch (alt14) - { - case 1: - // NDDL/base/antlr/NDDL3.g:175:20: 'in' - { - string_literal61 = (pANTLR3_COMMON_TOKEN) MATCHT(47, &FOLLOW_47_in_assignment882); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_47; stream_47->add(stream_47, string_literal61, NULL); } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:175:27: '=' - { - char_literal62 = (pANTLR3_COMMON_TOKEN) MATCHT(43, &FOLLOW_43_in_assignment886); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_43; stream_43->add(stream_43, char_literal62, NULL); } - - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_initializer_in_assignment889); - initializer63=initializer(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_initializer; stream_initializer->add(stream_initializer, initializer63.tree, NULL); } - char_literal64 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_assignment891); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal64, NULL); } - - - - /* AST REWRITE - * elements : initializer, 43, qualified - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 175:48: -> ^( '=' qualified initializer ) - { - // NDDL/base/antlr/NDDL3.g:175:51: ^( '=' qualified initializer ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_43 == NULL ? NULL : stream_43->nextNode(stream_43), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_qualified == NULL ? NULL : stream_qualified->nextTree(stream_qualified)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_initializer == NULL ? NULL : stream_initializer->nextTree(stream_initializer)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto ruleassignmentEx; /* Prevent compiler warnings */ - ruleassignmentEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_43 != NULL) stream_43->free(stream_43); - if (stream_47 != NULL) stream_47->free(stream_47); - if (stream_37 != NULL) stream_37->free(stream_37); - if (stream_qualified != NULL) stream_qualified->free(stream_qualified); - if (stream_initializer != NULL) stream_initializer->free(stream_initializer); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end assignment */ - -/** - * $ANTLR start initializer - * NDDL/base/antlr/NDDL3.g:178:1: initializer : ( anyValue | allocation ); - */ -static NDDL3Parser_initializer_return -initializer(pNDDL3Parser ctx) -{ - NDDL3Parser_initializer_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_anyValue_return anyValue65; - #undef RETURN_TYPE_anyValue65 - #define RETURN_TYPE_anyValue65 NDDL3Parser_anyValue_return - - NDDL3Parser_allocation_return allocation66; - #undef RETURN_TYPE_allocation66 - #define RETURN_TYPE_allocation66 NDDL3Parser_allocation_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - anyValue65.tree = NULL; - - allocation66.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:179:5: ( anyValue | allocation ) - - ANTLR3_UINT32 alt15; - - alt15=2; - - - { - int LA15_0 = LA(1); - if ( (((LA15_0 >= IDENT) && (LA15_0 <= STRING)) || LA15_0 == 33 || LA15_0 == 38 || LA15_0 == 45 || LA15_0 == 72 || ((LA15_0 >= 102) && (LA15_0 <= 107))) ) - { - alt15=1; - } - else if ( (LA15_0 == 44) ) - { - alt15=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 15; - EXCEPTION->state = 0; - - - goto ruleinitializerEx; - } - } - switch (alt15) - { - case 1: - // NDDL/base/antlr/NDDL3.g:179:9: anyValue - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_anyValue_in_initializer924); - anyValue65=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleinitializerEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, anyValue65.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:180:9: allocation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_allocation_in_initializer934); - allocation66=allocation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleinitializerEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, allocation66.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleinitializerEx; /* Prevent compiler warnings */ - ruleinitializerEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end initializer */ - -/** - * $ANTLR start classDeclaration - * NDDL/base/antlr/NDDL3.g:183:1: classDeclaration : 'class' c= IDENT ( ( ( 'extends' x= IDENT )? classBlock ) -> ^( 'class' $c ( ^( 'extends' $x) )? classBlock ) | ';' -> ^( 'class' $c ';' ) ) ; - */ -static NDDL3Parser_classDeclaration_return -classDeclaration(pNDDL3Parser ctx) -{ - NDDL3Parser_classDeclaration_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN c; - pANTLR3_COMMON_TOKEN x; - pANTLR3_COMMON_TOKEN string_literal67; - pANTLR3_COMMON_TOKEN string_literal68; - pANTLR3_COMMON_TOKEN char_literal70; - NDDL3Parser_classBlock_return classBlock69; - #undef RETURN_TYPE_classBlock69 - #define RETURN_TYPE_classBlock69 NDDL3Parser_classBlock_return - - pANTLR3_BASE_TREE c_tree; - pANTLR3_BASE_TREE x_tree; - pANTLR3_BASE_TREE string_literal67_tree; - pANTLR3_BASE_TREE string_literal68_tree; - pANTLR3_BASE_TREE char_literal70_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_49; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_48; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_IDENT; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_37; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_classBlock; - /* Initialize rule variables - */ - - - root_0 = NULL; - - c = NULL; - x = NULL; - string_literal67 = NULL; - string_literal68 = NULL; - char_literal70 = NULL; - classBlock69.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - c_tree = NULL; - x_tree = NULL; - string_literal67_tree = NULL; - string_literal68_tree = NULL; - char_literal70_tree = NULL; - - stream_49 = NULL; - #define CREATE_stream_49 if (stream_49 == NULL) {stream_49 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 49"); } - stream_48 = NULL; - #define CREATE_stream_48 if (stream_48 == NULL) {stream_48 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 48"); } - stream_IDENT = NULL; - #define CREATE_stream_IDENT if (stream_IDENT == NULL) {stream_IDENT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token IDENT"); } - stream_37 = NULL; - #define CREATE_stream_37 if (stream_37 == NULL) {stream_37 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 37"); } - stream_classBlock = NULL; - #define CREATE_stream_classBlock if (stream_classBlock == NULL) {stream_classBlock = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule classBlock"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:184:2: ( 'class' c= IDENT ( ( ( 'extends' x= IDENT )? classBlock ) -> ^( 'class' $c ( ^( 'extends' $x) )? classBlock ) | ';' -> ^( 'class' $c ';' ) ) ) - // NDDL/base/antlr/NDDL3.g:184:4: 'class' c= IDENT ( ( ( 'extends' x= IDENT )? classBlock ) -> ^( 'class' $c ( ^( 'extends' $x) )? classBlock ) | ';' -> ^( 'class' $c ';' ) ) - { - string_literal67 = (pANTLR3_COMMON_TOKEN) MATCHT(48, &FOLLOW_48_in_classDeclaration956); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_48; stream_48->add(stream_48, string_literal67, NULL); } - - c = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_classDeclaration960); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, c, NULL); } - - - // NDDL/base/antlr/NDDL3.g:185:3: ( ( ( 'extends' x= IDENT )? classBlock ) -> ^( 'class' $c ( ^( 'extends' $x) )? classBlock ) | ';' -> ^( 'class' $c ';' ) ) - { - int alt17=2; - - { - int LA17_0 = LA(1); - if ( (LA17_0 == 33 || LA17_0 == 49) ) - { - alt17=1; - } - else if ( (LA17_0 == 37) ) - { - alt17=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 17; - EXCEPTION->state = 0; - - - goto ruleclassDeclarationEx; - } - } - switch (alt17) - { - case 1: - // NDDL/base/antlr/NDDL3.g:185:5: ( ( 'extends' x= IDENT )? classBlock ) - { - // NDDL/base/antlr/NDDL3.g:185:5: ( ( 'extends' x= IDENT )? classBlock ) - // NDDL/base/antlr/NDDL3.g:185:6: ( 'extends' x= IDENT )? classBlock - { - - // NDDL/base/antlr/NDDL3.g:185:6: ( 'extends' x= IDENT )? - { - int alt16=2; - { - int LA16_0 = LA(1); - if ( (LA16_0 == 49) ) - { - alt16=1; - } - } - switch (alt16) - { - case 1: - // NDDL/base/antlr/NDDL3.g:185:7: 'extends' x= IDENT - { - string_literal68 = (pANTLR3_COMMON_TOKEN) MATCHT(49, &FOLLOW_49_in_classDeclaration968); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_49; stream_49->add(stream_49, string_literal68, NULL); } - - x = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_classDeclaration972); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, x, NULL); } - - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_classBlock_in_classDeclaration976); - classBlock69=classBlock(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_classBlock; stream_classBlock->add(stream_classBlock, classBlock69.tree, NULL); } - - } - - - - /* AST REWRITE - * elements : classBlock, c, 49, x, 48 - * token labels : c, x - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_c; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_x; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_c=antlr3RewriteRuleTOKENStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token c", c); - stream_x=antlr3RewriteRuleTOKENStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token x", x); - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 186:11: -> ^( 'class' $c ( ^( 'extends' $x) )? classBlock ) - { - // NDDL/base/antlr/NDDL3.g:186:14: ^( 'class' $c ( ^( 'extends' $x) )? classBlock ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_48 == NULL ? NULL : stream_48->nextNode(stream_48), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_c == NULL ? NULL : stream_c->nextNode(stream_c)); - // NDDL/base/antlr/NDDL3.g:186:27: ( ^( 'extends' $x) )? - { - if ( (stream_49 != NULL && stream_49->hasNext(stream_49)) ||(stream_x != NULL && stream_x->hasNext(stream_x)) ) - { - // NDDL/base/antlr/NDDL3.g:186:27: ^( 'extends' $x) - { - pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_49 == NULL ? NULL : stream_49->nextNode(stream_49), root_2)); - - ADAPTOR->addChild(ADAPTOR, root_2, stream_x == NULL ? NULL : stream_x->nextNode(stream_x)); - - ADAPTOR->addChild(ADAPTOR, root_1, root_2); - } - - } - if ( stream_49 != NULL) stream_49->reset(stream_49); - if ( stream_x != NULL) stream_x->reset(stream_x); - - } - ADAPTOR->addChild(ADAPTOR, root_1, stream_classBlock == NULL ? NULL : stream_classBlock->nextTree(stream_classBlock)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_c != NULL) stream_c->free(stream_c); - if (stream_x != NULL) stream_x->free(stream_x); - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:187:5: ';' - { - char_literal70 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_classDeclaration1012); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal70, NULL); } - - - - /* AST REWRITE - * elements : c, 37, 48 - * token labels : c - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_c; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_c=antlr3RewriteRuleTOKENStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token c", c); - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 188:17: -> ^( 'class' $c ';' ) - { - // NDDL/base/antlr/NDDL3.g:188:20: ^( 'class' $c ';' ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_48 == NULL ? NULL : stream_48->nextNode(stream_48), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_c == NULL ? NULL : stream_c->nextNode(stream_c)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_37 == NULL ? NULL : stream_37->nextNode(stream_37)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_c != NULL) stream_c->free(stream_c); - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - break; - - } - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleclassDeclarationEx; /* Prevent compiler warnings */ - ruleclassDeclarationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_49 != NULL) stream_49->free(stream_49); - if (stream_48 != NULL) stream_48->free(stream_48); - if (stream_IDENT != NULL) stream_IDENT->free(stream_IDENT); - if (stream_37 != NULL) stream_37->free(stream_37); - if (stream_classBlock != NULL) stream_classBlock->free(stream_classBlock); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end classDeclaration */ - -/** - * $ANTLR start classBlock - * NDDL/base/antlr/NDDL3.g:192:1: classBlock : '{' ( classStatement )* '}' ; - */ -static NDDL3Parser_classBlock_return -classBlock(pNDDL3Parser ctx) -{ - NDDL3Parser_classBlock_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal71; - pANTLR3_COMMON_TOKEN char_literal73; - NDDL3Parser_classStatement_return classStatement72; - #undef RETURN_TYPE_classStatement72 - #define RETURN_TYPE_classStatement72 NDDL3Parser_classStatement_return - - pANTLR3_BASE_TREE char_literal71_tree; - pANTLR3_BASE_TREE char_literal73_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal71 = NULL; - char_literal73 = NULL; - classStatement72.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal71_tree = NULL; - char_literal73_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:193:2: ( '{' ( classStatement )* '}' ) - // NDDL/base/antlr/NDDL3.g:193:4: '{' ( classStatement )* '}' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal71 = (pANTLR3_COMMON_TOKEN) MATCHT(33, &FOLLOW_33_in_classBlock1055); - if (HASEXCEPTION()) - { - goto ruleclassBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal71_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal71)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal71_tree, root_0)); - } - - // NDDL/base/antlr/NDDL3.g:193:9: ( classStatement )* - - for (;;) - { - int alt18=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA18_0 = LA(1); - if ( (LA18_0 == IDENT || LA18_0 == 37 || LA18_0 == 40 || ((LA18_0 >= 50) && (LA18_0 <= 51)) || ((LA18_0 >= 53) && (LA18_0 <= 56))) ) - { - alt18=1; - } - - } - switch (alt18) - { - case 1: - // NDDL/base/antlr/NDDL3.g:193:9: classStatement - { - FOLLOWPUSH(FOLLOW_classStatement_in_classBlock1058); - classStatement72=classStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, classStatement72.tree); - - } - break; - - default: - goto loop18; /* break out of the loop */ - break; - } - } - loop18: ; /* Jump out to here if this rule does not match */ - - char_literal73 = (pANTLR3_COMMON_TOKEN) MATCHT(35, &FOLLOW_35_in_classBlock1061); - if (HASEXCEPTION()) - { - goto ruleclassBlockEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleclassBlockEx; /* Prevent compiler warnings */ - ruleclassBlockEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end classBlock */ - -/** - * $ANTLR start classStatement - * NDDL/base/antlr/NDDL3.g:196:1: classStatement : ( variableDeclarations | constructor | tokenType | noopstatement ); - */ -static NDDL3Parser_classStatement_return -classStatement(pNDDL3Parser ctx) -{ - NDDL3Parser_classStatement_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_variableDeclarations_return variableDeclarations74; - #undef RETURN_TYPE_variableDeclarations74 - #define RETURN_TYPE_variableDeclarations74 NDDL3Parser_variableDeclarations_return - - NDDL3Parser_constructor_return constructor75; - #undef RETURN_TYPE_constructor75 - #define RETURN_TYPE_constructor75 NDDL3Parser_constructor_return - - NDDL3Parser_tokenType_return tokenType76; - #undef RETURN_TYPE_tokenType76 - #define RETURN_TYPE_tokenType76 NDDL3Parser_tokenType_return - - NDDL3Parser_noopstatement_return noopstatement77; - #undef RETURN_TYPE_noopstatement77 - #define RETURN_TYPE_noopstatement77 NDDL3Parser_noopstatement_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - variableDeclarations74.tree = NULL; - - constructor75.tree = NULL; - - tokenType76.tree = NULL; - - noopstatement77.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:197:2: ( variableDeclarations | constructor | tokenType | noopstatement ) - - ANTLR3_UINT32 alt19; - - alt19=4; - - switch ( LA(1) ) - { - case 40: - case 53: - case 54: - case 55: - case 56: - { - alt19=1; - } - break; - case IDENT: - { - - { - int LA19_2 = LA(2); - if ( (LA19_2 == IDENT) ) - { - alt19=1; - } - else if ( (LA19_2 == 41) ) - { - alt19=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 19; - EXCEPTION->state = 2; - - - goto ruleclassStatementEx; - } - } - } - break; - case 50: - case 51: - { - alt19=3; - } - break; - case 37: - { - alt19=4; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 19; - EXCEPTION->state = 0; - - - goto ruleclassStatementEx; - } - - switch (alt19) - { - case 1: - // NDDL/base/antlr/NDDL3.g:197:4: variableDeclarations - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_variableDeclarations_in_classStatement1073); - variableDeclarations74=variableDeclarations(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, variableDeclarations74.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:198:4: constructor - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_constructor_in_classStatement1078); - constructor75=constructor(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constructor75.tree); - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:199:4: tokenType - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_tokenType_in_classStatement1083); - tokenType76=tokenType(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, tokenType76.tree); - - } - break; - case 4: - // NDDL/base/antlr/NDDL3.g:200:4: noopstatement - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_noopstatement_in_classStatement1088); - noopstatement77=noopstatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, noopstatement77.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleclassStatementEx; /* Prevent compiler warnings */ - ruleclassStatementEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end classStatement */ - -/** - * $ANTLR start constructor - * NDDL/base/antlr/NDDL3.g:203:1: constructor : IDENT constructorParameterList constructorBlock -> ^( CONSTRUCTOR IDENT constructorParameterList constructorBlock ) ; - */ -static NDDL3Parser_constructor_return -constructor(pNDDL3Parser ctx) -{ - NDDL3Parser_constructor_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN IDENT78; - NDDL3Parser_constructorParameterList_return constructorParameterList79; - #undef RETURN_TYPE_constructorParameterList79 - #define RETURN_TYPE_constructorParameterList79 NDDL3Parser_constructorParameterList_return - - NDDL3Parser_constructorBlock_return constructorBlock80; - #undef RETURN_TYPE_constructorBlock80 - #define RETURN_TYPE_constructorBlock80 NDDL3Parser_constructorBlock_return - - pANTLR3_BASE_TREE IDENT78_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_IDENT; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_constructorParameterList; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_constructorBlock; - /* Initialize rule variables - */ - - - root_0 = NULL; - - IDENT78 = NULL; - constructorParameterList79.tree = NULL; - - constructorBlock80.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - IDENT78_tree = NULL; - - stream_IDENT = NULL; - #define CREATE_stream_IDENT if (stream_IDENT == NULL) {stream_IDENT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token IDENT"); } - stream_constructorParameterList = NULL; - #define CREATE_stream_constructorParameterList if (stream_constructorParameterList == NULL) {stream_constructorParameterList = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule constructorParameterList"); } - stream_constructorBlock = NULL; - #define CREATE_stream_constructorBlock if (stream_constructorBlock == NULL) {stream_constructorBlock = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule constructorBlock"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:204:2: ( IDENT constructorParameterList constructorBlock -> ^( CONSTRUCTOR IDENT constructorParameterList constructorBlock ) ) - // NDDL/base/antlr/NDDL3.g:204:4: IDENT constructorParameterList constructorBlock - { - IDENT78 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_constructor1099); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, IDENT78, NULL); } - - FOLLOWPUSH(FOLLOW_constructorParameterList_in_constructor1101); - constructorParameterList79=constructorParameterList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_constructorParameterList; stream_constructorParameterList->add(stream_constructorParameterList, constructorParameterList79.tree, NULL); } - FOLLOWPUSH(FOLLOW_constructorBlock_in_constructor1103); - constructorBlock80=constructorBlock(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_constructorBlock; stream_constructorBlock->add(stream_constructorBlock, constructorBlock80.tree, NULL); } - - - /* AST REWRITE - * elements : constructorParameterList, constructorBlock, IDENT - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 205:4: -> ^( CONSTRUCTOR IDENT constructorParameterList constructorBlock ) - { - // NDDL/base/antlr/NDDL3.g:205:7: ^( CONSTRUCTOR IDENT constructorParameterList constructorBlock ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, CONSTRUCTOR, (pANTLR3_UINT8)"CONSTRUCTOR"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_IDENT == NULL ? NULL : stream_IDENT->nextNode(stream_IDENT)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_constructorParameterList == NULL ? NULL : stream_constructorParameterList->nextTree(stream_constructorParameterList)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_constructorBlock == NULL ? NULL : stream_constructorBlock->nextTree(stream_constructorBlock)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorEx; /* Prevent compiler warnings */ - ruleconstructorEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_IDENT != NULL) stream_IDENT->free(stream_IDENT); - if (stream_constructorParameterList != NULL) stream_constructorParameterList->free(stream_constructorParameterList); - if (stream_constructorBlock != NULL) stream_constructorBlock->free(stream_constructorBlock); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end constructor */ - -/** - * $ANTLR start constructorBlock - * NDDL/base/antlr/NDDL3.g:208:1: constructorBlock : '{' ( constructorStatement )* '}' ; - */ -static NDDL3Parser_constructorBlock_return -constructorBlock(pNDDL3Parser ctx) -{ - NDDL3Parser_constructorBlock_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal81; - pANTLR3_COMMON_TOKEN char_literal83; - NDDL3Parser_constructorStatement_return constructorStatement82; - #undef RETURN_TYPE_constructorStatement82 - #define RETURN_TYPE_constructorStatement82 NDDL3Parser_constructorStatement_return - - pANTLR3_BASE_TREE char_literal81_tree; - pANTLR3_BASE_TREE char_literal83_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal81 = NULL; - char_literal83 = NULL; - constructorStatement82.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal81_tree = NULL; - char_literal83_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:209:2: ( '{' ( constructorStatement )* '}' ) - // NDDL/base/antlr/NDDL3.g:209:4: '{' ( constructorStatement )* '}' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal81 = (pANTLR3_COMMON_TOKEN) MATCHT(33, &FOLLOW_33_in_constructorBlock1129); - if (HASEXCEPTION()) - { - goto ruleconstructorBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal81_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal81)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal81_tree, root_0)); - } - - // NDDL/base/antlr/NDDL3.g:209:9: ( constructorStatement )* - - for (;;) - { - int alt20=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA20_0 = LA(1); - if ( (LA20_0 == IDENT || LA20_0 == 37 || LA20_0 == 45 || LA20_0 == 75) ) - { - alt20=1; - } - - } - switch (alt20) - { - case 1: - // NDDL/base/antlr/NDDL3.g:209:9: constructorStatement - { - FOLLOWPUSH(FOLLOW_constructorStatement_in_constructorBlock1132); - constructorStatement82=constructorStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constructorStatement82.tree); - - } - break; - - default: - goto loop20; /* break out of the loop */ - break; - } - } - loop20: ; /* Jump out to here if this rule does not match */ - - char_literal83 = (pANTLR3_COMMON_TOKEN) MATCHT(35, &FOLLOW_35_in_constructorBlock1135); - if (HASEXCEPTION()) - { - goto ruleconstructorBlockEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorBlockEx; /* Prevent compiler warnings */ - ruleconstructorBlockEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end constructorBlock */ - -/** - * $ANTLR start constructorStatement - * NDDL/base/antlr/NDDL3.g:212:1: constructorStatement : ( assignment | superInvocation | noopstatement ); - */ -static NDDL3Parser_constructorStatement_return -constructorStatement(pNDDL3Parser ctx) -{ - NDDL3Parser_constructorStatement_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_assignment_return assignment84; - #undef RETURN_TYPE_assignment84 - #define RETURN_TYPE_assignment84 NDDL3Parser_assignment_return - - NDDL3Parser_superInvocation_return superInvocation85; - #undef RETURN_TYPE_superInvocation85 - #define RETURN_TYPE_superInvocation85 NDDL3Parser_superInvocation_return - - NDDL3Parser_noopstatement_return noopstatement86; - #undef RETURN_TYPE_noopstatement86 - #define RETURN_TYPE_noopstatement86 NDDL3Parser_noopstatement_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - assignment84.tree = NULL; - - superInvocation85.tree = NULL; - - noopstatement86.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:213:2: ( assignment | superInvocation | noopstatement ) - - ANTLR3_UINT32 alt21; - - alt21=3; - - switch ( LA(1) ) - { - case IDENT: - case 45: - { - alt21=1; - } - break; - case 75: - { - alt21=2; - } - break; - case 37: - { - alt21=3; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 21; - EXCEPTION->state = 0; - - - goto ruleconstructorStatementEx; - } - - switch (alt21) - { - case 1: - // NDDL/base/antlr/NDDL3.g:213:4: assignment - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_assignment_in_constructorStatement1147); - assignment84=assignment(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, assignment84.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:214:4: superInvocation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_superInvocation_in_constructorStatement1152); - superInvocation85=superInvocation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, superInvocation85.tree); - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:215:4: noopstatement - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_noopstatement_in_constructorStatement1157); - noopstatement86=noopstatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, noopstatement86.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleconstructorStatementEx; /* Prevent compiler warnings */ - ruleconstructorStatementEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end constructorStatement */ - -/** - * $ANTLR start constructorParameterList - * NDDL/base/antlr/NDDL3.g:218:1: constructorParameterList : '(' ( constructorParameters )? ')' ; - */ -static NDDL3Parser_constructorParameterList_return -constructorParameterList(pNDDL3Parser ctx) -{ - NDDL3Parser_constructorParameterList_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal87; - pANTLR3_COMMON_TOKEN char_literal89; - NDDL3Parser_constructorParameters_return constructorParameters88; - #undef RETURN_TYPE_constructorParameters88 - #define RETURN_TYPE_constructorParameters88 NDDL3Parser_constructorParameters_return - - pANTLR3_BASE_TREE char_literal87_tree; - pANTLR3_BASE_TREE char_literal89_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal87 = NULL; - char_literal89 = NULL; - constructorParameters88.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal87_tree = NULL; - char_literal89_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:219:2: ( '(' ( constructorParameters )? ')' ) - // NDDL/base/antlr/NDDL3.g:219:4: '(' ( constructorParameters )? ')' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal87 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_constructorParameterList1168); - if (HASEXCEPTION()) - { - goto ruleconstructorParameterListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal87_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal87)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal87_tree, root_0)); - } - - // NDDL/base/antlr/NDDL3.g:219:9: ( constructorParameters )? - { - int alt22=2; - { - int LA22_0 = LA(1); - if ( (LA22_0 == IDENT || ((LA22_0 >= 53) && (LA22_0 <= 56))) ) - { - alt22=1; - } - } - switch (alt22) - { - case 1: - // NDDL/base/antlr/NDDL3.g:219:9: constructorParameters - { - FOLLOWPUSH(FOLLOW_constructorParameters_in_constructorParameterList1171); - constructorParameters88=constructorParameters(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorParameterListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constructorParameters88.tree); - - } - break; - - } - } - char_literal89 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_constructorParameterList1174); - if (HASEXCEPTION()) - { - goto ruleconstructorParameterListEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorParameterListEx; /* Prevent compiler warnings */ - ruleconstructorParameterListEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end constructorParameterList */ - -/** - * $ANTLR start constructorParameters - * NDDL/base/antlr/NDDL3.g:222:1: constructorParameters : constructorParameter ( ',' constructorParameters )? ; - */ -static NDDL3Parser_constructorParameters_return -constructorParameters(pNDDL3Parser ctx) -{ - NDDL3Parser_constructorParameters_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal91; - NDDL3Parser_constructorParameter_return constructorParameter90; - #undef RETURN_TYPE_constructorParameter90 - #define RETURN_TYPE_constructorParameter90 NDDL3Parser_constructorParameter_return - - NDDL3Parser_constructorParameters_return constructorParameters92; - #undef RETURN_TYPE_constructorParameters92 - #define RETURN_TYPE_constructorParameters92 NDDL3Parser_constructorParameters_return - - pANTLR3_BASE_TREE char_literal91_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal91 = NULL; - constructorParameter90.tree = NULL; - - constructorParameters92.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal91_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:223:2: ( constructorParameter ( ',' constructorParameters )? ) - // NDDL/base/antlr/NDDL3.g:223:4: constructorParameter ( ',' constructorParameters )? - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_constructorParameter_in_constructorParameters1186); - constructorParameter90=constructorParameter(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorParametersEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constructorParameter90.tree); - - // NDDL/base/antlr/NDDL3.g:223:26: ( ',' constructorParameters )? - { - int alt23=2; - { - int LA23_0 = LA(1); - if ( (LA23_0 == 34) ) - { - alt23=1; - } - } - switch (alt23) - { - case 1: - // NDDL/base/antlr/NDDL3.g:223:27: ',' constructorParameters - { - char_literal91 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_constructorParameters1190); - if (HASEXCEPTION()) - { - goto ruleconstructorParametersEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_constructorParameters_in_constructorParameters1193); - constructorParameters92=constructorParameters(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorParametersEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constructorParameters92.tree); - - } - break; - - } - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorParametersEx; /* Prevent compiler warnings */ - ruleconstructorParametersEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end constructorParameters */ - -/** - * $ANTLR start constructorParameter - * NDDL/base/antlr/NDDL3.g:226:1: constructorParameter : type IDENT -> ^( VARIABLE IDENT type ) ; - */ -static NDDL3Parser_constructorParameter_return -constructorParameter(pNDDL3Parser ctx) -{ - NDDL3Parser_constructorParameter_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN IDENT94; - NDDL3Parser_type_return type93; - #undef RETURN_TYPE_type93 - #define RETURN_TYPE_type93 NDDL3Parser_type_return - - pANTLR3_BASE_TREE IDENT94_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_IDENT; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_type; - /* Initialize rule variables - */ - - - root_0 = NULL; - - IDENT94 = NULL; - type93.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - IDENT94_tree = NULL; - - stream_IDENT = NULL; - #define CREATE_stream_IDENT if (stream_IDENT == NULL) {stream_IDENT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token IDENT"); } - stream_type = NULL; - #define CREATE_stream_type if (stream_type == NULL) {stream_type = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule type"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:227:2: ( type IDENT -> ^( VARIABLE IDENT type ) ) - // NDDL/base/antlr/NDDL3.g:227:4: type IDENT - { - FOLLOWPUSH(FOLLOW_type_in_constructorParameter1206); - type93=type(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorParameterEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_type; stream_type->add(stream_type, type93.tree, NULL); } - IDENT94 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_constructorParameter1208); - if (HASEXCEPTION()) - { - goto ruleconstructorParameterEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, IDENT94, NULL); } - - - - /* AST REWRITE - * elements : IDENT, type - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 228:4: -> ^( VARIABLE IDENT type ) - { - // NDDL/base/antlr/NDDL3.g:228:7: ^( VARIABLE IDENT type ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, VARIABLE, (pANTLR3_UINT8)"VARIABLE"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_IDENT == NULL ? NULL : stream_IDENT->nextNode(stream_IDENT)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_type == NULL ? NULL : stream_type->nextTree(stream_type)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorParameterEx; /* Prevent compiler warnings */ - ruleconstructorParameterEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_IDENT != NULL) stream_IDENT->free(stream_IDENT); - if (stream_type != NULL) stream_type->free(stream_type); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end constructorParameter */ - -/** - * $ANTLR start tokenType - * NDDL/base/antlr/NDDL3.g:231:1: tokenType : ( 'predicate' | 'action' ) IDENT tokenBlock ; - */ -static NDDL3Parser_tokenType_return -tokenType(pNDDL3Parser ctx) -{ - NDDL3Parser_tokenType_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set95; - pANTLR3_COMMON_TOKEN IDENT96; - NDDL3Parser_tokenBlock_return tokenBlock97; - #undef RETURN_TYPE_tokenBlock97 - #define RETURN_TYPE_tokenBlock97 NDDL3Parser_tokenBlock_return - - pANTLR3_BASE_TREE set95_tree; - pANTLR3_BASE_TREE IDENT96_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set95 = NULL; - IDENT96 = NULL; - tokenBlock97.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - set95_tree = NULL; - IDENT96_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:232:2: ( ( 'predicate' | 'action' ) IDENT tokenBlock ) - // NDDL/base/antlr/NDDL3.g:232:4: ( 'predicate' | 'action' ) IDENT tokenBlock - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - set95=(pANTLR3_COMMON_TOKEN)LT(1); - set95=(pANTLR3_COMMON_TOKEN)LT(1); - if ( ((LA(1) >= 50) && (LA(1) <= 51)) ) - { - CONSUME(); - if ( BACKTRACKING==0 ) root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set95)), root_0)); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_tokenType1232; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_tokenType1232); goto ruletokenTypeEx; - } - - IDENT96 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_tokenType1241); - if (HASEXCEPTION()) - { - goto ruletokenTypeEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT96_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT96)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT96_tree); - } - FOLLOWPUSH(FOLLOW_tokenBlock_in_tokenType1243); - tokenBlock97=tokenBlock(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenTypeEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, tokenBlock97.tree); - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenTypeEx; /* Prevent compiler warnings */ - ruletokenTypeEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end tokenType */ - -/** - * $ANTLR start tokenBlock - * NDDL/base/antlr/NDDL3.g:235:1: tokenBlock : '{' ( tokenStatement )* '}' ; - */ -static NDDL3Parser_tokenBlock_return -tokenBlock(pNDDL3Parser ctx) -{ - NDDL3Parser_tokenBlock_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal98; - pANTLR3_COMMON_TOKEN char_literal100; - NDDL3Parser_tokenStatement_return tokenStatement99; - #undef RETURN_TYPE_tokenStatement99 - #define RETURN_TYPE_tokenStatement99 NDDL3Parser_tokenStatement_return - - pANTLR3_BASE_TREE char_literal98_tree; - pANTLR3_BASE_TREE char_literal100_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal98 = NULL; - char_literal100 = NULL; - tokenStatement99.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal98_tree = NULL; - char_literal100_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:236:2: ( '{' ( tokenStatement )* '}' ) - // NDDL/base/antlr/NDDL3.g:236:4: '{' ( tokenStatement )* '}' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal98 = (pANTLR3_COMMON_TOKEN) MATCHT(33, &FOLLOW_33_in_tokenBlock1255); - if (HASEXCEPTION()) - { - goto ruletokenBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal98_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal98)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal98_tree, root_0)); - } - - // NDDL/base/antlr/NDDL3.g:236:9: ( tokenStatement )* - - for (;;) - { - int alt24=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA24_0 = LA(1); - if ( (((LA24_0 >= IDENT) && (LA24_0 <= STRING)) || LA24_0 == 33 || LA24_0 == 38 || ((LA24_0 >= 40) && (LA24_0 <= 41)) || LA24_0 == 45 || ((LA24_0 >= 53) && (LA24_0 <= 56)) || LA24_0 == 63 || LA24_0 == 72 || ((LA24_0 >= 102) && (LA24_0 <= 107))) ) - { - alt24=1; - } - - } - switch (alt24) - { - case 1: - // NDDL/base/antlr/NDDL3.g:236:9: tokenStatement - { - FOLLOWPUSH(FOLLOW_tokenStatement_in_tokenBlock1258); - tokenStatement99=tokenStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, tokenStatement99.tree); - - } - break; - - default: - goto loop24; /* break out of the loop */ - break; - } - } - loop24: ; /* Jump out to here if this rule does not match */ - - char_literal100 = (pANTLR3_COMMON_TOKEN) MATCHT(35, &FOLLOW_35_in_tokenBlock1261); - if (HASEXCEPTION()) - { - goto ruletokenBlockEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenBlockEx; /* Prevent compiler warnings */ - ruletokenBlockEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end tokenBlock */ - -/** - * $ANTLR start tokenStatement - * NDDL/base/antlr/NDDL3.g:240:1: tokenStatement : ( variableDeclarations | constraintInstantiation | assignment ); - */ -static NDDL3Parser_tokenStatement_return -tokenStatement(pNDDL3Parser ctx) -{ - NDDL3Parser_tokenStatement_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_variableDeclarations_return variableDeclarations101; - #undef RETURN_TYPE_variableDeclarations101 - #define RETURN_TYPE_variableDeclarations101 NDDL3Parser_variableDeclarations_return - - NDDL3Parser_constraintInstantiation_return constraintInstantiation102; - #undef RETURN_TYPE_constraintInstantiation102 - #define RETURN_TYPE_constraintInstantiation102 NDDL3Parser_constraintInstantiation_return - - NDDL3Parser_assignment_return assignment103; - #undef RETURN_TYPE_assignment103 - #define RETURN_TYPE_assignment103 NDDL3Parser_assignment_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - variableDeclarations101.tree = NULL; - - constraintInstantiation102.tree = NULL; - - assignment103.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:241:2: ( variableDeclarations | constraintInstantiation | assignment ) - - ANTLR3_UINT32 alt25; - - alt25=3; - - alt25 = cdfa25.predict(ctx, RECOGNIZER, ISTREAM, &cdfa25); - if (HASEXCEPTION()) - { - goto ruletokenStatementEx; - } - if (HASFAILED()) - { - return retval; - } - switch (alt25) - { - case 1: - // NDDL/base/antlr/NDDL3.g:241:4: variableDeclarations - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_variableDeclarations_in_tokenStatement1274); - variableDeclarations101=variableDeclarations(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, variableDeclarations101.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:242:4: constraintInstantiation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_constraintInstantiation_in_tokenStatement1279); - constraintInstantiation102=constraintInstantiation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constraintInstantiation102.tree); - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:243:4: assignment - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_assignment_in_tokenStatement1284); - assignment103=assignment(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, assignment103.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruletokenStatementEx; /* Prevent compiler warnings */ - ruletokenStatementEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end tokenStatement */ - -/** - * $ANTLR start rule - * NDDL/base/antlr/NDDL3.g:246:1: rule : IDENT '::' IDENT ruleBlock ; - */ -static NDDL3Parser_rule_return -rule(pNDDL3Parser ctx) -{ - NDDL3Parser_rule_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN IDENT104; - pANTLR3_COMMON_TOKEN string_literal105; - pANTLR3_COMMON_TOKEN IDENT106; - NDDL3Parser_ruleBlock_return ruleBlock107; - #undef RETURN_TYPE_ruleBlock107 - #define RETURN_TYPE_ruleBlock107 NDDL3Parser_ruleBlock_return - - pANTLR3_BASE_TREE IDENT104_tree; - pANTLR3_BASE_TREE string_literal105_tree; - pANTLR3_BASE_TREE IDENT106_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - IDENT104 = NULL; - string_literal105 = NULL; - IDENT106 = NULL; - ruleBlock107.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - IDENT104_tree = NULL; - string_literal105_tree = NULL; - IDENT106_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:247:5: ( IDENT '::' IDENT ruleBlock ) - // NDDL/base/antlr/NDDL3.g:247:7: IDENT '::' IDENT ruleBlock - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - IDENT104 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_rule1298); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT104_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT104)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT104_tree); - } - string_literal105 = (pANTLR3_COMMON_TOKEN) MATCHT(52, &FOLLOW_52_in_rule1300); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal105_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal105)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal105_tree, root_0)); - } - IDENT106 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_rule1303); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT106_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT106)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT106_tree); - } - FOLLOWPUSH(FOLLOW_ruleBlock_in_rule1305); - ruleBlock107=ruleBlock(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, ruleBlock107.tree); - - } - - } - - - // This is where rules clean up and exit - // - goto ruleruleEx; /* Prevent compiler warnings */ - ruleruleEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end rule */ - -/** - * $ANTLR start ruleBlock - * NDDL/base/antlr/NDDL3.g:250:1: ruleBlock : ( '{' ( ruleStatement )* '}' | ruleStatement -> ^( '{' ruleStatement ) ); - */ -static NDDL3Parser_ruleBlock_return -ruleBlock(pNDDL3Parser ctx) -{ - NDDL3Parser_ruleBlock_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal108; - pANTLR3_COMMON_TOKEN char_literal110; - NDDL3Parser_ruleStatement_return ruleStatement109; - #undef RETURN_TYPE_ruleStatement109 - #define RETURN_TYPE_ruleStatement109 NDDL3Parser_ruleStatement_return - - NDDL3Parser_ruleStatement_return ruleStatement111; - #undef RETURN_TYPE_ruleStatement111 - #define RETURN_TYPE_ruleStatement111 NDDL3Parser_ruleStatement_return - - pANTLR3_BASE_TREE char_literal108_tree; - pANTLR3_BASE_TREE char_literal110_tree; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_ruleStatement; - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal108 = NULL; - char_literal110 = NULL; - ruleStatement109.tree = NULL; - - ruleStatement111.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal108_tree = NULL; - char_literal110_tree = NULL; - - stream_ruleStatement = NULL; - #define CREATE_stream_ruleStatement if (stream_ruleStatement == NULL) {stream_ruleStatement = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule ruleStatement"); } - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:251:2: ( '{' ( ruleStatement )* '}' | ruleStatement -> ^( '{' ruleStatement ) ) - - ANTLR3_UINT32 alt27; - - alt27=2; - - alt27 = cdfa27.predict(ctx, RECOGNIZER, ISTREAM, &cdfa27); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - if (HASFAILED()) - { - return retval; - } - switch (alt27) - { - case 1: - // NDDL/base/antlr/NDDL3.g:251:4: '{' ( ruleStatement )* '}' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal108 = (pANTLR3_COMMON_TOKEN) MATCHT(33, &FOLLOW_33_in_ruleBlock1316); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal108_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal108)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal108_tree, root_0)); - } - - // NDDL/base/antlr/NDDL3.g:251:9: ( ruleStatement )* - - for (;;) - { - int alt26=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA26_0 = LA(1); - if ( (((LA26_0 >= IDENT) && (LA26_0 <= STRING)) || LA26_0 == 33 || ((LA26_0 >= 37) && (LA26_0 <= 38)) || ((LA26_0 >= 40) && (LA26_0 <= 41)) || LA26_0 == 45 || ((LA26_0 >= 53) && (LA26_0 <= 56)) || LA26_0 == 63 || LA26_0 == 72 || LA26_0 == 76 || ((LA26_0 >= 78) && (LA26_0 <= 107))) ) - { - alt26=1; - } - - } - switch (alt26) - { - case 1: - // NDDL/base/antlr/NDDL3.g:251:9: ruleStatement - { - FOLLOWPUSH(FOLLOW_ruleStatement_in_ruleBlock1319); - ruleStatement109=ruleStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, ruleStatement109.tree); - - } - break; - - default: - goto loop26; /* break out of the loop */ - break; - } - } - loop26: ; /* Jump out to here if this rule does not match */ - - char_literal110 = (pANTLR3_COMMON_TOKEN) MATCHT(35, &FOLLOW_35_in_ruleBlock1322); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - if (HASFAILED()) - { - return retval; - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:252:4: ruleStatement - { - FOLLOWPUSH(FOLLOW_ruleStatement_in_ruleBlock1328); - ruleStatement111=ruleStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_ruleStatement; stream_ruleStatement->add(stream_ruleStatement, ruleStatement111.tree, NULL); } - - - /* AST REWRITE - * elements : ruleStatement, 33 - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 252:18: -> ^( '{' ruleStatement ) - { - // NDDL/base/antlr/NDDL3.g:252:21: ^( '{' ruleStatement ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, 33, (pANTLR3_UINT8)"33"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_ruleStatement == NULL ? NULL : stream_ruleStatement->nextTree(stream_ruleStatement)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleruleBlockEx; /* Prevent compiler warnings */ - ruleruleBlockEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_ruleStatement != NULL) stream_ruleStatement->free(stream_ruleStatement); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end ruleBlock */ - -/** - * $ANTLR start ruleStatement - * NDDL/base/antlr/NDDL3.g:255:1: ruleStatement : ( relation | variableDeclarations | constraintInstantiation | flowControl | noopstatement ); - */ -static NDDL3Parser_ruleStatement_return -ruleStatement(pNDDL3Parser ctx) -{ - NDDL3Parser_ruleStatement_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_relation_return relation112; - #undef RETURN_TYPE_relation112 - #define RETURN_TYPE_relation112 NDDL3Parser_relation_return - - NDDL3Parser_variableDeclarations_return variableDeclarations113; - #undef RETURN_TYPE_variableDeclarations113 - #define RETURN_TYPE_variableDeclarations113 NDDL3Parser_variableDeclarations_return - - NDDL3Parser_constraintInstantiation_return constraintInstantiation114; - #undef RETURN_TYPE_constraintInstantiation114 - #define RETURN_TYPE_constraintInstantiation114 NDDL3Parser_constraintInstantiation_return - - NDDL3Parser_flowControl_return flowControl115; - #undef RETURN_TYPE_flowControl115 - #define RETURN_TYPE_flowControl115 NDDL3Parser_flowControl_return - - NDDL3Parser_noopstatement_return noopstatement116; - #undef RETURN_TYPE_noopstatement116 - #define RETURN_TYPE_noopstatement116 NDDL3Parser_noopstatement_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - relation112.tree = NULL; - - variableDeclarations113.tree = NULL; - - constraintInstantiation114.tree = NULL; - - flowControl115.tree = NULL; - - noopstatement116.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:256:2: ( relation | variableDeclarations | constraintInstantiation | flowControl | noopstatement ) - - ANTLR3_UINT32 alt28; - - alt28=5; - - switch ( LA(1) ) - { - case IDENT: - { - switch ( LA(2) ) - { - case 37: - case 41: - case 46: - case 62: - case 64: - case 65: - case 66: - case 67: - case 68: - case 69: - case 70: - case 71: - case 72: - case 73: - case 74: - { - alt28=3; - } - break; - case 79: - case 80: - case 81: - case 82: - case 83: - case 84: - case 85: - case 86: - case 87: - case 88: - case 89: - case 90: - case 91: - case 92: - case 93: - case 94: - case 95: - case 96: - case 97: - case 98: - case 99: - case 100: - case 101: - { - alt28=1; - } - break; - case IDENT: - { - alt28=2; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 28; - EXCEPTION->state = 1; - - - goto ruleruleStatementEx; - } - - } - break; - case 79: - case 80: - case 81: - case 82: - case 83: - case 84: - case 85: - case 86: - case 87: - case 88: - case 89: - case 90: - case 91: - case 92: - case 93: - case 94: - case 95: - case 96: - case 97: - case 98: - case 99: - case 100: - case 101: - { - alt28=1; - } - break; - case 40: - case 53: - case 54: - case 55: - case 56: - { - alt28=2; - } - break; - case 45: - { - - { - int LA28_4 = LA(2); - if ( (((LA28_4 >= 79) && (LA28_4 <= 101))) ) - { - alt28=1; - } - else if ( (LA28_4 == 37 || LA28_4 == 46 || LA28_4 == 62 || ((LA28_4 >= 64) && (LA28_4 <= 74))) ) - { - alt28=3; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 28; - EXCEPTION->state = 4; - - - goto ruleruleStatementEx; - } - } - } - break; - case INT: - case FLOAT: - case STRING: - case 33: - case 38: - case 41: - case 63: - case 72: - case 102: - case 103: - case 104: - case 105: - case 106: - case 107: - { - alt28=3; - } - break; - case 76: - case 78: - { - alt28=4; - } - break; - case 37: - { - alt28=5; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 28; - EXCEPTION->state = 0; - - - goto ruleruleStatementEx; - } - - switch (alt28) - { - case 1: - // NDDL/base/antlr/NDDL3.g:256:4: relation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_relation_in_ruleStatement1347); - relation112=relation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, relation112.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:257:4: variableDeclarations - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_variableDeclarations_in_ruleStatement1352); - variableDeclarations113=variableDeclarations(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, variableDeclarations113.tree); - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:258:4: constraintInstantiation - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_constraintInstantiation_in_ruleStatement1357); - constraintInstantiation114=constraintInstantiation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, constraintInstantiation114.tree); - - } - break; - case 4: - // NDDL/base/antlr/NDDL3.g:259:4: flowControl - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_flowControl_in_ruleStatement1362); - flowControl115=flowControl(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, flowControl115.tree); - - } - break; - case 5: - // NDDL/base/antlr/NDDL3.g:260:4: noopstatement - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_noopstatement_in_ruleStatement1367); - noopstatement116=noopstatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, noopstatement116.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleruleStatementEx; /* Prevent compiler warnings */ - ruleruleStatementEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end ruleStatement */ - -/** - * $ANTLR start type - * NDDL/base/antlr/NDDL3.g:263:1: type : ( 'int' | 'float' | 'bool' | 'string' | IDENT ); - */ -static NDDL3Parser_type_return -type(pNDDL3Parser ctx) -{ - NDDL3Parser_type_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set117; - - pANTLR3_BASE_TREE set117_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set117 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - set117_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:264:5: ( 'int' | 'float' | 'bool' | 'string' | IDENT ) - // NDDL/base/antlr/NDDL3.g: - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - set117=(pANTLR3_COMMON_TOKEN)LT(1); - if ( LA(1) == IDENT || ((LA(1) >= 53) && (LA(1) <= 56)) ) - { - CONSUME(); - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set117))); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_type0; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_type0); goto ruletypeEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruletypeEx; /* Prevent compiler warnings */ - ruletypeEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end type */ - -/** - * $ANTLR start relation - * NDDL/base/antlr/NDDL3.g:271:1: relation : (token= tokenVarRef )? temporalRelation tokenInstanceList ';' -> ^( TOKEN_RELATION ( $token)? temporalRelation tokenInstanceList ) ; - */ -static NDDL3Parser_relation_return -relation(pNDDL3Parser ctx) -{ - NDDL3Parser_relation_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal120; - NDDL3Parser_tokenVarRef_return token; - #undef RETURN_TYPE_token - #define RETURN_TYPE_token NDDL3Parser_tokenVarRef_return - - NDDL3Parser_temporalRelation_return temporalRelation118; - #undef RETURN_TYPE_temporalRelation118 - #define RETURN_TYPE_temporalRelation118 NDDL3Parser_temporalRelation_return - - NDDL3Parser_tokenInstanceList_return tokenInstanceList119; - #undef RETURN_TYPE_tokenInstanceList119 - #define RETURN_TYPE_tokenInstanceList119 NDDL3Parser_tokenInstanceList_return - - pANTLR3_BASE_TREE char_literal120_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_37; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_temporalRelation; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_tokenVarRef; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_tokenInstanceList; - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal120 = NULL; - token.tree = NULL; - - temporalRelation118.tree = NULL; - - tokenInstanceList119.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal120_tree = NULL; - - stream_37 = NULL; - #define CREATE_stream_37 if (stream_37 == NULL) {stream_37 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 37"); } - stream_temporalRelation = NULL; - #define CREATE_stream_temporalRelation if (stream_temporalRelation == NULL) {stream_temporalRelation = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule temporalRelation"); } - stream_tokenVarRef = NULL; - #define CREATE_stream_tokenVarRef if (stream_tokenVarRef == NULL) {stream_tokenVarRef = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule tokenVarRef"); } - stream_tokenInstanceList = NULL; - #define CREATE_stream_tokenInstanceList if (stream_tokenInstanceList == NULL) {stream_tokenInstanceList = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule tokenInstanceList"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:272:5: ( (token= tokenVarRef )? temporalRelation tokenInstanceList ';' -> ^( TOKEN_RELATION ( $token)? temporalRelation tokenInstanceList ) ) - // NDDL/base/antlr/NDDL3.g:272:7: (token= tokenVarRef )? temporalRelation tokenInstanceList ';' - { - - // NDDL/base/antlr/NDDL3.g:272:12: (token= tokenVarRef )? - { - int alt29=2; - { - int LA29_0 = LA(1); - if ( (LA29_0 == IDENT || LA29_0 == 45) ) - { - alt29=1; - } - } - switch (alt29) - { - case 1: - // NDDL/base/antlr/NDDL3.g:272:12: token= tokenVarRef - { - FOLLOWPUSH(FOLLOW_tokenVarRef_in_relation1418); - token=tokenVarRef(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_tokenVarRef; stream_tokenVarRef->add(stream_tokenVarRef, token.tree, NULL); } - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_temporalRelation_in_relation1421); - temporalRelation118=temporalRelation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_temporalRelation; stream_temporalRelation->add(stream_temporalRelation, temporalRelation118.tree, NULL); } - FOLLOWPUSH(FOLLOW_tokenInstanceList_in_relation1423); - tokenInstanceList119=tokenInstanceList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_tokenInstanceList; stream_tokenInstanceList->add(stream_tokenInstanceList, tokenInstanceList119.tree, NULL); } - char_literal120 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_relation1425); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal120, NULL); } - - - - /* AST REWRITE - * elements : temporalRelation, tokenInstanceList, token - * token labels : - * rule labels : retval, token - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_token; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - stream_token=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token token", token.tree != NULL ? token.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 273:4: -> ^( TOKEN_RELATION ( $token)? temporalRelation tokenInstanceList ) - { - // NDDL/base/antlr/NDDL3.g:273:7: ^( TOKEN_RELATION ( $token)? temporalRelation tokenInstanceList ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, TOKEN_RELATION, (pANTLR3_UINT8)"TOKEN_RELATION"), root_1)); - - // NDDL/base/antlr/NDDL3.g:273:24: ( $token)? - { - if ( (stream_token != NULL && stream_token->hasNext(stream_token)) ) - { - ADAPTOR->addChild(ADAPTOR, root_1, stream_token == NULL ? NULL : stream_token->nextTree(stream_token)); - - } - if ( stream_token != NULL) stream_token->reset(stream_token); - - } - ADAPTOR->addChild(ADAPTOR, root_1, stream_temporalRelation == NULL ? NULL : stream_temporalRelation->nextTree(stream_temporalRelation)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_tokenInstanceList == NULL ? NULL : stream_tokenInstanceList->nextTree(stream_tokenInstanceList)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - if (stream_token != NULL) stream_token->free(stream_token); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto rulerelationEx; /* Prevent compiler warnings */ - rulerelationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_37 != NULL) stream_37->free(stream_37); - if (stream_temporalRelation != NULL) stream_temporalRelation->free(stream_temporalRelation); - if (stream_tokenVarRef != NULL) stream_tokenVarRef->free(stream_tokenVarRef); - if (stream_tokenInstanceList != NULL) stream_tokenInstanceList->free(stream_tokenInstanceList); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end relation */ - -/** - * $ANTLR start problemStmt - * NDDL/base/antlr/NDDL3.g:276:1: problemStmt : ( 'rejectable' | 'goal' | 'fact' ) tokenInstanceList ';' ; - */ -static NDDL3Parser_problemStmt_return -problemStmt(pNDDL3Parser ctx) -{ - NDDL3Parser_problemStmt_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal121; - pANTLR3_COMMON_TOKEN string_literal122; - pANTLR3_COMMON_TOKEN string_literal123; - pANTLR3_COMMON_TOKEN char_literal125; - NDDL3Parser_tokenInstanceList_return tokenInstanceList124; - #undef RETURN_TYPE_tokenInstanceList124 - #define RETURN_TYPE_tokenInstanceList124 NDDL3Parser_tokenInstanceList_return - - pANTLR3_BASE_TREE string_literal121_tree; - pANTLR3_BASE_TREE string_literal122_tree; - pANTLR3_BASE_TREE string_literal123_tree; - pANTLR3_BASE_TREE char_literal125_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal121 = NULL; - string_literal122 = NULL; - string_literal123 = NULL; - char_literal125 = NULL; - tokenInstanceList124.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal121_tree = NULL; - string_literal122_tree = NULL; - string_literal123_tree = NULL; - char_literal125_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:277:5: ( ( 'rejectable' | 'goal' | 'fact' ) tokenInstanceList ';' ) - // NDDL/base/antlr/NDDL3.g:277:7: ( 'rejectable' | 'goal' | 'fact' ) tokenInstanceList ';' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - - // NDDL/base/antlr/NDDL3.g:277:7: ( 'rejectable' | 'goal' | 'fact' ) - { - int alt30=3; - switch ( LA(1) ) - { - case 57: - { - alt30=1; - } - break; - case 58: - { - alt30=2; - } - break; - case 59: - { - alt30=3; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 30; - EXCEPTION->state = 0; - - - goto ruleproblemStmtEx; - } - - switch (alt30) - { - case 1: - // NDDL/base/antlr/NDDL3.g:277:8: 'rejectable' - { - string_literal121 = (pANTLR3_COMMON_TOKEN) MATCHT(57, &FOLLOW_57_in_problemStmt1460); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal121_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal121)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal121_tree, root_0)); - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:277:24: 'goal' - { - string_literal122 = (pANTLR3_COMMON_TOKEN) MATCHT(58, &FOLLOW_58_in_problemStmt1465); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal122_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal122)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal122_tree, root_0)); - } - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:277:34: 'fact' - { - string_literal123 = (pANTLR3_COMMON_TOKEN) MATCHT(59, &FOLLOW_59_in_problemStmt1470); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal123_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal123)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal123_tree, root_0)); - } - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_tokenInstanceList_in_problemStmt1474); - tokenInstanceList124=tokenInstanceList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, tokenInstanceList124.tree); - char_literal125 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_problemStmt1476); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleproblemStmtEx; /* Prevent compiler warnings */ - ruleproblemStmtEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end problemStmt */ - -/** - * $ANTLR start tokenInstanceList - * NDDL/base/antlr/NDDL3.g:280:1: tokenInstanceList : ( tokenVarRef | '(' ( tokenInstances )? ')' ); - */ -static NDDL3Parser_tokenInstanceList_return -tokenInstanceList(pNDDL3Parser ctx) -{ - NDDL3Parser_tokenInstanceList_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal127; - pANTLR3_COMMON_TOKEN char_literal129; - NDDL3Parser_tokenVarRef_return tokenVarRef126; - #undef RETURN_TYPE_tokenVarRef126 - #define RETURN_TYPE_tokenVarRef126 NDDL3Parser_tokenVarRef_return - - NDDL3Parser_tokenInstances_return tokenInstances128; - #undef RETURN_TYPE_tokenInstances128 - #define RETURN_TYPE_tokenInstances128 NDDL3Parser_tokenInstances_return - - pANTLR3_BASE_TREE char_literal127_tree; - pANTLR3_BASE_TREE char_literal129_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal127 = NULL; - char_literal129 = NULL; - tokenVarRef126.tree = NULL; - - tokenInstances128.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal127_tree = NULL; - char_literal129_tree = NULL; - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:281:2: ( tokenVarRef | '(' ( tokenInstances )? ')' ) - - ANTLR3_UINT32 alt32; - - alt32=2; - - - { - int LA32_0 = LA(1); - if ( (LA32_0 == IDENT || LA32_0 == 45) ) - { - alt32=1; - } - else if ( (LA32_0 == 41) ) - { - alt32=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 32; - EXCEPTION->state = 0; - - - goto ruletokenInstanceListEx; - } - } - switch (alt32) - { - case 1: - // NDDL/base/antlr/NDDL3.g:281:4: tokenVarRef - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_tokenVarRef_in_tokenInstanceList1496); - tokenVarRef126=tokenVarRef(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenInstanceListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, tokenVarRef126.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:282:4: '(' ( tokenInstances )? ')' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal127 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_tokenInstanceList1501); - if (HASEXCEPTION()) - { - goto ruletokenInstanceListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal127_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal127)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal127_tree, root_0)); - } - - // NDDL/base/antlr/NDDL3.g:282:9: ( tokenInstances )? - { - int alt31=2; - { - int LA31_0 = LA(1); - if ( (LA31_0 == IDENT || LA31_0 == 45 || ((LA31_0 >= 60) && (LA31_0 <= 61))) ) - { - alt31=1; - } - } - switch (alt31) - { - case 1: - // NDDL/base/antlr/NDDL3.g:282:9: tokenInstances - { - FOLLOWPUSH(FOLLOW_tokenInstances_in_tokenInstanceList1504); - tokenInstances128=tokenInstances(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenInstanceListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, tokenInstances128.tree); - - } - break; - - } - } - char_literal129 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_tokenInstanceList1507); - if (HASEXCEPTION()) - { - goto ruletokenInstanceListEx; - } - if (HASFAILED()) - { - return retval; - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruletokenInstanceListEx; /* Prevent compiler warnings */ - ruletokenInstanceListEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end tokenInstanceList */ - -/** - * $ANTLR start tokenVarRef - * NDDL/base/antlr/NDDL3.g:285:1: tokenVarRef : ( IDENT | 'this' ); - */ -static NDDL3Parser_tokenVarRef_return -tokenVarRef(pNDDL3Parser ctx) -{ - NDDL3Parser_tokenVarRef_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set130; - - pANTLR3_BASE_TREE set130_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set130 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - set130_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:286:2: ( IDENT | 'this' ) - // NDDL/base/antlr/NDDL3.g: - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - set130=(pANTLR3_COMMON_TOKEN)LT(1); - if ( LA(1) == IDENT || LA(1) == 45 ) - { - CONSUME(); - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set130))); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_tokenVarRef0; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_tokenVarRef0); goto ruletokenVarRefEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenVarRefEx; /* Prevent compiler warnings */ - ruletokenVarRefEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end tokenVarRef */ - -/** - * $ANTLR start tokenInstances - * NDDL/base/antlr/NDDL3.g:290:1: tokenInstances : tokenInstance ( ',' tokenInstance )* ; - */ -static NDDL3Parser_tokenInstances_return -tokenInstances(pNDDL3Parser ctx) -{ - NDDL3Parser_tokenInstances_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal132; - NDDL3Parser_tokenInstance_return tokenInstance131; - #undef RETURN_TYPE_tokenInstance131 - #define RETURN_TYPE_tokenInstance131 NDDL3Parser_tokenInstance_return - - NDDL3Parser_tokenInstance_return tokenInstance133; - #undef RETURN_TYPE_tokenInstance133 - #define RETURN_TYPE_tokenInstance133 NDDL3Parser_tokenInstance_return - - pANTLR3_BASE_TREE char_literal132_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal132 = NULL; - tokenInstance131.tree = NULL; - - tokenInstance133.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal132_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:291:2: ( tokenInstance ( ',' tokenInstance )* ) - // NDDL/base/antlr/NDDL3.g:291:4: tokenInstance ( ',' tokenInstance )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_tokenInstance_in_tokenInstances1536); - tokenInstance131=tokenInstance(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenInstancesEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, tokenInstance131.tree); - - // NDDL/base/antlr/NDDL3.g:291:18: ( ',' tokenInstance )* - - for (;;) - { - int alt33=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA33_0 = LA(1); - if ( (LA33_0 == 34) ) - { - alt33=1; - } - - } - switch (alt33) - { - case 1: - // NDDL/base/antlr/NDDL3.g:291:19: ',' tokenInstance - { - char_literal132 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_tokenInstances1539); - if (HASEXCEPTION()) - { - goto ruletokenInstancesEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_tokenInstance_in_tokenInstances1542); - tokenInstance133=tokenInstance(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenInstancesEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, tokenInstance133.tree); - - } - break; - - default: - goto loop33; /* break out of the loop */ - break; - } - } - loop33: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenInstancesEx; /* Prevent compiler warnings */ - ruletokenInstancesEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end tokenInstances */ - -/** - * $ANTLR start tokenInstance - * NDDL/base/antlr/NDDL3.g:294:1: tokenInstance : ( tokenAnnotation )? qualified ( IDENT )? -> ^( PREDICATE_INSTANCE qualified ( IDENT )? ( tokenAnnotation )? ) ; - */ -static NDDL3Parser_tokenInstance_return -tokenInstance(pNDDL3Parser ctx) -{ - NDDL3Parser_tokenInstance_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN IDENT136; - NDDL3Parser_tokenAnnotation_return tokenAnnotation134; - #undef RETURN_TYPE_tokenAnnotation134 - #define RETURN_TYPE_tokenAnnotation134 NDDL3Parser_tokenAnnotation_return - - NDDL3Parser_qualified_return qualified135; - #undef RETURN_TYPE_qualified135 - #define RETURN_TYPE_qualified135 NDDL3Parser_qualified_return - - pANTLR3_BASE_TREE IDENT136_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_IDENT; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_tokenAnnotation; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_qualified; - /* Initialize rule variables - */ - - - root_0 = NULL; - - IDENT136 = NULL; - tokenAnnotation134.tree = NULL; - - qualified135.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - IDENT136_tree = NULL; - - stream_IDENT = NULL; - #define CREATE_stream_IDENT if (stream_IDENT == NULL) {stream_IDENT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token IDENT"); } - stream_tokenAnnotation = NULL; - #define CREATE_stream_tokenAnnotation if (stream_tokenAnnotation == NULL) {stream_tokenAnnotation = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule tokenAnnotation"); } - stream_qualified = NULL; - #define CREATE_stream_qualified if (stream_qualified == NULL) {stream_qualified = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule qualified"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:295:2: ( ( tokenAnnotation )? qualified ( IDENT )? -> ^( PREDICATE_INSTANCE qualified ( IDENT )? ( tokenAnnotation )? ) ) - // NDDL/base/antlr/NDDL3.g:295:4: ( tokenAnnotation )? qualified ( IDENT )? - { - - // NDDL/base/antlr/NDDL3.g:295:4: ( tokenAnnotation )? - { - int alt34=2; - { - int LA34_0 = LA(1); - if ( (((LA34_0 >= 60) && (LA34_0 <= 61))) ) - { - alt34=1; - } - } - switch (alt34) - { - case 1: - // NDDL/base/antlr/NDDL3.g:295:4: tokenAnnotation - { - FOLLOWPUSH(FOLLOW_tokenAnnotation_in_tokenInstance1555); - tokenAnnotation134=tokenAnnotation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenInstanceEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_tokenAnnotation; stream_tokenAnnotation->add(stream_tokenAnnotation, tokenAnnotation134.tree, NULL); } - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_qualified_in_tokenInstance1558); - qualified135=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenInstanceEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_qualified; stream_qualified->add(stream_qualified, qualified135.tree, NULL); } - - // NDDL/base/antlr/NDDL3.g:295:31: ( IDENT )? - { - int alt35=2; - { - int LA35_0 = LA(1); - if ( (LA35_0 == IDENT) ) - { - alt35=1; - } - } - switch (alt35) - { - case 1: - // NDDL/base/antlr/NDDL3.g:295:31: IDENT - { - IDENT136 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_tokenInstance1560); - if (HASEXCEPTION()) - { - goto ruletokenInstanceEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, IDENT136, NULL); } - - - } - break; - - } - } - - - /* AST REWRITE - * elements : IDENT, qualified, tokenAnnotation - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 296:10: -> ^( PREDICATE_INSTANCE qualified ( IDENT )? ( tokenAnnotation )? ) - { - // NDDL/base/antlr/NDDL3.g:296:13: ^( PREDICATE_INSTANCE qualified ( IDENT )? ( tokenAnnotation )? ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, PREDICATE_INSTANCE, (pANTLR3_UINT8)"PREDICATE_INSTANCE"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_qualified == NULL ? NULL : stream_qualified->nextTree(stream_qualified)); - // NDDL/base/antlr/NDDL3.g:296:44: ( IDENT )? - { - if ( (stream_IDENT != NULL && stream_IDENT->hasNext(stream_IDENT)) ) - { - ADAPTOR->addChild(ADAPTOR, root_1, stream_IDENT == NULL ? NULL : stream_IDENT->nextNode(stream_IDENT)); - - } - if ( stream_IDENT != NULL) stream_IDENT->reset(stream_IDENT); - - } - // NDDL/base/antlr/NDDL3.g:296:51: ( tokenAnnotation )? - { - if ( (stream_tokenAnnotation != NULL && stream_tokenAnnotation->hasNext(stream_tokenAnnotation)) ) - { - ADAPTOR->addChild(ADAPTOR, root_1, stream_tokenAnnotation == NULL ? NULL : stream_tokenAnnotation->nextTree(stream_tokenAnnotation)); - - } - if ( stream_tokenAnnotation != NULL) stream_tokenAnnotation->reset(stream_tokenAnnotation); - - } - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenInstanceEx; /* Prevent compiler warnings */ - ruletokenInstanceEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_IDENT != NULL) stream_IDENT->free(stream_IDENT); - if (stream_tokenAnnotation != NULL) stream_tokenAnnotation->free(stream_tokenAnnotation); - if (stream_qualified != NULL) stream_qualified->free(stream_qualified); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end tokenInstance */ - -/** - * $ANTLR start tokenAnnotation - * NDDL/base/antlr/NDDL3.g:299:1: tokenAnnotation : ( 'condition' | 'effect' ); - */ -static NDDL3Parser_tokenAnnotation_return -tokenAnnotation(pNDDL3Parser ctx) -{ - NDDL3Parser_tokenAnnotation_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set137; - - pANTLR3_BASE_TREE set137_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set137 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - set137_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:300:2: ( 'condition' | 'effect' ) - // NDDL/base/antlr/NDDL3.g: - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - set137=(pANTLR3_COMMON_TOKEN)LT(1); - if ( ((LA(1) >= 60) && (LA(1) <= 61)) ) - { - CONSUME(); - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set137))); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_tokenAnnotation0; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_tokenAnnotation0); goto ruletokenAnnotationEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenAnnotationEx; /* Prevent compiler warnings */ - ruletokenAnnotationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end tokenAnnotation */ - -/** - * $ANTLR start constraintInstantiation - * NDDL/base/antlr/NDDL3.g:303:1: constraintInstantiation : ( ( ( IDENT variableArgumentList ( ':' violationMsg )? ';' )=> IDENT variableArgumentList ( ':' violationMsg )? ';' ) -> ^( CONSTRAINT_INSTANTIATION IDENT variableArgumentList ( violationMsg )? ) | enforceStatement ); - */ -static NDDL3Parser_constraintInstantiation_return -constraintInstantiation(pNDDL3Parser ctx) -{ - NDDL3Parser_constraintInstantiation_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN IDENT138; - pANTLR3_COMMON_TOKEN char_literal140; - pANTLR3_COMMON_TOKEN char_literal142; - NDDL3Parser_variableArgumentList_return variableArgumentList139; - #undef RETURN_TYPE_variableArgumentList139 - #define RETURN_TYPE_variableArgumentList139 NDDL3Parser_variableArgumentList_return - - NDDL3Parser_violationMsg_return violationMsg141; - #undef RETURN_TYPE_violationMsg141 - #define RETURN_TYPE_violationMsg141 NDDL3Parser_violationMsg_return - - NDDL3Parser_enforceStatement_return enforceStatement143; - #undef RETURN_TYPE_enforceStatement143 - #define RETURN_TYPE_enforceStatement143 NDDL3Parser_enforceStatement_return - - pANTLR3_BASE_TREE IDENT138_tree; - pANTLR3_BASE_TREE char_literal140_tree; - pANTLR3_BASE_TREE char_literal142_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_IDENT; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_62; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_37; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_violationMsg; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_variableArgumentList; - /* Initialize rule variables - */ - - - root_0 = NULL; - - IDENT138 = NULL; - char_literal140 = NULL; - char_literal142 = NULL; - variableArgumentList139.tree = NULL; - - violationMsg141.tree = NULL; - - enforceStatement143.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - IDENT138_tree = NULL; - char_literal140_tree = NULL; - char_literal142_tree = NULL; - - stream_IDENT = NULL; - #define CREATE_stream_IDENT if (stream_IDENT == NULL) {stream_IDENT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token IDENT"); } - stream_62 = NULL; - #define CREATE_stream_62 if (stream_62 == NULL) {stream_62 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 62"); } - stream_37 = NULL; - #define CREATE_stream_37 if (stream_37 == NULL) {stream_37 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 37"); } - stream_violationMsg = NULL; - #define CREATE_stream_violationMsg if (stream_violationMsg == NULL) {stream_violationMsg = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule violationMsg"); } - stream_variableArgumentList = NULL; - #define CREATE_stream_variableArgumentList if (stream_variableArgumentList == NULL) {stream_variableArgumentList = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule variableArgumentList"); } - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:304:2: ( ( ( IDENT variableArgumentList ( ':' violationMsg )? ';' )=> IDENT variableArgumentList ( ':' violationMsg )? ';' ) -> ^( CONSTRAINT_INSTANTIATION IDENT variableArgumentList ( violationMsg )? ) | enforceStatement ) - - ANTLR3_UINT32 alt37; - - alt37=2; - - alt37 = cdfa37.predict(ctx, RECOGNIZER, ISTREAM, &cdfa37); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - if (HASFAILED()) - { - return retval; - } - switch (alt37) - { - case 1: - // NDDL/base/antlr/NDDL3.g:304:4: ( ( IDENT variableArgumentList ( ':' violationMsg )? ';' )=> IDENT variableArgumentList ( ':' violationMsg )? ';' ) - { - // NDDL/base/antlr/NDDL3.g:304:4: ( ( IDENT variableArgumentList ( ':' violationMsg )? ';' )=> IDENT variableArgumentList ( ':' violationMsg )? ';' ) - // NDDL/base/antlr/NDDL3.g:304:5: ( IDENT variableArgumentList ( ':' violationMsg )? ';' )=> IDENT variableArgumentList ( ':' violationMsg )? ';' - { - IDENT138 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_constraintInstantiation1626); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, IDENT138, NULL); } - - FOLLOWPUSH(FOLLOW_variableArgumentList_in_constraintInstantiation1628); - variableArgumentList139=variableArgumentList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_variableArgumentList; stream_variableArgumentList->add(stream_variableArgumentList, variableArgumentList139.tree, NULL); } - - // NDDL/base/antlr/NDDL3.g:304:86: ( ':' violationMsg )? - { - int alt36=2; - { - int LA36_0 = LA(1); - if ( (LA36_0 == 62) ) - { - alt36=1; - } - } - switch (alt36) - { - case 1: - // NDDL/base/antlr/NDDL3.g:304:87: ':' violationMsg - { - char_literal140 = (pANTLR3_COMMON_TOKEN) MATCHT(62, &FOLLOW_62_in_constraintInstantiation1631); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_62; stream_62->add(stream_62, char_literal140, NULL); } - - FOLLOWPUSH(FOLLOW_violationMsg_in_constraintInstantiation1633); - violationMsg141=violationMsg(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_violationMsg; stream_violationMsg->add(stream_violationMsg, violationMsg141.tree, NULL); } - - } - break; - - } - } - char_literal142 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_constraintInstantiation1637); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal142, NULL); } - - - } - - - - /* AST REWRITE - * elements : variableArgumentList, violationMsg, IDENT - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 305:4: -> ^( CONSTRAINT_INSTANTIATION IDENT variableArgumentList ( violationMsg )? ) - { - // NDDL/base/antlr/NDDL3.g:305:7: ^( CONSTRAINT_INSTANTIATION IDENT variableArgumentList ( violationMsg )? ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, CONSTRAINT_INSTANTIATION, (pANTLR3_UINT8)"CONSTRAINT_INSTANTIATION"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_IDENT == NULL ? NULL : stream_IDENT->nextNode(stream_IDENT)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_variableArgumentList == NULL ? NULL : stream_variableArgumentList->nextTree(stream_variableArgumentList)); - // NDDL/base/antlr/NDDL3.g:305:61: ( violationMsg )? - { - if ( (stream_violationMsg != NULL && stream_violationMsg->hasNext(stream_violationMsg)) ) - { - ADAPTOR->addChild(ADAPTOR, root_1, stream_violationMsg == NULL ? NULL : stream_violationMsg->nextTree(stream_violationMsg)); - - } - if ( stream_violationMsg != NULL) stream_violationMsg->reset(stream_violationMsg); - - } - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:306:5: enforceStatement - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_enforceStatement_in_constraintInstantiation1660); - enforceStatement143=enforceStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, enforceStatement143.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleconstraintInstantiationEx; /* Prevent compiler warnings */ - ruleconstraintInstantiationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_IDENT != NULL) stream_IDENT->free(stream_IDENT); - if (stream_62 != NULL) stream_62->free(stream_62); - if (stream_37 != NULL) stream_37->free(stream_37); - if (stream_violationMsg != NULL) stream_violationMsg->free(stream_violationMsg); - if (stream_variableArgumentList != NULL) stream_variableArgumentList->free(stream_variableArgumentList); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end constraintInstantiation */ - -/** - * $ANTLR start enforceStatement - * NDDL/base/antlr/NDDL3.g:309:1: enforceStatement : ( 'enforce' )? result= cexpression ( ':' vm= violationMsg )? ';' -> ^( EXPRESSION_ENFORCE $result ( $vm)? ) ; - */ -static NDDL3Parser_enforceStatement_return -enforceStatement(pNDDL3Parser ctx) -{ - NDDL3Parser_enforceStatement_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal144; - pANTLR3_COMMON_TOKEN char_literal145; - pANTLR3_COMMON_TOKEN char_literal146; - NDDL3Parser_cexpression_return result; - #undef RETURN_TYPE_result - #define RETURN_TYPE_result NDDL3Parser_cexpression_return - - NDDL3Parser_violationMsg_return vm; - #undef RETURN_TYPE_vm - #define RETURN_TYPE_vm NDDL3Parser_violationMsg_return - - pANTLR3_BASE_TREE string_literal144_tree; - pANTLR3_BASE_TREE char_literal145_tree; - pANTLR3_BASE_TREE char_literal146_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_62; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_63; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_37; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_violationMsg; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_cexpression; - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal144 = NULL; - char_literal145 = NULL; - char_literal146 = NULL; - result.tree = NULL; - - vm.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal144_tree = NULL; - char_literal145_tree = NULL; - char_literal146_tree = NULL; - - stream_62 = NULL; - #define CREATE_stream_62 if (stream_62 == NULL) {stream_62 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 62"); } - stream_63 = NULL; - #define CREATE_stream_63 if (stream_63 == NULL) {stream_63 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 63"); } - stream_37 = NULL; - #define CREATE_stream_37 if (stream_37 == NULL) {stream_37 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 37"); } - stream_violationMsg = NULL; - #define CREATE_stream_violationMsg if (stream_violationMsg == NULL) {stream_violationMsg = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule violationMsg"); } - stream_cexpression = NULL; - #define CREATE_stream_cexpression if (stream_cexpression == NULL) {stream_cexpression = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule cexpression"); } - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:310:5: ( ( 'enforce' )? result= cexpression ( ':' vm= violationMsg )? ';' -> ^( EXPRESSION_ENFORCE $result ( $vm)? ) ) - // NDDL/base/antlr/NDDL3.g:310:7: ( 'enforce' )? result= cexpression ( ':' vm= violationMsg )? ';' - { - - // NDDL/base/antlr/NDDL3.g:310:7: ( 'enforce' )? - { - int alt38=2; - { - int LA38_0 = LA(1); - if ( (LA38_0 == 63) ) - { - alt38=1; - } - } - switch (alt38) - { - case 1: - // NDDL/base/antlr/NDDL3.g:310:7: 'enforce' - { - string_literal144 = (pANTLR3_COMMON_TOKEN) MATCHT(63, &FOLLOW_63_in_enforceStatement1675); - if (HASEXCEPTION()) - { - goto ruleenforceStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_63; stream_63->add(stream_63, string_literal144, NULL); } - - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_cexpression_in_enforceStatement1680); - result=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleenforceStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_cexpression; stream_cexpression->add(stream_cexpression, result.tree, NULL); } - - // NDDL/base/antlr/NDDL3.g:310:37: ( ':' vm= violationMsg )? - { - int alt39=2; - { - int LA39_0 = LA(1); - if ( (LA39_0 == 62) ) - { - alt39=1; - } - } - switch (alt39) - { - case 1: - // NDDL/base/antlr/NDDL3.g:310:38: ':' vm= violationMsg - { - char_literal145 = (pANTLR3_COMMON_TOKEN) MATCHT(62, &FOLLOW_62_in_enforceStatement1683); - if (HASEXCEPTION()) - { - goto ruleenforceStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_62; stream_62->add(stream_62, char_literal145, NULL); } - - FOLLOWPUSH(FOLLOW_violationMsg_in_enforceStatement1687); - vm=violationMsg(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleenforceStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_violationMsg; stream_violationMsg->add(stream_violationMsg, vm.tree, NULL); } - - } - break; - - } - } - char_literal146 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_enforceStatement1691); - if (HASEXCEPTION()) - { - goto ruleenforceStatementEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal146, NULL); } - - - - /* AST REWRITE - * elements : result, vm - * token labels : - * rule labels : vm, result, retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_vm; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_result; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_vm=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token vm", vm.tree != NULL ? vm.tree : NULL); - stream_result=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token result", result.tree != NULL ? result.tree : NULL); - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 311:6: -> ^( EXPRESSION_ENFORCE $result ( $vm)? ) - { - // NDDL/base/antlr/NDDL3.g:311:9: ^( EXPRESSION_ENFORCE $result ( $vm)? ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, EXPRESSION_ENFORCE, (pANTLR3_UINT8)"EXPRESSION_ENFORCE"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_result == NULL ? NULL : stream_result->nextTree(stream_result)); - // NDDL/base/antlr/NDDL3.g:311:38: ( $vm)? - { - if ( (stream_vm != NULL && stream_vm->hasNext(stream_vm)) ) - { - ADAPTOR->addChild(ADAPTOR, root_1, stream_vm == NULL ? NULL : stream_vm->nextTree(stream_vm)); - - } - if ( stream_vm != NULL) stream_vm->reset(stream_vm); - - } - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_vm != NULL) stream_vm->free(stream_vm); - if (stream_result != NULL) stream_result->free(stream_result); - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - - } - - - // This is where rules clean up and exit - // - goto ruleenforceStatementEx; /* Prevent compiler warnings */ - ruleenforceStatementEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_62 != NULL) stream_62->free(stream_62); - if (stream_63 != NULL) stream_63->free(stream_63); - if (stream_37 != NULL) stream_37->free(stream_37); - if (stream_violationMsg != NULL) stream_violationMsg->free(stream_violationMsg); - if (stream_cexpression != NULL) stream_cexpression->free(stream_cexpression); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end enforceStatement */ - -/** - * $ANTLR start violationMsg - * NDDL/base/antlr/NDDL3.g:314:1: violationMsg : stringLiteral ; - */ -static NDDL3Parser_violationMsg_return -violationMsg(pNDDL3Parser ctx) -{ - NDDL3Parser_violationMsg_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_stringLiteral_return stringLiteral147; - #undef RETURN_TYPE_stringLiteral147 - #define RETURN_TYPE_stringLiteral147 NDDL3Parser_stringLiteral_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - stringLiteral147.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:315:2: ( stringLiteral ) - // NDDL/base/antlr/NDDL3.g:315:4: stringLiteral - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_stringLiteral_in_violationMsg1721); - stringLiteral147=stringLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleviolationMsgEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, stringLiteral147.tree); - - } - - } - - - // This is where rules clean up and exit - // - goto ruleviolationMsgEx; /* Prevent compiler warnings */ - ruleviolationMsgEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end violationMsg */ - -/** - * $ANTLR start cexpression - * NDDL/base/antlr/NDDL3.g:318:1: cexpression : cbooleanOrExpression ; - */ -static NDDL3Parser_cexpression_return -cexpression(pNDDL3Parser ctx) -{ - NDDL3Parser_cexpression_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_cbooleanOrExpression_return cbooleanOrExpression148; - #undef RETURN_TYPE_cbooleanOrExpression148 - #define RETURN_TYPE_cbooleanOrExpression148 NDDL3Parser_cbooleanOrExpression_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - cbooleanOrExpression148.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:319:2: ( cbooleanOrExpression ) - // NDDL/base/antlr/NDDL3.g:319:4: cbooleanOrExpression - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_cbooleanOrExpression_in_cexpression1734); - cbooleanOrExpression148=cbooleanOrExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cbooleanOrExpression148.tree); - - } - - } - - - // This is where rules clean up and exit - // - goto rulecexpressionEx; /* Prevent compiler warnings */ - rulecexpressionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end cexpression */ - -/** - * $ANTLR start cbooleanOrExpression - * NDDL/base/antlr/NDDL3.g:322:1: cbooleanOrExpression : cbooleanAndExpression ( '||' cbooleanAndExpression )* ; - */ -static NDDL3Parser_cbooleanOrExpression_return -cbooleanOrExpression(pNDDL3Parser ctx) -{ - NDDL3Parser_cbooleanOrExpression_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal150; - NDDL3Parser_cbooleanAndExpression_return cbooleanAndExpression149; - #undef RETURN_TYPE_cbooleanAndExpression149 - #define RETURN_TYPE_cbooleanAndExpression149 NDDL3Parser_cbooleanAndExpression_return - - NDDL3Parser_cbooleanAndExpression_return cbooleanAndExpression151; - #undef RETURN_TYPE_cbooleanAndExpression151 - #define RETURN_TYPE_cbooleanAndExpression151 NDDL3Parser_cbooleanAndExpression_return - - pANTLR3_BASE_TREE string_literal150_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal150 = NULL; - cbooleanAndExpression149.tree = NULL; - - cbooleanAndExpression151.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal150_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:323:2: ( cbooleanAndExpression ( '||' cbooleanAndExpression )* ) - // NDDL/base/antlr/NDDL3.g:323:4: cbooleanAndExpression ( '||' cbooleanAndExpression )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1746); - cbooleanAndExpression149=cbooleanAndExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecbooleanOrExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cbooleanAndExpression149.tree); - - // NDDL/base/antlr/NDDL3.g:323:26: ( '||' cbooleanAndExpression )* - - for (;;) - { - int alt40=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA40_0 = LA(1); - if ( (LA40_0 == 64) ) - { - alt40=1; - } - - } - switch (alt40) - { - case 1: - // NDDL/base/antlr/NDDL3.g:323:27: '||' cbooleanAndExpression - { - string_literal150 = (pANTLR3_COMMON_TOKEN) MATCHT(64, &FOLLOW_64_in_cbooleanOrExpression1749); - if (HASEXCEPTION()) - { - goto rulecbooleanOrExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal150_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal150)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal150_tree, root_0)); - } - FOLLOWPUSH(FOLLOW_cbooleanAndExpression_in_cbooleanOrExpression1752); - cbooleanAndExpression151=cbooleanAndExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecbooleanOrExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cbooleanAndExpression151.tree); - - } - break; - - default: - goto loop40; /* break out of the loop */ - break; - } - } - loop40: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulecbooleanOrExpressionEx; /* Prevent compiler warnings */ - rulecbooleanOrExpressionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end cbooleanOrExpression */ - -/** - * $ANTLR start cbooleanAndExpression - * NDDL/base/antlr/NDDL3.g:326:1: cbooleanAndExpression : a= crelationalExpression ( '&&' b= crelationalExpression )* ; - */ -static NDDL3Parser_cbooleanAndExpression_return -cbooleanAndExpression(pNDDL3Parser ctx) -{ - NDDL3Parser_cbooleanAndExpression_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal152; - NDDL3Parser_crelationalExpression_return a; - #undef RETURN_TYPE_a - #define RETURN_TYPE_a NDDL3Parser_crelationalExpression_return - - NDDL3Parser_crelationalExpression_return b; - #undef RETURN_TYPE_b - #define RETURN_TYPE_b NDDL3Parser_crelationalExpression_return - - pANTLR3_BASE_TREE string_literal152_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal152 = NULL; - a.tree = NULL; - - b.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal152_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:327:2: (a= crelationalExpression ( '&&' b= crelationalExpression )* ) - // NDDL/base/antlr/NDDL3.g:327:4: a= crelationalExpression ( '&&' b= crelationalExpression )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_crelationalExpression_in_cbooleanAndExpression1768); - a=crelationalExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecbooleanAndExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, a.tree); - - // NDDL/base/antlr/NDDL3.g:327:28: ( '&&' b= crelationalExpression )* - - for (;;) - { - int alt41=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA41_0 = LA(1); - if ( (LA41_0 == 65) ) - { - alt41=1; - } - - } - switch (alt41) - { - case 1: - // NDDL/base/antlr/NDDL3.g:327:29: '&&' b= crelationalExpression - { - string_literal152 = (pANTLR3_COMMON_TOKEN) MATCHT(65, &FOLLOW_65_in_cbooleanAndExpression1771); - if (HASEXCEPTION()) - { - goto rulecbooleanAndExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal152_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal152)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal152_tree, root_0)); - } - FOLLOWPUSH(FOLLOW_crelationalExpression_in_cbooleanAndExpression1776); - b=crelationalExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecbooleanAndExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, b.tree); - - } - break; - - default: - goto loop41; /* break out of the loop */ - break; - } - } - loop41: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulecbooleanAndExpressionEx; /* Prevent compiler warnings */ - rulecbooleanAndExpressionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end cbooleanAndExpression */ - -/** - * $ANTLR start crelationalExpression - * NDDL/base/antlr/NDDL3.g:330:1: crelationalExpression : a= cadditiveExpression ( ( '==' | '!=' | '<' | '>' | '>=' | '<=' ) cadditiveExpression )* ; - */ -static NDDL3Parser_crelationalExpression_return -crelationalExpression(pNDDL3Parser ctx) -{ - NDDL3Parser_crelationalExpression_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set153; - NDDL3Parser_cadditiveExpression_return a; - #undef RETURN_TYPE_a - #define RETURN_TYPE_a NDDL3Parser_cadditiveExpression_return - - NDDL3Parser_cadditiveExpression_return cadditiveExpression154; - #undef RETURN_TYPE_cadditiveExpression154 - #define RETURN_TYPE_cadditiveExpression154 NDDL3Parser_cadditiveExpression_return - - pANTLR3_BASE_TREE set153_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set153 = NULL; - a.tree = NULL; - - cadditiveExpression154.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - set153_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:331:2: (a= cadditiveExpression ( ( '==' | '!=' | '<' | '>' | '>=' | '<=' ) cadditiveExpression )* ) - // NDDL/base/antlr/NDDL3.g:331:4: a= cadditiveExpression ( ( '==' | '!=' | '<' | '>' | '>=' | '<=' ) cadditiveExpression )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_cadditiveExpression_in_crelationalExpression1800); - a=cadditiveExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecrelationalExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, a.tree); - - // NDDL/base/antlr/NDDL3.g:331:26: ( ( '==' | '!=' | '<' | '>' | '>=' | '<=' ) cadditiveExpression )* - - for (;;) - { - int alt42=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA42_0 = LA(1); - if ( (((LA42_0 >= 66) && (LA42_0 <= 71))) ) - { - alt42=1; - } - - } - switch (alt42) - { - case 1: - // NDDL/base/antlr/NDDL3.g:331:27: ( '==' | '!=' | '<' | '>' | '>=' | '<=' ) cadditiveExpression - { - set153=(pANTLR3_COMMON_TOKEN)LT(1); - set153=(pANTLR3_COMMON_TOKEN)LT(1); - if ( ((LA(1) >= 66) && (LA(1) <= 71)) ) - { - CONSUME(); - if ( BACKTRACKING==0 ) root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set153)), root_0)); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_crelationalExpression1803; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_crelationalExpression1803); goto rulecrelationalExpressionEx; - } - - FOLLOWPUSH(FOLLOW_cadditiveExpression_in_crelationalExpression1828); - cadditiveExpression154=cadditiveExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecrelationalExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cadditiveExpression154.tree); - - } - break; - - default: - goto loop42; /* break out of the loop */ - break; - } - } - loop42: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulecrelationalExpressionEx; /* Prevent compiler warnings */ - rulecrelationalExpressionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end crelationalExpression */ - -/** - * $ANTLR start cadditiveExpression - * NDDL/base/antlr/NDDL3.g:334:1: cadditiveExpression : cmultiplicativeExpression ( ( '+' | '-' ) cmultiplicativeExpression )* ; - */ -static NDDL3Parser_cadditiveExpression_return -cadditiveExpression(pNDDL3Parser ctx) -{ - NDDL3Parser_cadditiveExpression_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set156; - NDDL3Parser_cmultiplicativeExpression_return cmultiplicativeExpression155; - #undef RETURN_TYPE_cmultiplicativeExpression155 - #define RETURN_TYPE_cmultiplicativeExpression155 NDDL3Parser_cmultiplicativeExpression_return - - NDDL3Parser_cmultiplicativeExpression_return cmultiplicativeExpression157; - #undef RETURN_TYPE_cmultiplicativeExpression157 - #define RETURN_TYPE_cmultiplicativeExpression157 NDDL3Parser_cmultiplicativeExpression_return - - pANTLR3_BASE_TREE set156_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set156 = NULL; - cmultiplicativeExpression155.tree = NULL; - - cmultiplicativeExpression157.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - set156_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:335:2: ( cmultiplicativeExpression ( ( '+' | '-' ) cmultiplicativeExpression )* ) - // NDDL/base/antlr/NDDL3.g:335:4: cmultiplicativeExpression ( ( '+' | '-' ) cmultiplicativeExpression )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1851); - cmultiplicativeExpression155=cmultiplicativeExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecadditiveExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cmultiplicativeExpression155.tree); - - // NDDL/base/antlr/NDDL3.g:335:30: ( ( '+' | '-' ) cmultiplicativeExpression )* - - for (;;) - { - int alt43=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA43_0 = LA(1); - if ( (((LA43_0 >= 72) && (LA43_0 <= 73))) ) - { - alt43=1; - } - - } - switch (alt43) - { - case 1: - // NDDL/base/antlr/NDDL3.g:335:31: ( '+' | '-' ) cmultiplicativeExpression - { - set156=(pANTLR3_COMMON_TOKEN)LT(1); - set156=(pANTLR3_COMMON_TOKEN)LT(1); - if ( ((LA(1) >= 72) && (LA(1) <= 73)) ) - { - CONSUME(); - if ( BACKTRACKING==0 ) root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set156)), root_0)); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_cadditiveExpression1854; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_cadditiveExpression1854); goto rulecadditiveExpressionEx; - } - - FOLLOWPUSH(FOLLOW_cmultiplicativeExpression_in_cadditiveExpression1863); - cmultiplicativeExpression157=cmultiplicativeExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecadditiveExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cmultiplicativeExpression157.tree); - - } - break; - - default: - goto loop43; /* break out of the loop */ - break; - } - } - loop43: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulecadditiveExpressionEx; /* Prevent compiler warnings */ - rulecadditiveExpressionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end cadditiveExpression */ - -/** - * $ANTLR start cmultiplicativeExpression - * NDDL/base/antlr/NDDL3.g:338:1: cmultiplicativeExpression : cprimary ( '*' cprimary )* ; - */ -static NDDL3Parser_cmultiplicativeExpression_return -cmultiplicativeExpression(pNDDL3Parser ctx) -{ - NDDL3Parser_cmultiplicativeExpression_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal159; - NDDL3Parser_cprimary_return cprimary158; - #undef RETURN_TYPE_cprimary158 - #define RETURN_TYPE_cprimary158 NDDL3Parser_cprimary_return - - NDDL3Parser_cprimary_return cprimary160; - #undef RETURN_TYPE_cprimary160 - #define RETURN_TYPE_cprimary160 NDDL3Parser_cprimary_return - - pANTLR3_BASE_TREE char_literal159_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal159 = NULL; - cprimary158.tree = NULL; - - cprimary160.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal159_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:339:2: ( cprimary ( '*' cprimary )* ) - // NDDL/base/antlr/NDDL3.g:339:4: cprimary ( '*' cprimary )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_cprimary_in_cmultiplicativeExpression1880); - cprimary158=cprimary(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecmultiplicativeExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cprimary158.tree); - - // NDDL/base/antlr/NDDL3.g:339:13: ( '*' cprimary )* - - for (;;) - { - int alt44=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA44_0 = LA(1); - if ( (LA44_0 == 74) ) - { - alt44=1; - } - - } - switch (alt44) - { - case 1: - // NDDL/base/antlr/NDDL3.g:339:14: '*' cprimary - { - char_literal159 = (pANTLR3_COMMON_TOKEN) MATCHT(74, &FOLLOW_74_in_cmultiplicativeExpression1883); - if (HASEXCEPTION()) - { - goto rulecmultiplicativeExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal159_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal159)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal159_tree, root_0)); - } - FOLLOWPUSH(FOLLOW_cprimary_in_cmultiplicativeExpression1886); - cprimary160=cprimary(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecmultiplicativeExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cprimary160.tree); - - } - break; - - default: - goto loop44; /* break out of the loop */ - break; - } - } - loop44: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulecmultiplicativeExpressionEx; /* Prevent compiler warnings */ - rulecmultiplicativeExpressionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end cmultiplicativeExpression */ - -/** - * $ANTLR start cprimary - * NDDL/base/antlr/NDDL3.g:342:1: cprimary : ( anyValue | name= IDENT '(' ex= cexpressionList ')' -> ^( FUNCTION_CALL $name ^( '(' cexpressionList ) ) | '(' cbooleanOrExpression ')' ); - */ -static NDDL3Parser_cprimary_return -cprimary(pNDDL3Parser ctx) -{ - NDDL3Parser_cprimary_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN name; - pANTLR3_COMMON_TOKEN char_literal162; - pANTLR3_COMMON_TOKEN char_literal163; - pANTLR3_COMMON_TOKEN char_literal164; - pANTLR3_COMMON_TOKEN char_literal166; - NDDL3Parser_cexpressionList_return ex; - #undef RETURN_TYPE_ex - #define RETURN_TYPE_ex NDDL3Parser_cexpressionList_return - - NDDL3Parser_anyValue_return anyValue161; - #undef RETURN_TYPE_anyValue161 - #define RETURN_TYPE_anyValue161 NDDL3Parser_anyValue_return - - NDDL3Parser_cbooleanOrExpression_return cbooleanOrExpression165; - #undef RETURN_TYPE_cbooleanOrExpression165 - #define RETURN_TYPE_cbooleanOrExpression165 NDDL3Parser_cbooleanOrExpression_return - - pANTLR3_BASE_TREE name_tree; - pANTLR3_BASE_TREE char_literal162_tree; - pANTLR3_BASE_TREE char_literal163_tree; - pANTLR3_BASE_TREE char_literal164_tree; - pANTLR3_BASE_TREE char_literal166_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_IDENT; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_42; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_41; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_cexpressionList; - /* Initialize rule variables - */ - - - root_0 = NULL; - - name = NULL; - char_literal162 = NULL; - char_literal163 = NULL; - char_literal164 = NULL; - char_literal166 = NULL; - ex.tree = NULL; - - anyValue161.tree = NULL; - - cbooleanOrExpression165.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - name_tree = NULL; - char_literal162_tree = NULL; - char_literal163_tree = NULL; - char_literal164_tree = NULL; - char_literal166_tree = NULL; - - stream_IDENT = NULL; - #define CREATE_stream_IDENT if (stream_IDENT == NULL) {stream_IDENT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token IDENT"); } - stream_42 = NULL; - #define CREATE_stream_42 if (stream_42 == NULL) {stream_42 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 42"); } - stream_41 = NULL; - #define CREATE_stream_41 if (stream_41 == NULL) {stream_41 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 41"); } - stream_cexpressionList = NULL; - #define CREATE_stream_cexpressionList if (stream_cexpressionList == NULL) {stream_cexpressionList = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule cexpressionList"); } - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:343:2: ( anyValue | name= IDENT '(' ex= cexpressionList ')' -> ^( FUNCTION_CALL $name ^( '(' cexpressionList ) ) | '(' cbooleanOrExpression ')' ) - - ANTLR3_UINT32 alt45; - - alt45=3; - - switch ( LA(1) ) - { - case INT: - case FLOAT: - case STRING: - case 33: - case 38: - case 45: - case 72: - case 102: - case 103: - case 104: - case 105: - case 106: - case 107: - { - alt45=1; - } - break; - case IDENT: - { - - { - int LA45_2 = LA(2); - if ( (LA45_2 == 41) ) - { - alt45=2; - } - else if ( (LA45_2 == 34 || LA45_2 == 37 || LA45_2 == 42 || LA45_2 == 46 || LA45_2 == 62 || ((LA45_2 >= 64) && (LA45_2 <= 74))) ) - { - alt45=1; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 45; - EXCEPTION->state = 2; - - - goto rulecprimaryEx; - } - } - } - break; - case 41: - { - alt45=3; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 45; - EXCEPTION->state = 0; - - - goto rulecprimaryEx; - } - - switch (alt45) - { - case 1: - // NDDL/base/antlr/NDDL3.g:343:4: anyValue - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_anyValue_in_cprimary1900); - anyValue161=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecprimaryEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, anyValue161.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:344:4: name= IDENT '(' ex= cexpressionList ')' - { - name = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_cprimary1908); - if (HASEXCEPTION()) - { - goto rulecprimaryEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_IDENT; stream_IDENT->add(stream_IDENT, name, NULL); } - - char_literal162 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_cprimary1910); - if (HASEXCEPTION()) - { - goto rulecprimaryEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_41; stream_41->add(stream_41, char_literal162, NULL); } - - FOLLOWPUSH(FOLLOW_cexpressionList_in_cprimary1914); - ex=cexpressionList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecprimaryEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_cexpressionList; stream_cexpressionList->add(stream_cexpressionList, ex.tree, NULL); } - char_literal163 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_cprimary1916); - if (HASEXCEPTION()) - { - goto rulecprimaryEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_42; stream_42->add(stream_42, char_literal163, NULL); } - - - - /* AST REWRITE - * elements : cexpressionList, 41, name - * token labels : name - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_name; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_name=antlr3RewriteRuleTOKENStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token name", name); - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 344:42: -> ^( FUNCTION_CALL $name ^( '(' cexpressionList ) ) - { - // NDDL/base/antlr/NDDL3.g:344:45: ^( FUNCTION_CALL $name ^( '(' cexpressionList ) ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, FUNCTION_CALL, (pANTLR3_UINT8)"FUNCTION_CALL"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_name == NULL ? NULL : stream_name->nextNode(stream_name)); - // NDDL/base/antlr/NDDL3.g:344:67: ^( '(' cexpressionList ) - { - pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_41 == NULL ? NULL : stream_41->nextNode(stream_41), root_2)); - - ADAPTOR->addChild(ADAPTOR, root_2, stream_cexpressionList == NULL ? NULL : stream_cexpressionList->nextTree(stream_cexpressionList)); - - ADAPTOR->addChild(ADAPTOR, root_1, root_2); - } - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_name != NULL) stream_name->free(stream_name); - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:345:4: '(' cbooleanOrExpression ')' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal164 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_cprimary1936); - if (HASEXCEPTION()) - { - goto rulecprimaryEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_cbooleanOrExpression_in_cprimary1939); - cbooleanOrExpression165=cbooleanOrExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecprimaryEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cbooleanOrExpression165.tree); - char_literal166 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_cprimary1941); - if (HASEXCEPTION()) - { - goto rulecprimaryEx; - } - if (HASFAILED()) - { - return retval; - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulecprimaryEx; /* Prevent compiler warnings */ - rulecprimaryEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_IDENT != NULL) stream_IDENT->free(stream_IDENT); - if (stream_42 != NULL) stream_42->free(stream_42); - if (stream_41 != NULL) stream_41->free(stream_41); - if (stream_cexpressionList != NULL) stream_cexpressionList->free(stream_cexpressionList); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end cprimary */ - -/** - * $ANTLR start cexpressionList - * NDDL/base/antlr/NDDL3.g:348:1: cexpressionList : cexpression ( ',' cexpression )* ; - */ -static NDDL3Parser_cexpressionList_return -cexpressionList(pNDDL3Parser ctx) -{ - NDDL3Parser_cexpressionList_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal168; - NDDL3Parser_cexpression_return cexpression167; - #undef RETURN_TYPE_cexpression167 - #define RETURN_TYPE_cexpression167 NDDL3Parser_cexpression_return - - NDDL3Parser_cexpression_return cexpression169; - #undef RETURN_TYPE_cexpression169 - #define RETURN_TYPE_cexpression169 NDDL3Parser_cexpression_return - - pANTLR3_BASE_TREE char_literal168_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal168 = NULL; - cexpression167.tree = NULL; - - cexpression169.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal168_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:349:2: ( cexpression ( ',' cexpression )* ) - // NDDL/base/antlr/NDDL3.g:349:4: cexpression ( ',' cexpression )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_cexpression_in_cexpressionList1954); - cexpression167=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cexpression167.tree); - - // NDDL/base/antlr/NDDL3.g:349:16: ( ',' cexpression )* - - for (;;) - { - int alt46=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA46_0 = LA(1); - if ( (LA46_0 == 34) ) - { - alt46=1; - } - - } - switch (alt46) - { - case 1: - // NDDL/base/antlr/NDDL3.g:349:17: ',' cexpression - { - char_literal168 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_cexpressionList1957); - if (HASEXCEPTION()) - { - goto rulecexpressionListEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_cexpression_in_cexpressionList1960); - cexpression169=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, cexpression169.tree); - - } - break; - - default: - goto loop46; /* break out of the loop */ - break; - } - } - loop46: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulecexpressionListEx; /* Prevent compiler warnings */ - rulecexpressionListEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end cexpressionList */ - -/** - * $ANTLR start superInvocation - * NDDL/base/antlr/NDDL3.g:352:1: superInvocation : 'super' variableArgumentList ';' ; - */ -static NDDL3Parser_superInvocation_return -superInvocation(pNDDL3Parser ctx) -{ - NDDL3Parser_superInvocation_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal170; - pANTLR3_COMMON_TOKEN char_literal172; - NDDL3Parser_variableArgumentList_return variableArgumentList171; - #undef RETURN_TYPE_variableArgumentList171 - #define RETURN_TYPE_variableArgumentList171 NDDL3Parser_variableArgumentList_return - - pANTLR3_BASE_TREE string_literal170_tree; - pANTLR3_BASE_TREE char_literal172_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - string_literal170 = NULL; - char_literal172 = NULL; - variableArgumentList171.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal170_tree = NULL; - char_literal172_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:353:2: ( 'super' variableArgumentList ';' ) - // NDDL/base/antlr/NDDL3.g:353:4: 'super' variableArgumentList ';' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - string_literal170 = (pANTLR3_COMMON_TOKEN) MATCHT(75, &FOLLOW_75_in_superInvocation1975); - if (HASEXCEPTION()) - { - goto rulesuperInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal170_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal170)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal170_tree, root_0)); - } - FOLLOWPUSH(FOLLOW_variableArgumentList_in_superInvocation1978); - variableArgumentList171=variableArgumentList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulesuperInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, variableArgumentList171.tree); - char_literal172 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_superInvocation1980); - if (HASEXCEPTION()) - { - goto rulesuperInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulesuperInvocationEx; /* Prevent compiler warnings */ - rulesuperInvocationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end superInvocation */ - -/** - * $ANTLR start variableArgumentList - * NDDL/base/antlr/NDDL3.g:356:1: variableArgumentList : '(' ( variableArguments )? ')' ; - */ -static NDDL3Parser_variableArgumentList_return -variableArgumentList(pNDDL3Parser ctx) -{ - NDDL3Parser_variableArgumentList_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal173; - pANTLR3_COMMON_TOKEN char_literal175; - NDDL3Parser_variableArguments_return variableArguments174; - #undef RETURN_TYPE_variableArguments174 - #define RETURN_TYPE_variableArguments174 NDDL3Parser_variableArguments_return - - pANTLR3_BASE_TREE char_literal173_tree; - pANTLR3_BASE_TREE char_literal175_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal173 = NULL; - char_literal175 = NULL; - variableArguments174.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal173_tree = NULL; - char_literal175_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:357:2: ( '(' ( variableArguments )? ')' ) - // NDDL/base/antlr/NDDL3.g:357:4: '(' ( variableArguments )? ')' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal173 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_variableArgumentList1992); - if (HASEXCEPTION()) - { - goto rulevariableArgumentListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal173_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal173)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal173_tree, root_0)); - } - - // NDDL/base/antlr/NDDL3.g:357:9: ( variableArguments )? - { - int alt47=2; - { - int LA47_0 = LA(1); - if ( (((LA47_0 >= IDENT) && (LA47_0 <= STRING)) || LA47_0 == 33 || LA47_0 == 38 || LA47_0 == 45 || LA47_0 == 72 || ((LA47_0 >= 102) && (LA47_0 <= 107))) ) - { - alt47=1; - } - } - switch (alt47) - { - case 1: - // NDDL/base/antlr/NDDL3.g:357:9: variableArguments - { - FOLLOWPUSH(FOLLOW_variableArguments_in_variableArgumentList1995); - variableArguments174=variableArguments(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableArgumentListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, variableArguments174.tree); - - } - break; - - } - } - char_literal175 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_variableArgumentList1998); - if (HASEXCEPTION()) - { - goto rulevariableArgumentListEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulevariableArgumentListEx; /* Prevent compiler warnings */ - rulevariableArgumentListEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end variableArgumentList */ - -/** - * $ANTLR start variableArguments - * NDDL/base/antlr/NDDL3.g:360:1: variableArguments : variableArgument ( ',' variableArgument )* ; - */ -static NDDL3Parser_variableArguments_return -variableArguments(pNDDL3Parser ctx) -{ - NDDL3Parser_variableArguments_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal177; - NDDL3Parser_variableArgument_return variableArgument176; - #undef RETURN_TYPE_variableArgument176 - #define RETURN_TYPE_variableArgument176 NDDL3Parser_variableArgument_return - - NDDL3Parser_variableArgument_return variableArgument178; - #undef RETURN_TYPE_variableArgument178 - #define RETURN_TYPE_variableArgument178 NDDL3Parser_variableArgument_return - - pANTLR3_BASE_TREE char_literal177_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal177 = NULL; - variableArgument176.tree = NULL; - - variableArgument178.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal177_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:361:2: ( variableArgument ( ',' variableArgument )* ) - // NDDL/base/antlr/NDDL3.g:361:4: variableArgument ( ',' variableArgument )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_variableArgument_in_variableArguments2010); - variableArgument176=variableArgument(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableArgumentsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, variableArgument176.tree); - - // NDDL/base/antlr/NDDL3.g:361:21: ( ',' variableArgument )* - - for (;;) - { - int alt48=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA48_0 = LA(1); - if ( (LA48_0 == 34) ) - { - alt48=1; - } - - } - switch (alt48) - { - case 1: - // NDDL/base/antlr/NDDL3.g:361:22: ',' variableArgument - { - char_literal177 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_variableArguments2013); - if (HASEXCEPTION()) - { - goto rulevariableArgumentsEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_variableArgument_in_variableArguments2016); - variableArgument178=variableArgument(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableArgumentsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, variableArgument178.tree); - - } - break; - - default: - goto loop48; /* break out of the loop */ - break; - } - } - loop48: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulevariableArgumentsEx; /* Prevent compiler warnings */ - rulevariableArgumentsEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end variableArguments */ - -/** - * $ANTLR start variableArgument - * NDDL/base/antlr/NDDL3.g:364:1: variableArgument : anyValue ; - */ -static NDDL3Parser_variableArgument_return -variableArgument(pNDDL3Parser ctx) -{ - NDDL3Parser_variableArgument_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_anyValue_return anyValue179; - #undef RETURN_TYPE_anyValue179 - #define RETURN_TYPE_anyValue179 NDDL3Parser_anyValue_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - anyValue179.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:365:2: ( anyValue ) - // NDDL/base/antlr/NDDL3.g:365:4: anyValue - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_anyValue_in_variableArgument2029); - anyValue179=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableArgumentEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, anyValue179.tree); - - } - - } - - - // This is where rules clean up and exit - // - goto rulevariableArgumentEx; /* Prevent compiler warnings */ - rulevariableArgumentEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end variableArgument */ - -/** - * $ANTLR start typeArgumentList - * NDDL/base/antlr/NDDL3.g:368:1: typeArgumentList : '(' ( typeArguments )? ')' ; - */ -static NDDL3Parser_typeArgumentList_return -typeArgumentList(pNDDL3Parser ctx) -{ - NDDL3Parser_typeArgumentList_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal180; - pANTLR3_COMMON_TOKEN char_literal182; - NDDL3Parser_typeArguments_return typeArguments181; - #undef RETURN_TYPE_typeArguments181 - #define RETURN_TYPE_typeArguments181 NDDL3Parser_typeArguments_return - - pANTLR3_BASE_TREE char_literal180_tree; - pANTLR3_BASE_TREE char_literal182_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal180 = NULL; - char_literal182 = NULL; - typeArguments181.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal180_tree = NULL; - char_literal182_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:369:2: ( '(' ( typeArguments )? ')' ) - // NDDL/base/antlr/NDDL3.g:369:4: '(' ( typeArguments )? ')' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal180 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_typeArgumentList2040); - if (HASEXCEPTION()) - { - goto ruletypeArgumentListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - char_literal180_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, char_literal180)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, char_literal180_tree, root_0)); - } - - // NDDL/base/antlr/NDDL3.g:369:9: ( typeArguments )? - { - int alt49=2; - { - int LA49_0 = LA(1); - if ( (LA49_0 == IDENT) ) - { - alt49=1; - } - } - switch (alt49) - { - case 1: - // NDDL/base/antlr/NDDL3.g:369:9: typeArguments - { - FOLLOWPUSH(FOLLOW_typeArguments_in_typeArgumentList2043); - typeArguments181=typeArguments(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletypeArgumentListEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, typeArguments181.tree); - - } - break; - - } - } - char_literal182 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_typeArgumentList2046); - if (HASEXCEPTION()) - { - goto ruletypeArgumentListEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletypeArgumentListEx; /* Prevent compiler warnings */ - ruletypeArgumentListEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end typeArgumentList */ - -/** - * $ANTLR start typeArguments - * NDDL/base/antlr/NDDL3.g:372:1: typeArguments : typeArgument ( ',' typeArgument )* ; - */ -static NDDL3Parser_typeArguments_return -typeArguments(pNDDL3Parser ctx) -{ - NDDL3Parser_typeArguments_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal184; - NDDL3Parser_typeArgument_return typeArgument183; - #undef RETURN_TYPE_typeArgument183 - #define RETURN_TYPE_typeArgument183 NDDL3Parser_typeArgument_return - - NDDL3Parser_typeArgument_return typeArgument185; - #undef RETURN_TYPE_typeArgument185 - #define RETURN_TYPE_typeArgument185 NDDL3Parser_typeArgument_return - - pANTLR3_BASE_TREE char_literal184_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal184 = NULL; - typeArgument183.tree = NULL; - - typeArgument185.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal184_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:373:2: ( typeArgument ( ',' typeArgument )* ) - // NDDL/base/antlr/NDDL3.g:373:4: typeArgument ( ',' typeArgument )* - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_typeArgument_in_typeArguments2058); - typeArgument183=typeArgument(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletypeArgumentsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, typeArgument183.tree); - - // NDDL/base/antlr/NDDL3.g:373:17: ( ',' typeArgument )* - - for (;;) - { - int alt50=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA50_0 = LA(1); - if ( (LA50_0 == 34) ) - { - alt50=1; - } - - } - switch (alt50) - { - case 1: - // NDDL/base/antlr/NDDL3.g:373:18: ',' typeArgument - { - char_literal184 = (pANTLR3_COMMON_TOKEN) MATCHT(34, &FOLLOW_34_in_typeArguments2061); - if (HASEXCEPTION()) - { - goto ruletypeArgumentsEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_typeArgument_in_typeArguments2064); - typeArgument185=typeArgument(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletypeArgumentsEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, typeArgument185.tree); - - } - break; - - default: - goto loop50; /* break out of the loop */ - break; - } - } - loop50: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto ruletypeArgumentsEx; /* Prevent compiler warnings */ - ruletypeArgumentsEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end typeArguments */ - -/** - * $ANTLR start typeArgument - * NDDL/base/antlr/NDDL3.g:376:1: typeArgument : IDENT ; - */ -static NDDL3Parser_typeArgument_return -typeArgument(pNDDL3Parser ctx) -{ - NDDL3Parser_typeArgument_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN IDENT186; - - pANTLR3_BASE_TREE IDENT186_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - IDENT186 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - IDENT186_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:377:2: ( IDENT ) - // NDDL/base/antlr/NDDL3.g:377:4: IDENT - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - IDENT186 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_typeArgument2077); - if (HASEXCEPTION()) - { - goto ruletypeArgumentEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT186_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT186)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT186_tree); - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletypeArgumentEx; /* Prevent compiler warnings */ - ruletypeArgumentEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end typeArgument */ - -/** - * $ANTLR start flowControl - * NDDL/base/antlr/NDDL3.g:380:1: flowControl : ( 'if' '(' result= cexpression ')' a= ruleBlock ( ( 'else' )=> 'else' b= ruleBlock | ) -> {hasElse == false}? ^( 'if' ^( EXPRESSION_RETURN $result) $a) -> ^( 'if' ^( EXPRESSION_RETURN $result) $a $b) | 'foreach' '(' IDENT 'in' qualified ')' ruleBlock ); - */ -static NDDL3Parser_flowControl_return -flowControl(pNDDL3Parser ctx) -{ - NDDL3Parser_flowControl_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN string_literal187; - pANTLR3_COMMON_TOKEN char_literal188; - pANTLR3_COMMON_TOKEN char_literal189; - pANTLR3_COMMON_TOKEN string_literal190; - pANTLR3_COMMON_TOKEN string_literal191; - pANTLR3_COMMON_TOKEN char_literal192; - pANTLR3_COMMON_TOKEN IDENT193; - pANTLR3_COMMON_TOKEN string_literal194; - pANTLR3_COMMON_TOKEN char_literal196; - NDDL3Parser_cexpression_return result; - #undef RETURN_TYPE_result - #define RETURN_TYPE_result NDDL3Parser_cexpression_return - - NDDL3Parser_ruleBlock_return a; - #undef RETURN_TYPE_a - #define RETURN_TYPE_a NDDL3Parser_ruleBlock_return - - NDDL3Parser_ruleBlock_return b; - #undef RETURN_TYPE_b - #define RETURN_TYPE_b NDDL3Parser_ruleBlock_return - - NDDL3Parser_qualified_return qualified195; - #undef RETURN_TYPE_qualified195 - #define RETURN_TYPE_qualified195 NDDL3Parser_qualified_return - - NDDL3Parser_ruleBlock_return ruleBlock197; - #undef RETURN_TYPE_ruleBlock197 - #define RETURN_TYPE_ruleBlock197 NDDL3Parser_ruleBlock_return - - pANTLR3_BASE_TREE string_literal187_tree; - pANTLR3_BASE_TREE char_literal188_tree; - pANTLR3_BASE_TREE char_literal189_tree; - pANTLR3_BASE_TREE string_literal190_tree; - pANTLR3_BASE_TREE string_literal191_tree; - pANTLR3_BASE_TREE char_literal192_tree; - pANTLR3_BASE_TREE IDENT193_tree; - pANTLR3_BASE_TREE string_literal194_tree; - pANTLR3_BASE_TREE char_literal196_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_77; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_42; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_41; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_76; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_ruleBlock; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_cexpression; - /* Initialize rule variables - */ - - - root_0 = NULL; - - - bool hasElse = false; - - string_literal187 = NULL; - char_literal188 = NULL; - char_literal189 = NULL; - string_literal190 = NULL; - string_literal191 = NULL; - char_literal192 = NULL; - IDENT193 = NULL; - string_literal194 = NULL; - char_literal196 = NULL; - result.tree = NULL; - - a.tree = NULL; - - b.tree = NULL; - - qualified195.tree = NULL; - - ruleBlock197.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - string_literal187_tree = NULL; - char_literal188_tree = NULL; - char_literal189_tree = NULL; - string_literal190_tree = NULL; - string_literal191_tree = NULL; - char_literal192_tree = NULL; - IDENT193_tree = NULL; - string_literal194_tree = NULL; - char_literal196_tree = NULL; - - stream_77 = NULL; - #define CREATE_stream_77 if (stream_77 == NULL) {stream_77 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 77"); } - stream_42 = NULL; - #define CREATE_stream_42 if (stream_42 == NULL) {stream_42 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 42"); } - stream_41 = NULL; - #define CREATE_stream_41 if (stream_41 == NULL) {stream_41 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 41"); } - stream_76 = NULL; - #define CREATE_stream_76 if (stream_76 == NULL) {stream_76 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 76"); } - stream_ruleBlock = NULL; - #define CREATE_stream_ruleBlock if (stream_ruleBlock == NULL) {stream_ruleBlock = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule ruleBlock"); } - stream_cexpression = NULL; - #define CREATE_stream_cexpression if (stream_cexpression == NULL) {stream_cexpression = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule cexpression"); } - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:384:5: ( 'if' '(' result= cexpression ')' a= ruleBlock ( ( 'else' )=> 'else' b= ruleBlock | ) -> {hasElse == false}? ^( 'if' ^( EXPRESSION_RETURN $result) $a) -> ^( 'if' ^( EXPRESSION_RETURN $result) $a $b) | 'foreach' '(' IDENT 'in' qualified ')' ruleBlock ) - - ANTLR3_UINT32 alt52; - - alt52=2; - - - { - int LA52_0 = LA(1); - if ( (LA52_0 == 76) ) - { - alt52=1; - } - else if ( (LA52_0 == 78) ) - { - alt52=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 52; - EXCEPTION->state = 0; - - - goto ruleflowControlEx; - } - } - switch (alt52) - { - case 1: - // NDDL/base/antlr/NDDL3.g:384:7: 'if' '(' result= cexpression ')' a= ruleBlock ( ( 'else' )=> 'else' b= ruleBlock | ) - { - string_literal187 = (pANTLR3_COMMON_TOKEN) MATCHT(76, &FOLLOW_76_in_flowControl2097); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_76; stream_76->add(stream_76, string_literal187, NULL); } - - char_literal188 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_flowControl2099); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_41; stream_41->add(stream_41, char_literal188, NULL); } - - FOLLOWPUSH(FOLLOW_cexpression_in_flowControl2103); - result=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_cexpression; stream_cexpression->add(stream_cexpression, result.tree, NULL); } - char_literal189 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_flowControl2105); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_42; stream_42->add(stream_42, char_literal189, NULL); } - - FOLLOWPUSH(FOLLOW_ruleBlock_in_flowControl2109); - a=ruleBlock(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_ruleBlock; stream_ruleBlock->add(stream_ruleBlock, a.tree, NULL); } - - // NDDL/base/antlr/NDDL3.g:384:51: ( ( 'else' )=> 'else' b= ruleBlock | ) - { - int alt51=2; - - { - int LA51_0 = LA(1); - if ( (LA51_0 == 77) ) - { - - { - int LA51_1 = LA(2); - if ( (synpred2_NDDL3(ctx)) ) - { - alt51=1; - } - else if ( (ANTLR3_TRUE) ) - { - alt51=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 51; - EXCEPTION->state = 1; - - - goto ruleflowControlEx; - } - } - } - else if ( (LA51_0 == EOF || ((LA51_0 >= IDENT) && (LA51_0 <= STRING)) || ((LA51_0 >= 32) && (LA51_0 <= 33)) || ((LA51_0 >= 35) && (LA51_0 <= 38)) || ((LA51_0 >= 40) && (LA51_0 <= 41)) || ((LA51_0 >= 44) && (LA51_0 <= 45)) || LA51_0 == 48 || ((LA51_0 >= 53) && (LA51_0 <= 59)) || LA51_0 == 63 || LA51_0 == 72 || LA51_0 == 76 || ((LA51_0 >= 78) && (LA51_0 <= 108))) ) - { - alt51=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 51; - EXCEPTION->state = 0; - - - goto ruleflowControlEx; - } - } - switch (alt51) - { - case 1: - // NDDL/base/antlr/NDDL3.g:384:52: ( 'else' )=> 'else' b= ruleBlock - { - string_literal190 = (pANTLR3_COMMON_TOKEN) MATCHT(77, &FOLLOW_77_in_flowControl2117); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_77; stream_77->add(stream_77, string_literal190, NULL); } - - FOLLOWPUSH(FOLLOW_ruleBlock_in_flowControl2121); - b=ruleBlock(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_ruleBlock; stream_ruleBlock->add(stream_ruleBlock, b.tree, NULL); } - if ( BACKTRACKING==0 ) - { - hasElse = true; - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:384:100: - { - } - break; - - } - } - - - /* AST REWRITE - * elements : b, a, result, 76, result, 76, a - * token labels : - * rule labels : result, retval, b, a - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_result; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_b; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_a; - - stream_result=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token result", result.tree != NULL ? result.tree : NULL); - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - stream_b=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token b", b.tree != NULL ? b.tree : NULL); - stream_a=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token a", a.tree != NULL ? a.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 385:10: -> {hasElse == false}? ^( 'if' ^( EXPRESSION_RETURN $result) $a) - if (hasElse == false) - { - // NDDL/base/antlr/NDDL3.g:385:33: ^( 'if' ^( EXPRESSION_RETURN $result) $a) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_76 == NULL ? NULL : stream_76->nextNode(stream_76), root_1)); - - // NDDL/base/antlr/NDDL3.g:385:40: ^( EXPRESSION_RETURN $result) - { - pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, EXPRESSION_RETURN, (pANTLR3_UINT8)"EXPRESSION_RETURN"), root_2)); - - ADAPTOR->addChild(ADAPTOR, root_2, stream_result == NULL ? NULL : stream_result->nextTree(stream_result)); - - ADAPTOR->addChild(ADAPTOR, root_1, root_2); - } - ADAPTOR->addChild(ADAPTOR, root_1, stream_a == NULL ? NULL : stream_a->nextTree(stream_a)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - else // 386:10: -> ^( 'if' ^( EXPRESSION_RETURN $result) $a $b) - { - // NDDL/base/antlr/NDDL3.g:386:13: ^( 'if' ^( EXPRESSION_RETURN $result) $a $b) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_76 == NULL ? NULL : stream_76->nextNode(stream_76), root_1)); - - // NDDL/base/antlr/NDDL3.g:386:20: ^( EXPRESSION_RETURN $result) - { - pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, EXPRESSION_RETURN, (pANTLR3_UINT8)"EXPRESSION_RETURN"), root_2)); - - ADAPTOR->addChild(ADAPTOR, root_2, stream_result == NULL ? NULL : stream_result->nextTree(stream_result)); - - ADAPTOR->addChild(ADAPTOR, root_1, root_2); - } - ADAPTOR->addChild(ADAPTOR, root_1, stream_a == NULL ? NULL : stream_a->nextTree(stream_a)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_b == NULL ? NULL : stream_b->nextTree(stream_b)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_result != NULL) stream_result->free(stream_result); - if (stream_retval != NULL) stream_retval->free(stream_retval); - if (stream_b != NULL) stream_b->free(stream_b); - if (stream_a != NULL) stream_a->free(stream_a); - - - } - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:387:4: 'foreach' '(' IDENT 'in' qualified ')' ruleBlock - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - string_literal191 = (pANTLR3_COMMON_TOKEN) MATCHT(78, &FOLLOW_78_in_flowControl2186); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal191_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal191)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal191_tree, root_0)); - } - char_literal192 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_flowControl2189); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - IDENT193 = (pANTLR3_COMMON_TOKEN) MATCHT(IDENT, &FOLLOW_IDENT_in_flowControl2192); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - IDENT193_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, IDENT193)); - ADAPTOR->addChild(ADAPTOR, root_0, IDENT193_tree); - } - string_literal194 = (pANTLR3_COMMON_TOKEN) MATCHT(47, &FOLLOW_47_in_flowControl2194); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_qualified_in_flowControl2197); - qualified195=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, qualified195.tree); - char_literal196 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_flowControl2199); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_ruleBlock_in_flowControl2202); - ruleBlock197=ruleBlock(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleflowControlEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, ruleBlock197.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleflowControlEx; /* Prevent compiler warnings */ - ruleflowControlEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_77 != NULL) stream_77->free(stream_77); - if (stream_42 != NULL) stream_42->free(stream_42); - if (stream_41 != NULL) stream_41->free(stream_41); - if (stream_76 != NULL) stream_76->free(stream_76); - if (stream_ruleBlock != NULL) stream_ruleBlock->free(stream_ruleBlock); - if (stream_cexpression != NULL) stream_cexpression->free(stream_cexpression); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end flowControl */ - -/** - * $ANTLR start guardExpression - * NDDL/base/antlr/NDDL3.g:390:1: guardExpression : '(' anyValue ( ( '==' | '!=' ) anyValue )? ')' ; - */ -static NDDL3Parser_guardExpression_return -guardExpression(pNDDL3Parser ctx) -{ - NDDL3Parser_guardExpression_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal198; - pANTLR3_COMMON_TOKEN string_literal200; - pANTLR3_COMMON_TOKEN string_literal201; - pANTLR3_COMMON_TOKEN char_literal203; - NDDL3Parser_anyValue_return anyValue199; - #undef RETURN_TYPE_anyValue199 - #define RETURN_TYPE_anyValue199 NDDL3Parser_anyValue_return - - NDDL3Parser_anyValue_return anyValue202; - #undef RETURN_TYPE_anyValue202 - #define RETURN_TYPE_anyValue202 NDDL3Parser_anyValue_return - - pANTLR3_BASE_TREE char_literal198_tree; - pANTLR3_BASE_TREE string_literal200_tree; - pANTLR3_BASE_TREE string_literal201_tree; - pANTLR3_BASE_TREE char_literal203_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal198 = NULL; - string_literal200 = NULL; - string_literal201 = NULL; - char_literal203 = NULL; - anyValue199.tree = NULL; - - anyValue202.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal198_tree = NULL; - string_literal200_tree = NULL; - string_literal201_tree = NULL; - char_literal203_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:391:2: ( '(' anyValue ( ( '==' | '!=' ) anyValue )? ')' ) - // NDDL/base/antlr/NDDL3.g:391:4: '(' anyValue ( ( '==' | '!=' ) anyValue )? ')' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal198 = (pANTLR3_COMMON_TOKEN) MATCHT(41, &FOLLOW_41_in_guardExpression2214); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - FOLLOWPUSH(FOLLOW_anyValue_in_guardExpression2217); - anyValue199=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, anyValue199.tree); - - // NDDL/base/antlr/NDDL3.g:391:18: ( ( '==' | '!=' ) anyValue )? - { - int alt54=2; - { - int LA54_0 = LA(1); - if ( (((LA54_0 >= 66) && (LA54_0 <= 67))) ) - { - alt54=1; - } - } - switch (alt54) - { - case 1: - // NDDL/base/antlr/NDDL3.g:391:19: ( '==' | '!=' ) anyValue - { - - // NDDL/base/antlr/NDDL3.g:391:19: ( '==' | '!=' ) - { - int alt53=2; - - { - int LA53_0 = LA(1); - if ( (LA53_0 == 66) ) - { - alt53=1; - } - else if ( (LA53_0 == 67) ) - { - alt53=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 53; - EXCEPTION->state = 0; - - - goto ruleguardExpressionEx; - } - } - switch (alt53) - { - case 1: - // NDDL/base/antlr/NDDL3.g:391:20: '==' - { - string_literal200 = (pANTLR3_COMMON_TOKEN) MATCHT(66, &FOLLOW_66_in_guardExpression2221); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal200_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal200)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal200_tree, root_0)); - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:391:28: '!=' - { - string_literal201 = (pANTLR3_COMMON_TOKEN) MATCHT(67, &FOLLOW_67_in_guardExpression2226); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal201_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal201)); - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, string_literal201_tree, root_0)); - } - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_anyValue_in_guardExpression2230); - anyValue202=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, anyValue202.tree); - - } - break; - - } - } - char_literal203 = (pANTLR3_COMMON_TOKEN) MATCHT(42, &FOLLOW_42_in_guardExpression2234); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleguardExpressionEx; /* Prevent compiler warnings */ - ruleguardExpressionEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end guardExpression */ - -/** - * $ANTLR start allocationStmt - * NDDL/base/antlr/NDDL3.g:394:1: allocationStmt : allocation ';' ; - */ -static NDDL3Parser_allocationStmt_return -allocationStmt(pNDDL3Parser ctx) -{ - NDDL3Parser_allocationStmt_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal205; - NDDL3Parser_allocation_return allocation204; - #undef RETURN_TYPE_allocation204 - #define RETURN_TYPE_allocation204 NDDL3Parser_allocation_return - - pANTLR3_BASE_TREE char_literal205_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal205 = NULL; - allocation204.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal205_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:395:2: ( allocation ';' ) - // NDDL/base/antlr/NDDL3.g:395:4: allocation ';' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_allocation_in_allocationStmt2256); - allocation204=allocation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleallocationStmtEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, allocation204.tree); - char_literal205 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_allocationStmt2258); - if (HASEXCEPTION()) - { - goto ruleallocationStmtEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleallocationStmtEx; /* Prevent compiler warnings */ - ruleallocationStmtEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end allocationStmt */ - -/** - * $ANTLR start temporalRelation - * NDDL/base/antlr/NDDL3.g:398:1: temporalRelation : ( 'after' | 'any' | 'before' | 'contained_by' | 'contains' | 'contains_end' | 'contains_start' | 'ends' | 'ends_after' | 'ends_after_start' | 'ends_before' | 'ends_during' | 'equal' | 'equals' | 'meets' | 'met_by' | 'parallels' | 'paralleled_by' | 'starts' | 'starts_after' | 'starts_before' | 'starts_before_end' | 'starts_during' ); - */ -static NDDL3Parser_temporalRelation_return -temporalRelation(pNDDL3Parser ctx) -{ - NDDL3Parser_temporalRelation_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set206; - - pANTLR3_BASE_TREE set206_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set206 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - set206_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:399:5: ( 'after' | 'any' | 'before' | 'contained_by' | 'contains' | 'contains_end' | 'contains_start' | 'ends' | 'ends_after' | 'ends_after_start' | 'ends_before' | 'ends_during' | 'equal' | 'equals' | 'meets' | 'met_by' | 'parallels' | 'paralleled_by' | 'starts' | 'starts_after' | 'starts_before' | 'starts_before_end' | 'starts_during' ) - // NDDL/base/antlr/NDDL3.g: - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - set206=(pANTLR3_COMMON_TOKEN)LT(1); - if ( ((LA(1) >= 79) && (LA(1) <= 101)) ) - { - CONSUME(); - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set206))); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_temporalRelation0; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_temporalRelation0); goto ruletemporalRelationEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruletemporalRelationEx; /* Prevent compiler warnings */ - ruletemporalRelationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end temporalRelation */ - -/** - * $ANTLR start literalValue - * NDDL/base/antlr/NDDL3.g:424:1: literalValue : ( booleanLiteral | numericLiteral | stringLiteral ); - */ -static NDDL3Parser_literalValue_return -literalValue(pNDDL3Parser ctx) -{ - NDDL3Parser_literalValue_return retval; - - pANTLR3_BASE_TREE root_0; - - NDDL3Parser_booleanLiteral_return booleanLiteral207; - #undef RETURN_TYPE_booleanLiteral207 - #define RETURN_TYPE_booleanLiteral207 NDDL3Parser_booleanLiteral_return - - NDDL3Parser_numericLiteral_return numericLiteral208; - #undef RETURN_TYPE_numericLiteral208 - #define RETURN_TYPE_numericLiteral208 NDDL3Parser_numericLiteral_return - - NDDL3Parser_stringLiteral_return stringLiteral209; - #undef RETURN_TYPE_stringLiteral209 - #define RETURN_TYPE_stringLiteral209 NDDL3Parser_stringLiteral_return - - - /* Initialize rule variables - */ - - - root_0 = NULL; - - booleanLiteral207.tree = NULL; - - numericLiteral208.tree = NULL; - - stringLiteral209.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:425:5: ( booleanLiteral | numericLiteral | stringLiteral ) - - ANTLR3_UINT32 alt55; - - alt55=3; - - switch ( LA(1) ) - { - case 102: - case 103: - { - alt55=1; - } - break; - case INT: - case FLOAT: - case 72: - case 104: - case 105: - case 106: - case 107: - { - alt55=2; - } - break; - case STRING: - { - alt55=3; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 55; - EXCEPTION->state = 0; - - - goto ruleliteralValueEx; - } - - switch (alt55) - { - case 1: - // NDDL/base/antlr/NDDL3.g:425:9: booleanLiteral - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_booleanLiteral_in_literalValue2511); - booleanLiteral207=booleanLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleliteralValueEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, booleanLiteral207.tree); - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:426:9: numericLiteral - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_numericLiteral_in_literalValue2521); - numericLiteral208=numericLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleliteralValueEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, numericLiteral208.tree); - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:427:9: stringLiteral - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FOLLOWPUSH(FOLLOW_stringLiteral_in_literalValue2531); - stringLiteral209=stringLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleliteralValueEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, stringLiteral209.tree); - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleliteralValueEx; /* Prevent compiler warnings */ - ruleliteralValueEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end literalValue */ - -/** - * $ANTLR start booleanLiteral - * NDDL/base/antlr/NDDL3.g:430:1: booleanLiteral : ( 'true' | 'false' ); - */ -static NDDL3Parser_booleanLiteral_return -booleanLiteral(pNDDL3Parser ctx) -{ - NDDL3Parser_booleanLiteral_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set210; - - pANTLR3_BASE_TREE set210_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set210 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - set210_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:431:5: ( 'true' | 'false' ) - // NDDL/base/antlr/NDDL3.g: - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - set210=(pANTLR3_COMMON_TOKEN)LT(1); - if ( ((LA(1) >= 102) && (LA(1) <= 103)) ) - { - CONSUME(); - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set210))); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_booleanLiteral0; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_booleanLiteral0); goto rulebooleanLiteralEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto rulebooleanLiteralEx; /* Prevent compiler warnings */ - rulebooleanLiteralEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end booleanLiteral */ - -/** - * $ANTLR start numericLiteral - * NDDL/base/antlr/NDDL3.g:435:1: numericLiteral : ( INT | FLOAT | ( '+' )? ( 'inf' | 'inff' ) | '-inf' | '-inff' ); - */ -static NDDL3Parser_numericLiteral_return -numericLiteral(pNDDL3Parser ctx) -{ - NDDL3Parser_numericLiteral_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN INT211; - pANTLR3_COMMON_TOKEN FLOAT212; - pANTLR3_COMMON_TOKEN char_literal213; - pANTLR3_COMMON_TOKEN set214; - pANTLR3_COMMON_TOKEN string_literal215; - pANTLR3_COMMON_TOKEN string_literal216; - - pANTLR3_BASE_TREE INT211_tree; - pANTLR3_BASE_TREE FLOAT212_tree; - pANTLR3_BASE_TREE char_literal213_tree; - pANTLR3_BASE_TREE set214_tree; - pANTLR3_BASE_TREE string_literal215_tree; - pANTLR3_BASE_TREE string_literal216_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - INT211 = NULL; - FLOAT212 = NULL; - char_literal213 = NULL; - set214 = NULL; - string_literal215 = NULL; - string_literal216 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - INT211_tree = NULL; - FLOAT212_tree = NULL; - char_literal213_tree = NULL; - set214_tree = NULL; - string_literal215_tree = NULL; - string_literal216_tree = NULL; - - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:436:2: ( INT | FLOAT | ( '+' )? ( 'inf' | 'inff' ) | '-inf' | '-inff' ) - - ANTLR3_UINT32 alt57; - - alt57=5; - - switch ( LA(1) ) - { - case INT: - { - alt57=1; - } - break; - case FLOAT: - { - alt57=2; - } - break; - case 72: - case 104: - case 105: - { - alt57=3; - } - break; - case 106: - { - alt57=4; - } - break; - case 107: - { - alt57=5; - } - break; - - default: - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 57; - EXCEPTION->state = 0; - - - goto rulenumericLiteralEx; - } - - switch (alt57) - { - case 1: - // NDDL/base/antlr/NDDL3.g:436:4: INT - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - INT211 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_numericLiteral2579); - if (HASEXCEPTION()) - { - goto rulenumericLiteralEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - INT211_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, INT211)); - ADAPTOR->addChild(ADAPTOR, root_0, INT211_tree); - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:437:4: FLOAT - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - FLOAT212 = (pANTLR3_COMMON_TOKEN) MATCHT(FLOAT, &FOLLOW_FLOAT_in_numericLiteral2584); - if (HASEXCEPTION()) - { - goto rulenumericLiteralEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - FLOAT212_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, FLOAT212)); - ADAPTOR->addChild(ADAPTOR, root_0, FLOAT212_tree); - } - - } - break; - case 3: - // NDDL/base/antlr/NDDL3.g:438:4: ( '+' )? ( 'inf' | 'inff' ) - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - - // NDDL/base/antlr/NDDL3.g:438:4: ( '+' )? - { - int alt56=2; - { - int LA56_0 = LA(1); - if ( (LA56_0 == 72) ) - { - alt56=1; - } - } - switch (alt56) - { - case 1: - // NDDL/base/antlr/NDDL3.g:438:5: '+' - { - char_literal213 = (pANTLR3_COMMON_TOKEN) MATCHT(72, &FOLLOW_72_in_numericLiteral2590); - if (HASEXCEPTION()) - { - goto rulenumericLiteralEx; - } - if (HASFAILED()) - { - return retval; - } - - } - break; - - } - } - set214=(pANTLR3_COMMON_TOKEN)LT(1); - if ( ((LA(1) >= 104) && (LA(1) <= 105)) ) - { - CONSUME(); - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set214))); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_numericLiteral2595; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_numericLiteral2595); goto rulenumericLiteralEx; - } - - - } - break; - case 4: - // NDDL/base/antlr/NDDL3.g:439:4: '-inf' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - string_literal215 = (pANTLR3_COMMON_TOKEN) MATCHT(106, &FOLLOW_106_in_numericLiteral2606); - if (HASEXCEPTION()) - { - goto rulenumericLiteralEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal215_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal215)); - ADAPTOR->addChild(ADAPTOR, root_0, string_literal215_tree); - } - - } - break; - case 5: - // NDDL/base/antlr/NDDL3.g:440:9: '-inff' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - string_literal216 = (pANTLR3_COMMON_TOKEN) MATCHT(107, &FOLLOW_107_in_numericLiteral2617); - if (HASEXCEPTION()) - { - goto rulenumericLiteralEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - string_literal216_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, string_literal216)); - ADAPTOR->addChild(ADAPTOR, root_0, string_literal216_tree); - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulenumericLiteralEx; /* Prevent compiler warnings */ - rulenumericLiteralEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end numericLiteral */ - -/** - * $ANTLR start stringLiteral - * NDDL/base/antlr/NDDL3.g:443:1: stringLiteral : STRING ; - */ -static NDDL3Parser_stringLiteral_return -stringLiteral(pNDDL3Parser ctx) -{ - NDDL3Parser_stringLiteral_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN STRING217; - - pANTLR3_BASE_TREE STRING217_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - STRING217 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - STRING217_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:444:5: ( STRING ) - // NDDL/base/antlr/NDDL3.g:444:9: STRING - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - STRING217 = (pANTLR3_COMMON_TOKEN) MATCHT(STRING, &FOLLOW_STRING_in_stringLiteral2634); - if (HASEXCEPTION()) - { - goto rulestringLiteralEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { - STRING217_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STRING217)); - ADAPTOR->addChild(ADAPTOR, root_0, STRING217_tree); - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulestringLiteralEx; /* Prevent compiler warnings */ - rulestringLiteralEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end stringLiteral */ - -/** - * $ANTLR start methodInvocation - * NDDL/base/antlr/NDDL3.g:447:1: methodInvocation : ( qualified '.' methodName variableArgumentList ';' -> ^( METHOD_CALL qualified methodName variableArgumentList ) | 'close' variableArgumentList ';' -> ^( CLOSE CLOSE ) ); - */ -static NDDL3Parser_methodInvocation_return -methodInvocation(pNDDL3Parser ctx) -{ - NDDL3Parser_methodInvocation_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal219; - pANTLR3_COMMON_TOKEN char_literal222; - pANTLR3_COMMON_TOKEN string_literal223; - pANTLR3_COMMON_TOKEN char_literal225; - NDDL3Parser_qualified_return qualified218; - #undef RETURN_TYPE_qualified218 - #define RETURN_TYPE_qualified218 NDDL3Parser_qualified_return - - NDDL3Parser_methodName_return methodName220; - #undef RETURN_TYPE_methodName220 - #define RETURN_TYPE_methodName220 NDDL3Parser_methodName_return - - NDDL3Parser_variableArgumentList_return variableArgumentList221; - #undef RETURN_TYPE_variableArgumentList221 - #define RETURN_TYPE_variableArgumentList221 NDDL3Parser_variableArgumentList_return - - NDDL3Parser_variableArgumentList_return variableArgumentList224; - #undef RETURN_TYPE_variableArgumentList224 - #define RETURN_TYPE_variableArgumentList224 NDDL3Parser_variableArgumentList_return - - pANTLR3_BASE_TREE char_literal219_tree; - pANTLR3_BASE_TREE char_literal222_tree; - pANTLR3_BASE_TREE string_literal223_tree; - pANTLR3_BASE_TREE char_literal225_tree; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_108; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_46; - pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_37; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_variableArgumentList; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_methodName; - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_qualified; - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal219 = NULL; - char_literal222 = NULL; - string_literal223 = NULL; - char_literal225 = NULL; - qualified218.tree = NULL; - - methodName220.tree = NULL; - - variableArgumentList221.tree = NULL; - - variableArgumentList224.tree = NULL; - - retval.start = LT(1); retval.stop = retval.start; - - char_literal219_tree = NULL; - char_literal222_tree = NULL; - string_literal223_tree = NULL; - char_literal225_tree = NULL; - - stream_108 = NULL; - #define CREATE_stream_108 if (stream_108 == NULL) {stream_108 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 108"); } - stream_46 = NULL; - #define CREATE_stream_46 if (stream_46 == NULL) {stream_46 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 46"); } - stream_37 = NULL; - #define CREATE_stream_37 if (stream_37 == NULL) {stream_37 = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token 37"); } - stream_variableArgumentList = NULL; - #define CREATE_stream_variableArgumentList if (stream_variableArgumentList == NULL) {stream_variableArgumentList = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule variableArgumentList"); } - stream_methodName = NULL; - #define CREATE_stream_methodName if (stream_methodName == NULL) {stream_methodName = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule methodName"); } - stream_qualified = NULL; - #define CREATE_stream_qualified if (stream_qualified == NULL) {stream_qualified = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule qualified"); } - - retval.tree = NULL; - { - { - // NDDL/base/antlr/NDDL3.g:448:5: ( qualified '.' methodName variableArgumentList ';' -> ^( METHOD_CALL qualified methodName variableArgumentList ) | 'close' variableArgumentList ';' -> ^( CLOSE CLOSE ) ) - - ANTLR3_UINT32 alt58; - - alt58=2; - - - { - int LA58_0 = LA(1); - if ( (LA58_0 == IDENT || LA58_0 == 45) ) - { - alt58=1; - } - else if ( (LA58_0 == 108) ) - { - alt58=2; - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 58; - EXCEPTION->state = 0; - - - goto rulemethodInvocationEx; - } - } - switch (alt58) - { - case 1: - // NDDL/base/antlr/NDDL3.g:448:9: qualified '.' methodName variableArgumentList ';' - { - FOLLOWPUSH(FOLLOW_qualified_in_methodInvocation2657); - qualified218=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_qualified; stream_qualified->add(stream_qualified, qualified218.tree, NULL); } - char_literal219 = (pANTLR3_COMMON_TOKEN) MATCHT(46, &FOLLOW_46_in_methodInvocation2659); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_46; stream_46->add(stream_46, char_literal219, NULL); } - - FOLLOWPUSH(FOLLOW_methodName_in_methodInvocation2661); - methodName220=methodName(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_methodName; stream_methodName->add(stream_methodName, methodName220.tree, NULL); } - FOLLOWPUSH(FOLLOW_variableArgumentList_in_methodInvocation2663); - variableArgumentList221=variableArgumentList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_variableArgumentList; stream_variableArgumentList->add(stream_variableArgumentList, variableArgumentList221.tree, NULL); } - char_literal222 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_methodInvocation2665); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal222, NULL); } - - - - /* AST REWRITE - * elements : methodName, qualified, variableArgumentList - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 449:13: -> ^( METHOD_CALL qualified methodName variableArgumentList ) - { - // NDDL/base/antlr/NDDL3.g:449:16: ^( METHOD_CALL qualified methodName variableArgumentList ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, METHOD_CALL, (pANTLR3_UINT8)"METHOD_CALL"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, stream_qualified == NULL ? NULL : stream_qualified->nextTree(stream_qualified)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_methodName == NULL ? NULL : stream_methodName->nextTree(stream_methodName)); - ADAPTOR->addChild(ADAPTOR, root_1, stream_variableArgumentList == NULL ? NULL : stream_variableArgumentList->nextTree(stream_variableArgumentList)); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - break; - case 2: - // NDDL/base/antlr/NDDL3.g:450:4: 'close' variableArgumentList ';' - { - string_literal223 = (pANTLR3_COMMON_TOKEN) MATCHT(108, &FOLLOW_108_in_methodInvocation2694); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_108; stream_108->add(stream_108, string_literal223, NULL); } - - FOLLOWPUSH(FOLLOW_variableArgumentList_in_methodInvocation2696); - variableArgumentList224=variableArgumentList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_variableArgumentList; stream_variableArgumentList->add(stream_variableArgumentList, variableArgumentList224.tree, NULL); } - char_literal225 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_methodInvocation2698); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - if (HASFAILED()) - { - return retval; - } - if ( BACKTRACKING==0 ) { CREATE_stream_37; stream_37->add(stream_37, char_literal225, NULL); } - - - - /* AST REWRITE - * elements : - * token labels : - * rule labels : retval - * token list labels : - * rule list labels : - */ - if ( BACKTRACKING==0 ) - { - pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; - - stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); - - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - retval.tree = root_0; - // 451:4: -> ^( CLOSE CLOSE ) - { - // NDDL/base/antlr/NDDL3.g:451:7: ^( CLOSE CLOSE ) - { - pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, CLOSE, (pANTLR3_UINT8)"CLOSE"), root_1)); - - ADAPTOR->addChild(ADAPTOR, root_1, (pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, CLOSE, (pANTLR3_UINT8)"CLOSE")); - - ADAPTOR->addChild(ADAPTOR, root_0, root_1); - } - - } - - retval.tree = root_0; // set result root - if (stream_retval != NULL) stream_retval->free(stream_retval); - - - } - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulemethodInvocationEx; /* Prevent compiler warnings */ - rulemethodInvocationEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - if (stream_108 != NULL) stream_108->free(stream_108); - if (stream_46 != NULL) stream_46->free(stream_46); - if (stream_37 != NULL) stream_37->free(stream_37); - if (stream_variableArgumentList != NULL) stream_variableArgumentList->free(stream_variableArgumentList); - if (stream_methodName != NULL) stream_methodName->free(stream_methodName); - if (stream_qualified != NULL) stream_qualified->free(stream_qualified); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end methodInvocation */ - -/** - * $ANTLR start methodName - * NDDL/base/antlr/NDDL3.g:454:1: methodName : ( IDENT | 'close' ); - */ -static NDDL3Parser_methodName_return -methodName(pNDDL3Parser ctx) -{ - NDDL3Parser_methodName_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN set226; - - pANTLR3_BASE_TREE set226_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - set226 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - set226_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:455:2: ( IDENT | 'close' ) - // NDDL/base/antlr/NDDL3.g: - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - set226=(pANTLR3_COMMON_TOKEN)LT(1); - if ( LA(1) == IDENT || LA(1) == 108 ) - { - CONSUME(); - if ( BACKTRACKING==0 ) ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set226))); - PERRORRECOVERY=ANTLR3_FALSE;FAILEDFLAG=ANTLR3_FALSE; - - } - else - { - if (BACKTRACKING>0) - { - FAILEDFLAG = ANTLR3_TRUE; - return retval; - } - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - EXCEPTION->expectingSet = &FOLLOW_set_in_methodName0; - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_methodName0); goto rulemethodNameEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto rulemethodNameEx; /* Prevent compiler warnings */ - rulemethodNameEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end methodName */ - -/** - * $ANTLR start noopstatement - * NDDL/base/antlr/NDDL3.g:459:1: noopstatement : ';' ; - */ -static NDDL3Parser_noopstatement_return -noopstatement(pNDDL3Parser ctx) -{ - NDDL3Parser_noopstatement_return retval; - - pANTLR3_BASE_TREE root_0; - - pANTLR3_COMMON_TOKEN char_literal227; - - pANTLR3_BASE_TREE char_literal227_tree; - - /* Initialize rule variables - */ - - - root_0 = NULL; - - char_literal227 = NULL; - retval.start = LT(1); retval.stop = retval.start; - - char_literal227_tree = NULL; - - - retval.tree = NULL; - { - // NDDL/base/antlr/NDDL3.g:460:2: ( ';' ) - // NDDL/base/antlr/NDDL3.g:460:4: ';' - { - root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); - - char_literal227 = (pANTLR3_COMMON_TOKEN) MATCHT(37, &FOLLOW_37_in_noopstatement2739); - if (HASEXCEPTION()) - { - goto rulenoopstatementEx; - } - if (HASFAILED()) - { - return retval; - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulenoopstatementEx; /* Prevent compiler warnings */ - rulenoopstatementEx: ; - retval.stop = LT(-1); - - if ( BACKTRACKING==0 ) - { - retval.stop = LT(-1); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); - ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); - } - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); - } - - return retval; -} -/* $ANTLR end noopstatement */ - -// $ANTLR start synpred1_NDDL3 -static void synpred1_NDDL3_fragment(pNDDL3Parser ctx ) -{ - // NDDL/base/antlr/NDDL3.g:304:5: ( IDENT variableArgumentList ( ':' violationMsg )? ';' ) - // NDDL/base/antlr/NDDL3.g:304:6: IDENT variableArgumentList ( ':' violationMsg )? ';' - { - MATCHT(IDENT, &FOLLOW_IDENT_in_synpred1_NDDL31612); - if (HASEXCEPTION()) - { - goto rulesynpred1_NDDL3Ex; - } - if (HASFAILED()) - { - return ; - } - FOLLOWPUSH(FOLLOW_variableArgumentList_in_synpred1_NDDL31614); - variableArgumentList(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulesynpred1_NDDL3Ex; - } - if (HASFAILED()) - { - return ; - } - - // NDDL/base/antlr/NDDL3.g:304:33: ( ':' violationMsg )? - { - int alt59=2; - { - int LA59_0 = LA(1); - if ( (LA59_0 == 62) ) - { - alt59=1; - } - } - switch (alt59) - { - case 1: - // NDDL/base/antlr/NDDL3.g:304:34: ':' violationMsg - { - MATCHT(62, &FOLLOW_62_in_synpred1_NDDL31617); - if (HASEXCEPTION()) - { - goto rulesynpred1_NDDL3Ex; - } - if (HASFAILED()) - { - return ; - } - FOLLOWPUSH(FOLLOW_violationMsg_in_synpred1_NDDL31619); - violationMsg(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulesynpred1_NDDL3Ex; - } - if (HASFAILED()) - { - return ; - } - - } - break; - - } - } - MATCHT(37, &FOLLOW_37_in_synpred1_NDDL31623); - if (HASEXCEPTION()) - { - goto rulesynpred1_NDDL3Ex; - } - if (HASFAILED()) - { - return ; - } - - } - -// This is where rules clean up and exit -// -goto rulesynpred1_NDDL3Ex; /* Prevent compiler warnings */ -rulesynpred1_NDDL3Ex: ; - -} -// $ANTLR end synpred1_NDDL3 - -// $ANTLR start synpred2_NDDL3 -static void synpred2_NDDL3_fragment(pNDDL3Parser ctx ) -{ - // NDDL/base/antlr/NDDL3.g:384:52: ( 'else' ) - // NDDL/base/antlr/NDDL3.g:384:53: 'else' - { - MATCHT(77, &FOLLOW_77_in_synpred2_NDDL32113); - if (HASEXCEPTION()) - { - goto rulesynpred2_NDDL3Ex; - } - if (HASFAILED()) - { - return ; - } - - } - -// This is where rules clean up and exit -// -goto rulesynpred2_NDDL3Ex; /* Prevent compiler warnings */ -rulesynpred2_NDDL3Ex: ; - -} -// $ANTLR end synpred2_NDDL3 -/* End of parsing rules - * ============================================== - */ - -/* ============================================== - * Syntactic predicates - */ -static ANTLR3_BOOLEAN synpred2_NDDL3(pNDDL3Parser ctx) -{ - ANTLR3_MARKER start; - ANTLR3_BOOLEAN success; - - BACKTRACKING++; - start = MARK(); - synpred2_NDDL3_fragment(ctx); // can never throw exception - success = !(FAILEDFLAG); - REWIND(start); - BACKTRACKING--; - FAILEDFLAG = ANTLR3_FALSE; - return success; -} -static ANTLR3_BOOLEAN synpred1_NDDL3(pNDDL3Parser ctx) -{ - ANTLR3_MARKER start; - ANTLR3_BOOLEAN success; - - BACKTRACKING++; - start = MARK(); - synpred1_NDDL3_fragment(ctx); // can never throw exception - success = !(FAILEDFLAG); - REWIND(start); - BACKTRACKING--; - FAILEDFLAG = ANTLR3_FALSE; - return success; -} - -/* End of syntactic predicates - * ============================================== - */ - - - - - - -/* End of code - * ============================================================================= - */ diff --git a/src/PLASMA/NDDL/base/NDDL3Parser.h b/src/PLASMA/NDDL/base/NDDL3Parser.h deleted file mode 100644 index 9cf387d22..000000000 --- a/src/PLASMA/NDDL/base/NDDL3Parser.h +++ /dev/null @@ -1,1190 +0,0 @@ -/** \file - * This C header file was generated by $ANTLR version 3.1.2 - * - * - From the grammar source file : NDDL/base/antlr/NDDL3.g - * - On : 2011-08-29 18:06:01 - * - for the parser : NDDL3ParserParser * - * Editing it, at least manually, is not wise. - * - * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. - * - * - * The parser NDDL3Parser has the callable functions (rules) shown below, - * which will invoke the code for the associated rule in the source grammar - * assuming that the input stream is pointing to a token/text stream that could begin - * this rule. - * - * For instance if you call the first (topmost) rule in a parser grammar, you will - * get the results of a full parse, but calling a rule half way through the grammar will - * allow you to pass part of a full token stream to the parser, such as for syntax checking - * in editors and so on. - * - * The parser entry points are called indirectly (by function pointer to function) via - * a parser context typedef pNDDL3Parser, which is returned from a call to NDDL3ParserNew(). - * - * The methods in pNDDL3Parser are as follows: - * - * - NDDL3Parser_nddl_return pNDDL3Parser->nddl(pNDDL3Parser) - * - NDDL3Parser_nddlStatement_return pNDDL3Parser->nddlStatement(pNDDL3Parser) - * - NDDL3Parser_enumDefinition_return pNDDL3Parser->enumDefinition(pNDDL3Parser) - * - NDDL3Parser_enumValues_return pNDDL3Parser->enumValues(pNDDL3Parser) - * - NDDL3Parser_typeDefinition_return pNDDL3Parser->typeDefinition(pNDDL3Parser) - * - NDDL3Parser_baseDomain_return pNDDL3Parser->baseDomain(pNDDL3Parser) - * - NDDL3Parser_intervalBaseDomain_return pNDDL3Parser->intervalBaseDomain(pNDDL3Parser) - * - NDDL3Parser_enumeratedBaseDomain_return pNDDL3Parser->enumeratedBaseDomain(pNDDL3Parser) - * - NDDL3Parser_baseDomainValue_return pNDDL3Parser->baseDomainValue(pNDDL3Parser) - * - NDDL3Parser_variableDeclarations_return pNDDL3Parser->variableDeclarations(pNDDL3Parser) - * - NDDL3Parser_nameWithBaseDomain_return pNDDL3Parser->nameWithBaseDomain(pNDDL3Parser) - * - NDDL3Parser_anyValue_return pNDDL3Parser->anyValue(pNDDL3Parser) - * - NDDL3Parser_allocation_return pNDDL3Parser->allocation(pNDDL3Parser) - * - NDDL3Parser_constructorInvocation_return pNDDL3Parser->constructorInvocation(pNDDL3Parser) - * - NDDL3Parser_qualified_return pNDDL3Parser->qualified(pNDDL3Parser) - * - NDDL3Parser_assignment_return pNDDL3Parser->assignment(pNDDL3Parser) - * - NDDL3Parser_initializer_return pNDDL3Parser->initializer(pNDDL3Parser) - * - NDDL3Parser_classDeclaration_return pNDDL3Parser->classDeclaration(pNDDL3Parser) - * - NDDL3Parser_classBlock_return pNDDL3Parser->classBlock(pNDDL3Parser) - * - NDDL3Parser_classStatement_return pNDDL3Parser->classStatement(pNDDL3Parser) - * - NDDL3Parser_constructor_return pNDDL3Parser->constructor(pNDDL3Parser) - * - NDDL3Parser_constructorBlock_return pNDDL3Parser->constructorBlock(pNDDL3Parser) - * - NDDL3Parser_constructorStatement_return pNDDL3Parser->constructorStatement(pNDDL3Parser) - * - NDDL3Parser_constructorParameterList_return pNDDL3Parser->constructorParameterList(pNDDL3Parser) - * - NDDL3Parser_constructorParameters_return pNDDL3Parser->constructorParameters(pNDDL3Parser) - * - NDDL3Parser_constructorParameter_return pNDDL3Parser->constructorParameter(pNDDL3Parser) - * - NDDL3Parser_tokenType_return pNDDL3Parser->tokenType(pNDDL3Parser) - * - NDDL3Parser_tokenBlock_return pNDDL3Parser->tokenBlock(pNDDL3Parser) - * - NDDL3Parser_tokenStatement_return pNDDL3Parser->tokenStatement(pNDDL3Parser) - * - NDDL3Parser_rule_return pNDDL3Parser->rule(pNDDL3Parser) - * - NDDL3Parser_ruleBlock_return pNDDL3Parser->ruleBlock(pNDDL3Parser) - * - NDDL3Parser_ruleStatement_return pNDDL3Parser->ruleStatement(pNDDL3Parser) - * - NDDL3Parser_type_return pNDDL3Parser->type(pNDDL3Parser) - * - NDDL3Parser_relation_return pNDDL3Parser->relation(pNDDL3Parser) - * - NDDL3Parser_problemStmt_return pNDDL3Parser->problemStmt(pNDDL3Parser) - * - NDDL3Parser_tokenInstanceList_return pNDDL3Parser->tokenInstanceList(pNDDL3Parser) - * - NDDL3Parser_tokenVarRef_return pNDDL3Parser->tokenVarRef(pNDDL3Parser) - * - NDDL3Parser_tokenInstances_return pNDDL3Parser->tokenInstances(pNDDL3Parser) - * - NDDL3Parser_tokenInstance_return pNDDL3Parser->tokenInstance(pNDDL3Parser) - * - NDDL3Parser_tokenAnnotation_return pNDDL3Parser->tokenAnnotation(pNDDL3Parser) - * - NDDL3Parser_constraintInstantiation_return pNDDL3Parser->constraintInstantiation(pNDDL3Parser) - * - NDDL3Parser_enforceStatement_return pNDDL3Parser->enforceStatement(pNDDL3Parser) - * - NDDL3Parser_violationMsg_return pNDDL3Parser->violationMsg(pNDDL3Parser) - * - NDDL3Parser_cexpression_return pNDDL3Parser->cexpression(pNDDL3Parser) - * - NDDL3Parser_cbooleanOrExpression_return pNDDL3Parser->cbooleanOrExpression(pNDDL3Parser) - * - NDDL3Parser_cbooleanAndExpression_return pNDDL3Parser->cbooleanAndExpression(pNDDL3Parser) - * - NDDL3Parser_crelationalExpression_return pNDDL3Parser->crelationalExpression(pNDDL3Parser) - * - NDDL3Parser_cadditiveExpression_return pNDDL3Parser->cadditiveExpression(pNDDL3Parser) - * - NDDL3Parser_cmultiplicativeExpression_return pNDDL3Parser->cmultiplicativeExpression(pNDDL3Parser) - * - NDDL3Parser_cprimary_return pNDDL3Parser->cprimary(pNDDL3Parser) - * - NDDL3Parser_cexpressionList_return pNDDL3Parser->cexpressionList(pNDDL3Parser) - * - NDDL3Parser_superInvocation_return pNDDL3Parser->superInvocation(pNDDL3Parser) - * - NDDL3Parser_variableArgumentList_return pNDDL3Parser->variableArgumentList(pNDDL3Parser) - * - NDDL3Parser_variableArguments_return pNDDL3Parser->variableArguments(pNDDL3Parser) - * - NDDL3Parser_variableArgument_return pNDDL3Parser->variableArgument(pNDDL3Parser) - * - NDDL3Parser_typeArgumentList_return pNDDL3Parser->typeArgumentList(pNDDL3Parser) - * - NDDL3Parser_typeArguments_return pNDDL3Parser->typeArguments(pNDDL3Parser) - * - NDDL3Parser_typeArgument_return pNDDL3Parser->typeArgument(pNDDL3Parser) - * - NDDL3Parser_flowControl_return pNDDL3Parser->flowControl(pNDDL3Parser) - * - NDDL3Parser_guardExpression_return pNDDL3Parser->guardExpression(pNDDL3Parser) - * - NDDL3Parser_allocationStmt_return pNDDL3Parser->allocationStmt(pNDDL3Parser) - * - NDDL3Parser_temporalRelation_return pNDDL3Parser->temporalRelation(pNDDL3Parser) - * - NDDL3Parser_literalValue_return pNDDL3Parser->literalValue(pNDDL3Parser) - * - NDDL3Parser_booleanLiteral_return pNDDL3Parser->booleanLiteral(pNDDL3Parser) - * - NDDL3Parser_numericLiteral_return pNDDL3Parser->numericLiteral(pNDDL3Parser) - * - NDDL3Parser_stringLiteral_return pNDDL3Parser->stringLiteral(pNDDL3Parser) - * - NDDL3Parser_methodInvocation_return pNDDL3Parser->methodInvocation(pNDDL3Parser) - * - NDDL3Parser_methodName_return pNDDL3Parser->methodName(pNDDL3Parser) - * - NDDL3Parser_noopstatement_return pNDDL3Parser->noopstatement(pNDDL3Parser) - * - * - * - * The return type for any particular rule is of course determined by the source - * grammar file. - */ -// [The "BSD licence"] -// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC -// http://www.temporal-wave.com -// http://www.linkedin.com/in/jimidle -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef _NDDL3Parser_H -#define _NDDL3Parser_H -/* ============================================================================= - * Standard antlr3 C runtime definitions - */ -#include - -/* End of standard antlr 3 runtime definitions - * ============================================================================= - */ - -#include "NddlInterpreter.hh" - - -using namespace EUROPA; - -// Forward declaration so that we can use this function in apifuncs -typedef struct NDDL3Parser_Ctx_struct NDDL3Parser, * pNDDL3Parser; -static void newNDDL3ParserFree(pNDDL3Parser ctx); - - -#ifdef __cplusplus -extern "C" { -#endif - -// Forward declare the context typedef so that we can use it before it is -// properly defined. Delegators and delegates (from import statements) are -// interdependent and their context structures contain pointers to each other -// C only allows such things to be declared if you pre-declare the typedef. -// -typedef struct NDDL3Parser_Ctx_struct NDDL3Parser, * pNDDL3Parser; - - - -#ifdef ANTLR3_WINDOWS -// Disable: Unreferenced parameter, - Rules with parameters that are not used -// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) -// initialized but unused variable - tree rewrite variables declared but not needed -// Unreferenced local variable - lexer rule declares but does not always use _type -// potentially unitialized variable used - retval always returned from a rule -// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns -// -// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at -// and the codegen must generate some of these warnings by necessity, apart from 4100, which is -// usually generated when a parser rule is given a parameter that it does not use. Mostly though -// this is a matter of orthogonality hence I disable that one. -// -#pragma warning( disable : 4100 ) -#pragma warning( disable : 4101 ) -#pragma warning( disable : 4127 ) -#pragma warning( disable : 4189 ) -#pragma warning( disable : 4505 ) -#pragma warning( disable : 4701 ) -#endif - -/* ======================== - * BACKTRACKING IS ENABLED - * ======================== - */ -typedef struct NDDL3Parser_nddl_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_nddl_return; - -typedef struct NDDL3Parser_nddlStatement_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_nddlStatement_return; - -typedef struct NDDL3Parser_enumDefinition_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_enumDefinition_return; - -typedef struct NDDL3Parser_enumValues_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_enumValues_return; - -typedef struct NDDL3Parser_typeDefinition_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_typeDefinition_return; - -typedef struct NDDL3Parser_baseDomain_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_baseDomain_return; - -typedef struct NDDL3Parser_intervalBaseDomain_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_intervalBaseDomain_return; - -typedef struct NDDL3Parser_enumeratedBaseDomain_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_enumeratedBaseDomain_return; - -typedef struct NDDL3Parser_baseDomainValue_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_baseDomainValue_return; - -typedef struct NDDL3Parser_variableDeclarations_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_variableDeclarations_return; - -typedef struct NDDL3Parser_nameWithBaseDomain_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_nameWithBaseDomain_return; - -typedef struct NDDL3Parser_anyValue_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_anyValue_return; - -typedef struct NDDL3Parser_allocation_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_allocation_return; - -typedef struct NDDL3Parser_constructorInvocation_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_constructorInvocation_return; - -typedef struct NDDL3Parser_qualified_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_qualified_return; - -typedef struct NDDL3Parser_assignment_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_assignment_return; - -typedef struct NDDL3Parser_initializer_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_initializer_return; - -typedef struct NDDL3Parser_classDeclaration_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_classDeclaration_return; - -typedef struct NDDL3Parser_classBlock_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_classBlock_return; - -typedef struct NDDL3Parser_classStatement_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_classStatement_return; - -typedef struct NDDL3Parser_constructor_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_constructor_return; - -typedef struct NDDL3Parser_constructorBlock_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_constructorBlock_return; - -typedef struct NDDL3Parser_constructorStatement_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_constructorStatement_return; - -typedef struct NDDL3Parser_constructorParameterList_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_constructorParameterList_return; - -typedef struct NDDL3Parser_constructorParameters_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_constructorParameters_return; - -typedef struct NDDL3Parser_constructorParameter_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_constructorParameter_return; - -typedef struct NDDL3Parser_tokenType_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_tokenType_return; - -typedef struct NDDL3Parser_tokenBlock_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_tokenBlock_return; - -typedef struct NDDL3Parser_tokenStatement_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_tokenStatement_return; - -typedef struct NDDL3Parser_rule_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_rule_return; - -typedef struct NDDL3Parser_ruleBlock_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_ruleBlock_return; - -typedef struct NDDL3Parser_ruleStatement_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_ruleStatement_return; - -typedef struct NDDL3Parser_type_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_type_return; - -typedef struct NDDL3Parser_relation_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_relation_return; - -typedef struct NDDL3Parser_problemStmt_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_problemStmt_return; - -typedef struct NDDL3Parser_tokenInstanceList_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_tokenInstanceList_return; - -typedef struct NDDL3Parser_tokenVarRef_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_tokenVarRef_return; - -typedef struct NDDL3Parser_tokenInstances_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_tokenInstances_return; - -typedef struct NDDL3Parser_tokenInstance_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_tokenInstance_return; - -typedef struct NDDL3Parser_tokenAnnotation_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_tokenAnnotation_return; - -typedef struct NDDL3Parser_constraintInstantiation_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_constraintInstantiation_return; - -typedef struct NDDL3Parser_enforceStatement_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_enforceStatement_return; - -typedef struct NDDL3Parser_violationMsg_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_violationMsg_return; - -typedef struct NDDL3Parser_cexpression_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_cexpression_return; - -typedef struct NDDL3Parser_cbooleanOrExpression_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_cbooleanOrExpression_return; - -typedef struct NDDL3Parser_cbooleanAndExpression_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_cbooleanAndExpression_return; - -typedef struct NDDL3Parser_crelationalExpression_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_crelationalExpression_return; - -typedef struct NDDL3Parser_cadditiveExpression_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_cadditiveExpression_return; - -typedef struct NDDL3Parser_cmultiplicativeExpression_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_cmultiplicativeExpression_return; - -typedef struct NDDL3Parser_cprimary_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_cprimary_return; - -typedef struct NDDL3Parser_cexpressionList_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_cexpressionList_return; - -typedef struct NDDL3Parser_superInvocation_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_superInvocation_return; - -typedef struct NDDL3Parser_variableArgumentList_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_variableArgumentList_return; - -typedef struct NDDL3Parser_variableArguments_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_variableArguments_return; - -typedef struct NDDL3Parser_variableArgument_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_variableArgument_return; - -typedef struct NDDL3Parser_typeArgumentList_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_typeArgumentList_return; - -typedef struct NDDL3Parser_typeArguments_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_typeArguments_return; - -typedef struct NDDL3Parser_typeArgument_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_typeArgument_return; - -typedef struct NDDL3Parser_flowControl_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_flowControl_return; - -typedef struct NDDL3Parser_guardExpression_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_guardExpression_return; - -typedef struct NDDL3Parser_allocationStmt_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_allocationStmt_return; - -typedef struct NDDL3Parser_temporalRelation_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_temporalRelation_return; - -typedef struct NDDL3Parser_literalValue_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_literalValue_return; - -typedef struct NDDL3Parser_booleanLiteral_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_booleanLiteral_return; - -typedef struct NDDL3Parser_numericLiteral_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_numericLiteral_return; - -typedef struct NDDL3Parser_stringLiteral_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_stringLiteral_return; - -typedef struct NDDL3Parser_methodInvocation_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_methodInvocation_return; - -typedef struct NDDL3Parser_methodName_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_methodName_return; - -typedef struct NDDL3Parser_noopstatement_return_struct -{ - /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees - */ - pANTLR3_COMMON_TOKEN start; - pANTLR3_COMMON_TOKEN stop; - pANTLR3_BASE_TREE tree; - -} - NDDL3Parser_noopstatement_return; - - - -/** Context tracking structure for NDDL3Parser - */ -struct NDDL3Parser_Ctx_struct -{ - /** Built in ANTLR3 context tracker contains all the generic elements - * required for context tracking. - */ - pANTLR3_PARSER pParser; - - - NDDL3Parser_nddl_return (*nddl) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_nddlStatement_return (*nddlStatement) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_enumDefinition_return (*enumDefinition) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_enumValues_return (*enumValues) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_typeDefinition_return (*typeDefinition) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_baseDomain_return (*baseDomain) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_intervalBaseDomain_return (*intervalBaseDomain) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_enumeratedBaseDomain_return (*enumeratedBaseDomain) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_baseDomainValue_return (*baseDomainValue) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_variableDeclarations_return (*variableDeclarations) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_nameWithBaseDomain_return (*nameWithBaseDomain) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_anyValue_return (*anyValue) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_allocation_return (*allocation) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_constructorInvocation_return (*constructorInvocation) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_qualified_return (*qualified) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_assignment_return (*assignment) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_initializer_return (*initializer) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_classDeclaration_return (*classDeclaration) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_classBlock_return (*classBlock) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_classStatement_return (*classStatement) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_constructor_return (*constructor) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_constructorBlock_return (*constructorBlock) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_constructorStatement_return (*constructorStatement) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_constructorParameterList_return (*constructorParameterList) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_constructorParameters_return (*constructorParameters) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_constructorParameter_return (*constructorParameter) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_tokenType_return (*tokenType) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_tokenBlock_return (*tokenBlock) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_tokenStatement_return (*tokenStatement) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_rule_return (*rule) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_ruleBlock_return (*ruleBlock) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_ruleStatement_return (*ruleStatement) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_type_return (*type) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_relation_return (*relation) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_problemStmt_return (*problemStmt) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_tokenInstanceList_return (*tokenInstanceList) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_tokenVarRef_return (*tokenVarRef) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_tokenInstances_return (*tokenInstances) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_tokenInstance_return (*tokenInstance) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_tokenAnnotation_return (*tokenAnnotation) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_constraintInstantiation_return (*constraintInstantiation) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_enforceStatement_return (*enforceStatement) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_violationMsg_return (*violationMsg) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_cexpression_return (*cexpression) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_cbooleanOrExpression_return (*cbooleanOrExpression) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_cbooleanAndExpression_return (*cbooleanAndExpression) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_crelationalExpression_return (*crelationalExpression) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_cadditiveExpression_return (*cadditiveExpression) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_cmultiplicativeExpression_return (*cmultiplicativeExpression) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_cprimary_return (*cprimary) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_cexpressionList_return (*cexpressionList) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_superInvocation_return (*superInvocation) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_variableArgumentList_return (*variableArgumentList) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_variableArguments_return (*variableArguments) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_variableArgument_return (*variableArgument) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_typeArgumentList_return (*typeArgumentList) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_typeArguments_return (*typeArguments) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_typeArgument_return (*typeArgument) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_flowControl_return (*flowControl) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_guardExpression_return (*guardExpression) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_allocationStmt_return (*allocationStmt) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_temporalRelation_return (*temporalRelation) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_literalValue_return (*literalValue) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_booleanLiteral_return (*booleanLiteral) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_numericLiteral_return (*numericLiteral) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_stringLiteral_return (*stringLiteral) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_methodInvocation_return (*methodInvocation) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_methodName_return (*methodName) (struct NDDL3Parser_Ctx_struct * ctx); - NDDL3Parser_noopstatement_return (*noopstatement) (struct NDDL3Parser_Ctx_struct * ctx); - ANTLR3_BOOLEAN (*synpred1_NDDL3) (struct NDDL3Parser_Ctx_struct * ctx); - ANTLR3_BOOLEAN (*synpred2_NDDL3) (struct NDDL3Parser_Ctx_struct * ctx); - // Delegated rules - const char * (*getGrammarFileName)(); - void (*free) (struct NDDL3Parser_Ctx_struct * ctx); - /* @headerFile.members() */ - pANTLR3_BASE_TREE_ADAPTOR adaptor; - pANTLR3_VECTOR_FACTORY vectors; - /* End @headerFile.members() */ - - std::vector* parserErrors; - -}; - -// Function protoypes for the constructor functions that external translation units -// such as delegators and delegates may wish to call. -// -ANTLR3_API pNDDL3Parser NDDL3ParserNew (pANTLR3_COMMON_TOKEN_STREAM instream); -ANTLR3_API pNDDL3Parser NDDL3ParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); - -/** Symbolic definitions of all the tokens that the parser will work with. - * \{ - * - * Antlr will define EOF, but we can't use that as it it is too common in - * in C header files and that would be confusing. There is no way to filter this out at the moment - * so we just undef it here for now. That isn't the value we get back from C recognizers - * anyway. We are looking for ANTLR3_TOKEN_EOF. - */ -#ifdef EOF -#undef EOF -#endif -#ifdef Tokens -#undef Tokens -#endif -#define EXPONENT 28 -#define FLOAT_SUFFIX 29 -#define CONSTRUCTOR_INVOCATION 6 -#define OCTAL_ESC 24 -#define EOF -1 -#define T__93 93 -#define T__94 94 -#define T__91 91 -#define T__92 92 -#define T__90 90 -#define INCLUDE 21 -#define PREDICATE_INSTANCE 9 -#define COMMENT 30 -#define T__99 99 -#define T__98 98 -#define T__97 97 -#define T__96 96 -#define T__95 95 -#define T__80 80 -#define T__81 81 -#define T__82 82 -#define T__83 83 -#define LINE_COMMENT 31 -#define INT 17 -#define T__85 85 -#define T__84 84 -#define T__87 87 -#define METHOD_CALL 7 -#define T__86 86 -#define T__89 89 -#define T__88 88 -#define WS 20 -#define T__71 71 -#define T__72 72 -#define VARIABLE 11 -#define T__70 70 -#define T__76 76 -#define T__75 75 -#define FUNCTION_CALL 14 -#define T__74 74 -#define T__73 73 -#define CONSTRUCTOR 5 -#define T__79 79 -#define T__78 78 -#define T__77 77 -#define T__68 68 -#define T__69 69 -#define T__66 66 -#define T__67 67 -#define T__64 64 -#define T__65 65 -#define INT_SUFFIX 27 -#define T__62 62 -#define T__63 63 -#define FLOAT 18 -#define TOKEN_RELATION 10 -#define T__61 61 -#define T__60 60 -#define EXPRESSION_ENFORCE 12 -#define T__55 55 -#define ESCAPE_SEQUENCE 22 -#define T__56 56 -#define T__57 57 -#define T__58 58 -#define T__51 51 -#define T__52 52 -#define T__53 53 -#define T__54 54 -#define T__107 107 -#define T__108 108 -#define T__59 59 -#define T__103 103 -#define T__104 104 -#define T__105 105 -#define T__106 106 -#define IDENT 16 -#define DIGIT 26 -#define T__50 50 -#define T__42 42 -#define T__43 43 -#define T__40 40 -#define T__41 41 -#define T__46 46 -#define T__47 47 -#define T__44 44 -#define T__45 45 -#define T__48 48 -#define T__49 49 -#define UNICODE_ESC 23 -#define HEX_DIGIT 25 -#define T__102 102 -#define T__101 101 -#define T__100 100 -#define T__32 32 -#define T__33 33 -#define T__34 34 -#define T__35 35 -#define EXPRESSION_RETURN 13 -#define CLOSE 15 -#define T__36 36 -#define T__37 37 -#define T__38 38 -#define NDDL 8 -#define T__39 39 -#define CONSTRAINT_INSTANTIATION 4 -#define STRING 19 -#ifdef EOF -#undef EOF -#define EOF ANTLR3_TOKEN_EOF -#endif - -#ifndef TOKENSOURCE -#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource -#endif - -/* End of token definitions for NDDL3Parser - * ============================================================================= - */ -/** \} */ - -#ifdef __cplusplus -} -#endif - -#endif - -/* END - Note:Keep extra line feed to satisfy UNIX systems */ diff --git a/src/PLASMA/NDDL/base/NDDL3Tree.cpp b/src/PLASMA/NDDL/base/NDDL3Tree.cpp deleted file mode 100644 index 51c23f46d..000000000 --- a/src/PLASMA/NDDL/base/NDDL3Tree.cpp +++ /dev/null @@ -1,8703 +0,0 @@ -/** \file - * This C source file was generated by $ANTLR version 3.1.2 - * - * - From the grammar source file : NDDL/base/antlr/NDDL3Tree.g - * - On : 2012-01-27 14:56:23 - * - for the tree parser : NDDL3TreeTreeParser * - * Editing it, at least manually, is not wise. - * - * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. - * - * -*/ -// [The "BSD licence"] -// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC -// http://www.temporal-wave.com -// http://www.linkedin.com/in/jimidle -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* ----------------------------------------- - * Include the ANTLR3 generated header file. - */ -#include "NDDL3Tree.h" -/* ----------------------------------------- */ - - - - - -/* MACROS that hide the C interface implementations from the - * generated code, which makes it a little more understandable to the human eye. - * I am very much against using C pre-processor macros for function calls and bits - * of code as you cannot see what is happening when single stepping in debuggers - * and so on. The exception (in my book at least) is for generated code, where you are - * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() - * hides some indirect calls, but is always referring to the input stream. This is - * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig - * the runtime interfaces without changing the generated code too often, without - * confusing the reader of the generated output, who may not wish to know the gory - * details of the interface inheritance. - */ - -#define CTX ctx - -/* Aids in accessing scopes for grammar programmers - */ -#undef SCOPE_TYPE -#undef SCOPE_STACK -#undef SCOPE_TOP -#define SCOPE_TYPE(scope) pNDDL3Tree_##scope##_SCOPE -#define SCOPE_STACK(scope) pNDDL3Tree_##scope##Stack -#define SCOPE_TOP(scope) ctx->pNDDL3Tree_##scope##Top -#define SCOPE_SIZE(scope) (ctx->SCOPE_STACK(scope)->size(ctx->SCOPE_STACK(scope))) -#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) - -/* Macros for accessing things in the parser - */ - -#undef PARSER -#undef RECOGNIZER -#undef HAVEPARSEDRULE -#undef INPUT -#undef STRSTREAM -#undef HASEXCEPTION -#undef EXCEPTION -#undef MATCHT -#undef MATCHANYT -#undef FOLLOWSTACK -#undef FOLLOWPUSH -#undef FOLLOWPOP -#undef PRECOVER -#undef PREPORTERROR -#undef LA -#undef LT -#undef CONSTRUCTEX -#undef CONSUME -#undef MARK -#undef REWIND -#undef REWINDLAST -#undef PERRORRECOVERY -#undef HASFAILED -#undef FAILEDFLAG -#undef RECOVERFROMMISMATCHEDSET -#undef RECOVERFROMMISMATCHEDELEMENT -#undef BACKTRACKING -#undef ADAPTOR -#undef RULEMEMO -#undef SEEK -#undef INDEX -#undef DBG - -#define PARSER ctx->pTreeParser -#define RECOGNIZER PARSER->rec -#define PSRSTATE RECOGNIZER->state -#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) -#define INPUT PARSER->ctnstream -#define ISTREAM INPUT->tnstream->istream -#define STRSTREAM INPUT->tnstream -#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) -#define EXCEPTION PSRSTATE->exception -#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) -#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) -#define FOLLOWSTACK PSRSTATE->following -#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) -#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) -#define PRECOVER() RECOGNIZER->recover(RECOGNIZER) -#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) -#define LA(n) ISTREAM->_LA(ISTREAM, n) -#define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n) -#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) -#define CONSUME() ISTREAM->consume(ISTREAM) -#define MARK() ISTREAM->mark(ISTREAM) -#define REWIND(m) ISTREAM->rewind(ISTREAM, m) -#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) -#define PERRORRECOVERY PSRSTATE->errorRecovery -#define FAILEDFLAG PSRSTATE->failed -#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) -#define BACKTRACKING PSRSTATE->backtracking -#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) -#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) -#define ADAPTOR INPUT->adaptor -#define RULEMEMO PSRSTATE->ruleMemo -#define SEEK(n) ISTREAM->seek(ISTREAM, n) -#define INDEX() ISTREAM->index(ISTREAM) -#define DBG RECOGNIZER->debugger - - -#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt - -/* The 4 tokens defined below may well clash with your own #defines or token types. If so - * then for the present you must use different names for your defines as these are hard coded - * in the code generator. It would be better not to use such names internally, and maybe - * we can change this in a forthcoming release. I deliberately do not #undef these - * here as this will at least give you a redefined error somewhere if they clash. - */ -#define UP ANTLR3_TOKEN_UP -#define DOWN ANTLR3_TOKEN_DOWN -#define EOR ANTLR3_TOKEN_EOR -#define INVALID ANTLR3_TOKEN_INVALID - - -/* ============================================================================= - * Functions to create and destroy scopes. First come the rule scopes, followed - * by the global declared scopes. - */ - - - -/* ============================================================================= */ - -/* ============================================================================= - * Start of recognizer - */ - - - -/** \brief Table of all token names in symbolic order, mainly used for - * error reporting. - */ -pANTLR3_UINT8 NDDL3TreeTokenNames[105+4] - = { - (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ - (pANTLR3_UINT8) "", - (pANTLR3_UINT8) "", - (pANTLR3_UINT8) "", - (pANTLR3_UINT8) "CONSTRAINT_INSTANTIATION", - (pANTLR3_UINT8) "CONSTRUCTOR", - (pANTLR3_UINT8) "CONSTRUCTOR_INVOCATION", - (pANTLR3_UINT8) "METHOD_CALL", - (pANTLR3_UINT8) "NDDL", - (pANTLR3_UINT8) "PREDICATE_INSTANCE", - (pANTLR3_UINT8) "TOKEN_RELATION", - (pANTLR3_UINT8) "VARIABLE", - (pANTLR3_UINT8) "EXPRESSION_ENFORCE", - (pANTLR3_UINT8) "EXPRESSION_RETURN", - (pANTLR3_UINT8) "FUNCTION_CALL", - (pANTLR3_UINT8) "CLOSE", - (pANTLR3_UINT8) "IDENT", - (pANTLR3_UINT8) "INT", - (pANTLR3_UINT8) "FLOAT", - (pANTLR3_UINT8) "STRING", - (pANTLR3_UINT8) "WS", - (pANTLR3_UINT8) "INCLUDE", - (pANTLR3_UINT8) "ESCAPE_SEQUENCE", - (pANTLR3_UINT8) "UNICODE_ESC", - (pANTLR3_UINT8) "OCTAL_ESC", - (pANTLR3_UINT8) "HEX_DIGIT", - (pANTLR3_UINT8) "DIGIT", - (pANTLR3_UINT8) "INT_SUFFIX", - (pANTLR3_UINT8) "EXPONENT", - (pANTLR3_UINT8) "FLOAT_SUFFIX", - (pANTLR3_UINT8) "COMMENT", - (pANTLR3_UINT8) "LINE_COMMENT", - (pANTLR3_UINT8) "'enum'", - (pANTLR3_UINT8) "'{'", - (pANTLR3_UINT8) "','", - (pANTLR3_UINT8) "'}'", - (pANTLR3_UINT8) "'typedef'", - (pANTLR3_UINT8) "';'", - (pANTLR3_UINT8) "'['", - (pANTLR3_UINT8) "']'", - (pANTLR3_UINT8) "'filter'", - (pANTLR3_UINT8) "'('", - (pANTLR3_UINT8) "')'", - (pANTLR3_UINT8) "'='", - (pANTLR3_UINT8) "'new'", - (pANTLR3_UINT8) "'this'", - (pANTLR3_UINT8) "'.'", - (pANTLR3_UINT8) "'in'", - (pANTLR3_UINT8) "'class'", - (pANTLR3_UINT8) "'extends'", - (pANTLR3_UINT8) "'predicate'", - (pANTLR3_UINT8) "'action'", - (pANTLR3_UINT8) "'::'", - (pANTLR3_UINT8) "'int'", - (pANTLR3_UINT8) "'float'", - (pANTLR3_UINT8) "'bool'", - (pANTLR3_UINT8) "'string'", - (pANTLR3_UINT8) "'rejectable'", - (pANTLR3_UINT8) "'goal'", - (pANTLR3_UINT8) "'fact'", - (pANTLR3_UINT8) "'condition'", - (pANTLR3_UINT8) "'effect'", - (pANTLR3_UINT8) "':'", - (pANTLR3_UINT8) "'enforce'", - (pANTLR3_UINT8) "'||'", - (pANTLR3_UINT8) "'&&'", - (pANTLR3_UINT8) "'=='", - (pANTLR3_UINT8) "'!='", - (pANTLR3_UINT8) "'<'", - (pANTLR3_UINT8) "'>'", - (pANTLR3_UINT8) "'>='", - (pANTLR3_UINT8) "'<='", - (pANTLR3_UINT8) "'+'", - (pANTLR3_UINT8) "'-'", - (pANTLR3_UINT8) "'*'", - (pANTLR3_UINT8) "'super'", - (pANTLR3_UINT8) "'if'", - (pANTLR3_UINT8) "'else'", - (pANTLR3_UINT8) "'foreach'", - (pANTLR3_UINT8) "'after'", - (pANTLR3_UINT8) "'any'", - (pANTLR3_UINT8) "'before'", - (pANTLR3_UINT8) "'contained_by'", - (pANTLR3_UINT8) "'contains'", - (pANTLR3_UINT8) "'contains_end'", - (pANTLR3_UINT8) "'contains_start'", - (pANTLR3_UINT8) "'ends'", - (pANTLR3_UINT8) "'ends_after'", - (pANTLR3_UINT8) "'ends_after_start'", - (pANTLR3_UINT8) "'ends_before'", - (pANTLR3_UINT8) "'ends_during'", - (pANTLR3_UINT8) "'equal'", - (pANTLR3_UINT8) "'equals'", - (pANTLR3_UINT8) "'meets'", - (pANTLR3_UINT8) "'met_by'", - (pANTLR3_UINT8) "'parallels'", - (pANTLR3_UINT8) "'paralleled_by'", - (pANTLR3_UINT8) "'starts'", - (pANTLR3_UINT8) "'starts_after'", - (pANTLR3_UINT8) "'starts_before'", - (pANTLR3_UINT8) "'starts_before_end'", - (pANTLR3_UINT8) "'starts_during'", - (pANTLR3_UINT8) "'true'", - (pANTLR3_UINT8) "'false'", - (pANTLR3_UINT8) "'inf'", - (pANTLR3_UINT8) "'inff'", - (pANTLR3_UINT8) "'-inf'", - (pANTLR3_UINT8) "'-inff'", - (pANTLR3_UINT8) "'close'" - }; - - - -// Forward declare the locally static matching functions we have generated. -// -static void nddl (pNDDL3Tree ctx); -static Expr* enumDefinition (pNDDL3Tree ctx); -static void enumValues (pNDDL3Tree ctx, std::vector& values); -static Expr* typeDefinition (pNDDL3Tree ctx); -static DataType* type (pNDDL3Tree ctx); -static Domain* baseDomain (pNDDL3Tree ctx, const DataType* baseType); -static Expr* baseDomainValues (pNDDL3Tree ctx); -static ExprList* variableDeclarations (pNDDL3Tree ctx); -static Expr* variableInitialization (pNDDL3Tree ctx, const DataTypeId& dataType); -static Expr* initializer (pNDDL3Tree ctx, const char* varName); -static Expr* anyValue (pNDDL3Tree ctx); -static Expr* setElement (pNDDL3Tree ctx); -static Expr* valueSet (pNDDL3Tree ctx); -static Expr* literalValue (pNDDL3Tree ctx); -static Domain* booleanLiteral (pNDDL3Tree ctx); -static Domain* stringLiteral (pNDDL3Tree ctx); -static Domain* numericLiteral (pNDDL3Tree ctx); -static NDDL3Tree_floatLiteral_return floatLiteral (pNDDL3Tree ctx); -static NDDL3Tree_intLiteral_return intLiteral (pNDDL3Tree ctx); -static Expr* numericInterval (pNDDL3Tree ctx); -static Expr* allocation (pNDDL3Tree ctx, const char* name); -static void variableArgumentList (pNDDL3Tree ctx, std::vector& result); -static NDDL3Tree_identifier_return identifier (pNDDL3Tree ctx); -static ExprConstraint* constraintInstantiation (pNDDL3Tree ctx); -static void violationMsg (pNDDL3Tree ctx, std::string& result); -static Expr* classDeclaration (pNDDL3Tree ctx); -static void classBlock (pNDDL3Tree ctx, ObjectType* objType); -static void componentTypeEntry (pNDDL3Tree ctx, ObjectType* objType); -static void classVariable (pNDDL3Tree ctx, ObjectType* objType); -static void constructor (pNDDL3Tree ctx, ObjectType* objType); -static void constructorArgument (pNDDL3Tree ctx, std::vector& argNames, std::vector& argTypes); -static ExprConstructorSuperCall* constructorSuper (pNDDL3Tree ctx, ObjectType* objType); -static ExprAssignment* assignment (pNDDL3Tree ctx); -static void tokenType (pNDDL3Tree ctx, ObjectType* objType); -static void tokenStatements (pNDDL3Tree ctx, InterpretedTokenType* tokenType); -static Expr* tokenParameter (pNDDL3Tree ctx, InterpretedTokenType* tokenType); -static Expr* tokenParameterAssignment (pNDDL3Tree ctx); -static Expr* standardConstraint (pNDDL3Tree ctx); -static Expr* rule (pNDDL3Tree ctx); -static void ruleBlock (pNDDL3Tree ctx, std::vector& ruleBody); -static Expr* ruleStatement (pNDDL3Tree ctx); -static Expr* ifStatement (pNDDL3Tree ctx); -static ExprIfGuard* guardExpression (pNDDL3Tree ctx); -static NDDL3Tree_guardRelop_return guardRelop (pNDDL3Tree ctx); -static Expr* loopStatement (pNDDL3Tree ctx); -static Expr* problemStmt (pNDDL3Tree ctx); -static NDDL3Tree_problemStmtType_return problemStmtType (pNDDL3Tree ctx); -static Expr* relation (pNDDL3Tree ctx); -static void predicateInstanceList (pNDDL3Tree ctx, std::vector& instances); -static PredicateInstanceRef* predicateInstance (pNDDL3Tree ctx); -static PredicateInstanceRef* predicateVarRef (pNDDL3Tree ctx); -static NDDL3Tree_tokenAnnotation_return tokenAnnotation (pNDDL3Tree ctx); -static void qualifiedString (pNDDL3Tree ctx, std::string& result); -static Expr* qualified (pNDDL3Tree ctx); -static void qualifiedToken (pNDDL3Tree ctx, std::string& tokenStr, TokenTypeId& tokenType); -static NDDL3Tree_temporalRelation_return temporalRelation (pNDDL3Tree ctx); -static Expr* methodInvocation (pNDDL3Tree ctx); -static NDDL3Tree_methodName_return methodName (pNDDL3Tree ctx); -static void cexpressionList (pNDDL3Tree ctx, std::vector &args); -static CExpr* cexpression (pNDDL3Tree ctx); -static NDDL3Tree_cexprOp_return cexprOp (pNDDL3Tree ctx); -static Expr* enforceExpression (pNDDL3Tree ctx); -static Expr* expressionCleanReturn (pNDDL3Tree ctx); -static void NDDL3TreeFree(pNDDL3Tree ctx); -/* For use in tree output where we are accumulating rule labels via label += ruleRef - * we need a function that knows how to free a return scope when the list is destroyed. - * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. - */ -static void ANTLR3_CDECL freeScope(void * scope) -{ - ANTLR3_FREE(scope); -} - -/** \brief Name of the grammar file that generated this code - */ -static const char fileName[] = "NDDL/base/antlr/NDDL3Tree.g"; - -/** \brief Return the name of the grammar file that generated this code. - */ -static const char * getGrammarFileName() -{ - return fileName; -} -/** \brief Create a new NDDL3Tree parser and return a context for it. - * - * \param[in] instream Pointer to an input stream interface. - * - * \return Pointer to new parser context upon success. - */ -ANTLR3_API pNDDL3Tree -NDDL3TreeNew (pANTLR3_COMMON_TREE_NODE_STREAM instream) -{ - // See if we can create a new parser with the standard constructor - // - return NDDL3TreeNewSSD(instream, NULL); -} - -/** \brief Create a new NDDL3Tree parser and return a context for it. - * - * \param[in] instream Pointer to an input stream interface. - * - * \return Pointer to new parser context upon success. - */ -ANTLR3_API pNDDL3Tree -NDDL3TreeNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) -{ - pNDDL3Tree ctx; /* Context structure we will build and return */ - - ctx = (pNDDL3Tree) ANTLR3_CALLOC(1, sizeof(NDDL3Tree)); - - if (ctx == NULL) - { - // Failed to allocate memory for parser context - // - return NULL; - } - - /* ------------------------------------------------------------------- - * Memory for basic structure is allocated, now to fill in - * the base ANTLR3 structures. We initialize the function pointers - * for the standard ANTLR3 parser function set, but upon return - * from here, the programmer may set the pointers to provide custom - * implementations of each function. - * - * We don't use the macros defined in NDDL3Tree.h here, in order that you can get a sense - * of what goes where. - */ - - /* Create a base Tree parser/recognizer, using the supplied tree node stream - */ - ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state); - /* Install the implementation of our NDDL3Tree interface - */ - ctx->nddl = nddl; - ctx->enumDefinition = enumDefinition; - ctx->enumValues = enumValues; - ctx->typeDefinition = typeDefinition; - ctx->type = type; - ctx->baseDomain = baseDomain; - ctx->baseDomainValues = baseDomainValues; - ctx->variableDeclarations = variableDeclarations; - ctx->variableInitialization = variableInitialization; - ctx->initializer = initializer; - ctx->anyValue = anyValue; - ctx->setElement = setElement; - ctx->valueSet = valueSet; - ctx->literalValue = literalValue; - ctx->booleanLiteral = booleanLiteral; - ctx->stringLiteral = stringLiteral; - ctx->numericLiteral = numericLiteral; - ctx->floatLiteral = floatLiteral; - ctx->intLiteral = intLiteral; - ctx->numericInterval = numericInterval; - ctx->allocation = allocation; - ctx->variableArgumentList = variableArgumentList; - ctx->identifier = identifier; - ctx->constraintInstantiation = constraintInstantiation; - ctx->violationMsg = violationMsg; - ctx->classDeclaration = classDeclaration; - ctx->classBlock = classBlock; - ctx->componentTypeEntry = componentTypeEntry; - ctx->classVariable = classVariable; - ctx->constructor = constructor; - ctx->constructorArgument = constructorArgument; - ctx->constructorSuper = constructorSuper; - ctx->assignment = assignment; - ctx->tokenType = tokenType; - ctx->tokenStatements = tokenStatements; - ctx->tokenParameter = tokenParameter; - ctx->tokenParameterAssignment = tokenParameterAssignment; - ctx->standardConstraint = standardConstraint; - ctx->rule = rule; - ctx->ruleBlock = ruleBlock; - ctx->ruleStatement = ruleStatement; - ctx->ifStatement = ifStatement; - ctx->guardExpression = guardExpression; - ctx->guardRelop = guardRelop; - ctx->loopStatement = loopStatement; - ctx->problemStmt = problemStmt; - ctx->problemStmtType = problemStmtType; - ctx->relation = relation; - ctx->predicateInstanceList = predicateInstanceList; - ctx->predicateInstance = predicateInstance; - ctx->predicateVarRef = predicateVarRef; - ctx->tokenAnnotation = tokenAnnotation; - ctx->qualifiedString = qualifiedString; - ctx->qualified = qualified; - ctx->qualifiedToken = qualifiedToken; - ctx->temporalRelation = temporalRelation; - ctx->methodInvocation = methodInvocation; - ctx->methodName = methodName; - ctx->cexpressionList = cexpressionList; - ctx->cexpression = cexpression; - ctx->cexprOp = cexprOp; - ctx->enforceExpression = enforceExpression; - ctx->expressionCleanReturn = expressionCleanReturn; - ctx->free = NDDL3TreeFree; - ctx->getGrammarFileName = getGrammarFileName; - - /* Install the scope pushing methods. - */ - - - - - - // TODO: Install custom error message display that gathers them in CTX->SymbolTable - //RECOGNIZER->displayRecognitionError = reportAntlrError; - - // Add a function with the following signature: - // void reportAntlrError(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames); - // use the meat from displayRecognitionError() in antlr3baserecognizer.c - - - /* Install the token table - */ - PSRSTATE->tokenNames = NDDL3TreeTokenNames; - - - /* Return the newly built parser to the caller - */ - return ctx; -} - -/** Free the parser resources - */ - static void - NDDL3TreeFree(pNDDL3Tree ctx) - { - /* Free any scope memory - */ - - - // Free this parser - // - ctx->pTreeParser->free(ctx->pTreeParser); - ANTLR3_FREE(ctx); - - /* Everything is released, so we can return - */ - return; - } - -/** Return token names used by this tree parser - * - * The returned pointer is used as an index into the token names table (using the token - * number as the index). - * - * \return Pointer to first char * in the table. - */ -static pANTLR3_UINT8 *getTokenNames() -{ - return NDDL3TreeTokenNames; -} - - - - static const char* c_str(pANTLR3_UINT8 chars) - { - // TODO: what's the best way to do this? - return (const char*)chars; - } - - // TODO: make sure we also get ANTLR errors, see apifuncs below - static void reportSemanticError(pNDDL3Tree treeWalker, const std::string& msg) - { - treeWalker->SymbolTable->reportError(treeWalker,msg); - // TODO: make sure cleanup is done correctly - throw msg; - } - - static std::string getAutoLabel(const char* prefix) - { - static int idx = 0; - std::ostringstream os; - os << prefix << "_" << idx++; - - return os.str(); - } - - static DataRef evalExpr(pNDDL3Tree treeWalker,Expr* expr) - { - return expr->eval(*(treeWalker->SymbolTable)); - } - - static void pushContext(pNDDL3Tree treeWalker, NddlSymbolTable* st) - { - treeWalker->SymbolTable = st; - } - - static void popContext(pNDDL3Tree treeWalker) - { - NddlSymbolTable* st = treeWalker->SymbolTable; - treeWalker->SymbolTable = st->getParentST(); - delete st; - check_error(treeWalker->SymbolTable != NULL); - } - - - -/* Declare the bitsets - */ - -/** Bitset defining follow set for error recovery in rule state: FOLLOW_NDDL_in_nddl70 */ -static ANTLR3_BITWORD FOLLOW_NDDL_in_nddl70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_NDDL_in_nddl70 = { FOLLOW_NDDL_in_nddl70_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_classDeclaration_in_nddl86 */ -static ANTLR3_BITWORD FOLLOW_classDeclaration_in_nddl86_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_classDeclaration_in_nddl86 = { FOLLOW_classDeclaration_in_nddl86_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enumDefinition_in_nddl102 */ -static ANTLR3_BITWORD FOLLOW_enumDefinition_in_nddl102_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_enumDefinition_in_nddl102 = { FOLLOW_enumDefinition_in_nddl102_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_typeDefinition_in_nddl112 */ -static ANTLR3_BITWORD FOLLOW_typeDefinition_in_nddl112_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_typeDefinition_in_nddl112 = { FOLLOW_typeDefinition_in_nddl112_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableDeclarations_in_nddl122 */ -static ANTLR3_BITWORD FOLLOW_variableDeclarations_in_nddl122_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_variableDeclarations_in_nddl122 = { FOLLOW_variableDeclarations_in_nddl122_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_assignment_in_nddl132 */ -static ANTLR3_BITWORD FOLLOW_assignment_in_nddl132_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_assignment_in_nddl132 = { FOLLOW_assignment_in_nddl132_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constraintInstantiation_in_nddl142 */ -static ANTLR3_BITWORD FOLLOW_constraintInstantiation_in_nddl142_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_constraintInstantiation_in_nddl142 = { FOLLOW_constraintInstantiation_in_nddl142_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enforceExpression_in_nddl152 */ -static ANTLR3_BITWORD FOLLOW_enforceExpression_in_nddl152_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_enforceExpression_in_nddl152 = { FOLLOW_enforceExpression_in_nddl152_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_allocation_in_nddl162 */ -static ANTLR3_BITWORD FOLLOW_allocation_in_nddl162_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_allocation_in_nddl162 = { FOLLOW_allocation_in_nddl162_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_rule_in_nddl173 */ -static ANTLR3_BITWORD FOLLOW_rule_in_nddl173_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_rule_in_nddl173 = { FOLLOW_rule_in_nddl173_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_problemStmt_in_nddl183 */ -static ANTLR3_BITWORD FOLLOW_problemStmt_in_nddl183_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_problemStmt_in_nddl183 = { FOLLOW_problemStmt_in_nddl183_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_relation_in_nddl193 */ -static ANTLR3_BITWORD FOLLOW_relation_in_nddl193_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_relation_in_nddl193 = { FOLLOW_relation_in_nddl193_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_methodInvocation_in_nddl203 */ -static ANTLR3_BITWORD FOLLOW_methodInvocation_in_nddl203_bits[] = { ANTLR3_UINT64_LIT(0x0E11081100009CD8) }; -static ANTLR3_BITSET_LIST FOLLOW_methodInvocation_in_nddl203 = { FOLLOW_methodInvocation_in_nddl203_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_32_in_enumDefinition255 */ -static ANTLR3_BITWORD FOLLOW_32_in_enumDefinition255_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_32_in_enumDefinition255 = { FOLLOW_32_in_enumDefinition255_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_enumDefinition259 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_enumDefinition259_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_enumDefinition259 = { FOLLOW_IDENT_in_enumDefinition259_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enumValues_in_enumDefinition261 */ -static ANTLR3_BITWORD FOLLOW_enumValues_in_enumDefinition261_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_enumValues_in_enumDefinition261 = { FOLLOW_enumValues_in_enumDefinition261_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_enumValues298 */ -static ANTLR3_BITWORD FOLLOW_33_in_enumValues298_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_enumValues298 = { FOLLOW_33_in_enumValues298_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_enumValues303 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_enumValues303_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010008) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_enumValues303 = { FOLLOW_IDENT_in_enumValues303_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_36_in_typeDefinition351 */ -static ANTLR3_BITWORD FOLLOW_36_in_typeDefinition351_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_36_in_typeDefinition351 = { FOLLOW_36_in_typeDefinition351_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_typeDefinition367 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_typeDefinition367_bits[] = { ANTLR3_UINT64_LIT(0x01E0000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_typeDefinition367 = { FOLLOW_IDENT_in_typeDefinition367_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_type_in_typeDefinition383 */ -static ANTLR3_BITWORD FOLLOW_type_in_typeDefinition383_bits[] = { ANTLR3_UINT64_LIT(0x0000004200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_type_in_typeDefinition383 = { FOLLOW_type_in_typeDefinition383_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_baseDomain_in_typeDefinition390 */ -static ANTLR3_BITWORD FOLLOW_baseDomain_in_typeDefinition390_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_baseDomain_in_typeDefinition390 = { FOLLOW_baseDomain_in_typeDefinition390_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_53_in_type438 */ -static ANTLR3_BITWORD FOLLOW_53_in_type438_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_53_in_type438 = { FOLLOW_53_in_type438_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_54_in_type454 */ -static ANTLR3_BITWORD FOLLOW_54_in_type454_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_54_in_type454 = { FOLLOW_54_in_type454_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_55_in_type470 */ -static ANTLR3_BITWORD FOLLOW_55_in_type470_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_55_in_type470 = { FOLLOW_55_in_type470_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_56_in_type486 */ -static ANTLR3_BITWORD FOLLOW_56_in_type486_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_56_in_type486 = { FOLLOW_56_in_type486_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_type502 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_type502_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_type502 = { FOLLOW_IDENT_in_type502_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_baseDomainValues_in_baseDomain556 */ -static ANTLR3_BITWORD FOLLOW_baseDomainValues_in_baseDomain556_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_baseDomainValues_in_baseDomain556 = { FOLLOW_baseDomainValues_in_baseDomain556_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_numericInterval_in_baseDomainValues604 */ -static ANTLR3_BITWORD FOLLOW_numericInterval_in_baseDomainValues604_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_numericInterval_in_baseDomainValues604 = { FOLLOW_numericInterval_in_baseDomainValues604_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_valueSet_in_baseDomainValues618 */ -static ANTLR3_BITWORD FOLLOW_valueSet_in_baseDomainValues618_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_valueSet_in_baseDomainValues618 = { FOLLOW_valueSet_in_baseDomainValues618_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_VARIABLE_in_variableDeclarations672 */ -static ANTLR3_BITWORD FOLLOW_VARIABLE_in_variableDeclarations672_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_VARIABLE_in_variableDeclarations672 = { FOLLOW_VARIABLE_in_variableDeclarations672_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_type_in_variableDeclarations689 */ -static ANTLR3_BITWORD FOLLOW_type_in_variableDeclarations689_bits[] = { ANTLR3_UINT64_LIT(0x0000080000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_type_in_variableDeclarations689 = { FOLLOW_type_in_variableDeclarations689_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableInitialization_in_variableDeclarations707 */ -static ANTLR3_BITWORD FOLLOW_variableInitialization_in_variableDeclarations707_bits[] = { ANTLR3_UINT64_LIT(0x0000080000010008) }; -static ANTLR3_BITSET_LIST FOLLOW_variableInitialization_in_variableDeclarations707 = { FOLLOW_variableInitialization_in_variableDeclarations707_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_variableInitialization790 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_variableInitialization790_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_variableInitialization790 = { FOLLOW_IDENT_in_variableInitialization790_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_43_in_variableInitialization807 */ -static ANTLR3_BITWORD FOLLOW_43_in_variableInitialization807_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_43_in_variableInitialization807 = { FOLLOW_43_in_variableInitialization807_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_variableInitialization811 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_variableInitialization811_bits[] = { ANTLR3_UINT64_LIT(0x00006042000F0040), ANTLR3_UINT64_LIT(0x00000FC000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_variableInitialization811 = { FOLLOW_IDENT_in_variableInitialization811_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_initializer_in_variableInitialization818 */ -static ANTLR3_BITWORD FOLLOW_initializer_in_variableInitialization818_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_initializer_in_variableInitialization818 = { FOLLOW_initializer_in_variableInitialization818_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_initializer881 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_initializer881_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_initializer881 = { FOLLOW_anyValue_in_initializer881_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_allocation_in_initializer898 */ -static ANTLR3_BITWORD FOLLOW_allocation_in_initializer898_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_allocation_in_initializer898 = { FOLLOW_allocation_in_initializer898_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_literalValue_in_anyValue948 */ -static ANTLR3_BITWORD FOLLOW_literalValue_in_anyValue948_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_literalValue_in_anyValue948 = { FOLLOW_literalValue_in_anyValue948_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_baseDomainValues_in_anyValue964 */ -static ANTLR3_BITWORD FOLLOW_baseDomainValues_in_anyValue964_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_baseDomainValues_in_anyValue964 = { FOLLOW_baseDomainValues_in_anyValue964_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_anyValue980 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_anyValue980_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_anyValue980 = { FOLLOW_qualified_in_anyValue980_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_literalValue_in_setElement1029 */ -static ANTLR3_BITWORD FOLLOW_literalValue_in_setElement1029_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_literalValue_in_setElement1029 = { FOLLOW_literalValue_in_setElement1029_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_setElement1045 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_setElement1045_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_setElement1045 = { FOLLOW_qualified_in_setElement1045_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_valueSet1094 */ -static ANTLR3_BITWORD FOLLOW_33_in_valueSet1094_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_valueSet1094 = { FOLLOW_33_in_valueSet1094_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_setElement_in_valueSet1111 */ -static ANTLR3_BITWORD FOLLOW_setElement_in_valueSet1111_bits[] = { ANTLR3_UINT64_LIT(0x00006042000F0008), ANTLR3_UINT64_LIT(0x00000FC000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_setElement_in_valueSet1111 = { FOLLOW_setElement_in_valueSet1111_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_booleanLiteral_in_literalValue1189 */ -static ANTLR3_BITWORD FOLLOW_booleanLiteral_in_literalValue1189_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_booleanLiteral_in_literalValue1189 = { FOLLOW_booleanLiteral_in_literalValue1189_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_numericLiteral_in_literalValue1205 */ -static ANTLR3_BITWORD FOLLOW_numericLiteral_in_literalValue1205_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_numericLiteral_in_literalValue1205 = { FOLLOW_numericLiteral_in_literalValue1205_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_stringLiteral_in_literalValue1221 */ -static ANTLR3_BITWORD FOLLOW_stringLiteral_in_literalValue1221_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_stringLiteral_in_literalValue1221 = { FOLLOW_stringLiteral_in_literalValue1221_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_102_in_booleanLiteral1268 */ -static ANTLR3_BITWORD FOLLOW_102_in_booleanLiteral1268_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_102_in_booleanLiteral1268 = { FOLLOW_102_in_booleanLiteral1268_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_103_in_booleanLiteral1293 */ -static ANTLR3_BITWORD FOLLOW_103_in_booleanLiteral1293_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_103_in_booleanLiteral1293 = { FOLLOW_103_in_booleanLiteral1293_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_STRING_in_stringLiteral1323 */ -static ANTLR3_BITWORD FOLLOW_STRING_in_stringLiteral1323_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_STRING_in_stringLiteral1323 = { FOLLOW_STRING_in_stringLiteral1323_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_floatLiteral_in_numericLiteral1361 */ -static ANTLR3_BITWORD FOLLOW_floatLiteral_in_numericLiteral1361_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_floatLiteral_in_numericLiteral1361 = { FOLLOW_floatLiteral_in_numericLiteral1361_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_intLiteral_in_numericLiteral1376 */ -static ANTLR3_BITWORD FOLLOW_intLiteral_in_numericLiteral1376_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_intLiteral_in_numericLiteral1376 = { FOLLOW_intLiteral_in_numericLiteral1376_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_floatLiteral0 */ -static ANTLR3_BITWORD FOLLOW_set_in_floatLiteral0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_floatLiteral0 = { FOLLOW_set_in_floatLiteral0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_intLiteral0 */ -static ANTLR3_BITWORD FOLLOW_set_in_intLiteral0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_intLiteral0 = { FOLLOW_set_in_intLiteral0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_38_in_numericInterval1483 */ -static ANTLR3_BITWORD FOLLOW_38_in_numericInterval1483_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_38_in_numericInterval1483 = { FOLLOW_38_in_numericInterval1483_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_numericLiteral_in_numericInterval1502 */ -static ANTLR3_BITWORD FOLLOW_numericLiteral_in_numericInterval1502_bits[] = { ANTLR3_UINT64_LIT(0x0000000000060000), ANTLR3_UINT64_LIT(0x00000F0000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_numericLiteral_in_numericInterval1502 = { FOLLOW_numericLiteral_in_numericInterval1502_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_numericLiteral_in_numericInterval1518 */ -static ANTLR3_BITWORD FOLLOW_numericLiteral_in_numericInterval1518_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_numericLiteral_in_numericInterval1518 = { FOLLOW_numericLiteral_in_numericInterval1518_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_CONSTRUCTOR_INVOCATION_in_allocation1576 */ -static ANTLR3_BITWORD FOLLOW_CONSTRUCTOR_INVOCATION_in_allocation1576_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_CONSTRUCTOR_INVOCATION_in_allocation1576 = { FOLLOW_CONSTRUCTOR_INVOCATION_in_allocation1576_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_allocation1604 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_allocation1604_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_allocation1604 = { FOLLOW_IDENT_in_allocation1604_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_allocation1631 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_allocation1631_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_allocation1631 = { FOLLOW_variableArgumentList_in_allocation1631_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_variableArgumentList1701 */ -static ANTLR3_BITWORD FOLLOW_41_in_variableArgumentList1701_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_variableArgumentList1701 = { FOLLOW_41_in_variableArgumentList1701_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_variableArgumentList1720 */ -static ANTLR3_BITWORD FOLLOW_41_in_variableArgumentList1720_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_variableArgumentList1720 = { FOLLOW_41_in_variableArgumentList1720_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_initializer_in_variableArgumentList1749 */ -static ANTLR3_BITWORD FOLLOW_initializer_in_variableArgumentList1749_bits[] = { ANTLR3_UINT64_LIT(0x00006042000F0048), ANTLR3_UINT64_LIT(0x00000FC000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_initializer_in_variableArgumentList1749 = { FOLLOW_initializer_in_variableArgumentList1749_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_identifier0 */ -static ANTLR3_BITWORD FOLLOW_set_in_identifier0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_identifier0 = { FOLLOW_set_in_identifier0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_CONSTRAINT_INSTANTIATION_in_constraintInstantiation1866 */ -static ANTLR3_BITWORD FOLLOW_CONSTRAINT_INSTANTIATION_in_constraintInstantiation1866_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_CONSTRAINT_INSTANTIATION_in_constraintInstantiation1866 = { FOLLOW_CONSTRAINT_INSTANTIATION_in_constraintInstantiation1866_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_constraintInstantiation1894 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_constraintInstantiation1894_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_constraintInstantiation1894 = { FOLLOW_IDENT_in_constraintInstantiation1894_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_constraintInstantiation1920 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_constraintInstantiation1920_bits[] = { ANTLR3_UINT64_LIT(0x0000000000080008) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_constraintInstantiation1920 = { FOLLOW_variableArgumentList_in_constraintInstantiation1920_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_violationMsg_in_constraintInstantiation1948 */ -static ANTLR3_BITWORD FOLLOW_violationMsg_in_constraintInstantiation1948_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_violationMsg_in_constraintInstantiation1948 = { FOLLOW_violationMsg_in_constraintInstantiation1948_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_STRING_in_violationMsg2034 */ -static ANTLR3_BITWORD FOLLOW_STRING_in_violationMsg2034_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_STRING_in_violationMsg2034 = { FOLLOW_STRING_in_violationMsg2034_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_48_in_classDeclaration2069 */ -static ANTLR3_BITWORD FOLLOW_48_in_classDeclaration2069_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_48_in_classDeclaration2069 = { FOLLOW_48_in_classDeclaration2069_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_classDeclaration2084 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_classDeclaration2084_bits[] = { ANTLR3_UINT64_LIT(0x0002002200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_classDeclaration2084 = { FOLLOW_IDENT_in_classDeclaration2084_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_49_in_classDeclaration2115 */ -static ANTLR3_BITWORD FOLLOW_49_in_classDeclaration2115_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_49_in_classDeclaration2115 = { FOLLOW_49_in_classDeclaration2115_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_classDeclaration2119 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_classDeclaration2119_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_classDeclaration2119 = { FOLLOW_IDENT_in_classDeclaration2119_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_classBlock_in_classDeclaration2181 */ -static ANTLR3_BITWORD FOLLOW_classBlock_in_classDeclaration2181_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_classBlock_in_classDeclaration2181 = { FOLLOW_classBlock_in_classDeclaration2181_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_37_in_classDeclaration2208 */ -static ANTLR3_BITWORD FOLLOW_37_in_classDeclaration2208_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_37_in_classDeclaration2208 = { FOLLOW_37_in_classDeclaration2208_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_classBlock2258 */ -static ANTLR3_BITWORD FOLLOW_33_in_classBlock2258_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_classBlock2258 = { FOLLOW_33_in_classBlock2258_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_classBlock2264 */ -static ANTLR3_BITWORD FOLLOW_33_in_classBlock2264_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_classBlock2264 = { FOLLOW_33_in_classBlock2264_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_componentTypeEntry_in_classBlock2266 */ -static ANTLR3_BITWORD FOLLOW_componentTypeEntry_in_classBlock2266_bits[] = { ANTLR3_UINT64_LIT(0x000C000000000828) }; -static ANTLR3_BITSET_LIST FOLLOW_componentTypeEntry_in_classBlock2266 = { FOLLOW_componentTypeEntry_in_classBlock2266_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_classVariable_in_componentTypeEntry2282 */ -static ANTLR3_BITWORD FOLLOW_classVariable_in_componentTypeEntry2282_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_classVariable_in_componentTypeEntry2282 = { FOLLOW_classVariable_in_componentTypeEntry2282_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructor_in_componentTypeEntry2288 */ -static ANTLR3_BITWORD FOLLOW_constructor_in_componentTypeEntry2288_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constructor_in_componentTypeEntry2288 = { FOLLOW_constructor_in_componentTypeEntry2288_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenType_in_componentTypeEntry2294 */ -static ANTLR3_BITWORD FOLLOW_tokenType_in_componentTypeEntry2294_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenType_in_componentTypeEntry2294 = { FOLLOW_tokenType_in_componentTypeEntry2294_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_VARIABLE_in_classVariable2321 */ -static ANTLR3_BITWORD FOLLOW_VARIABLE_in_classVariable2321_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_VARIABLE_in_classVariable2321 = { FOLLOW_VARIABLE_in_classVariable2321_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_type_in_classVariable2344 */ -static ANTLR3_BITWORD FOLLOW_type_in_classVariable2344_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_type_in_classVariable2344 = { FOLLOW_type_in_classVariable2344_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_classVariable2368 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_classVariable2368_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010008) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_classVariable2368 = { FOLLOW_IDENT_in_classVariable2368_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_CONSTRUCTOR_in_constructor2461 */ -static ANTLR3_BITWORD FOLLOW_CONSTRUCTOR_in_constructor2461_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_CONSTRUCTOR_in_constructor2461 = { FOLLOW_CONSTRUCTOR_in_constructor2461_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_constructor2468 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_constructor2468_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_constructor2468 = { FOLLOW_IDENT_in_constructor2468_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_constructor2474 */ -static ANTLR3_BITWORD FOLLOW_41_in_constructor2474_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_constructor2474 = { FOLLOW_41_in_constructor2474_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorArgument_in_constructor2476 */ -static ANTLR3_BITWORD FOLLOW_constructorArgument_in_constructor2476_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000808) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorArgument_in_constructor2476 = { FOLLOW_constructorArgument_in_constructor2476_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_constructor2485 */ -static ANTLR3_BITWORD FOLLOW_33_in_constructor2485_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_constructor2485 = { FOLLOW_33_in_constructor2485_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constructorSuper_in_constructor2489 */ -static ANTLR3_BITWORD FOLLOW_constructorSuper_in_constructor2489_bits[] = { ANTLR3_UINT64_LIT(0x0000080000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_constructorSuper_in_constructor2489 = { FOLLOW_constructorSuper_in_constructor2489_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_assignment_in_constructor2505 */ -static ANTLR3_BITWORD FOLLOW_assignment_in_constructor2505_bits[] = { ANTLR3_UINT64_LIT(0x0000080000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_assignment_in_constructor2505 = { FOLLOW_assignment_in_constructor2505_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_VARIABLE_in_constructorArgument2531 */ -static ANTLR3_BITWORD FOLLOW_VARIABLE_in_constructorArgument2531_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_VARIABLE_in_constructorArgument2531 = { FOLLOW_VARIABLE_in_constructorArgument2531_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_constructorArgument2538 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_constructorArgument2538_bits[] = { ANTLR3_UINT64_LIT(0x01E0000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_constructorArgument2538 = { FOLLOW_IDENT_in_constructorArgument2538_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_type_in_constructorArgument2545 */ -static ANTLR3_BITWORD FOLLOW_type_in_constructorArgument2545_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_type_in_constructorArgument2545 = { FOLLOW_type_in_constructorArgument2545_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_75_in_constructorSuper2575 */ -static ANTLR3_BITWORD FOLLOW_75_in_constructorSuper2575_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_75_in_constructorSuper2575 = { FOLLOW_75_in_constructorSuper2575_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_constructorSuper2580 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_constructorSuper2580_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_constructorSuper2580 = { FOLLOW_variableArgumentList_in_constructorSuper2580_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_43_in_assignment2607 */ -static ANTLR3_BITWORD FOLLOW_43_in_assignment2607_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_43_in_assignment2607 = { FOLLOW_43_in_assignment2607_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_assignment2614 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_assignment2614_bits[] = { ANTLR3_UINT64_LIT(0x00006042000F0040), ANTLR3_UINT64_LIT(0x00000FC000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_assignment2614 = { FOLLOW_qualified_in_assignment2614_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_initializer_in_assignment2621 */ -static ANTLR3_BITWORD FOLLOW_initializer_in_assignment2621_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_initializer_in_assignment2621 = { FOLLOW_initializer_in_assignment2621_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_tokenType2650 */ -static ANTLR3_BITWORD FOLLOW_set_in_tokenType2650_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_tokenType2650 = { FOLLOW_set_in_tokenType2650_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_tokenType2663 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_tokenType2663_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_tokenType2663 = { FOLLOW_IDENT_in_tokenType2663_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenStatements_in_tokenType2674 */ -static ANTLR3_BITWORD FOLLOW_tokenStatements_in_tokenType2674_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenStatements_in_tokenType2674 = { FOLLOW_tokenStatements_in_tokenType2674_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_tokenStatements2697 */ -static ANTLR3_BITWORD FOLLOW_33_in_tokenStatements2697_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_tokenStatements2697 = { FOLLOW_33_in_tokenStatements2697_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenParameter_in_tokenStatements2733 */ -static ANTLR3_BITWORD FOLLOW_tokenParameter_in_tokenStatements2733_bits[] = { ANTLR3_UINT64_LIT(0x0000080000001818) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenParameter_in_tokenStatements2733 = { FOLLOW_tokenParameter_in_tokenStatements2733_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenParameterAssignment_in_tokenStatements2757 */ -static ANTLR3_BITWORD FOLLOW_tokenParameterAssignment_in_tokenStatements2757_bits[] = { ANTLR3_UINT64_LIT(0x0000080000001818) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenParameterAssignment_in_tokenStatements2757 = { FOLLOW_tokenParameterAssignment_in_tokenStatements2757_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_standardConstraint_in_tokenStatements2779 */ -static ANTLR3_BITWORD FOLLOW_standardConstraint_in_tokenStatements2779_bits[] = { ANTLR3_UINT64_LIT(0x0000080000001818) }; -static ANTLR3_BITSET_LIST FOLLOW_standardConstraint_in_tokenStatements2779 = { FOLLOW_standardConstraint_in_tokenStatements2779_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enforceExpression_in_tokenStatements2802 */ -static ANTLR3_BITWORD FOLLOW_enforceExpression_in_tokenStatements2802_bits[] = { ANTLR3_UINT64_LIT(0x0000080000001818) }; -static ANTLR3_BITSET_LIST FOLLOW_enforceExpression_in_tokenStatements2802 = { FOLLOW_enforceExpression_in_tokenStatements2802_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableDeclarations_in_tokenParameter2886 */ -static ANTLR3_BITWORD FOLLOW_variableDeclarations_in_tokenParameter2886_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableDeclarations_in_tokenParameter2886 = { FOLLOW_variableDeclarations_in_tokenParameter2886_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_assignment_in_tokenParameterAssignment2943 */ -static ANTLR3_BITWORD FOLLOW_assignment_in_tokenParameterAssignment2943_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_assignment_in_tokenParameterAssignment2943 = { FOLLOW_assignment_in_tokenParameterAssignment2943_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constraintInstantiation_in_standardConstraint2995 */ -static ANTLR3_BITWORD FOLLOW_constraintInstantiation_in_standardConstraint2995_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constraintInstantiation_in_standardConstraint2995 = { FOLLOW_constraintInstantiation_in_standardConstraint2995_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_52_in_rule3036 */ -static ANTLR3_BITWORD FOLLOW_52_in_rule3036_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_52_in_rule3036 = { FOLLOW_52_in_rule3036_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_rule3043 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_rule3043_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_rule3043 = { FOLLOW_IDENT_in_rule3043_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_rule3050 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_rule3050_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_rule3050 = { FOLLOW_IDENT_in_rule3050_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleBlock_in_rule3060 */ -static ANTLR3_BITWORD FOLLOW_ruleBlock_in_rule3060_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleBlock_in_rule3060 = { FOLLOW_ruleBlock_in_rule3060_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_33_in_ruleBlock3082 */ -static ANTLR3_BITWORD FOLLOW_33_in_ruleBlock3082_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_33_in_ruleBlock3082 = { FOLLOW_33_in_ruleBlock3082_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleStatement_in_ruleBlock3090 */ -static ANTLR3_BITWORD FOLLOW_ruleStatement_in_ruleBlock3090_bits[] = { ANTLR3_UINT64_LIT(0x0000080000001C18), ANTLR3_UINT64_LIT(0x0000000000005000) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleStatement_in_ruleBlock3090 = { FOLLOW_ruleStatement_in_ruleBlock3090_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_constraintInstantiation_in_ruleStatement3117 */ -static ANTLR3_BITWORD FOLLOW_constraintInstantiation_in_ruleStatement3117_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_constraintInstantiation_in_ruleStatement3117 = { FOLLOW_constraintInstantiation_in_ruleStatement3117_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_enforceExpression_in_ruleStatement3129 */ -static ANTLR3_BITWORD FOLLOW_enforceExpression_in_ruleStatement3129_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_enforceExpression_in_ruleStatement3129 = { FOLLOW_enforceExpression_in_ruleStatement3129_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_assignment_in_ruleStatement3138 */ -static ANTLR3_BITWORD FOLLOW_assignment_in_ruleStatement3138_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_assignment_in_ruleStatement3138 = { FOLLOW_assignment_in_ruleStatement3138_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableDeclarations_in_ruleStatement3147 */ -static ANTLR3_BITWORD FOLLOW_variableDeclarations_in_ruleStatement3147_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_variableDeclarations_in_ruleStatement3147 = { FOLLOW_variableDeclarations_in_ruleStatement3147_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ifStatement_in_ruleStatement3156 */ -static ANTLR3_BITWORD FOLLOW_ifStatement_in_ruleStatement3156_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_ifStatement_in_ruleStatement3156 = { FOLLOW_ifStatement_in_ruleStatement3156_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_loopStatement_in_ruleStatement3165 */ -static ANTLR3_BITWORD FOLLOW_loopStatement_in_ruleStatement3165_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_loopStatement_in_ruleStatement3165 = { FOLLOW_loopStatement_in_ruleStatement3165_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_relation_in_ruleStatement3174 */ -static ANTLR3_BITWORD FOLLOW_relation_in_ruleStatement3174_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_relation_in_ruleStatement3174 = { FOLLOW_relation_in_ruleStatement3174_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_76_in_ifStatement3206 */ -static ANTLR3_BITWORD FOLLOW_76_in_ifStatement3206_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_76_in_ifStatement3206 = { FOLLOW_76_in_ifStatement3206_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_guardExpression_in_ifStatement3213 */ -static ANTLR3_BITWORD FOLLOW_guardExpression_in_ifStatement3213_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_guardExpression_in_ifStatement3213 = { FOLLOW_guardExpression_in_ifStatement3213_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleBlock_in_ifStatement3218 */ -static ANTLR3_BITWORD FOLLOW_ruleBlock_in_ifStatement3218_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000008) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleBlock_in_ifStatement3218 = { FOLLOW_ruleBlock_in_ifStatement3218_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleBlock_in_ifStatement3224 */ -static ANTLR3_BITWORD FOLLOW_ruleBlock_in_ifStatement3224_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleBlock_in_ifStatement3224 = { FOLLOW_ruleBlock_in_ifStatement3224_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_guardRelop_in_guardExpression3269 */ -static ANTLR3_BITWORD FOLLOW_guardRelop_in_guardExpression3269_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_guardRelop_in_guardExpression3269 = { FOLLOW_guardRelop_in_guardExpression3269_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_guardExpression3275 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_guardExpression3275_bits[] = { ANTLR3_UINT64_LIT(0x00006042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_guardExpression3275 = { FOLLOW_anyValue_in_guardExpression3275_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_guardExpression3279 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_guardExpression3279_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_guardExpression3279 = { FOLLOW_anyValue_in_guardExpression3279_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_guardExpression3297 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_guardExpression3297_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_guardExpression3297 = { FOLLOW_anyValue_in_guardExpression3297_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_EXPRESSION_RETURN_in_guardExpression3312 */ -static ANTLR3_BITWORD FOLLOW_EXPRESSION_RETURN_in_guardExpression3312_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_EXPRESSION_RETURN_in_guardExpression3312 = { FOLLOW_EXPRESSION_RETURN_in_guardExpression3312_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_expressionCleanReturn_in_guardExpression3316 */ -static ANTLR3_BITWORD FOLLOW_expressionCleanReturn_in_guardExpression3316_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_expressionCleanReturn_in_guardExpression3316 = { FOLLOW_expressionCleanReturn_in_guardExpression3316_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_guardRelop0 */ -static ANTLR3_BITWORD FOLLOW_set_in_guardRelop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_guardRelop0 = { FOLLOW_set_in_guardRelop0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_78_in_loopStatement3406 */ -static ANTLR3_BITWORD FOLLOW_78_in_loopStatement3406_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_78_in_loopStatement3406 = { FOLLOW_78_in_loopStatement3406_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_loopStatement3413 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_loopStatement3413_bits[] = { ANTLR3_UINT64_LIT(0x00006042000F0000), ANTLR3_UINT64_LIT(0x00000FC000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_loopStatement3413 = { FOLLOW_IDENT_in_loopStatement3413_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_loopStatement3420 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_loopStatement3420_bits[] = { ANTLR3_UINT64_LIT(0x0000000200000000) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_loopStatement3420 = { FOLLOW_qualified_in_loopStatement3420_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_ruleBlock_in_loopStatement3432 */ -static ANTLR3_BITWORD FOLLOW_ruleBlock_in_loopStatement3432_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_ruleBlock_in_loopStatement3432 = { FOLLOW_ruleBlock_in_loopStatement3432_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_problemStmtType_in_problemStmt3479 */ -static ANTLR3_BITWORD FOLLOW_problemStmtType_in_problemStmt3479_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_problemStmtType_in_problemStmt3479 = { FOLLOW_problemStmtType_in_problemStmt3479_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_predicateInstanceList_in_problemStmt3481 */ -static ANTLR3_BITWORD FOLLOW_predicateInstanceList_in_problemStmt3481_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_predicateInstanceList_in_problemStmt3481 = { FOLLOW_predicateInstanceList_in_problemStmt3481_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_problemStmtType0 */ -static ANTLR3_BITWORD FOLLOW_set_in_problemStmtType0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_problemStmtType0 = { FOLLOW_set_in_problemStmtType0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_TOKEN_RELATION_in_relation3616 */ -static ANTLR3_BITWORD FOLLOW_TOKEN_RELATION_in_relation3616_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_TOKEN_RELATION_in_relation3616 = { FOLLOW_TOKEN_RELATION_in_relation3616_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_predicateVarRef_in_relation3624 */ -static ANTLR3_BITWORD FOLLOW_predicateVarRef_in_relation3624_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000), ANTLR3_UINT64_LIT(0x0000003FFFFF8000) }; -static ANTLR3_BITSET_LIST FOLLOW_predicateVarRef_in_relation3624 = { FOLLOW_predicateVarRef_in_relation3624_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_temporalRelation_in_relation3635 */ -static ANTLR3_BITWORD FOLLOW_temporalRelation_in_relation3635_bits[] = { ANTLR3_UINT64_LIT(0x0000220000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_temporalRelation_in_relation3635 = { FOLLOW_temporalRelation_in_relation3635_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_predicateInstanceList_in_relation3643 */ -static ANTLR3_BITWORD FOLLOW_predicateInstanceList_in_relation3643_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_predicateInstanceList_in_relation3643 = { FOLLOW_predicateInstanceList_in_relation3643_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_predicateInstanceList3665 */ -static ANTLR3_BITWORD FOLLOW_41_in_predicateInstanceList3665_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_predicateInstanceList3665 = { FOLLOW_41_in_predicateInstanceList3665_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_predicateInstance_in_predicateInstanceList3673 */ -static ANTLR3_BITWORD FOLLOW_predicateInstance_in_predicateInstanceList3673_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000208) }; -static ANTLR3_BITSET_LIST FOLLOW_predicateInstance_in_predicateInstanceList3673 = { FOLLOW_predicateInstance_in_predicateInstanceList3673_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_predicateVarRef_in_predicateInstanceList3689 */ -static ANTLR3_BITWORD FOLLOW_predicateVarRef_in_predicateInstanceList3689_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_predicateVarRef_in_predicateInstanceList3689 = { FOLLOW_predicateVarRef_in_predicateInstanceList3689_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_PREDICATE_INSTANCE_in_predicateInstance3724 */ -static ANTLR3_BITWORD FOLLOW_PREDICATE_INSTANCE_in_predicateInstance3724_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_PREDICATE_INSTANCE_in_predicateInstance3724 = { FOLLOW_PREDICATE_INSTANCE_in_predicateInstance3724_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualifiedToken_in_predicateInstance3731 */ -static ANTLR3_BITWORD FOLLOW_qualifiedToken_in_predicateInstance3731_bits[] = { ANTLR3_UINT64_LIT(0x3000000000010008) }; -static ANTLR3_BITSET_LIST FOLLOW_qualifiedToken_in_predicateInstance3731 = { FOLLOW_qualifiedToken_in_predicateInstance3731_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_predicateInstance3742 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_predicateInstance3742_bits[] = { ANTLR3_UINT64_LIT(0x3000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_predicateInstance3742 = { FOLLOW_IDENT_in_predicateInstance3742_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_tokenAnnotation_in_predicateInstance3755 */ -static ANTLR3_BITWORD FOLLOW_tokenAnnotation_in_predicateInstance3755_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_tokenAnnotation_in_predicateInstance3755 = { FOLLOW_tokenAnnotation_in_predicateInstance3755_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_identifier_in_predicateVarRef3796 */ -static ANTLR3_BITWORD FOLLOW_identifier_in_predicateVarRef3796_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_identifier_in_predicateVarRef3796 = { FOLLOW_identifier_in_predicateVarRef3796_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_tokenAnnotation0 */ -static ANTLR3_BITWORD FOLLOW_set_in_tokenAnnotation0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_tokenAnnotation0 = { FOLLOW_set_in_tokenAnnotation0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_identifier_in_qualifiedString3842 */ -static ANTLR3_BITWORD FOLLOW_identifier_in_qualifiedString3842_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_identifier_in_qualifiedString3842 = { FOLLOW_identifier_in_qualifiedString3842_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_46_in_qualifiedString3873 */ -static ANTLR3_BITWORD FOLLOW_46_in_qualifiedString3873_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_46_in_qualifiedString3873 = { FOLLOW_46_in_qualifiedString3873_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualifiedString_in_qualifiedString3877 */ -static ANTLR3_BITWORD FOLLOW_qualifiedString_in_qualifiedString3877_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; -static ANTLR3_BITSET_LIST FOLLOW_qualifiedString_in_qualifiedString3877 = { FOLLOW_qualifiedString_in_qualifiedString3877_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_qualifiedString3899 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_qualifiedString3899_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010008) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_qualifiedString3899 = { FOLLOW_IDENT_in_qualifiedString3899_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualifiedString_in_qualified3950 */ -static ANTLR3_BITWORD FOLLOW_qualifiedString_in_qualified3950_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_qualifiedString_in_qualified3950 = { FOLLOW_qualifiedString_in_qualified3950_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualifiedString_in_qualifiedToken3989 */ -static ANTLR3_BITWORD FOLLOW_qualifiedString_in_qualifiedToken3989_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_qualifiedString_in_qualifiedToken3989 = { FOLLOW_qualifiedString_in_qualifiedToken3989_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_temporalRelation0 */ -static ANTLR3_BITWORD FOLLOW_set_in_temporalRelation0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_temporalRelation0 = { FOLLOW_set_in_temporalRelation0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_METHOD_CALL_in_methodInvocation4466 */ -static ANTLR3_BITWORD FOLLOW_METHOD_CALL_in_methodInvocation4466_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_METHOD_CALL_in_methodInvocation4466 = { FOLLOW_METHOD_CALL_in_methodInvocation4466_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_qualified_in_methodInvocation4470 */ -static ANTLR3_BITWORD FOLLOW_qualified_in_methodInvocation4470_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000), ANTLR3_UINT64_LIT(0x0000100000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_qualified_in_methodInvocation4470 = { FOLLOW_qualified_in_methodInvocation4470_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_methodName_in_methodInvocation4474 */ -static ANTLR3_BITWORD FOLLOW_methodName_in_methodInvocation4474_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_methodName_in_methodInvocation4474 = { FOLLOW_methodName_in_methodInvocation4474_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_variableArgumentList_in_methodInvocation4476 */ -static ANTLR3_BITWORD FOLLOW_variableArgumentList_in_methodInvocation4476_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_variableArgumentList_in_methodInvocation4476 = { FOLLOW_variableArgumentList_in_methodInvocation4476_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_CLOSE_in_methodInvocation4494 */ -static ANTLR3_BITWORD FOLLOW_CLOSE_in_methodInvocation4494_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_CLOSE_in_methodInvocation4494 = { FOLLOW_CLOSE_in_methodInvocation4494_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_CLOSE_in_methodInvocation4496 */ -static ANTLR3_BITWORD FOLLOW_CLOSE_in_methodInvocation4496_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_CLOSE_in_methodInvocation4496 = { FOLLOW_CLOSE_in_methodInvocation4496_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_methodName0 */ -static ANTLR3_BITWORD FOLLOW_set_in_methodName0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_methodName0 = { FOLLOW_set_in_methodName0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_cexpressionList4536 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_cexpressionList4536_bits[] = { ANTLR3_UINT64_LIT(0x00006042000F4002), ANTLR3_UINT64_LIT(0x00000FC0000007FF) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_cexpressionList4536 = { FOLLOW_cexpression_in_cexpressionList4536_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexprOp_in_cexpression4564 */ -static ANTLR3_BITWORD FOLLOW_cexprOp_in_cexpression4564_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_cexprOp_in_cexpression4564 = { FOLLOW_cexprOp_in_cexpression4564_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_cexpression4568 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_cexpression4568_bits[] = { ANTLR3_UINT64_LIT(0x00006042000F4008), ANTLR3_UINT64_LIT(0x00000FC0000007FF) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_cexpression4568 = { FOLLOW_cexpression_in_cexpression4568_bits, 2 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_cexpression4572 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_cexpression4572_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_cexpression4572 = { FOLLOW_cexpression_in_cexpression4572_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_anyValue_in_cexpression4590 */ -static ANTLR3_BITWORD FOLLOW_anyValue_in_cexpression4590_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_anyValue_in_cexpression4590 = { FOLLOW_anyValue_in_cexpression4590_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_FUNCTION_CALL_in_cexpression4606 */ -static ANTLR3_BITWORD FOLLOW_FUNCTION_CALL_in_cexpression4606_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_FUNCTION_CALL_in_cexpression4606 = { FOLLOW_FUNCTION_CALL_in_cexpression4606_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_IDENT_in_cexpression4610 */ -static ANTLR3_BITWORD FOLLOW_IDENT_in_cexpression4610_bits[] = { ANTLR3_UINT64_LIT(0x0000020000000000) }; -static ANTLR3_BITSET_LIST FOLLOW_IDENT_in_cexpression4610 = { FOLLOW_IDENT_in_cexpression4610_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_41_in_cexpression4613 */ -static ANTLR3_BITWORD FOLLOW_41_in_cexpression4613_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_41_in_cexpression4613 = { FOLLOW_41_in_cexpression4613_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpressionList_in_cexpression4615 */ -static ANTLR3_BITWORD FOLLOW_cexpressionList_in_cexpression4615_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpressionList_in_cexpression4615 = { FOLLOW_cexpressionList_in_cexpression4615_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_cexprOp0 */ -static ANTLR3_BITWORD FOLLOW_set_in_cexprOp0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_set_in_cexprOp0 = { FOLLOW_set_in_cexprOp0_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_EXPRESSION_ENFORCE_in_enforceExpression4710 */ -static ANTLR3_BITWORD FOLLOW_EXPRESSION_ENFORCE_in_enforceExpression4710_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; -static ANTLR3_BITSET_LIST FOLLOW_EXPRESSION_ENFORCE_in_enforceExpression4710 = { FOLLOW_EXPRESSION_ENFORCE_in_enforceExpression4710_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_enforceExpression4714 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_enforceExpression4714_bits[] = { ANTLR3_UINT64_LIT(0x0000000000080008) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_enforceExpression4714 = { FOLLOW_cexpression_in_enforceExpression4714_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_violationMsg_in_enforceExpression4716 */ -static ANTLR3_BITWORD FOLLOW_violationMsg_in_enforceExpression4716_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; -static ANTLR3_BITSET_LIST FOLLOW_violationMsg_in_enforceExpression4716 = { FOLLOW_violationMsg_in_enforceExpression4716_bits, 1 }; -/** Bitset defining follow set for error recovery in rule state: FOLLOW_cexpression_in_expressionCleanReturn4744 */ -static ANTLR3_BITWORD FOLLOW_cexpression_in_expressionCleanReturn4744_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; -static ANTLR3_BITSET_LIST FOLLOW_cexpression_in_expressionCleanReturn4744 = { FOLLOW_cexpression_in_expressionCleanReturn4744_bits, 1 }; - - - - -/* ============================================== - * Parsing rules - */ -/** - * $ANTLR start nddl - * NDDL/base/antlr/NDDL3Tree.g:81:1: nddl : ^( NDDL ( (child= classDeclaration | child= enumDefinition | child= typeDefinition | child= variableDeclarations | child= assignment | child= constraintInstantiation | child= enforceExpression | child= allocation[NULL] | child= rule | child= problemStmt | child= relation | child= methodInvocation ) )* ) ; - */ -static void -nddl(pNDDL3Tree ctx) -{ - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:82:2: ( ^( NDDL ( (child= classDeclaration | child= enumDefinition | child= typeDefinition | child= variableDeclarations | child= assignment | child= constraintInstantiation | child= enforceExpression | child= allocation[NULL] | child= rule | child= problemStmt | child= relation | child= methodInvocation ) )* ) ) - // NDDL/base/antlr/NDDL3Tree.g:82:4: ^( NDDL ( (child= classDeclaration | child= enumDefinition | child= typeDefinition | child= variableDeclarations | child= assignment | child= constraintInstantiation | child= enforceExpression | child= allocation[NULL] | child= rule | child= problemStmt | child= relation | child= methodInvocation ) )* ) - { - MATCHT(NDDL, &FOLLOW_NDDL_in_nddl70); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:83:3: ( (child= classDeclaration | child= enumDefinition | child= typeDefinition | child= variableDeclarations | child= assignment | child= constraintInstantiation | child= enforceExpression | child= allocation[NULL] | child= rule | child= problemStmt | child= relation | child= methodInvocation ) )* - - for (;;) - { - int alt2=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA2_0 = LA(1); - if ( (LA2_0 == CONSTRAINT_INSTANTIATION || ((LA2_0 >= CONSTRUCTOR_INVOCATION) && (LA2_0 <= METHOD_CALL)) || ((LA2_0 >= TOKEN_RELATION) && (LA2_0 <= EXPRESSION_ENFORCE)) || LA2_0 == CLOSE || LA2_0 == 32 || LA2_0 == 36 || LA2_0 == 43 || LA2_0 == 48 || LA2_0 == 52 || ((LA2_0 >= 57) && (LA2_0 <= 59))) ) - { - alt2=1; - } - - } - switch (alt2) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:83:5: (child= classDeclaration | child= enumDefinition | child= typeDefinition | child= variableDeclarations | child= assignment | child= constraintInstantiation | child= enforceExpression | child= allocation[NULL] | child= rule | child= problemStmt | child= relation | child= methodInvocation ) - { - { - - // debugMsg("NddlInterpreter:nddl","Line:" << LEXER->getLine(LEXER)); - - } - - // NDDL/base/antlr/NDDL3Tree.g:86:5: (child= classDeclaration | child= enumDefinition | child= typeDefinition | child= variableDeclarations | child= assignment | child= constraintInstantiation | child= enforceExpression | child= allocation[NULL] | child= rule | child= problemStmt | child= relation | child= methodInvocation ) - { - int alt1=12; - switch ( LA(1) ) - { - case 48: - { - alt1=1; - } - break; - case 32: - { - alt1=2; - } - break; - case 36: - { - alt1=3; - } - break; - case VARIABLE: - { - alt1=4; - } - break; - case 43: - { - alt1=5; - } - break; - case CONSTRAINT_INSTANTIATION: - { - alt1=6; - } - break; - case EXPRESSION_ENFORCE: - { - alt1=7; - } - break; - case CONSTRUCTOR_INVOCATION: - { - alt1=8; - } - break; - case 52: - { - alt1=9; - } - break; - case 57: - case 58: - case 59: - { - alt1=10; - } - break; - case TOKEN_RELATION: - { - alt1=11; - } - break; - case METHOD_CALL: - case CLOSE: - { - alt1=12; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 1; - EXCEPTION->state = 0; - - - goto rulenddlEx; - } - - switch (alt1) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:86:7: child= classDeclaration - { - FOLLOWPUSH(FOLLOW_classDeclaration_in_nddl86); - child=classDeclaration(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:87:13: child= enumDefinition - { - FOLLOWPUSH(FOLLOW_enumDefinition_in_nddl102); - child=enumDefinition(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:88:7: child= typeDefinition - { - FOLLOWPUSH(FOLLOW_typeDefinition_in_nddl112); - child=typeDefinition(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 4: - // NDDL/base/antlr/NDDL3Tree.g:89:7: child= variableDeclarations - { - FOLLOWPUSH(FOLLOW_variableDeclarations_in_nddl122); - child=variableDeclarations(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 5: - // NDDL/base/antlr/NDDL3Tree.g:90:7: child= assignment - { - FOLLOWPUSH(FOLLOW_assignment_in_nddl132); - child=assignment(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 6: - // NDDL/base/antlr/NDDL3Tree.g:91:7: child= constraintInstantiation - { - FOLLOWPUSH(FOLLOW_constraintInstantiation_in_nddl142); - child=constraintInstantiation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 7: - // NDDL/base/antlr/NDDL3Tree.g:92:7: child= enforceExpression - { - FOLLOWPUSH(FOLLOW_enforceExpression_in_nddl152); - child=enforceExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 8: - // NDDL/base/antlr/NDDL3Tree.g:93:7: child= allocation[NULL] - { - FOLLOWPUSH(FOLLOW_allocation_in_nddl162); - child=allocation(ctx, NULL); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 9: - // NDDL/base/antlr/NDDL3Tree.g:94:7: child= rule - { - FOLLOWPUSH(FOLLOW_rule_in_nddl173); - child=rule(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 10: - // NDDL/base/antlr/NDDL3Tree.g:95:7: child= problemStmt - { - FOLLOWPUSH(FOLLOW_problemStmt_in_nddl183); - child=problemStmt(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 11: - // NDDL/base/antlr/NDDL3Tree.g:96:7: child= relation - { - FOLLOWPUSH(FOLLOW_relation_in_nddl193); - child=relation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - case 12: - // NDDL/base/antlr/NDDL3Tree.g:97:7: child= methodInvocation - { - FOLLOWPUSH(FOLLOW_methodInvocation_in_nddl203); - child=methodInvocation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - - } - break; - - } - } - { - - if (child != NULL) { - debugMsg("NddlInterpreter:nddl","Evaluating:" << child->toString()); - evalExpr(CTX,child); - - // TODO!!: systematically deal with memory mgmt for all Exprs. - delete child; - child = NULL; - - CTX->SymbolTable->getPlanDatabase()->getConstraintEngine()->propagate(); - } - CTX->SymbolTable->getPlanDatabase()->getConstraintEngine()->propagate(); - - - } - - } - break; - - default: - goto loop2; /* break out of the loop */ - break; - } - } - loop2: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulenddlEx; - } - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulenddlEx; /* Prevent compiler warnings */ - rulenddlEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end nddl */ - -/** - * $ANTLR start enumDefinition - * NDDL/base/antlr/NDDL3Tree.g:118:1: enumDefinition returns [Expr* result] : ^( 'enum' name= IDENT enumValues[values] ) ; - */ -static Expr* -enumDefinition(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - pANTLR3_BASE_TREE name; - - /* Initialize rule variables - */ - - - - std::vector values; - - name = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:122:5: ( ^( 'enum' name= IDENT enumValues[values] ) ) - // NDDL/base/antlr/NDDL3Tree.g:122:9: ^( 'enum' name= IDENT enumValues[values] ) - { - MATCHT(32, &FOLLOW_32_in_enumDefinition255); - if (HASEXCEPTION()) - { - goto ruleenumDefinitionEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleenumDefinitionEx; - } - - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_enumDefinition259); - if (HASEXCEPTION()) - { - goto ruleenumDefinitionEx; - } - - FOLLOWPUSH(FOLLOW_enumValues_in_enumDefinition261); - enumValues(ctx, values); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleenumDefinitionEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleenumDefinitionEx; - } - - { - - const char* enumName = c_str((name->getText(name))->chars); - result = new ExprEnumdef(enumName,values); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleenumDefinitionEx; /* Prevent compiler warnings */ - ruleenumDefinitionEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end enumDefinition */ - -/** - * $ANTLR start enumValues - * NDDL/base/antlr/NDDL3Tree.g:129:1: enumValues[std::vector& values] : ^( '{' (v= IDENT )+ ) ; - */ -static void -enumValues(pNDDL3Tree ctx, std::vector& values) -{ - pANTLR3_BASE_TREE v; - - /* Initialize rule variables - */ - - - v = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:130:5: ( ^( '{' (v= IDENT )+ ) ) - // NDDL/base/antlr/NDDL3Tree.g:130:13: ^( '{' (v= IDENT )+ ) - { - MATCHT(33, &FOLLOW_33_in_enumValues298); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - - // NDDL/base/antlr/NDDL3Tree.g:130:19: (v= IDENT )+ - { - int cnt3=0; - - for (;;) - { - int alt3=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA3_0 = LA(1); - if ( (LA3_0 == IDENT) ) - { - alt3=1; - } - - } - switch (alt3) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:130:20: v= IDENT - { - v = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_enumValues303); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - - { - values.push_back(c_str((v->getText(v))->chars)); - } - - } - break; - - default: - - if ( cnt3 >= 1 ) - { - goto loop3; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleenumValuesEx; - } - cnt3++; - } - loop3: ; /* Jump to here if this rule does not match */ - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleenumValuesEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruleenumValuesEx; /* Prevent compiler warnings */ - ruleenumValuesEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end enumValues */ - -/** - * $ANTLR start typeDefinition - * NDDL/base/antlr/NDDL3Tree.g:133:1: typeDefinition returns [Expr* result] : ^( 'typedef' name= IDENT dataType= type domain= baseDomain[dataType] ) ; - */ -static Expr* -typeDefinition(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - pANTLR3_BASE_TREE name; - DataType* dataType; - #undef RETURN_TYPE_dataType - #define RETURN_TYPE_dataType DataType* - - Domain* domain; - #undef RETURN_TYPE_domain - #define RETURN_TYPE_domain Domain* - - /* Initialize rule variables - */ - - - name = NULL; - dataType = NULL; - domain = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:134:5: ( ^( 'typedef' name= IDENT dataType= type domain= baseDomain[dataType] ) ) - // NDDL/base/antlr/NDDL3Tree.g:134:9: ^( 'typedef' name= IDENT dataType= type domain= baseDomain[dataType] ) - { - MATCHT(36, &FOLLOW_36_in_typeDefinition351); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_typeDefinition367); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - - FOLLOWPUSH(FOLLOW_type_in_typeDefinition383); - dataType=type(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - - FOLLOWPUSH(FOLLOW_baseDomain_in_typeDefinition390); - domain=baseDomain(ctx, dataType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruletypeDefinitionEx; - } - - { - - const char* newName = c_str((name->getText(name))->chars); - result = new ExprTypedef(dataType->getId(),newName,domain); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletypeDefinitionEx; /* Prevent compiler warnings */ - ruletypeDefinitionEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end typeDefinition */ - -/** - * $ANTLR start type - * NDDL/base/antlr/NDDL3Tree.g:145:1: type returns [DataType* result] : (name= 'int' | name= 'float' | name= 'bool' | name= 'string' | name= IDENT ) ; - */ -static DataType* -type(pNDDL3Tree ctx) -{ - DataType* result = NULL; - - pANTLR3_BASE_TREE name; - - /* Initialize rule variables - */ - - - name = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:146:5: ( (name= 'int' | name= 'float' | name= 'bool' | name= 'string' | name= IDENT ) ) - // NDDL/base/antlr/NDDL3Tree.g:146:9: (name= 'int' | name= 'float' | name= 'bool' | name= 'string' | name= IDENT ) - { - - // NDDL/base/antlr/NDDL3Tree.g:146:9: (name= 'int' | name= 'float' | name= 'bool' | name= 'string' | name= IDENT ) - { - int alt4=5; - switch ( LA(1) ) - { - case 53: - { - alt4=1; - } - break; - case 54: - { - alt4=2; - } - break; - case 55: - { - alt4=3; - } - break; - case 56: - { - alt4=4; - } - break; - case IDENT: - { - alt4=5; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 4; - EXCEPTION->state = 0; - - - goto ruletypeEx; - } - - switch (alt4) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:146:13: name= 'int' - { - name = (pANTLR3_BASE_TREE) MATCHT(53, &FOLLOW_53_in_type438); - if (HASEXCEPTION()) - { - goto ruletypeEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:147:13: name= 'float' - { - name = (pANTLR3_BASE_TREE) MATCHT(54, &FOLLOW_54_in_type454); - if (HASEXCEPTION()) - { - goto ruletypeEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:148:13: name= 'bool' - { - name = (pANTLR3_BASE_TREE) MATCHT(55, &FOLLOW_55_in_type470); - if (HASEXCEPTION()) - { - goto ruletypeEx; - } - - - } - break; - case 4: - // NDDL/base/antlr/NDDL3Tree.g:149:13: name= 'string' - { - name = (pANTLR3_BASE_TREE) MATCHT(56, &FOLLOW_56_in_type486); - if (HASEXCEPTION()) - { - goto ruletypeEx; - } - - - } - break; - case 5: - // NDDL/base/antlr/NDDL3Tree.g:150:13: name= IDENT - { - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_type502); - if (HASEXCEPTION()) - { - goto ruletypeEx; - } - - - } - break; - - } - } - { - - const char* nameStr = c_str((name->getText(name))->chars); - DataTypeId dt = CTX->SymbolTable->getDataType(nameStr); - - if (dt.isId()) - result = (DataType*)dt; - else - reportSemanticError(CTX,"Unknown data type:"+std::string(nameStr)); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletypeEx; /* Prevent compiler warnings */ - ruletypeEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end type */ - -/** - * $ANTLR start baseDomain - * NDDL/base/antlr/NDDL3Tree.g:163:1: baseDomain[const DataType* baseType] returns [Domain* result] : child= baseDomainValues ; - */ -static Domain* -baseDomain(pNDDL3Tree ctx, const DataType* baseType) -{ - Domain* result = NULL; - - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:164:5: (child= baseDomainValues ) - // NDDL/base/antlr/NDDL3Tree.g:164:9: child= baseDomainValues - { - FOLLOWPUSH(FOLLOW_baseDomainValues_in_baseDomain556); - child=baseDomainValues(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulebaseDomainEx; - } - - { - - DataRef data=evalExpr(CTX,child); - ConstrainedVariableId value = data.getValue(); - if (!baseType->isAssignableFrom(value->getDataType())) { - reportSemanticError(CTX, - "Can't assign "+value->toString()+" to "+baseType->getName().toString()); - } - - result = value->lastDomain().copy(); - delete child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulebaseDomainEx; /* Prevent compiler warnings */ - rulebaseDomainEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end baseDomain */ - -/** - * $ANTLR start baseDomainValues - * NDDL/base/antlr/NDDL3Tree.g:178:1: baseDomainValues returns [Expr* result] : (child= numericInterval | child= valueSet ) ; - */ -static Expr* -baseDomainValues(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:179:5: ( (child= numericInterval | child= valueSet ) ) - // NDDL/base/antlr/NDDL3Tree.g:179:9: (child= numericInterval | child= valueSet ) - { - - // NDDL/base/antlr/NDDL3Tree.g:179:9: (child= numericInterval | child= valueSet ) - { - int alt5=2; - - { - int LA5_0 = LA(1); - if ( (LA5_0 == 38) ) - { - alt5=1; - } - else if ( (LA5_0 == 33) ) - { - alt5=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 5; - EXCEPTION->state = 0; - - - goto rulebaseDomainValuesEx; - } - } - switch (alt5) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:179:11: child= numericInterval - { - FOLLOWPUSH(FOLLOW_numericInterval_in_baseDomainValues604); - child=numericInterval(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulebaseDomainValuesEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:180:11: child= valueSet - { - FOLLOWPUSH(FOLLOW_valueSet_in_baseDomainValues618); - child=valueSet(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulebaseDomainValuesEx; - } - - - } - break; - - } - } - { - - result = child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulebaseDomainValuesEx; /* Prevent compiler warnings */ - rulebaseDomainValuesEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end baseDomainValues */ - -/** - * $ANTLR start variableDeclarations - * NDDL/base/antlr/NDDL3Tree.g:187:1: variableDeclarations returns [ExprList* result] : ^( VARIABLE dataType= type (child= variableInitialization[dataType->getId()] )+ ) ; - */ -static ExprList* -variableDeclarations(pNDDL3Tree ctx) -{ - ExprList* result = NULL; - - DataType* dataType; - #undef RETURN_TYPE_dataType - #define RETURN_TYPE_dataType DataType* - - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - - result = new ExprList(); - - dataType = NULL; - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:191:5: ( ^( VARIABLE dataType= type (child= variableInitialization[dataType->getId()] )+ ) ) - // NDDL/base/antlr/NDDL3Tree.g:191:9: ^( VARIABLE dataType= type (child= variableInitialization[dataType->getId()] )+ ) - { - MATCHT(VARIABLE, &FOLLOW_VARIABLE_in_variableDeclarations672); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - - FOLLOWPUSH(FOLLOW_type_in_variableDeclarations689); - dataType=type(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - - // NDDL/base/antlr/NDDL3Tree.g:193:13: (child= variableInitialization[dataType->getId()] )+ - { - int cnt6=0; - - for (;;) - { - int alt6=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA6_0 = LA(1); - if ( (LA6_0 == IDENT || LA6_0 == 43) ) - { - alt6=1; - } - - } - switch (alt6) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:193:14: child= variableInitialization[dataType->getId()] - { - FOLLOWPUSH(FOLLOW_variableInitialization_in_variableDeclarations707); - child=variableInitialization(ctx, dataType->getId()); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - - { - - result->addChild(child); - - } - - } - break; - - default: - - if ( cnt6 >= 1 ) - { - goto loop6; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto rulevariableDeclarationsEx; - } - cnt6++; - } - loop6: ; /* Jump to here if this rule does not match */ - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulevariableDeclarationsEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto rulevariableDeclarationsEx; /* Prevent compiler warnings */ - rulevariableDeclarationsEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end variableDeclarations */ - -/** - * $ANTLR start variableInitialization - * NDDL/base/antlr/NDDL3Tree.g:201:1: variableInitialization[const DataTypeId& dataType] returns [Expr* result] : (name= IDENT | ^( '=' name= IDENT initExpr= initializer[varName] ) ) ; - */ -static Expr* -variableInitialization(pNDDL3Tree ctx, const DataTypeId& dataType) -{ - Expr* result = NULL; - - pANTLR3_BASE_TREE name; - Expr* initExpr; - #undef RETURN_TYPE_initExpr - #define RETURN_TYPE_initExpr Expr* - - /* Initialize rule variables - */ - - - - const char* varName; - - name = NULL; - initExpr = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:205:5: ( (name= IDENT | ^( '=' name= IDENT initExpr= initializer[varName] ) ) ) - // NDDL/base/antlr/NDDL3Tree.g:205:9: (name= IDENT | ^( '=' name= IDENT initExpr= initializer[varName] ) ) - { - - // NDDL/base/antlr/NDDL3Tree.g:205:9: (name= IDENT | ^( '=' name= IDENT initExpr= initializer[varName] ) ) - { - int alt7=2; - - { - int LA7_0 = LA(1); - if ( (LA7_0 == IDENT) ) - { - alt7=1; - } - else if ( (LA7_0 == 43) ) - { - alt7=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 7; - EXCEPTION->state = 0; - - - goto rulevariableInitializationEx; - } - } - switch (alt7) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:205:13: name= IDENT - { - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_variableInitialization790); - if (HASEXCEPTION()) - { - goto rulevariableInitializationEx; - } - - { - varName = c_str((name->getText(name))->chars); - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:206:13: ^( '=' name= IDENT initExpr= initializer[varName] ) - { - MATCHT(43, &FOLLOW_43_in_variableInitialization807); - if (HASEXCEPTION()) - { - goto rulevariableInitializationEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulevariableInitializationEx; - } - - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_variableInitialization811); - if (HASEXCEPTION()) - { - goto rulevariableInitializationEx; - } - - { - varName = c_str((name->getText(name))->chars); - } - FOLLOWPUSH(FOLLOW_initializer_in_variableInitialization818); - initExpr=initializer(ctx, varName); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableInitializationEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulevariableInitializationEx; - } - - - } - break; - - } - } - { - - // TODO: type check initExpr; - result = new ExprVarDeclaration( - varName, - dataType, - initExpr, - true // canBeSpecified - ); - CTX->SymbolTable->addLocalVar(varName,dataType); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulevariableInitializationEx; /* Prevent compiler warnings */ - rulevariableInitializationEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end variableInitialization */ - -/** - * $ANTLR start initializer - * NDDL/base/antlr/NDDL3Tree.g:220:1: initializer[const char* varName] returns [Expr* result] : (child= anyValue | child= allocation[varName] ) ; - */ -static Expr* -initializer(pNDDL3Tree ctx, const char* varName) -{ - Expr* result = NULL; - - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:221:5: ( (child= anyValue | child= allocation[varName] ) ) - // NDDL/base/antlr/NDDL3Tree.g:221:9: (child= anyValue | child= allocation[varName] ) - { - - // NDDL/base/antlr/NDDL3Tree.g:221:9: (child= anyValue | child= allocation[varName] ) - { - int alt8=2; - - { - int LA8_0 = LA(1); - if ( (((LA8_0 >= IDENT) && (LA8_0 <= STRING)) || LA8_0 == 33 || LA8_0 == 38 || ((LA8_0 >= 45) && (LA8_0 <= 46)) || ((LA8_0 >= 102) && (LA8_0 <= 107))) ) - { - alt8=1; - } - else if ( (LA8_0 == CONSTRUCTOR_INVOCATION) ) - { - alt8=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 8; - EXCEPTION->state = 0; - - - goto ruleinitializerEx; - } - } - switch (alt8) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:221:13: child= anyValue - { - FOLLOWPUSH(FOLLOW_anyValue_in_initializer881); - child=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleinitializerEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:222:13: child= allocation[varName] - { - FOLLOWPUSH(FOLLOW_allocation_in_initializer898); - child=allocation(ctx, varName); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleinitializerEx; - } - - - } - break; - - } - } - { - - result = child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleinitializerEx; /* Prevent compiler warnings */ - ruleinitializerEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end initializer */ - -/** - * $ANTLR start anyValue - * NDDL/base/antlr/NDDL3Tree.g:229:1: anyValue returns [Expr* result] : (child= literalValue | child= baseDomainValues | child= qualified ) ; - */ -static Expr* -anyValue(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:230:5: ( (child= literalValue | child= baseDomainValues | child= qualified ) ) - // NDDL/base/antlr/NDDL3Tree.g:230:9: (child= literalValue | child= baseDomainValues | child= qualified ) - { - - // NDDL/base/antlr/NDDL3Tree.g:230:9: (child= literalValue | child= baseDomainValues | child= qualified ) - { - int alt9=3; - switch ( LA(1) ) - { - case INT: - case FLOAT: - case STRING: - case 102: - case 103: - case 104: - case 105: - case 106: - case 107: - { - alt9=1; - } - break; - case 33: - case 38: - { - alt9=2; - } - break; - case IDENT: - case 45: - case 46: - { - alt9=3; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 9; - EXCEPTION->state = 0; - - - goto ruleanyValueEx; - } - - switch (alt9) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:230:13: child= literalValue - { - FOLLOWPUSH(FOLLOW_literalValue_in_anyValue948); - child=literalValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleanyValueEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:231:13: child= baseDomainValues - { - FOLLOWPUSH(FOLLOW_baseDomainValues_in_anyValue964); - child=baseDomainValues(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleanyValueEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:232:13: child= qualified - { - FOLLOWPUSH(FOLLOW_qualified_in_anyValue980); - child=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleanyValueEx; - } - - - } - break; - - } - } - { - - result = child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleanyValueEx; /* Prevent compiler warnings */ - ruleanyValueEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end anyValue */ - -/** - * $ANTLR start setElement - * NDDL/base/antlr/NDDL3Tree.g:239:1: setElement returns [Expr* result] : (child= literalValue | child= qualified ) ; - */ -static Expr* -setElement(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:240:5: ( (child= literalValue | child= qualified ) ) - // NDDL/base/antlr/NDDL3Tree.g:240:9: (child= literalValue | child= qualified ) - { - - // NDDL/base/antlr/NDDL3Tree.g:240:9: (child= literalValue | child= qualified ) - { - int alt10=2; - - { - int LA10_0 = LA(1); - if ( (((LA10_0 >= INT) && (LA10_0 <= STRING)) || ((LA10_0 >= 102) && (LA10_0 <= 107))) ) - { - alt10=1; - } - else if ( (LA10_0 == IDENT || ((LA10_0 >= 45) && (LA10_0 <= 46))) ) - { - alt10=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 10; - EXCEPTION->state = 0; - - - goto rulesetElementEx; - } - } - switch (alt10) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:240:13: child= literalValue - { - FOLLOWPUSH(FOLLOW_literalValue_in_setElement1029); - child=literalValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulesetElementEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:241:13: child= qualified - { - FOLLOWPUSH(FOLLOW_qualified_in_setElement1045); - child=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulesetElementEx; - } - - - } - break; - - } - } - { - - result = child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulesetElementEx; /* Prevent compiler warnings */ - rulesetElementEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end setElement */ - -/** - * $ANTLR start valueSet - * NDDL/base/antlr/NDDL3Tree.g:248:1: valueSet returns [Expr* result] : ^( '{' (element= setElement )* ) ; - */ -static Expr* -valueSet(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - Expr* element; - #undef RETURN_TYPE_element - #define RETURN_TYPE_element Expr* - - /* Initialize rule variables - */ - - - - std::list values; - DataTypeId elementType; - - element = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:253:5: ( ^( '{' (element= setElement )* ) ) - // NDDL/base/antlr/NDDL3Tree.g:253:9: ^( '{' (element= setElement )* ) - { - MATCHT(33, &FOLLOW_33_in_valueSet1094); - if (HASEXCEPTION()) - { - goto rulevalueSetEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulevalueSetEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:254:13: (element= setElement )* - - for (;;) - { - int alt11=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA11_0 = LA(1); - if ( (((LA11_0 >= IDENT) && (LA11_0 <= STRING)) || ((LA11_0 >= 45) && (LA11_0 <= 46)) || ((LA11_0 >= 102) && (LA11_0 <= 107))) ) - { - alt11=1; - } - - } - switch (alt11) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:254:14: element= setElement - { - FOLLOWPUSH(FOLLOW_setElement_in_valueSet1111); - element=setElement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevalueSetEx; - } - - { - - DataRef elemValue = evalExpr(CTX,element); - const Domain& ev = elemValue.getValue()->lastDomain(); - edouble v = ev.getSingletonValue(); - - delete element; - - if (elementType.isNoId()) - elementType = ev.getDataType(); - else { - DataTypeId newElementType=ev.getDataType(); - if (!newElementType->isAssignableFrom(elementType) && - !elementType->isAssignableFrom(newElementType)) { - reportSemanticError(CTX, - "Incompatible types in value set: "+ - elementType->toString(values.front())+"("+elementType->getName().toString()+") "+ - newElementType->toString(v)+"("+newElementType->getName().toString()+")" - ); - } - } - - values.push_back(v); - - } - - } - break; - - default: - goto loop11; /* break out of the loop */ - break; - } - } - loop11: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulevalueSetEx; - } - - } - { - - Domain* newDomain = new EnumeratedDomain(elementType,values); - result = new ExprConstant( - elementType->getName().c_str(), - newDomain - ); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulevalueSetEx; /* Prevent compiler warnings */ - rulevalueSetEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end valueSet */ - -/** - * $ANTLR start literalValue - * NDDL/base/antlr/NDDL3Tree.g:289:1: literalValue returns [Expr* result] : (child= booleanLiteral | child= numericLiteral | child= stringLiteral ) ; - */ -static Expr* -literalValue(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - Domain* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Domain* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:290:5: ( (child= booleanLiteral | child= numericLiteral | child= stringLiteral ) ) - // NDDL/base/antlr/NDDL3Tree.g:290:9: (child= booleanLiteral | child= numericLiteral | child= stringLiteral ) - { - - // NDDL/base/antlr/NDDL3Tree.g:290:9: (child= booleanLiteral | child= numericLiteral | child= stringLiteral ) - { - int alt12=3; - switch ( LA(1) ) - { - case 102: - case 103: - { - alt12=1; - } - break; - case INT: - case FLOAT: - case 104: - case 105: - case 106: - case 107: - { - alt12=2; - } - break; - case STRING: - { - alt12=3; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 12; - EXCEPTION->state = 0; - - - goto ruleliteralValueEx; - } - - switch (alt12) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:290:13: child= booleanLiteral - { - FOLLOWPUSH(FOLLOW_booleanLiteral_in_literalValue1189); - child=booleanLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleliteralValueEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:291:13: child= numericLiteral - { - FOLLOWPUSH(FOLLOW_numericLiteral_in_literalValue1205); - child=numericLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleliteralValueEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:292:13: child= stringLiteral - { - FOLLOWPUSH(FOLLOW_stringLiteral_in_literalValue1221); - child=stringLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleliteralValueEx; - } - - - } - break; - - } - } - { - - result = new ExprConstant( - child->getTypeName().c_str(), - child - ); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleliteralValueEx; /* Prevent compiler warnings */ - ruleliteralValueEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end literalValue */ - -/** - * $ANTLR start booleanLiteral - * NDDL/base/antlr/NDDL3Tree.g:302:1: booleanLiteral returns [Domain* result] : ( 'true' | 'false' ); - */ -static Domain* -booleanLiteral(pNDDL3Tree ctx) -{ - Domain* result = NULL; - - /* Initialize rule variables - */ - - - { - { - // NDDL/base/antlr/NDDL3Tree.g:303:5: ( 'true' | 'false' ) - - ANTLR3_UINT32 alt13; - - alt13=2; - - - { - int LA13_0 = LA(1); - if ( (LA13_0 == 102) ) - { - alt13=1; - } - else if ( (LA13_0 == 103) ) - { - alt13=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 13; - EXCEPTION->state = 0; - - - goto rulebooleanLiteralEx; - } - } - switch (alt13) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:303:9: 'true' - { - MATCHT(102, &FOLLOW_102_in_booleanLiteral1268); - if (HASEXCEPTION()) - { - goto rulebooleanLiteralEx; - } - - { - result = new BoolDomain(true); - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:304:9: 'false' - { - MATCHT(103, &FOLLOW_103_in_booleanLiteral1293); - if (HASEXCEPTION()) - { - goto rulebooleanLiteralEx; - } - - { - result = new BoolDomain(false); - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulebooleanLiteralEx; /* Prevent compiler warnings */ - rulebooleanLiteralEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end booleanLiteral */ - -/** - * $ANTLR start stringLiteral - * NDDL/base/antlr/NDDL3Tree.g:307:1: stringLiteral returns [Domain* result] : str= STRING ; - */ -static Domain* -stringLiteral(pNDDL3Tree ctx) -{ - Domain* result = NULL; - - pANTLR3_BASE_TREE str; - - /* Initialize rule variables - */ - - - str = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:308:5: (str= STRING ) - // NDDL/base/antlr/NDDL3Tree.g:308:10: str= STRING - { - str = (pANTLR3_BASE_TREE) MATCHT(STRING, &FOLLOW_STRING_in_stringLiteral1323); - if (HASEXCEPTION()) - { - goto rulestringLiteralEx; - } - - { - - // remove quotes - std::string s(c_str((str->getText(str))->chars)); - s = s.substr(1,s.size()-2); - - LabelStr value(s); - result = new StringDomain(value,StringDT::instance()); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulestringLiteralEx; /* Prevent compiler warnings */ - rulestringLiteralEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end stringLiteral */ - -/** - * $ANTLR start numericLiteral - * NDDL/base/antlr/NDDL3Tree.g:319:1: numericLiteral returns [Domain* result] : (floating= floatLiteral | integer= intLiteral ); - */ -static Domain* -numericLiteral(pNDDL3Tree ctx) -{ - Domain* result = NULL; - - NDDL3Tree_floatLiteral_return floating; - #undef RETURN_TYPE_floating - #define RETURN_TYPE_floating NDDL3Tree_floatLiteral_return - - NDDL3Tree_intLiteral_return integer; - #undef RETURN_TYPE_integer - #define RETURN_TYPE_integer NDDL3Tree_intLiteral_return - - /* Initialize rule variables - */ - - - - - - { - { - // NDDL/base/antlr/NDDL3Tree.g:320:5: (floating= floatLiteral | integer= intLiteral ) - - ANTLR3_UINT32 alt14; - - alt14=2; - - - { - int LA14_0 = LA(1); - if ( (LA14_0 == FLOAT || LA14_0 == 105 || LA14_0 == 107) ) - { - alt14=1; - } - else if ( (LA14_0 == INT || LA14_0 == 104 || LA14_0 == 106) ) - { - alt14=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 14; - EXCEPTION->state = 0; - - - goto rulenumericLiteralEx; - } - } - switch (alt14) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:320:9: floating= floatLiteral - { - FOLLOWPUSH(FOLLOW_floatLiteral_in_numericLiteral1361); - floating=floatLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenumericLiteralEx; - } - - { - result = CTX->SymbolTable->makeNumericDomainFromLiteral("float",c_str((STRSTREAM->toStringSS(STRSTREAM, floating.start, floating.start))->chars)); - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:321:9: integer= intLiteral - { - FOLLOWPUSH(FOLLOW_intLiteral_in_numericLiteral1376); - integer=intLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenumericLiteralEx; - } - - { - result = CTX->SymbolTable->makeNumericDomainFromLiteral("int",c_str((STRSTREAM->toStringSS(STRSTREAM, integer.start, integer.start))->chars)); - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulenumericLiteralEx; /* Prevent compiler warnings */ - rulenumericLiteralEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end numericLiteral */ - -/** - * $ANTLR start floatLiteral - * NDDL/base/antlr/NDDL3Tree.g:324:1: floatLiteral : ( FLOAT | 'inff' | '-inff' ); - */ -static NDDL3Tree_floatLiteral_return -floatLiteral(pNDDL3Tree ctx) -{ - NDDL3Tree_floatLiteral_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:325:5: ( FLOAT | 'inff' | '-inff' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( LA(1) == FLOAT || LA(1) == 105 || LA(1) == 107 ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_floatLiteral0); goto rulefloatLiteralEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto rulefloatLiteralEx; /* Prevent compiler warnings */ - rulefloatLiteralEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end floatLiteral */ - -/** - * $ANTLR start intLiteral - * NDDL/base/antlr/NDDL3Tree.g:328:1: intLiteral : ( INT | 'inf' | '-inf' ); - */ -static NDDL3Tree_intLiteral_return -intLiteral(pNDDL3Tree ctx) -{ - NDDL3Tree_intLiteral_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:329:5: ( INT | 'inf' | '-inf' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( LA(1) == INT || LA(1) == 104 || LA(1) == 106 ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_intLiteral0); goto ruleintLiteralEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruleintLiteralEx; /* Prevent compiler warnings */ - ruleintLiteralEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end intLiteral */ - -/** - * $ANTLR start numericInterval - * NDDL/base/antlr/NDDL3Tree.g:332:1: numericInterval returns [Expr* result] : ^( '[' lower= numericLiteral upper= numericLiteral ) ; - */ -static Expr* -numericInterval(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - Domain* lower; - #undef RETURN_TYPE_lower - #define RETURN_TYPE_lower Domain* - - Domain* upper; - #undef RETURN_TYPE_upper - #define RETURN_TYPE_upper Domain* - - /* Initialize rule variables - */ - - - lower = NULL; - upper = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:333:5: ( ^( '[' lower= numericLiteral upper= numericLiteral ) ) - // NDDL/base/antlr/NDDL3Tree.g:333:9: ^( '[' lower= numericLiteral upper= numericLiteral ) - { - MATCHT(38, &FOLLOW_38_in_numericInterval1483); - if (HASEXCEPTION()) - { - goto rulenumericIntervalEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulenumericIntervalEx; - } - - FOLLOWPUSH(FOLLOW_numericLiteral_in_numericInterval1502); - lower=numericLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenumericIntervalEx; - } - - FOLLOWPUSH(FOLLOW_numericLiteral_in_numericInterval1518); - upper=numericLiteral(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulenumericIntervalEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulenumericIntervalEx; - } - - { - - edouble lb = lower->getSingletonValue(); - edouble ub = upper->getSingletonValue(); - Domain* baseDomain; - - if (lower->getTypeName().toString()=="float" || - upper->getTypeName().toString()=="float") - baseDomain = new IntervalDomain(lb,ub); - else - baseDomain = new IntervalIntDomain((eint)lb,(eint)ub); - - result = new ExprConstant( - lower->getTypeName().c_str(), - baseDomain - ); - - delete lower; - delete upper; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulenumericIntervalEx; /* Prevent compiler warnings */ - rulenumericIntervalEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end numericInterval */ - -/** - * $ANTLR start allocation - * NDDL/base/antlr/NDDL3Tree.g:358:1: allocation[const char* name] returns [Expr* result] : ^( CONSTRUCTOR_INVOCATION objType= IDENT ( variableArgumentList[args] )? ) ; - */ -static Expr* -allocation(pNDDL3Tree ctx, const char* name) -{ - Expr* result = NULL; - - pANTLR3_BASE_TREE objType; - - /* Initialize rule variables - */ - - - - std::vector args; - - objType = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:362:9: ( ^( CONSTRUCTOR_INVOCATION objType= IDENT ( variableArgumentList[args] )? ) ) - // NDDL/base/antlr/NDDL3Tree.g:362:17: ^( CONSTRUCTOR_INVOCATION objType= IDENT ( variableArgumentList[args] )? ) - { - MATCHT(CONSTRUCTOR_INVOCATION, &FOLLOW_CONSTRUCTOR_INVOCATION_in_allocation1576); - if (HASEXCEPTION()) - { - goto ruleallocationEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleallocationEx; - } - - objType = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_allocation1604); - if (HASEXCEPTION()) - { - goto ruleallocationEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:364:25: ( variableArgumentList[args] )? - { - int alt15=2; - { - int LA15_0 = LA(1); - if ( (LA15_0 == 41) ) - { - alt15=1; - } - } - switch (alt15) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:364:25: variableArgumentList[args] - { - FOLLOWPUSH(FOLLOW_variableArgumentList_in_allocation1631); - variableArgumentList(ctx, args); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleallocationEx; - } - - - } - break; - - } - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleallocationEx; - } - - { - - std::string objName = (name != NULL ? name : getAutoLabel("__Object")); - /*try { - CTX->SymbolTable->checkObjectFactory(c_str((objType->getText(objType))->chars),args); - } - catch (const std::string& errorMsg) { - reportSemanticError(CTX,errorMsg); - }*/ - result = new ExprNewObject( - c_str((objType->getText(objType))->chars), // objectType - objName.c_str(), - args - ); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleallocationEx; /* Prevent compiler warnings */ - ruleallocationEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end allocation */ - -/** - * $ANTLR start variableArgumentList - * NDDL/base/antlr/NDDL3Tree.g:382:1: variableArgumentList[std::vector& result] : ( '(' | ^( '(' (arg= initializer[NULL] )* ) ); - */ -static void -variableArgumentList(pNDDL3Tree ctx, std::vector& result) -{ - Expr* arg; - #undef RETURN_TYPE_arg - #define RETURN_TYPE_arg Expr* - - /* Initialize rule variables - */ - - - arg = NULL; - - { - { - // NDDL/base/antlr/NDDL3Tree.g:383:9: ( '(' | ^( '(' (arg= initializer[NULL] )* ) ) - - ANTLR3_UINT32 alt17; - - alt17=2; - - - { - int LA17_0 = LA(1); - if ( (LA17_0 == 41) ) - { - - { - int LA17_1 = LA(2); - if ( (LA17_1 == DOWN) ) - { - alt17=2; - } - else if ( (LA17_1 == UP || LA17_1 == STRING) ) - { - alt17=1; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 17; - EXCEPTION->state = 1; - - - goto rulevariableArgumentListEx; - } - } - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 17; - EXCEPTION->state = 0; - - - goto rulevariableArgumentListEx; - } - } - switch (alt17) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:383:17: '(' - { - MATCHT(41, &FOLLOW_41_in_variableArgumentList1701); - if (HASEXCEPTION()) - { - goto rulevariableArgumentListEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:384:17: ^( '(' (arg= initializer[NULL] )* ) - { - MATCHT(41, &FOLLOW_41_in_variableArgumentList1720); - if (HASEXCEPTION()) - { - goto rulevariableArgumentListEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulevariableArgumentListEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:385:25: (arg= initializer[NULL] )* - - for (;;) - { - int alt16=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA16_0 = LA(1); - if ( (LA16_0 == CONSTRUCTOR_INVOCATION || ((LA16_0 >= IDENT) && (LA16_0 <= STRING)) || LA16_0 == 33 || LA16_0 == 38 || ((LA16_0 >= 45) && (LA16_0 <= 46)) || ((LA16_0 >= 102) && (LA16_0 <= 107))) ) - { - alt16=1; - } - - } - switch (alt16) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:385:26: arg= initializer[NULL] - { - FOLLOWPUSH(FOLLOW_initializer_in_variableArgumentList1749); - arg=initializer(ctx, NULL); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulevariableArgumentListEx; - } - - { - result.push_back(arg); - } - - } - break; - - default: - goto loop16; /* break out of the loop */ - break; - } - } - loop16: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulevariableArgumentListEx; - } - - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulevariableArgumentListEx; /* Prevent compiler warnings */ - rulevariableArgumentListEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end variableArgumentList */ - -/** - * $ANTLR start identifier - * NDDL/base/antlr/NDDL3Tree.g:389:1: identifier : ( IDENT | 'this' ); - */ -static NDDL3Tree_identifier_return -identifier(pNDDL3Tree ctx) -{ - NDDL3Tree_identifier_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:390:9: ( IDENT | 'this' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( LA(1) == IDENT || LA(1) == 45 ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_identifier0); goto ruleidentifierEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruleidentifierEx; /* Prevent compiler warnings */ - ruleidentifierEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end identifier */ - -/** - * $ANTLR start constraintInstantiation - * NDDL/base/antlr/NDDL3Tree.g:394:1: constraintInstantiation returns [ExprConstraint* result] : ^( CONSTRAINT_INSTANTIATION name= IDENT variableArgumentList[args] ( violationMsg[vmsg] )? ) ; - */ -static ExprConstraint* -constraintInstantiation(pNDDL3Tree ctx) -{ - ExprConstraint* result = NULL; - - pANTLR3_BASE_TREE name; - - /* Initialize rule variables - */ - - - - std::vector args; - std::string vmsg; - - name = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:399:9: ( ^( CONSTRAINT_INSTANTIATION name= IDENT variableArgumentList[args] ( violationMsg[vmsg] )? ) ) - // NDDL/base/antlr/NDDL3Tree.g:400:15: ^( CONSTRAINT_INSTANTIATION name= IDENT variableArgumentList[args] ( violationMsg[vmsg] )? ) - { - MATCHT(CONSTRAINT_INSTANTIATION, &FOLLOW_CONSTRAINT_INSTANTIATION_in_constraintInstantiation1866); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_constraintInstantiation1894); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - - FOLLOWPUSH(FOLLOW_variableArgumentList_in_constraintInstantiation1920); - variableArgumentList(ctx, args); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:403:25: ( violationMsg[vmsg] )? - { - int alt18=2; - { - int LA18_0 = LA(1); - if ( (LA18_0 == STRING) ) - { - alt18=1; - } - } - switch (alt18) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:403:26: violationMsg[vmsg] - { - FOLLOWPUSH(FOLLOW_violationMsg_in_constraintInstantiation1948); - violationMsg(ctx, vmsg); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - - - } - break; - - } - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleconstraintInstantiationEx; - } - - { - - const char* cname = c_str((name->getText(name))->chars); - try { - CTX->SymbolTable->checkConstraint(cname,args); - } - catch (const std::string& errorMsg) { - reportSemanticError(CTX,errorMsg); - } - result = new ExprConstraint(cname,args,vmsg.c_str()); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstraintInstantiationEx; /* Prevent compiler warnings */ - ruleconstraintInstantiationEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end constraintInstantiation */ - -/** - * $ANTLR start violationMsg - * NDDL/base/antlr/NDDL3Tree.g:418:1: violationMsg[std::string& result] : str= STRING ; - */ -static void -violationMsg(pNDDL3Tree ctx, std::string& result) -{ - pANTLR3_BASE_TREE str; - - /* Initialize rule variables - */ - - - str = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:419:5: (str= STRING ) - // NDDL/base/antlr/NDDL3Tree.g:419:10: str= STRING - { - str = (pANTLR3_BASE_TREE) MATCHT(STRING, &FOLLOW_STRING_in_violationMsg2034); - if (HASEXCEPTION()) - { - goto ruleviolationMsgEx; - } - - { - - // remove quotes - std::string s(c_str((str->getText(str))->chars)); - result = s.substr(1,s.size()-2); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleviolationMsgEx; /* Prevent compiler warnings */ - ruleviolationMsgEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end violationMsg */ - -/** - * $ANTLR start classDeclaration - * NDDL/base/antlr/NDDL3Tree.g:427:1: classDeclaration returns [Expr* result] : ^( 'class' className= IDENT ( ^( 'extends' superClass= IDENT ) )? ( classBlock[objType] | ';' ) ) ; - */ -static Expr* -classDeclaration(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - pANTLR3_BASE_TREE className; - pANTLR3_BASE_TREE superClass; - - /* Initialize rule variables - */ - - - - const char* newClass = NULL; - const char* parentClass = "Object"; - ObjectType* objType = NULL; - - className = NULL; - superClass = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:433:2: ( ^( 'class' className= IDENT ( ^( 'extends' superClass= IDENT ) )? ( classBlock[objType] | ';' ) ) ) - // NDDL/base/antlr/NDDL3Tree.g:433:4: ^( 'class' className= IDENT ( ^( 'extends' superClass= IDENT ) )? ( classBlock[objType] | ';' ) ) - { - MATCHT(48, &FOLLOW_48_in_classDeclaration2069); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - className = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_classDeclaration2084); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - { - newClass = c_str((className->getText(className))->chars); - } - - // NDDL/base/antlr/NDDL3Tree.g:436:6: ( ^( 'extends' superClass= IDENT ) )? - { - int alt19=2; - { - int LA19_0 = LA(1); - if ( (LA19_0 == 49) ) - { - alt19=1; - } - } - switch (alt19) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:436:7: ^( 'extends' superClass= IDENT ) - { - MATCHT(49, &FOLLOW_49_in_classDeclaration2115); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - superClass = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_classDeclaration2119); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - { - parentClass = c_str((superClass->getText(superClass))->chars); - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - - } - break; - - } - } - { - - ObjectTypeId parent = CTX->SymbolTable->getObjectType(parentClass); - if (parent.isNoId()) - reportSemanticError(CTX,"class "+std::string(parentClass)+" is undefined"); - - objType = new ObjectType(newClass,parent); - // TODO: do this more cleanly. Needed to deal with self-reference inside class definition - CTX->SymbolTable->getPlanDatabase()->getSchema()->declareObjectType(newClass); - pushContext(CTX,new NddlClassSymbolTable(CTX->SymbolTable,objType)); - - } - - // NDDL/base/antlr/NDDL3Tree.g:449:12: ( classBlock[objType] | ';' ) - { - int alt20=2; - - { - int LA20_0 = LA(1); - if ( (LA20_0 == 33) ) - { - alt20=1; - } - else if ( (LA20_0 == 37) ) - { - alt20=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 20; - EXCEPTION->state = 0; - - - goto ruleclassDeclarationEx; - } - } - switch (alt20) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:450:10: classBlock[objType] - { - FOLLOWPUSH(FOLLOW_classBlock_in_classDeclaration2181); - classBlock(ctx, objType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - { - - result = new ExprObjectTypeDefinition(objType->getId()); - - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:454:12: ';' - { - MATCHT(37, &FOLLOW_37_in_classDeclaration2208); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - { - - result = new ExprObjectTypeDeclaration(objType->getName()); - delete objType; - - } - - } - break; - - } - } - { - - popContext(CTX); - - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleclassDeclarationEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruleclassDeclarationEx; /* Prevent compiler warnings */ - ruleclassDeclarationEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end classDeclaration */ - -/** - * $ANTLR start classBlock - * NDDL/base/antlr/NDDL3Tree.g:466:1: classBlock[ObjectType* objType] : ( '{' | ^( '{' ( componentTypeEntry[objType] )* ) ); - */ -static void -classBlock(pNDDL3Tree ctx, ObjectType* objType) -{ - /* Initialize rule variables - */ - - - { - { - // NDDL/base/antlr/NDDL3Tree.g:467:2: ( '{' | ^( '{' ( componentTypeEntry[objType] )* ) ) - - ANTLR3_UINT32 alt22; - - alt22=2; - - - { - int LA22_0 = LA(1); - if ( (LA22_0 == 33) ) - { - - { - int LA22_1 = LA(2); - if ( (LA22_1 == DOWN) ) - { - alt22=2; - } - else if ( (LA22_1 == UP) ) - { - alt22=1; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 22; - EXCEPTION->state = 1; - - - goto ruleclassBlockEx; - } - } - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 22; - EXCEPTION->state = 0; - - - goto ruleclassBlockEx; - } - } - switch (alt22) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:467:4: '{' - { - MATCHT(33, &FOLLOW_33_in_classBlock2258); - if (HASEXCEPTION()) - { - goto ruleclassBlockEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:468:4: ^( '{' ( componentTypeEntry[objType] )* ) - { - MATCHT(33, &FOLLOW_33_in_classBlock2264); - if (HASEXCEPTION()) - { - goto ruleclassBlockEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleclassBlockEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:468:10: ( componentTypeEntry[objType] )* - - for (;;) - { - int alt21=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA21_0 = LA(1); - if ( (LA21_0 == CONSTRUCTOR || LA21_0 == VARIABLE || ((LA21_0 >= 50) && (LA21_0 <= 51))) ) - { - alt21=1; - } - - } - switch (alt21) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:468:10: componentTypeEntry[objType] - { - FOLLOWPUSH(FOLLOW_componentTypeEntry_in_classBlock2266); - componentTypeEntry(ctx, objType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassBlockEx; - } - - - } - break; - - default: - goto loop21; /* break out of the loop */ - break; - } - } - loop21: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleclassBlockEx; - } - - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto ruleclassBlockEx; /* Prevent compiler warnings */ - ruleclassBlockEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end classBlock */ - -/** - * $ANTLR start componentTypeEntry - * NDDL/base/antlr/NDDL3Tree.g:471:1: componentTypeEntry[ObjectType* objType] : ( classVariable[objType] | constructor[objType] | tokenType[objType] ); - */ -static void -componentTypeEntry(pNDDL3Tree ctx, ObjectType* objType) -{ - /* Initialize rule variables - */ - - - { - { - // NDDL/base/antlr/NDDL3Tree.g:472:2: ( classVariable[objType] | constructor[objType] | tokenType[objType] ) - - ANTLR3_UINT32 alt23; - - alt23=3; - - switch ( LA(1) ) - { - case VARIABLE: - { - alt23=1; - } - break; - case CONSTRUCTOR: - { - alt23=2; - } - break; - case 50: - case 51: - { - alt23=3; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 23; - EXCEPTION->state = 0; - - - goto rulecomponentTypeEntryEx; - } - - switch (alt23) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:472:4: classVariable[objType] - { - FOLLOWPUSH(FOLLOW_classVariable_in_componentTypeEntry2282); - classVariable(ctx, objType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecomponentTypeEntryEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:473:4: constructor[objType] - { - FOLLOWPUSH(FOLLOW_constructor_in_componentTypeEntry2288); - constructor(ctx, objType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecomponentTypeEntryEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:474:4: tokenType[objType] - { - FOLLOWPUSH(FOLLOW_tokenType_in_componentTypeEntry2294); - tokenType(ctx, objType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecomponentTypeEntryEx; - } - - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulecomponentTypeEntryEx; /* Prevent compiler warnings */ - rulecomponentTypeEntryEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end componentTypeEntry */ - -/** - * $ANTLR start classVariable - * NDDL/base/antlr/NDDL3Tree.g:477:1: classVariable[ObjectType* objType] : ^( VARIABLE dataType= type (name= IDENT )+ ) ; - */ -static void -classVariable(pNDDL3Tree ctx, ObjectType* objType) -{ - pANTLR3_BASE_TREE name; - DataType* dataType; - #undef RETURN_TYPE_dataType - #define RETURN_TYPE_dataType DataType* - - /* Initialize rule variables - */ - - - name = NULL; - dataType = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:478:9: ( ^( VARIABLE dataType= type (name= IDENT )+ ) ) - // NDDL/base/antlr/NDDL3Tree.g:478:17: ^( VARIABLE dataType= type (name= IDENT )+ ) - { - MATCHT(VARIABLE, &FOLLOW_VARIABLE_in_classVariable2321); - if (HASEXCEPTION()) - { - goto ruleclassVariableEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleclassVariableEx; - } - - FOLLOWPUSH(FOLLOW_type_in_classVariable2344); - dataType=type(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleclassVariableEx; - } - - // NDDL/base/antlr/NDDL3Tree.g:480:19: (name= IDENT )+ - { - int cnt24=0; - - for (;;) - { - int alt24=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA24_0 = LA(1); - if ( (LA24_0 == IDENT) ) - { - alt24=1; - } - - } - switch (alt24) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:480:20: name= IDENT - { - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_classVariable2368); - if (HASEXCEPTION()) - { - goto ruleclassVariableEx; - } - - { - - objType->addMember(dataType->getId(),c_str((name->getText(name))->chars)); - - } - - } - break; - - default: - - if ( cnt24 >= 1 ) - { - goto loop24; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleclassVariableEx; - } - cnt24++; - } - loop24: ; /* Jump to here if this rule does not match */ - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleclassVariableEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruleclassVariableEx; /* Prevent compiler warnings */ - ruleclassVariableEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end classVariable */ - -/** - * $ANTLR start constructor - * NDDL/base/antlr/NDDL3Tree.g:488:1: constructor[ObjectType* objType] : ^( CONSTRUCTOR name= IDENT ^( '(' ( constructorArgument[argNames,argTypes] )* ) ^( '{' (superCallExpr= constructorSuper[objType] )? (child= assignment )* ) ) ; - */ -static void -constructor(pNDDL3Tree ctx, ObjectType* objType) -{ - pANTLR3_BASE_TREE name; - ExprConstructorSuperCall* superCallExpr; - #undef RETURN_TYPE_superCallExpr - #define RETURN_TYPE_superCallExpr ExprConstructorSuperCall* - - ExprAssignment* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child ExprAssignment* - - /* Initialize rule variables - */ - - - - std::vector argNames; - std::vector argTypes; - std::vector body; - pushContext(CTX,new NddlSymbolTable(CTX->SymbolTable)); - - name = NULL; - superCallExpr = NULL; - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:495:2: ( ^( CONSTRUCTOR name= IDENT ^( '(' ( constructorArgument[argNames,argTypes] )* ) ^( '{' (superCallExpr= constructorSuper[objType] )? (child= assignment )* ) ) ) - // NDDL/base/antlr/NDDL3Tree.g:495:4: ^( CONSTRUCTOR name= IDENT ^( '(' ( constructorArgument[argNames,argTypes] )* ) ^( '{' (superCallExpr= constructorSuper[objType] )? (child= assignment )* ) ) - { - MATCHT(CONSTRUCTOR, &FOLLOW_CONSTRUCTOR_in_constructor2461); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_constructor2468); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - MATCHT(41, &FOLLOW_41_in_constructor2474); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:497:10: ( constructorArgument[argNames,argTypes] )* - - for (;;) - { - int alt25=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA25_0 = LA(1); - if ( (LA25_0 == VARIABLE) ) - { - alt25=1; - } - - } - switch (alt25) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:497:10: constructorArgument[argNames,argTypes] - { - FOLLOWPUSH(FOLLOW_constructorArgument_in_constructor2476); - constructorArgument(ctx, argNames, argTypes); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - - } - break; - - default: - goto loop25; /* break out of the loop */ - break; - } - } - loop25: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - } - MATCHT(33, &FOLLOW_33_in_constructor2485); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:498:23: (superCallExpr= constructorSuper[objType] )? - { - int alt26=2; - { - int LA26_0 = LA(1); - if ( (LA26_0 == 75) ) - { - alt26=1; - } - } - switch (alt26) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:498:23: superCallExpr= constructorSuper[objType] - { - FOLLOWPUSH(FOLLOW_constructorSuper_in_constructor2489); - superCallExpr=constructorSuper(ctx, objType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - - } - break; - - } - } - - // NDDL/base/antlr/NDDL3Tree.g:499:10: (child= assignment )* - - for (;;) - { - int alt27=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA27_0 = LA(1); - if ( (LA27_0 == 43) ) - { - alt27=1; - } - - } - switch (alt27) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:499:11: child= assignment - { - FOLLOWPUSH(FOLLOW_assignment_in_constructor2505); - child=assignment(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - { - body.push_back(child); - } - - } - break; - - default: - goto loop27; /* break out of the loop */ - break; - } - } - loop27: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorEx; - } - - { - - std::ostringstream signature; - signature << objType->getName().c_str(); - - for (unsigned int i=0;iaddObjectFactory( - (new InterpretedObjectFactory( - objType->getId(), - signature.str(), - argNames, - argTypes, - superCallExpr, - body) - )->getId() - ); - - popContext(CTX); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorEx; /* Prevent compiler warnings */ - ruleconstructorEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end constructor */ - -/** - * $ANTLR start constructorArgument - * NDDL/base/antlr/NDDL3Tree.g:523:1: constructorArgument[std::vector& argNames,std::vector& argTypes] : ^( VARIABLE argName= IDENT argType= type ) ; - */ -static void -constructorArgument(pNDDL3Tree ctx, std::vector& argNames, std::vector& argTypes) -{ - pANTLR3_BASE_TREE argName; - DataType* argType; - #undef RETURN_TYPE_argType - #define RETURN_TYPE_argType DataType* - - /* Initialize rule variables - */ - - - argName = NULL; - argType = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:524:2: ( ^( VARIABLE argName= IDENT argType= type ) ) - // NDDL/base/antlr/NDDL3Tree.g:524:4: ^( VARIABLE argName= IDENT argType= type ) - { - MATCHT(VARIABLE, &FOLLOW_VARIABLE_in_constructorArgument2531); - if (HASEXCEPTION()) - { - goto ruleconstructorArgumentEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorArgumentEx; - } - - argName = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_constructorArgument2538); - if (HASEXCEPTION()) - { - goto ruleconstructorArgumentEx; - } - - FOLLOWPUSH(FOLLOW_type_in_constructorArgument2545); - argType=type(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorArgumentEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorArgumentEx; - } - - { - - const char* varName = c_str((argName->getText(argName))->chars); - argNames.push_back(varName); - argTypes.push_back(argType->getName().toString()); - CTX->SymbolTable->addLocalVar(varName,argType->getId()); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorArgumentEx; /* Prevent compiler warnings */ - ruleconstructorArgumentEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end constructorArgument */ - -/** - * $ANTLR start constructorSuper - * NDDL/base/antlr/NDDL3Tree.g:536:1: constructorSuper[ObjectType* objType] returns [ExprConstructorSuperCall* result] : ^( 'super' variableArgumentList[args] ) ; - */ -static ExprConstructorSuperCall* -constructorSuper(pNDDL3Tree ctx, ObjectType* objType) -{ - ExprConstructorSuperCall* result = NULL; - - /* Initialize rule variables - */ - - - - std::vector args; - - { - // NDDL/base/antlr/NDDL3Tree.g:540:2: ( ^( 'super' variableArgumentList[args] ) ) - // NDDL/base/antlr/NDDL3Tree.g:540:4: ^( 'super' variableArgumentList[args] ) - { - MATCHT(75, &FOLLOW_75_in_constructorSuper2575); - if (HASEXCEPTION()) - { - goto ruleconstructorSuperEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorSuperEx; - } - - FOLLOWPUSH(FOLLOW_variableArgumentList_in_constructorSuper2580); - variableArgumentList(ctx, args); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleconstructorSuperEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleconstructorSuperEx; - } - - { - - result = new ExprConstructorSuperCall(objType->getParent()->getName(),args); - /*try { - CTX->SymbolTable->checkObjectFactory(objType->getParent()->getName().c_str(),args); - } - catch (const std::string& errorMsg) { - reportSemanticError(CTX,errorMsg); - }*/ - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleconstructorSuperEx; /* Prevent compiler warnings */ - ruleconstructorSuperEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end constructorSuper */ - -/** - * $ANTLR start assignment - * NDDL/base/antlr/NDDL3Tree.g:554:1: assignment returns [ExprAssignment* result] : ^( '=' lhs= qualified rhs= initializer[lhs->toString().c_str()] ) ; - */ -static ExprAssignment* -assignment(pNDDL3Tree ctx) -{ - ExprAssignment* result = NULL; - - Expr* lhs; - #undef RETURN_TYPE_lhs - #define RETURN_TYPE_lhs Expr* - - Expr* rhs; - #undef RETURN_TYPE_rhs - #define RETURN_TYPE_rhs Expr* - - /* Initialize rule variables - */ - - - lhs = NULL; - rhs = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:555:2: ( ^( '=' lhs= qualified rhs= initializer[lhs->toString().c_str()] ) ) - // NDDL/base/antlr/NDDL3Tree.g:555:4: ^( '=' lhs= qualified rhs= initializer[lhs->toString().c_str()] ) - { - MATCHT(43, &FOLLOW_43_in_assignment2607); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - - FOLLOWPUSH(FOLLOW_qualified_in_assignment2614); - lhs=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - - FOLLOWPUSH(FOLLOW_initializer_in_assignment2621); - rhs=initializer(ctx, lhs->toString().c_str()); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleassignmentEx; - } - - { - - result = new ExprAssignment(lhs,rhs); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleassignmentEx; /* Prevent compiler warnings */ - ruleassignmentEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end assignment */ - -/** - * $ANTLR start tokenType - * NDDL/base/antlr/NDDL3Tree.g:564:1: tokenType[ObjectType* objType] : ^(kind= ( 'predicate' | 'action' ) ttName= IDENT tokenStatements[tokenType] ) ; - */ -static void -tokenType(pNDDL3Tree ctx, ObjectType* objType) -{ - pANTLR3_BASE_TREE kind; - pANTLR3_BASE_TREE ttName; - - /* Initialize rule variables - */ - - - - InterpretedTokenType* tokenType; - std::string tokenTypeName; - - kind = NULL; - ttName = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:569:2: ( ^(kind= ( 'predicate' | 'action' ) ttName= IDENT tokenStatements[tokenType] ) ) - // NDDL/base/antlr/NDDL3Tree.g:569:4: ^(kind= ( 'predicate' | 'action' ) ttName= IDENT tokenStatements[tokenType] ) - { - kind=(pANTLR3_BASE_TREE)LT(1); - if ( ((LA(1) >= 50) && (LA(1) <= 51)) ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_tokenType2650); goto ruletokenTypeEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruletokenTypeEx; - } - - ttName = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_tokenType2663); - if (HASEXCEPTION()) - { - goto ruletokenTypeEx; - } - - { - - tokenTypeName = objType->getName().toString() + "." + c_str((ttName->getText(ttName))->chars); - tokenType = new InterpretedTokenType(objType->getId(),tokenTypeName,c_str((kind->getText(kind))->chars)); - pushContext(CTX,new NddlTokenSymbolTable(CTX->SymbolTable,tokenType->getId(),objType->getId())); - - } - FOLLOWPUSH(FOLLOW_tokenStatements_in_tokenType2674); - tokenStatements(ctx, tokenType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenTypeEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruletokenTypeEx; - } - - { - - objType->addTokenType(tokenType->getId()); - popContext(CTX); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenTypeEx; /* Prevent compiler warnings */ - ruletokenTypeEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end tokenType */ - -/** - * $ANTLR start tokenStatements - * NDDL/base/antlr/NDDL3Tree.g:585:1: tokenStatements[InterpretedTokenType* tokenType] : ^( '{' ( (child= tokenParameter[tokenType] | child= tokenParameterAssignment | child= standardConstraint | child= enforceExpression ) )* ) ; - */ -static void -tokenStatements(pNDDL3Tree ctx, InterpretedTokenType* tokenType) -{ - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:586:2: ( ^( '{' ( (child= tokenParameter[tokenType] | child= tokenParameterAssignment | child= standardConstraint | child= enforceExpression ) )* ) ) - // NDDL/base/antlr/NDDL3Tree.g:586:4: ^( '{' ( (child= tokenParameter[tokenType] | child= tokenParameterAssignment | child= standardConstraint | child= enforceExpression ) )* ) - { - MATCHT(33, &FOLLOW_33_in_tokenStatements2697); - if (HASEXCEPTION()) - { - goto ruletokenStatementsEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruletokenStatementsEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:587:13: ( (child= tokenParameter[tokenType] | child= tokenParameterAssignment | child= standardConstraint | child= enforceExpression ) )* - - for (;;) - { - int alt29=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA29_0 = LA(1); - if ( (LA29_0 == CONSTRAINT_INSTANTIATION || ((LA29_0 >= VARIABLE) && (LA29_0 <= EXPRESSION_ENFORCE)) || LA29_0 == 43) ) - { - alt29=1; - } - - } - switch (alt29) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:588:17: (child= tokenParameter[tokenType] | child= tokenParameterAssignment | child= standardConstraint | child= enforceExpression ) - { - - // NDDL/base/antlr/NDDL3Tree.g:588:17: (child= tokenParameter[tokenType] | child= tokenParameterAssignment | child= standardConstraint | child= enforceExpression ) - { - int alt28=4; - switch ( LA(1) ) - { - case VARIABLE: - { - alt28=1; - } - break; - case 43: - { - alt28=2; - } - break; - case CONSTRAINT_INSTANTIATION: - { - alt28=3; - } - break; - case EXPRESSION_ENFORCE: - { - alt28=4; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 28; - EXCEPTION->state = 0; - - - goto ruletokenStatementsEx; - } - - switch (alt28) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:588:19: child= tokenParameter[tokenType] - { - FOLLOWPUSH(FOLLOW_tokenParameter_in_tokenStatements2733); - child=tokenParameter(ctx, tokenType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenStatementsEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:589:19: child= tokenParameterAssignment - { - FOLLOWPUSH(FOLLOW_tokenParameterAssignment_in_tokenStatements2757); - child=tokenParameterAssignment(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenStatementsEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:590:19: child= standardConstraint - { - FOLLOWPUSH(FOLLOW_standardConstraint_in_tokenStatements2779); - child=standardConstraint(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenStatementsEx; - } - - - } - break; - case 4: - // NDDL/base/antlr/NDDL3Tree.g:591:19: child= enforceExpression - { - FOLLOWPUSH(FOLLOW_enforceExpression_in_tokenStatements2802); - child=enforceExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenStatementsEx; - } - - - } - break; - - } - } - { - - tokenType->addBodyExpr(child); - - } - - } - break; - - default: - goto loop29; /* break out of the loop */ - break; - } - } - loop29: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruletokenStatementsEx; - } - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenStatementsEx; /* Prevent compiler warnings */ - ruletokenStatementsEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end tokenStatements */ - -/** - * $ANTLR start tokenParameter - * NDDL/base/antlr/NDDL3Tree.g:601:1: tokenParameter[InterpretedTokenType* tokenType] returns [Expr* result] : child= variableDeclarations ; - */ -static Expr* -tokenParameter(pNDDL3Tree ctx, InterpretedTokenType* tokenType) -{ - Expr* result = NULL; - - ExprList* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child ExprList* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:602:9: (child= variableDeclarations ) - // NDDL/base/antlr/NDDL3Tree.g:603:9: child= variableDeclarations - { - FOLLOWPUSH(FOLLOW_variableDeclarations_in_tokenParameter2886); - child=variableDeclarations(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenParameterEx; - } - - { - - const std::vector& vars=child->getChildren(); - for (unsigned int i=0;i(vars[i]); - tokenType->addArg(vd->getDataType(),vd->getName()); - } - result = child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenParameterEx; /* Prevent compiler warnings */ - ruletokenParameterEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end tokenParameter */ - -/** - * $ANTLR start tokenParameterAssignment - * NDDL/base/antlr/NDDL3Tree.g:614:1: tokenParameterAssignment returns [Expr* result] : child= assignment ; - */ -static Expr* -tokenParameterAssignment(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - ExprAssignment* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child ExprAssignment* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:615:9: (child= assignment ) - // NDDL/base/antlr/NDDL3Tree.g:616:9: child= assignment - { - FOLLOWPUSH(FOLLOW_assignment_in_tokenParameterAssignment2943); - child=assignment(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruletokenParameterAssignmentEx; - } - - { - - result = child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenParameterAssignmentEx; /* Prevent compiler warnings */ - ruletokenParameterAssignmentEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end tokenParameterAssignment */ - -/** - * $ANTLR start standardConstraint - * NDDL/base/antlr/NDDL3Tree.g:622:1: standardConstraint returns [Expr* result] : child= constraintInstantiation ; - */ -static Expr* -standardConstraint(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - ExprConstraint* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child ExprConstraint* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:623:9: (child= constraintInstantiation ) - // NDDL/base/antlr/NDDL3Tree.g:624:9: child= constraintInstantiation - { - FOLLOWPUSH(FOLLOW_constraintInstantiation_in_standardConstraint2995); - child=constraintInstantiation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulestandardConstraintEx; - } - - { - - result = child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulestandardConstraintEx; /* Prevent compiler warnings */ - rulestandardConstraintEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end standardConstraint */ - -/** - * $ANTLR start rule - * NDDL/base/antlr/NDDL3Tree.g:630:1: rule returns [Expr* result] : ^( '::' className= IDENT predicateName= IDENT ruleBlock[ruleBody] ) ; - */ -static Expr* -rule(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - pANTLR3_BASE_TREE className; - pANTLR3_BASE_TREE predicateName; - - /* Initialize rule variables - */ - - - - std::vector ruleBody; - std::string predName; - InterpretedTokenType* iTokenType=NULL; - - className = NULL; - predicateName = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:636:3: ( ^( '::' className= IDENT predicateName= IDENT ruleBlock[ruleBody] ) ) - // NDDL/base/antlr/NDDL3Tree.g:636:5: ^( '::' className= IDENT predicateName= IDENT ruleBlock[ruleBody] ) - { - MATCHT(52, &FOLLOW_52_in_rule3036); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - - className = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_rule3043); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - - predicateName = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_rule3050); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - - { - - std::string clazz = c_str((className->getText(className))->chars); - ObjectTypeId ot = CTX->SymbolTable->getObjectType(clazz.c_str()); - if (ot.isNoId()) - reportSemanticError(CTX,"class "+clazz+" has not been declared"); - - predName = clazz + "." + std::string(c_str((predicateName->getText(predicateName))->chars)); - debugMsg("NddlInterpreter","Parsing rule for:" << predName); - TokenTypeId tt = CTX->SymbolTable->getTokenType(predName.c_str()); - if (tt.isNoId()) - reportSemanticError(CTX,predName+" has not been declared"); - - iTokenType = dynamic_cast((EUROPA::TokenType*)tt); - - pushContext(CTX,new NddlTokenSymbolTable(CTX->SymbolTable,tt,ot)); - - } - FOLLOWPUSH(FOLLOW_ruleBlock_in_rule3060); - ruleBlock(ctx, ruleBody); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleruleEx; - } - - { - - char buff[10]; - sprintf(buff, "%u", className->getLine(className)); - std::string filename = "UNKNOWN"; - if (className->getToken(className)) { - if (className->getToken(className)->input) { - if (className->getToken(className)->input->fileName) { - filename = c_str(className->getToken(className)->input->fileName->chars); - } - } - } - std::string source="\"" + filename + "," + std::string(buff) + "\""; - InterpretedRuleFactory* rf = new InterpretedRuleFactory(predName,source,ruleBody); - if (iTokenType != NULL) - iTokenType->addRule(rf); - - result = new ExprRuleTypeDefinition(rf->getId()); - popContext(CTX); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleruleEx; /* Prevent compiler warnings */ - ruleruleEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end rule */ - -/** - * $ANTLR start ruleBlock - * NDDL/base/antlr/NDDL3Tree.g:678:1: ruleBlock[std::vector& ruleBody] : ^( '{' (child= ruleStatement )* ) ; - */ -static void -ruleBlock(pNDDL3Tree ctx, std::vector& ruleBody) -{ - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:679:2: ( ^( '{' (child= ruleStatement )* ) ) - // NDDL/base/antlr/NDDL3Tree.g:679:4: ^( '{' (child= ruleStatement )* ) - { - MATCHT(33, &FOLLOW_33_in_ruleBlock3082); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:680:4: (child= ruleStatement )* - - for (;;) - { - int alt30=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA30_0 = LA(1); - if ( (LA30_0 == CONSTRAINT_INSTANTIATION || ((LA30_0 >= TOKEN_RELATION) && (LA30_0 <= EXPRESSION_ENFORCE)) || LA30_0 == 43 || LA30_0 == 76 || LA30_0 == 78) ) - { - alt30=1; - } - - } - switch (alt30) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:680:5: child= ruleStatement - { - FOLLOWPUSH(FOLLOW_ruleStatement_in_ruleBlock3090); - child=ruleStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - - { - ruleBody.push_back(child); - } - - } - break; - - default: - goto loop30; /* break out of the loop */ - break; - } - } - loop30: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleruleBlockEx; - } - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleruleBlockEx; /* Prevent compiler warnings */ - ruleruleBlockEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end ruleBlock */ - -/** - * $ANTLR start ruleStatement - * NDDL/base/antlr/NDDL3Tree.g:684:1: ruleStatement returns [Expr* result] : (child= constraintInstantiation | child= enforceExpression | child= assignment | child= variableDeclarations | child= ifStatement | child= loopStatement | child= relation ) ; - */ -static Expr* -ruleStatement(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - Expr* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child Expr* - - /* Initialize rule variables - */ - - - child = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:685:2: ( (child= constraintInstantiation | child= enforceExpression | child= assignment | child= variableDeclarations | child= ifStatement | child= loopStatement | child= relation ) ) - // NDDL/base/antlr/NDDL3Tree.g:685:4: (child= constraintInstantiation | child= enforceExpression | child= assignment | child= variableDeclarations | child= ifStatement | child= loopStatement | child= relation ) - { - - // NDDL/base/antlr/NDDL3Tree.g:685:4: (child= constraintInstantiation | child= enforceExpression | child= assignment | child= variableDeclarations | child= ifStatement | child= loopStatement | child= relation ) - { - int alt31=7; - switch ( LA(1) ) - { - case CONSTRAINT_INSTANTIATION: - { - alt31=1; - } - break; - case EXPRESSION_ENFORCE: - { - alt31=2; - } - break; - case 43: - { - alt31=3; - } - break; - case VARIABLE: - { - alt31=4; - } - break; - case 76: - { - alt31=5; - } - break; - case 78: - { - alt31=6; - } - break; - case TOKEN_RELATION: - { - alt31=7; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 31; - EXCEPTION->state = 0; - - - goto ruleruleStatementEx; - } - - switch (alt31) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:685:6: child= constraintInstantiation - { - FOLLOWPUSH(FOLLOW_constraintInstantiation_in_ruleStatement3117); - child=constraintInstantiation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:686:9: child= enforceExpression - { - FOLLOWPUSH(FOLLOW_enforceExpression_in_ruleStatement3129); - child=enforceExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:687:6: child= assignment - { - FOLLOWPUSH(FOLLOW_assignment_in_ruleStatement3138); - child=assignment(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - - - } - break; - case 4: - // NDDL/base/antlr/NDDL3Tree.g:688:6: child= variableDeclarations - { - FOLLOWPUSH(FOLLOW_variableDeclarations_in_ruleStatement3147); - child=variableDeclarations(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - - - } - break; - case 5: - // NDDL/base/antlr/NDDL3Tree.g:689:6: child= ifStatement - { - FOLLOWPUSH(FOLLOW_ifStatement_in_ruleStatement3156); - child=ifStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - - - } - break; - case 6: - // NDDL/base/antlr/NDDL3Tree.g:690:6: child= loopStatement - { - FOLLOWPUSH(FOLLOW_loopStatement_in_ruleStatement3165); - child=loopStatement(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - - - } - break; - case 7: - // NDDL/base/antlr/NDDL3Tree.g:691:6: child= relation - { - FOLLOWPUSH(FOLLOW_relation_in_ruleStatement3174); - child=relation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleruleStatementEx; - } - - - } - break; - - } - } - { - - result = child; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleruleStatementEx; /* Prevent compiler warnings */ - ruleruleStatementEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end ruleStatement */ - -/** - * $ANTLR start ifStatement - * NDDL/base/antlr/NDDL3Tree.g:699:1: ifStatement returns [Expr* result] : ^( 'if' guard= guardExpression ruleBlock[ifBody] ( ruleBlock[elseBody] )? ) ; - */ -static Expr* -ifStatement(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - ExprIfGuard* guard; - #undef RETURN_TYPE_guard - #define RETURN_TYPE_guard ExprIfGuard* - - /* Initialize rule variables - */ - - - - std::vector ifBody; - std::vector elseBody; - - guard = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:704:2: ( ^( 'if' guard= guardExpression ruleBlock[ifBody] ( ruleBlock[elseBody] )? ) ) - // NDDL/base/antlr/NDDL3Tree.g:704:4: ^( 'if' guard= guardExpression ruleBlock[ifBody] ( ruleBlock[elseBody] )? ) - { - MATCHT(76, &FOLLOW_76_in_ifStatement3206); - if (HASEXCEPTION()) - { - goto ruleifStatementEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleifStatementEx; - } - - FOLLOWPUSH(FOLLOW_guardExpression_in_ifStatement3213); - guard=guardExpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleifStatementEx; - } - - FOLLOWPUSH(FOLLOW_ruleBlock_in_ifStatement3218); - ruleBlock(ctx, ifBody); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleifStatementEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:707:4: ( ruleBlock[elseBody] )? - { - int alt32=2; - { - int LA32_0 = LA(1); - if ( (LA32_0 == 33) ) - { - alt32=1; - } - } - switch (alt32) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:707:4: ruleBlock[elseBody] - { - FOLLOWPUSH(FOLLOW_ruleBlock_in_ifStatement3224); - ruleBlock(ctx, elseBody); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleifStatementEx; - } - - - } - break; - - } - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleifStatementEx; - } - - { - - result = new ExprIf(guard,ifBody,elseBody); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleifStatementEx; /* Prevent compiler warnings */ - ruleifStatementEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end ifStatement */ - -/** - * $ANTLR start guardExpression - * NDDL/base/antlr/NDDL3Tree.g:716:1: guardExpression returns [ExprIfGuard* result] : ( ^(relop= guardRelop lhs= anyValue rhs= anyValue ) | lhs= anyValue | ^( EXPRESSION_RETURN lhs= expressionCleanReturn ) ) ; - */ -static ExprIfGuard* -guardExpression(pNDDL3Tree ctx) -{ - ExprIfGuard* result = NULL; - - NDDL3Tree_guardRelop_return relop; - #undef RETURN_TYPE_relop - #define RETURN_TYPE_relop NDDL3Tree_guardRelop_return - - Expr* lhs; - #undef RETURN_TYPE_lhs - #define RETURN_TYPE_lhs Expr* - - Expr* rhs; - #undef RETURN_TYPE_rhs - #define RETURN_TYPE_rhs Expr* - - /* Initialize rule variables - */ - - - - const char* relopStr = "=="; - BoolDomain *dom = NULL; - - - lhs = NULL; - rhs = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:722:9: ( ( ^(relop= guardRelop lhs= anyValue rhs= anyValue ) | lhs= anyValue | ^( EXPRESSION_RETURN lhs= expressionCleanReturn ) ) ) - // NDDL/base/antlr/NDDL3Tree.g:722:11: ( ^(relop= guardRelop lhs= anyValue rhs= anyValue ) | lhs= anyValue | ^( EXPRESSION_RETURN lhs= expressionCleanReturn ) ) - { - - // NDDL/base/antlr/NDDL3Tree.g:722:11: ( ^(relop= guardRelop lhs= anyValue rhs= anyValue ) | lhs= anyValue | ^( EXPRESSION_RETURN lhs= expressionCleanReturn ) ) - { - int alt33=3; - switch ( LA(1) ) - { - case 66: - case 67: - { - alt33=1; - } - break; - case IDENT: - case INT: - case FLOAT: - case STRING: - case 33: - case 38: - case 45: - case 46: - case 102: - case 103: - case 104: - case 105: - case 106: - case 107: - { - alt33=2; - } - break; - case EXPRESSION_RETURN: - { - alt33=3; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 33; - EXCEPTION->state = 0; - - - goto ruleguardExpressionEx; - } - - switch (alt33) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:722:13: ^(relop= guardRelop lhs= anyValue rhs= anyValue ) - { - FOLLOWPUSH(FOLLOW_guardRelop_in_guardExpression3269); - relop=guardRelop(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - - { - relopStr=c_str((STRSTREAM->toStringSS(STRSTREAM, relop.start, relop.start))->chars); - } - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - FOLLOWPUSH(FOLLOW_anyValue_in_guardExpression3275); - lhs=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - FOLLOWPUSH(FOLLOW_anyValue_in_guardExpression3279); - rhs=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:723:13: lhs= anyValue - { - FOLLOWPUSH(FOLLOW_anyValue_in_guardExpression3297); - lhs=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:724:13: ^( EXPRESSION_RETURN lhs= expressionCleanReturn ) - { - MATCHT(EXPRESSION_RETURN, &FOLLOW_EXPRESSION_RETURN_in_guardExpression3312); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - FOLLOWPUSH(FOLLOW_expressionCleanReturn_in_guardExpression3316); - lhs=expressionCleanReturn(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - { - dom = new BoolDomain(true); - rhs = new ExprConstant(dom->getTypeName().c_str(), dom); - - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleguardExpressionEx; - } - - - } - break; - - } - } - { - - result = new ExprIfGuard(relopStr,lhs,rhs); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleguardExpressionEx; /* Prevent compiler warnings */ - ruleguardExpressionEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end guardExpression */ - -/** - * $ANTLR start guardRelop - * NDDL/base/antlr/NDDL3Tree.g:734:1: guardRelop : ( '==' | '!=' ); - */ -static NDDL3Tree_guardRelop_return -guardRelop(pNDDL3Tree ctx) -{ - NDDL3Tree_guardRelop_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:735:5: ( '==' | '!=' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( ((LA(1) >= 66) && (LA(1) <= 67)) ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_guardRelop0); goto ruleguardRelopEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruleguardRelopEx; /* Prevent compiler warnings */ - ruleguardRelopEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end guardRelop */ - -/** - * $ANTLR start loopStatement - * NDDL/base/antlr/NDDL3Tree.g:738:1: loopStatement returns [Expr* result] : ^( 'foreach' name= IDENT val= qualified ruleBlock[loopBody] ) ; - */ -static Expr* -loopStatement(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - pANTLR3_BASE_TREE name; - Expr* val; - #undef RETURN_TYPE_val - #define RETURN_TYPE_val Expr* - - /* Initialize rule variables - */ - - - - std::vector loopBody; - const char* loopVarName = NULL; - - name = NULL; - val = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:743:2: ( ^( 'foreach' name= IDENT val= qualified ruleBlock[loopBody] ) ) - // NDDL/base/antlr/NDDL3Tree.g:743:4: ^( 'foreach' name= IDENT val= qualified ruleBlock[loopBody] ) - { - MATCHT(78, &FOLLOW_78_in_loopStatement3406); - if (HASEXCEPTION()) - { - goto ruleloopStatementEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleloopStatementEx; - } - - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_loopStatement3413); - if (HASEXCEPTION()) - { - goto ruleloopStatementEx; - } - - FOLLOWPUSH(FOLLOW_qualified_in_loopStatement3420); - val=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleloopStatementEx; - } - - { - - loopVarName = c_str((name->getText(name))->chars); - CTX->SymbolTable->addLocalVar(loopVarName,val->getDataType()); - - } - FOLLOWPUSH(FOLLOW_ruleBlock_in_loopStatement3432); - ruleBlock(ctx, loopBody); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleloopStatementEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleloopStatementEx; - } - - { - - // TODO : modify ExprLoop to take val Expr instead, otherwise delete val. - result = new ExprLoop(loopVarName,val->toString().c_str(),loopBody); - delete val; - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleloopStatementEx; /* Prevent compiler warnings */ - ruleloopStatementEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end loopStatement */ - -/** - * $ANTLR start problemStmt - * NDDL/base/antlr/NDDL3Tree.g:759:1: problemStmt returns [Expr* result] : ^(t= problemStmtType predicateInstanceList[tokens] ) ; - */ -static Expr* -problemStmt(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - NDDL3Tree_problemStmtType_return t; - #undef RETURN_TYPE_t - #define RETURN_TYPE_t NDDL3Tree_problemStmtType_return - - /* Initialize rule variables - */ - - - - std::vector tokens; - - { - // NDDL/base/antlr/NDDL3Tree.g:764:9: ( ^(t= problemStmtType predicateInstanceList[tokens] ) ) - // NDDL/base/antlr/NDDL3Tree.g:764:17: ^(t= problemStmtType predicateInstanceList[tokens] ) - { - FOLLOWPUSH(FOLLOW_problemStmtType_in_problemStmt3479); - t=problemStmtType(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - - FOLLOWPUSH(FOLLOW_predicateInstanceList_in_problemStmt3481); - predicateInstanceList(ctx, tokens); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleproblemStmtEx; - } - - { - - result = new ExprProblemStmt(c_str((STRSTREAM->toStringSS(STRSTREAM, t.start, t.start))->chars),tokens); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleproblemStmtEx; /* Prevent compiler warnings */ - ruleproblemStmtEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end problemStmt */ - -/** - * $ANTLR start problemStmtType - * NDDL/base/antlr/NDDL3Tree.g:770:1: problemStmtType : ( 'goal' | 'rejectable' | 'fact' ); - */ -static NDDL3Tree_problemStmtType_return -problemStmtType(pNDDL3Tree ctx) -{ - NDDL3Tree_problemStmtType_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:771:9: ( 'goal' | 'rejectable' | 'fact' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( ((LA(1) >= 57) && (LA(1) <= 59)) ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_problemStmtType0); goto ruleproblemStmtTypeEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruleproblemStmtTypeEx; /* Prevent compiler warnings */ - ruleproblemStmtTypeEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end problemStmtType */ - -/** - * $ANTLR start relation - * NDDL/base/antlr/NDDL3Tree.g:776:1: relation returns [Expr* result] : ^( TOKEN_RELATION (pvr= predicateVarRef )? tr= temporalRelation predicateInstanceList[targets] ) ; - */ -static Expr* -relation(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - PredicateInstanceRef* pvr; - #undef RETURN_TYPE_pvr - #define RETURN_TYPE_pvr PredicateInstanceRef* - - NDDL3Tree_temporalRelation_return tr; - #undef RETURN_TYPE_tr - #define RETURN_TYPE_tr NDDL3Tree_temporalRelation_return - - /* Initialize rule variables - */ - - - - const char* relationType=NULL; - PredicateInstanceRef* source=NULL; - std::vector targets; - - pvr = NULL; - - - { - // NDDL/base/antlr/NDDL3Tree.g:782:2: ( ^( TOKEN_RELATION (pvr= predicateVarRef )? tr= temporalRelation predicateInstanceList[targets] ) ) - // NDDL/base/antlr/NDDL3Tree.g:782:4: ^( TOKEN_RELATION (pvr= predicateVarRef )? tr= temporalRelation predicateInstanceList[targets] ) - { - MATCHT(TOKEN_RELATION, &FOLLOW_TOKEN_RELATION_in_relation3616); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:783:4: (pvr= predicateVarRef )? - { - int alt34=2; - { - int LA34_0 = LA(1); - if ( (LA34_0 == IDENT || LA34_0 == 45) ) - { - alt34=1; - } - } - switch (alt34) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:783:5: pvr= predicateVarRef - { - FOLLOWPUSH(FOLLOW_predicateVarRef_in_relation3624); - pvr=predicateVarRef(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - - { - source = pvr; - } - - } - break; - - } - } - FOLLOWPUSH(FOLLOW_temporalRelation_in_relation3635); - tr=temporalRelation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - - { - relationType = c_str((STRSTREAM->toStringSS(STRSTREAM, tr.start, tr.start))->chars); - } - FOLLOWPUSH(FOLLOW_predicateInstanceList_in_relation3643); - predicateInstanceList(ctx, targets); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulerelationEx; - } - - { - - result = new ExprRelation(relationType,source,targets); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulerelationEx; /* Prevent compiler warnings */ - rulerelationEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end relation */ - -/** - * $ANTLR start predicateInstanceList - * NDDL/base/antlr/NDDL3Tree.g:792:1: predicateInstanceList[std::vector& instances] : ( ^( '(' (child= predicateInstance )* ) | pvr= predicateVarRef ); - */ -static void -predicateInstanceList(pNDDL3Tree ctx, std::vector& instances) -{ - PredicateInstanceRef* child; - #undef RETURN_TYPE_child - #define RETURN_TYPE_child PredicateInstanceRef* - - PredicateInstanceRef* pvr; - #undef RETURN_TYPE_pvr - #define RETURN_TYPE_pvr PredicateInstanceRef* - - /* Initialize rule variables - */ - - - child = NULL; - pvr = NULL; - - { - { - // NDDL/base/antlr/NDDL3Tree.g:793:2: ( ^( '(' (child= predicateInstance )* ) | pvr= predicateVarRef ) - - ANTLR3_UINT32 alt36; - - alt36=2; - - - { - int LA36_0 = LA(1); - if ( (LA36_0 == 41) ) - { - alt36=1; - } - else if ( (LA36_0 == IDENT || LA36_0 == 45) ) - { - alt36=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 36; - EXCEPTION->state = 0; - - - goto rulepredicateInstanceListEx; - } - } - switch (alt36) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:793:4: ^( '(' (child= predicateInstance )* ) - { - MATCHT(41, &FOLLOW_41_in_predicateInstanceList3665); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceListEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceListEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:794:4: (child= predicateInstance )* - - for (;;) - { - int alt35=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA35_0 = LA(1); - if ( (LA35_0 == PREDICATE_INSTANCE) ) - { - alt35=1; - } - - } - switch (alt35) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:794:5: child= predicateInstance - { - FOLLOWPUSH(FOLLOW_predicateInstance_in_predicateInstanceList3673); - child=predicateInstance(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceListEx; - } - - { - instances.push_back(child); - } - - } - break; - - default: - goto loop35; /* break out of the loop */ - break; - } - } - loop35: ; /* Jump out to here if this rule does not match */ - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceListEx; - } - - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:796:5: pvr= predicateVarRef - { - FOLLOWPUSH(FOLLOW_predicateVarRef_in_predicateInstanceList3689); - pvr=predicateVarRef(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceListEx; - } - - { - instances.push_back(pvr); - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulepredicateInstanceListEx; /* Prevent compiler warnings */ - rulepredicateInstanceListEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end predicateInstanceList */ - -/** - * $ANTLR start predicateInstance - * NDDL/base/antlr/NDDL3Tree.g:800:1: predicateInstance returns [PredicateInstanceRef* pi] : ^( PREDICATE_INSTANCE qualifiedToken[tokenStr,tokenType] (i= IDENT )? (ann= tokenAnnotation )? ) ; - */ -static PredicateInstanceRef* -predicateInstance(pNDDL3Tree ctx) -{ - PredicateInstanceRef* pi = NULL; - - pANTLR3_BASE_TREE i; - NDDL3Tree_tokenAnnotation_return ann; - #undef RETURN_TYPE_ann - #define RETURN_TYPE_ann NDDL3Tree_tokenAnnotation_return - - /* Initialize rule variables - */ - - - - const char* name = NULL; - const char* annotation = NULL; - std::string tokenStr; - TokenTypeId tokenType; - - i = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:807:2: ( ^( PREDICATE_INSTANCE qualifiedToken[tokenStr,tokenType] (i= IDENT )? (ann= tokenAnnotation )? ) ) - // NDDL/base/antlr/NDDL3Tree.g:807:4: ^( PREDICATE_INSTANCE qualifiedToken[tokenStr,tokenType] (i= IDENT )? (ann= tokenAnnotation )? ) - { - MATCHT(PREDICATE_INSTANCE, &FOLLOW_PREDICATE_INSTANCE_in_predicateInstance3724); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceEx; - } - - FOLLOWPUSH(FOLLOW_qualifiedToken_in_predicateInstance3731); - qualifiedToken(ctx, tokenStr, tokenType); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:809:5: (i= IDENT )? - { - int alt37=2; - { - int LA37_0 = LA(1); - if ( (LA37_0 == IDENT) ) - { - alt37=1; - } - } - switch (alt37) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:809:6: i= IDENT - { - i = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_predicateInstance3742); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceEx; - } - - { - name = c_str((i->getText(i))->chars); - } - - } - break; - - } - } - - // NDDL/base/antlr/NDDL3Tree.g:810:5: (ann= tokenAnnotation )? - { - int alt38=2; - { - int LA38_0 = LA(1); - if ( (((LA38_0 >= 60) && (LA38_0 <= 61))) ) - { - alt38=1; - } - } - switch (alt38) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:810:6: ann= tokenAnnotation - { - FOLLOWPUSH(FOLLOW_tokenAnnotation_in_predicateInstance3755); - ann=tokenAnnotation(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceEx; - } - - { - annotation = c_str((STRSTREAM->toStringSS(STRSTREAM, ann.start, ann.start))->chars); - } - - } - break; - - } - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulepredicateInstanceEx; - } - - { - - pi = new PredicateInstanceRef(tokenType,tokenStr.c_str(),name,annotation); - if (name != NULL) - CTX->SymbolTable->addLocalToken(name,tokenType); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulepredicateInstanceEx; /* Prevent compiler warnings */ - rulepredicateInstanceEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return pi; -} -/* $ANTLR end predicateInstance */ - -/** - * $ANTLR start predicateVarRef - * NDDL/base/antlr/NDDL3Tree.g:819:1: predicateVarRef returns [PredicateInstanceRef* pi] : i= identifier ; - */ -static PredicateInstanceRef* -predicateVarRef(pNDDL3Tree ctx) -{ - PredicateInstanceRef* pi = NULL; - - NDDL3Tree_identifier_return i; - #undef RETURN_TYPE_i - #define RETURN_TYPE_i NDDL3Tree_identifier_return - - /* Initialize rule variables - */ - - - - const char* varName = NULL; - TokenTypeId tokenType; - - { - // NDDL/base/antlr/NDDL3Tree.g:824:2: (i= identifier ) - // NDDL/base/antlr/NDDL3Tree.g:824:4: i= identifier - { - FOLLOWPUSH(FOLLOW_identifier_in_predicateVarRef3796); - i=identifier(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulepredicateVarRefEx; - } - - { - - varName = c_str((STRSTREAM->toStringSS(STRSTREAM, i.start, i.start))->chars); - tokenType = CTX->SymbolTable->getTypeForToken(varName); - if (tokenType.isNoId()) - reportSemanticError(CTX,std::string(varName)+" is an undefined token"); - - pi = new PredicateInstanceRef(tokenType,NULL,varName,""); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulepredicateVarRefEx; /* Prevent compiler warnings */ - rulepredicateVarRefEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return pi; -} -/* $ANTLR end predicateVarRef */ - -/** - * $ANTLR start tokenAnnotation - * NDDL/base/antlr/NDDL3Tree.g:835:1: tokenAnnotation : ( 'condition' | 'effect' ); - */ -static NDDL3Tree_tokenAnnotation_return -tokenAnnotation(pNDDL3Tree ctx) -{ - NDDL3Tree_tokenAnnotation_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:836:2: ( 'condition' | 'effect' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( ((LA(1) >= 60) && (LA(1) <= 61)) ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_tokenAnnotation0); goto ruletokenAnnotationEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruletokenAnnotationEx; /* Prevent compiler warnings */ - ruletokenAnnotationEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end tokenAnnotation */ - -/** - * $ANTLR start qualifiedString - * NDDL/base/antlr/NDDL3Tree.g:839:1: qualifiedString[std::string& result] : (name= identifier | ^( '.' prefix= qualifiedString[result] (q= IDENT )+ ) ) ; - */ -static void -qualifiedString(pNDDL3Tree ctx, std::string& result) -{ - pANTLR3_BASE_TREE q; - NDDL3Tree_identifier_return name; - #undef RETURN_TYPE_name - #define RETURN_TYPE_name NDDL3Tree_identifier_return - - /* Initialize rule variables - */ - - - q = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:840:5: ( (name= identifier | ^( '.' prefix= qualifiedString[result] (q= IDENT )+ ) ) ) - // NDDL/base/antlr/NDDL3Tree.g:841:5: (name= identifier | ^( '.' prefix= qualifiedString[result] (q= IDENT )+ ) ) - { - - // NDDL/base/antlr/NDDL3Tree.g:841:5: (name= identifier | ^( '.' prefix= qualifiedString[result] (q= IDENT )+ ) ) - { - int alt40=2; - - { - int LA40_0 = LA(1); - if ( (LA40_0 == IDENT || LA40_0 == 45) ) - { - alt40=1; - } - else if ( (LA40_0 == 46) ) - { - alt40=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 40; - EXCEPTION->state = 0; - - - goto rulequalifiedStringEx; - } - } - switch (alt40) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:841:10: name= identifier - { - FOLLOWPUSH(FOLLOW_identifier_in_qualifiedString3842); - name=identifier(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulequalifiedStringEx; - } - - { - result+=c_str((STRSTREAM->toStringSS(STRSTREAM, name.start, name.start))->chars); - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:842:10: ^( '.' prefix= qualifiedString[result] (q= IDENT )+ ) - { - MATCHT(46, &FOLLOW_46_in_qualifiedString3873); - if (HASEXCEPTION()) - { - goto rulequalifiedStringEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulequalifiedStringEx; - } - - FOLLOWPUSH(FOLLOW_qualifiedString_in_qualifiedString3877); - qualifiedString(ctx, result); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulequalifiedStringEx; - } - - // NDDL/base/antlr/NDDL3Tree.g:843:16: (q= IDENT )+ - { - int cnt39=0; - - for (;;) - { - int alt39=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA39_0 = LA(1); - if ( (LA39_0 == IDENT) ) - { - alt39=1; - } - - } - switch (alt39) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:843:17: q= IDENT - { - q = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_qualifiedString3899); - if (HASEXCEPTION()) - { - goto rulequalifiedStringEx; - } - - { - result += std::string(".") + c_str((q->getText(q))->chars); - } - - } - break; - - default: - - if ( cnt39 >= 1 ) - { - goto loop39; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto rulequalifiedStringEx; - } - cnt39++; - } - loop39: ; /* Jump to here if this rule does not match */ - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulequalifiedStringEx; - } - - - } - break; - - } - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulequalifiedStringEx; /* Prevent compiler warnings */ - rulequalifiedStringEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end qualifiedString */ - -/** - * $ANTLR start qualified - * NDDL/base/antlr/NDDL3Tree.g:847:1: qualified returns [Expr* result] : qualifiedString[varName] ; - */ -static Expr* -qualified(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - /* Initialize rule variables - */ - - - - std::string varName; - - { - // NDDL/base/antlr/NDDL3Tree.g:851:5: ( qualifiedString[varName] ) - // NDDL/base/antlr/NDDL3Tree.g:851:9: qualifiedString[varName] - { - FOLLOWPUSH(FOLLOW_qualifiedString_in_qualified3950); - qualifiedString(ctx, varName); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulequalifiedEx; - } - - { - - bool isEnum = false; - - //My guess is that there is a better way to do this. First check if it is an enum. - std::string secondPart = ""; - if (varName.rfind(".") != std::string::npos) { - secondPart = varName.substr(varName.rfind(".") + 1, std::string::npos); - } - - if (CTX->SymbolTable->isEnumValue(varName.c_str())) { - result = CTX->SymbolTable->makeEnumRef(varName.c_str()); - isEnum = true; - } else if (secondPart != "") { - if (CTX->SymbolTable->isEnumValue(secondPart.c_str())) { - result = CTX->SymbolTable->makeEnumRef(secondPart.c_str()); - isEnum = true; - } - } - - // TODO: should check for classes last, since this won't be common - ObjectTypeId ot = CTX->SymbolTable->getObjectType(varName.c_str()); // Hack! - if (ot.isId()) { // is a class reference - LabelStr value(varName); - result = new ExprConstant("string",new StringDomain((edouble)value,StringDT::instance())); - } - else if (!isEnum) { - std::string errorMsg; - DataTypeId dt = CTX->SymbolTable->getTypeForVar(varName.c_str(),errorMsg); - // TODO!!: do type checking at each "." - if (dt.isNoId()) - reportSemanticError(CTX,errorMsg); - result = new ExprVarRef(varName.c_str(),dt); - } - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulequalifiedEx; /* Prevent compiler warnings */ - rulequalifiedEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end qualified */ - -/** - * $ANTLR start qualifiedToken - * NDDL/base/antlr/NDDL3Tree.g:888:1: qualifiedToken[std::string& tokenStr, TokenTypeId& tokenType] : qualifiedString[tokenStr] ; - */ -static void -qualifiedToken(pNDDL3Tree ctx, std::string& tokenStr, TokenTypeId& tokenType) -{ - /* Initialize rule variables - */ - - - { - // NDDL/base/antlr/NDDL3Tree.g:889:5: ( qualifiedString[tokenStr] ) - // NDDL/base/antlr/NDDL3Tree.g:889:9: qualifiedString[tokenStr] - { - FOLLOWPUSH(FOLLOW_qualifiedString_in_qualifiedToken3989); - qualifiedString(ctx, tokenStr); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulequalifiedTokenEx; - } - - { - - std::string errorMsg; - tokenType = CTX->SymbolTable->getTypeForToken(tokenStr.c_str(),errorMsg); - if (tokenType.isNoId()) - reportSemanticError(CTX,errorMsg); - - } - - } - - } - - - // This is where rules clean up and exit - // - goto rulequalifiedTokenEx; /* Prevent compiler warnings */ - rulequalifiedTokenEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end qualifiedToken */ - -/** - * $ANTLR start temporalRelation - * NDDL/base/antlr/NDDL3Tree.g:898:1: temporalRelation : ( 'after' | 'any' | 'before' | 'contained_by' | 'contains' | 'contains_end' | 'contains_start' | 'ends' | 'ends_after' | 'ends_after_start' | 'ends_before' | 'ends_during' | 'equal' | 'equals' | 'meets' | 'met_by' | 'parallels' | 'paralleled_by' | 'starts' | 'starts_after' | 'starts_before' | 'starts_before_end' | 'starts_during' ); - */ -static NDDL3Tree_temporalRelation_return -temporalRelation(pNDDL3Tree ctx) -{ - NDDL3Tree_temporalRelation_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:899:9: ( 'after' | 'any' | 'before' | 'contained_by' | 'contains' | 'contains_end' | 'contains_start' | 'ends' | 'ends_after' | 'ends_after_start' | 'ends_before' | 'ends_during' | 'equal' | 'equals' | 'meets' | 'met_by' | 'parallels' | 'paralleled_by' | 'starts' | 'starts_after' | 'starts_before' | 'starts_before_end' | 'starts_during' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( ((LA(1) >= 79) && (LA(1) <= 101)) ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_temporalRelation0); goto ruletemporalRelationEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto ruletemporalRelationEx; /* Prevent compiler warnings */ - ruletemporalRelationEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end temporalRelation */ - -/** - * $ANTLR start methodInvocation - * NDDL/base/antlr/NDDL3Tree.g:924:1: methodInvocation returns [Expr* result] : ( ^( METHOD_CALL v= qualified op= methodName ( variableArgumentList[args] )? ) | ^( CLOSE CLOSE ) ); - */ -static Expr* -methodInvocation(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - Expr* v; - #undef RETURN_TYPE_v - #define RETURN_TYPE_v Expr* - - NDDL3Tree_methodName_return op; - #undef RETURN_TYPE_op - #define RETURN_TYPE_op NDDL3Tree_methodName_return - - /* Initialize rule variables - */ - - - - std::vector args; - - v = NULL; - - - { - { - // NDDL/base/antlr/NDDL3Tree.g:928:2: ( ^( METHOD_CALL v= qualified op= methodName ( variableArgumentList[args] )? ) | ^( CLOSE CLOSE ) ) - - ANTLR3_UINT32 alt42; - - alt42=2; - - - { - int LA42_0 = LA(1); - if ( (LA42_0 == METHOD_CALL) ) - { - alt42=1; - } - else if ( (LA42_0 == CLOSE) ) - { - alt42=2; - } - else - { - - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 42; - EXCEPTION->state = 0; - - - goto rulemethodInvocationEx; - } - } - switch (alt42) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:928:4: ^( METHOD_CALL v= qualified op= methodName ( variableArgumentList[args] )? ) - { - MATCHT(METHOD_CALL, &FOLLOW_METHOD_CALL_in_methodInvocation4466); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - FOLLOWPUSH(FOLLOW_qualified_in_methodInvocation4470); - v=qualified(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - FOLLOWPUSH(FOLLOW_methodName_in_methodInvocation4474); - op=methodName(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:928:44: ( variableArgumentList[args] )? - { - int alt41=2; - { - int LA41_0 = LA(1); - if ( (LA41_0 == 41) ) - { - alt41=1; - } - } - switch (alt41) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:928:44: variableArgumentList[args] - { - FOLLOWPUSH(FOLLOW_variableArgumentList_in_methodInvocation4476); - variableArgumentList(ctx, args); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - - } - break; - - } - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - { - - std::string mName = c_str((STRSTREAM->toStringSS(STRSTREAM, op.start, op.start))->chars); - - // Hack! data type for v should tell us whether we're dealing with a class - ExprConstant* classNameExpr = dynamic_cast(v); - if (classNameExpr != NULL) { - std::string className = classNameExpr->getConstantValue(); - debugMsg("NddlInterpreter:method","Trying class:"+className); - ObjectTypeId ot = CTX->SymbolTable->getObjectType(className.c_str()); - if (ot.isId()) { // is a class method - LabelStr value(mName); - mName = "class__"+mName; - } - } - - MethodId method = CTX->SymbolTable->getMethod(mName.c_str(),v,args); - if (method.isNoId()) - reportSemanticError(CTX,"Method "+mName+" is not defined"); - result = new ExprMethodCall(method,v,args); - - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:949:7: ^( CLOSE CLOSE ) - { - MATCHT(CLOSE, &FOLLOW_CLOSE_in_methodInvocation4494); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - MATCHT(CLOSE, &FOLLOW_CLOSE_in_methodInvocation4496); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulemethodInvocationEx; - } - - { - - // TODO: hack! - Expr* varExpr = NULL; - MethodId method = CTX->SymbolTable->getMethod("pdb_close",varExpr,args); - result = new ExprMethodCall(method,varExpr,args); - - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulemethodInvocationEx; /* Prevent compiler warnings */ - rulemethodInvocationEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end methodInvocation */ - -/** - * $ANTLR start methodName - * NDDL/base/antlr/NDDL3Tree.g:958:1: methodName : ( IDENT | 'close' ); - */ -static NDDL3Tree_methodName_return -methodName(pNDDL3Tree ctx) -{ - NDDL3Tree_methodName_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:959:2: ( IDENT | 'close' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( LA(1) == IDENT || LA(1) == 108 ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_methodName0); goto rulemethodNameEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto rulemethodNameEx; /* Prevent compiler warnings */ - rulemethodNameEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end methodName */ - -/** - * $ANTLR start cexpressionList - * NDDL/base/antlr/NDDL3Tree.g:963:1: cexpressionList[std::vector &args] : (expr= cexpression )* ; - */ -static void -cexpressionList(pNDDL3Tree ctx, std::vector &args) -{ - CExpr* expr; - #undef RETURN_TYPE_expr - #define RETURN_TYPE_expr CExpr* - - /* Initialize rule variables - */ - - - expr = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:964:2: ( (expr= cexpression )* ) - // NDDL/base/antlr/NDDL3Tree.g:964:5: (expr= cexpression )* - { - - // NDDL/base/antlr/NDDL3Tree.g:964:5: (expr= cexpression )* - - for (;;) - { - int alt43=2; - { - /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) - */ - int LA43_0 = LA(1); - if ( (LA43_0 == FUNCTION_CALL || ((LA43_0 >= IDENT) && (LA43_0 <= STRING)) || LA43_0 == 33 || LA43_0 == 38 || ((LA43_0 >= 45) && (LA43_0 <= 46)) || ((LA43_0 >= 64) && (LA43_0 <= 74)) || ((LA43_0 >= 102) && (LA43_0 <= 107))) ) - { - alt43=1; - } - - } - switch (alt43) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:964:6: expr= cexpression - { - FOLLOWPUSH(FOLLOW_cexpression_in_cexpressionList4536); - expr=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionListEx; - } - - { - args.push_back(expr); - } - - } - break; - - default: - goto loop43; /* break out of the loop */ - break; - } - } - loop43: ; /* Jump out to here if this rule does not match */ - - - } - - } - - - // This is where rules clean up and exit - // - goto rulecexpressionListEx; /* Prevent compiler warnings */ - rulecexpressionListEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return ; -} -/* $ANTLR end cexpressionList */ - -/** - * $ANTLR start cexpression - * NDDL/base/antlr/NDDL3Tree.g:967:1: cexpression returns [CExpr* result] : ( ^(cop= cexprOp leftValue= cexpression rightValue= cexpression ) | r= anyValue | ^( FUNCTION_CALL name= IDENT ^( '(' cexpressionList[args] ) ) ); - */ -static CExpr* -cexpression(pNDDL3Tree ctx) -{ - CExpr* result = NULL; - - pANTLR3_BASE_TREE name; - NDDL3Tree_cexprOp_return cop; - #undef RETURN_TYPE_cop - #define RETURN_TYPE_cop NDDL3Tree_cexprOp_return - - CExpr* leftValue; - #undef RETURN_TYPE_leftValue - #define RETURN_TYPE_leftValue CExpr* - - CExpr* rightValue; - #undef RETURN_TYPE_rightValue - #define RETURN_TYPE_rightValue CExpr* - - Expr* r; - #undef RETURN_TYPE_r - #define RETURN_TYPE_r Expr* - - /* Initialize rule variables - */ - - - - std::vector args; - - name = NULL; - - leftValue = NULL; - rightValue = NULL; - r = NULL; - - { - { - // NDDL/base/antlr/NDDL3Tree.g:971:2: ( ^(cop= cexprOp leftValue= cexpression rightValue= cexpression ) | r= anyValue | ^( FUNCTION_CALL name= IDENT ^( '(' cexpressionList[args] ) ) ) - - ANTLR3_UINT32 alt44; - - alt44=3; - - switch ( LA(1) ) - { - case 64: - case 65: - case 66: - case 67: - case 68: - case 69: - case 70: - case 71: - case 72: - case 73: - case 74: - { - alt44=1; - } - break; - case IDENT: - case INT: - case FLOAT: - case STRING: - case 33: - case 38: - case 45: - case 46: - case 102: - case 103: - case 104: - case 105: - case 106: - case 107: - { - alt44=2; - } - break; - case FUNCTION_CALL: - { - alt44=3; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 44; - EXCEPTION->state = 0; - - - goto rulecexpressionEx; - } - - switch (alt44) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:971:4: ^(cop= cexprOp leftValue= cexpression rightValue= cexpression ) - { - FOLLOWPUSH(FOLLOW_cexprOp_in_cexpression4564); - cop=cexprOp(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - FOLLOWPUSH(FOLLOW_cexpression_in_cexpression4568); - leftValue=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - FOLLOWPUSH(FOLLOW_cexpression_in_cexpression4572); - rightValue=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - { - - std::string op = c_str((STRSTREAM->toStringSS(STRSTREAM, cop.start, cop.start))->chars); - result = new CExprBinary(op, leftValue, rightValue); - - } - - } - break; - case 2: - // NDDL/base/antlr/NDDL3Tree.g:976:4: r= anyValue - { - FOLLOWPUSH(FOLLOW_anyValue_in_cexpression4590); - r=anyValue(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - { - - result = new CExprValue(r); - - } - - } - break; - case 3: - // NDDL/base/antlr/NDDL3Tree.g:980:4: ^( FUNCTION_CALL name= IDENT ^( '(' cexpressionList[args] ) ) - { - MATCHT(FUNCTION_CALL, &FOLLOW_FUNCTION_CALL_in_cexpression4606); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - name = (pANTLR3_BASE_TREE) MATCHT(IDENT, &FOLLOW_IDENT_in_cexpression4610); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - MATCHT(41, &FOLLOW_41_in_cexpression4613); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - - if ( LA(1)==ANTLR3_TOKEN_DOWN ) { - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - FOLLOWPUSH(FOLLOW_cexpressionList_in_cexpression4615); - cexpressionList(ctx, args); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto rulecexpressionEx; - } - - { - - std::string fName = c_str((name->getText(name))->chars); - CFunctionId func = CTX->SymbolTable->getCFunction(fName.c_str(),args); - - if (func.isNoId()) - reportSemanticError(CTX, "CFunction does not exist: " + fName); - - result = new CExprFunction(func, args); - - } - - } - break; - - } - } - } - - - // This is where rules clean up and exit - // - goto rulecexpressionEx; /* Prevent compiler warnings */ - rulecexpressionEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end cexpression */ - -/** - * $ANTLR start cexprOp - * NDDL/base/antlr/NDDL3Tree.g:992:1: cexprOp : ( '==' | '!=' | '<' | '<=' | '>' | '>=' | '||' | '&&' | '+' | '-' | '*' ); - */ -static NDDL3Tree_cexprOp_return -cexprOp(pNDDL3Tree ctx) -{ - NDDL3Tree_cexprOp_return retval; - - /* Initialize rule variables - */ - - - retval.start = LT(1); retval.stop = retval.start; - - { - // NDDL/base/antlr/NDDL3Tree.g:993:2: ( '==' | '!=' | '<' | '<=' | '>' | '>=' | '||' | '&&' | '+' | '-' | '*' ) - // NDDL/base/antlr/NDDL3Tree.g: - { - if ( ((LA(1) >= 64) && (LA(1) <= 74)) ) - { - CONSUME(); - PERRORRECOVERY=ANTLR3_FALSE; - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_cexprOp0); goto rulecexprOpEx; - } - - - } - - } - - - // This is where rules clean up and exit - // - goto rulecexprOpEx; /* Prevent compiler warnings */ - rulecexprOpEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return retval; -} -/* $ANTLR end cexprOp */ - -/** - * $ANTLR start enforceExpression - * NDDL/base/antlr/NDDL3Tree.g:1006:1: enforceExpression returns [Expr* result] : ^( EXPRESSION_ENFORCE value= cexpression ( violationMsg[vmsg] )? ) ; - */ -static Expr* -enforceExpression(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - CExpr* value; - #undef RETURN_TYPE_value - #define RETURN_TYPE_value CExpr* - - /* Initialize rule variables - */ - - - - BoolDomain* dom = NULL; - ExprConstant* con = NULL; - std::vector args; - std::string vmsg; - - value = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:1013:2: ( ^( EXPRESSION_ENFORCE value= cexpression ( violationMsg[vmsg] )? ) ) - // NDDL/base/antlr/NDDL3Tree.g:1013:4: ^( EXPRESSION_ENFORCE value= cexpression ( violationMsg[vmsg] )? ) - { - MATCHT(EXPRESSION_ENFORCE, &FOLLOW_EXPRESSION_ENFORCE_in_enforceExpression4710); - if (HASEXCEPTION()) - { - goto ruleenforceExpressionEx; - } - - - MATCHT(ANTLR3_TOKEN_DOWN, NULL); - if (HASEXCEPTION()) - { - goto ruleenforceExpressionEx; - } - - FOLLOWPUSH(FOLLOW_cexpression_in_enforceExpression4714); - value=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleenforceExpressionEx; - } - - - // NDDL/base/antlr/NDDL3Tree.g:1013:43: ( violationMsg[vmsg] )? - { - int alt45=2; - { - int LA45_0 = LA(1); - if ( (LA45_0 == STRING) ) - { - alt45=1; - } - } - switch (alt45) - { - case 1: - // NDDL/base/antlr/NDDL3Tree.g:1013:43: violationMsg[vmsg] - { - FOLLOWPUSH(FOLLOW_violationMsg_in_enforceExpression4716); - violationMsg(ctx, vmsg); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleenforceExpressionEx; - } - - - } - break; - - } - } - - MATCHT(ANTLR3_TOKEN_UP, NULL); - if (HASEXCEPTION()) - { - goto ruleenforceExpressionEx; - } - - { - - value->setEnforceContext(); - value->setViolationMsg(vmsg); - - /*try { - value->checkType(); - } catch(std::string msg) { - reportSemanticError(CTX, msg); - }*/ - - if (value->hasReturnValue()) { - dom = new BoolDomain(true); - con = new ExprConstant(dom->getTypeName().c_str(), dom); - args.push_back(value); - args.push_back(con); - result = new ExprConstraint("eq", args, NULL); - } else { - result = value; - } - - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleenforceExpressionEx; /* Prevent compiler warnings */ - ruleenforceExpressionEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end enforceExpression */ - -/** - * $ANTLR start expressionCleanReturn - * NDDL/base/antlr/NDDL3Tree.g:1036:1: expressionCleanReturn returns [Expr* result] : e= cexpression ; - */ -static Expr* -expressionCleanReturn(pNDDL3Tree ctx) -{ - Expr* result = NULL; - - CExpr* e; - #undef RETURN_TYPE_e - #define RETURN_TYPE_e CExpr* - - /* Initialize rule variables - */ - - - e = NULL; - - { - // NDDL/base/antlr/NDDL3Tree.g:1037:2: (e= cexpression ) - // NDDL/base/antlr/NDDL3Tree.g:1037:4: e= cexpression - { - FOLLOWPUSH(FOLLOW_cexpression_in_expressionCleanReturn4744); - e=cexpression(ctx); - - FOLLOWPOP(); - if (HASEXCEPTION()) - { - goto ruleexpressionCleanReturnEx; - } - - { - result = e; - } - - } - - } - - - // This is where rules clean up and exit - // - goto ruleexpressionCleanReturnEx; /* Prevent compiler warnings */ - ruleexpressionCleanReturnEx: ; - - if (HASEXCEPTION()) - { - PREPORTERROR(); - PRECOVER(); - } - - return result; -} -/* $ANTLR end expressionCleanReturn */ -/* End of parsing rules - * ============================================== - */ - -/* ============================================== - * Syntactic predicates - */ -/* End of syntactic predicates - * ============================================== - */ - - - - - - -/* End of code - * ============================================================================= - */ diff --git a/src/PLASMA/NDDL/base/NDDL3Tree.h b/src/PLASMA/NDDL/base/NDDL3Tree.h deleted file mode 100644 index 6b5fa33d0..000000000 --- a/src/PLASMA/NDDL/base/NDDL3Tree.h +++ /dev/null @@ -1,469 +0,0 @@ -/** \file - * This C header file was generated by $ANTLR version 3.1.2 - * - * - From the grammar source file : NDDL/base/antlr/NDDL3Tree.g - * - On : 2012-01-27 14:56:23 - * - for the tree parser : NDDL3TreeTreeParser * - * Editing it, at least manually, is not wise. - * - * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. - * - * - * The tree parser NDDL3Tree has the callable functions (rules) shown below, - * which will invoke the code for the associated rule in the source grammar - * assuming that the input stream is pointing to a token/text stream that could begin - * this rule. - * - * For instance if you call the first (topmost) rule in a parser grammar, you will - * get the results of a full parse, but calling a rule half way through the grammar will - * allow you to pass part of a full token stream to the parser, such as for syntax checking - * in editors and so on. - * - * The parser entry points are called indirectly (by function pointer to function) via - * a parser context typedef pNDDL3Tree, which is returned from a call to NDDL3TreeNew(). - * - * The methods in pNDDL3Tree are as follows: - * - * - void pNDDL3Tree->nddl(pNDDL3Tree) - * - Expr* pNDDL3Tree->enumDefinition(pNDDL3Tree) - * - void pNDDL3Tree->enumValues(pNDDL3Tree) - * - Expr* pNDDL3Tree->typeDefinition(pNDDL3Tree) - * - DataType* pNDDL3Tree->type(pNDDL3Tree) - * - Domain* pNDDL3Tree->baseDomain(pNDDL3Tree) - * - Expr* pNDDL3Tree->baseDomainValues(pNDDL3Tree) - * - ExprList* pNDDL3Tree->variableDeclarations(pNDDL3Tree) - * - Expr* pNDDL3Tree->variableInitialization(pNDDL3Tree) - * - Expr* pNDDL3Tree->initializer(pNDDL3Tree) - * - Expr* pNDDL3Tree->anyValue(pNDDL3Tree) - * - Expr* pNDDL3Tree->setElement(pNDDL3Tree) - * - Expr* pNDDL3Tree->valueSet(pNDDL3Tree) - * - Expr* pNDDL3Tree->literalValue(pNDDL3Tree) - * - Domain* pNDDL3Tree->booleanLiteral(pNDDL3Tree) - * - Domain* pNDDL3Tree->stringLiteral(pNDDL3Tree) - * - Domain* pNDDL3Tree->numericLiteral(pNDDL3Tree) - * - NDDL3Tree_floatLiteral_return pNDDL3Tree->floatLiteral(pNDDL3Tree) - * - NDDL3Tree_intLiteral_return pNDDL3Tree->intLiteral(pNDDL3Tree) - * - Expr* pNDDL3Tree->numericInterval(pNDDL3Tree) - * - Expr* pNDDL3Tree->allocation(pNDDL3Tree) - * - void pNDDL3Tree->variableArgumentList(pNDDL3Tree) - * - NDDL3Tree_identifier_return pNDDL3Tree->identifier(pNDDL3Tree) - * - ExprConstraint* pNDDL3Tree->constraintInstantiation(pNDDL3Tree) - * - void pNDDL3Tree->violationMsg(pNDDL3Tree) - * - Expr* pNDDL3Tree->classDeclaration(pNDDL3Tree) - * - void pNDDL3Tree->classBlock(pNDDL3Tree) - * - void pNDDL3Tree->componentTypeEntry(pNDDL3Tree) - * - void pNDDL3Tree->classVariable(pNDDL3Tree) - * - void pNDDL3Tree->constructor(pNDDL3Tree) - * - void pNDDL3Tree->constructorArgument(pNDDL3Tree) - * - ExprConstructorSuperCall* pNDDL3Tree->constructorSuper(pNDDL3Tree) - * - ExprAssignment* pNDDL3Tree->assignment(pNDDL3Tree) - * - void pNDDL3Tree->tokenType(pNDDL3Tree) - * - void pNDDL3Tree->tokenStatements(pNDDL3Tree) - * - Expr* pNDDL3Tree->tokenParameter(pNDDL3Tree) - * - Expr* pNDDL3Tree->tokenParameterAssignment(pNDDL3Tree) - * - Expr* pNDDL3Tree->standardConstraint(pNDDL3Tree) - * - Expr* pNDDL3Tree->rule(pNDDL3Tree) - * - void pNDDL3Tree->ruleBlock(pNDDL3Tree) - * - Expr* pNDDL3Tree->ruleStatement(pNDDL3Tree) - * - Expr* pNDDL3Tree->ifStatement(pNDDL3Tree) - * - ExprIfGuard* pNDDL3Tree->guardExpression(pNDDL3Tree) - * - NDDL3Tree_guardRelop_return pNDDL3Tree->guardRelop(pNDDL3Tree) - * - Expr* pNDDL3Tree->loopStatement(pNDDL3Tree) - * - Expr* pNDDL3Tree->problemStmt(pNDDL3Tree) - * - NDDL3Tree_problemStmtType_return pNDDL3Tree->problemStmtType(pNDDL3Tree) - * - Expr* pNDDL3Tree->relation(pNDDL3Tree) - * - void pNDDL3Tree->predicateInstanceList(pNDDL3Tree) - * - PredicateInstanceRef* pNDDL3Tree->predicateInstance(pNDDL3Tree) - * - PredicateInstanceRef* pNDDL3Tree->predicateVarRef(pNDDL3Tree) - * - NDDL3Tree_tokenAnnotation_return pNDDL3Tree->tokenAnnotation(pNDDL3Tree) - * - void pNDDL3Tree->qualifiedString(pNDDL3Tree) - * - Expr* pNDDL3Tree->qualified(pNDDL3Tree) - * - void pNDDL3Tree->qualifiedToken(pNDDL3Tree) - * - NDDL3Tree_temporalRelation_return pNDDL3Tree->temporalRelation(pNDDL3Tree) - * - Expr* pNDDL3Tree->methodInvocation(pNDDL3Tree) - * - NDDL3Tree_methodName_return pNDDL3Tree->methodName(pNDDL3Tree) - * - void pNDDL3Tree->cexpressionList(pNDDL3Tree) - * - CExpr* pNDDL3Tree->cexpression(pNDDL3Tree) - * - NDDL3Tree_cexprOp_return pNDDL3Tree->cexprOp(pNDDL3Tree) - * - Expr* pNDDL3Tree->enforceExpression(pNDDL3Tree) - * - Expr* pNDDL3Tree->expressionCleanReturn(pNDDL3Tree) - * - * The return type for any particular rule is of course determined by the source - * grammar file. - */ -// [The "BSD licence"] -// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC -// http://www.temporal-wave.com -// http://www.linkedin.com/in/jimidle -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef _NDDL3Tree_H -#define _NDDL3Tree_H -/* ============================================================================= - * Standard antlr3 C runtime definitions - */ -#include - -/* End of standard antlr 3 runtime definitions - * ============================================================================= - */ - -#include "Debug.hh" -#include "Domains.hh" -#include "NddlInterpreter.hh" - -using namespace EUROPA; - - - -#ifdef __cplusplus -extern "C" { -#endif - -// Forward declare the context typedef so that we can use it before it is -// properly defined. Delegators and delegates (from import statements) are -// interdependent and their context structures contain pointers to each other -// C only allows such things to be declared if you pre-declare the typedef. -// -typedef struct NDDL3Tree_Ctx_struct NDDL3Tree, * pNDDL3Tree; - - - -#ifdef ANTLR3_WINDOWS -// Disable: Unreferenced parameter, - Rules with parameters that are not used -// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) -// initialized but unused variable - tree rewrite variables declared but not needed -// Unreferenced local variable - lexer rule declares but does not always use _type -// potentially unitialized variable used - retval always returned from a rule -// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns -// -// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at -// and the codegen must generate some of these warnings by necessity, apart from 4100, which is -// usually generated when a parser rule is given a parameter that it does not use. Mostly though -// this is a matter of orthogonality hence I disable that one. -// -#pragma warning( disable : 4100 ) -#pragma warning( disable : 4101 ) -#pragma warning( disable : 4127 ) -#pragma warning( disable : 4189 ) -#pragma warning( disable : 4505 ) -#pragma warning( disable : 4701 ) -#endif -typedef struct NDDL3Tree_floatLiteral_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_floatLiteral_return; - -typedef struct NDDL3Tree_intLiteral_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_intLiteral_return; - -typedef struct NDDL3Tree_identifier_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_identifier_return; - -typedef struct NDDL3Tree_guardRelop_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_guardRelop_return; - -typedef struct NDDL3Tree_problemStmtType_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_problemStmtType_return; - -typedef struct NDDL3Tree_tokenAnnotation_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_tokenAnnotation_return; - -typedef struct NDDL3Tree_temporalRelation_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_temporalRelation_return; - -typedef struct NDDL3Tree_methodName_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_methodName_return; - -typedef struct NDDL3Tree_cexprOp_return_struct -{ - pANTLR3_BASE_TREE start; - pANTLR3_BASE_TREE stop; -} - NDDL3Tree_cexprOp_return; - - - -/** Context tracking structure for NDDL3Tree - */ -struct NDDL3Tree_Ctx_struct -{ - /** Built in ANTLR3 context tracker contains all the generic elements - * required for context tracking. - */ - pANTLR3_TREE_PARSER pTreeParser; - - - void (*nddl) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*enumDefinition) (struct NDDL3Tree_Ctx_struct * ctx); - void (*enumValues) (struct NDDL3Tree_Ctx_struct * ctx, std::vector& values); - Expr* (*typeDefinition) (struct NDDL3Tree_Ctx_struct * ctx); - DataType* (*type) (struct NDDL3Tree_Ctx_struct * ctx); - Domain* (*baseDomain) (struct NDDL3Tree_Ctx_struct * ctx, const DataType* baseType); - Expr* (*baseDomainValues) (struct NDDL3Tree_Ctx_struct * ctx); - ExprList* (*variableDeclarations) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*variableInitialization) (struct NDDL3Tree_Ctx_struct * ctx, const DataTypeId& dataType); - Expr* (*initializer) (struct NDDL3Tree_Ctx_struct * ctx, const char* varName); - Expr* (*anyValue) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*setElement) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*valueSet) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*literalValue) (struct NDDL3Tree_Ctx_struct * ctx); - Domain* (*booleanLiteral) (struct NDDL3Tree_Ctx_struct * ctx); - Domain* (*stringLiteral) (struct NDDL3Tree_Ctx_struct * ctx); - Domain* (*numericLiteral) (struct NDDL3Tree_Ctx_struct * ctx); - NDDL3Tree_floatLiteral_return (*floatLiteral) (struct NDDL3Tree_Ctx_struct * ctx); - NDDL3Tree_intLiteral_return (*intLiteral) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*numericInterval) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*allocation) (struct NDDL3Tree_Ctx_struct * ctx, const char* name); - void (*variableArgumentList) (struct NDDL3Tree_Ctx_struct * ctx, std::vector& result); - NDDL3Tree_identifier_return (*identifier) (struct NDDL3Tree_Ctx_struct * ctx); - ExprConstraint* (*constraintInstantiation) (struct NDDL3Tree_Ctx_struct * ctx); - void (*violationMsg) (struct NDDL3Tree_Ctx_struct * ctx, std::string& result); - Expr* (*classDeclaration) (struct NDDL3Tree_Ctx_struct * ctx); - void (*classBlock) (struct NDDL3Tree_Ctx_struct * ctx, ObjectType* objType); - void (*componentTypeEntry) (struct NDDL3Tree_Ctx_struct * ctx, ObjectType* objType); - void (*classVariable) (struct NDDL3Tree_Ctx_struct * ctx, ObjectType* objType); - void (*constructor) (struct NDDL3Tree_Ctx_struct * ctx, ObjectType* objType); - void (*constructorArgument) (struct NDDL3Tree_Ctx_struct * ctx, std::vector& argNames, std::vector& argTypes); - ExprConstructorSuperCall* (*constructorSuper) (struct NDDL3Tree_Ctx_struct * ctx, ObjectType* objType); - ExprAssignment* (*assignment) (struct NDDL3Tree_Ctx_struct * ctx); - void (*tokenType) (struct NDDL3Tree_Ctx_struct * ctx, ObjectType* objType); - void (*tokenStatements) (struct NDDL3Tree_Ctx_struct * ctx, InterpretedTokenType* tokenType); - Expr* (*tokenParameter) (struct NDDL3Tree_Ctx_struct * ctx, InterpretedTokenType* tokenType); - Expr* (*tokenParameterAssignment) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*standardConstraint) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*rule) (struct NDDL3Tree_Ctx_struct * ctx); - void (*ruleBlock) (struct NDDL3Tree_Ctx_struct * ctx, std::vector& ruleBody); - Expr* (*ruleStatement) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*ifStatement) (struct NDDL3Tree_Ctx_struct * ctx); - ExprIfGuard* (*guardExpression) (struct NDDL3Tree_Ctx_struct * ctx); - NDDL3Tree_guardRelop_return (*guardRelop) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*loopStatement) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*problemStmt) (struct NDDL3Tree_Ctx_struct * ctx); - NDDL3Tree_problemStmtType_return (*problemStmtType) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*relation) (struct NDDL3Tree_Ctx_struct * ctx); - void (*predicateInstanceList) (struct NDDL3Tree_Ctx_struct * ctx, std::vector& instances); - PredicateInstanceRef* (*predicateInstance) (struct NDDL3Tree_Ctx_struct * ctx); - PredicateInstanceRef* (*predicateVarRef) (struct NDDL3Tree_Ctx_struct * ctx); - NDDL3Tree_tokenAnnotation_return (*tokenAnnotation) (struct NDDL3Tree_Ctx_struct * ctx); - void (*qualifiedString) (struct NDDL3Tree_Ctx_struct * ctx, std::string& result); - Expr* (*qualified) (struct NDDL3Tree_Ctx_struct * ctx); - void (*qualifiedToken) (struct NDDL3Tree_Ctx_struct * ctx, std::string& tokenStr, TokenTypeId& tokenType); - NDDL3Tree_temporalRelation_return (*temporalRelation) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*methodInvocation) (struct NDDL3Tree_Ctx_struct * ctx); - NDDL3Tree_methodName_return (*methodName) (struct NDDL3Tree_Ctx_struct * ctx); - void (*cexpressionList) (struct NDDL3Tree_Ctx_struct * ctx, std::vector &args); - CExpr* (*cexpression) (struct NDDL3Tree_Ctx_struct * ctx); - NDDL3Tree_cexprOp_return (*cexprOp) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*enforceExpression) (struct NDDL3Tree_Ctx_struct * ctx); - Expr* (*expressionCleanReturn) (struct NDDL3Tree_Ctx_struct * ctx); - // Delegated rules - const char * (*getGrammarFileName)(); - void (*free) (struct NDDL3Tree_Ctx_struct * ctx); - - - NddlSymbolTable* SymbolTable; - NddlInterpreter* parserObj; - -}; - -// Function protoypes for the constructor functions that external translation units -// such as delegators and delegates may wish to call. -// -ANTLR3_API pNDDL3Tree NDDL3TreeNew (pANTLR3_COMMON_TREE_NODE_STREAM instream); -ANTLR3_API pNDDL3Tree NDDL3TreeNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); - -/** Symbolic definitions of all the tokens that the tree parser will work with. - * \{ - * - * Antlr will define EOF, but we can't use that as it it is too common in - * in C header files and that would be confusing. There is no way to filter this out at the moment - * so we just undef it here for now. That isn't the value we get back from C recognizers - * anyway. We are looking for ANTLR3_TOKEN_EOF. - */ -#ifdef EOF -#undef EOF -#endif -#ifdef Tokens -#undef Tokens -#endif -#define EXPONENT 28 -#define FLOAT_SUFFIX 29 -#define CONSTRUCTOR_INVOCATION 6 -#define OCTAL_ESC 24 -#define EOF -1 -#define T__93 93 -#define T__94 94 -#define T__91 91 -#define T__92 92 -#define T__90 90 -#define INCLUDE 21 -#define PREDICATE_INSTANCE 9 -#define COMMENT 30 -#define T__99 99 -#define T__98 98 -#define T__97 97 -#define T__96 96 -#define T__95 95 -#define T__80 80 -#define T__81 81 -#define T__82 82 -#define T__83 83 -#define LINE_COMMENT 31 -#define INT 17 -#define T__85 85 -#define T__84 84 -#define METHOD_CALL 7 -#define T__87 87 -#define T__86 86 -#define T__89 89 -#define T__88 88 -#define T__71 71 -#define WS 20 -#define T__72 72 -#define VARIABLE 11 -#define T__70 70 -#define T__76 76 -#define FUNCTION_CALL 14 -#define T__75 75 -#define T__74 74 -#define T__73 73 -#define CONSTRUCTOR 5 -#define T__79 79 -#define T__78 78 -#define T__77 77 -#define T__68 68 -#define T__69 69 -#define T__66 66 -#define T__67 67 -#define T__64 64 -#define T__65 65 -#define INT_SUFFIX 27 -#define T__62 62 -#define T__63 63 -#define FLOAT 18 -#define TOKEN_RELATION 10 -#define T__61 61 -#define T__60 60 -#define EXPRESSION_ENFORCE 12 -#define T__55 55 -#define ESCAPE_SEQUENCE 22 -#define T__56 56 -#define T__57 57 -#define T__58 58 -#define T__51 51 -#define T__52 52 -#define T__53 53 -#define T__54 54 -#define T__107 107 -#define T__108 108 -#define T__59 59 -#define T__103 103 -#define T__104 104 -#define T__105 105 -#define T__106 106 -#define IDENT 16 -#define DIGIT 26 -#define T__50 50 -#define T__42 42 -#define T__43 43 -#define T__40 40 -#define T__41 41 -#define T__46 46 -#define T__47 47 -#define T__44 44 -#define T__45 45 -#define T__48 48 -#define T__49 49 -#define UNICODE_ESC 23 -#define HEX_DIGIT 25 -#define T__102 102 -#define T__101 101 -#define T__100 100 -#define T__32 32 -#define T__33 33 -#define T__34 34 -#define EXPRESSION_RETURN 13 -#define T__35 35 -#define T__36 36 -#define CLOSE 15 -#define T__37 37 -#define NDDL 8 -#define T__38 38 -#define T__39 39 -#define CONSTRAINT_INSTANTIATION 4 -#define STRING 19 -#ifdef EOF -#undef EOF -#define EOF ANTLR3_TOKEN_EOF -#endif - -#ifndef TOKENSOURCE -#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource -#endif - -/* End of token definitions for NDDL3Tree - * ============================================================================= - */ -/** \} */ - -#ifdef __cplusplus -} -#endif - -#endif - -/* END - Note:Keep extra line feed to satisfy UNIX systems */ diff --git a/src/PLASMA/NDDL/base/NDDL3Tree.tokens b/src/PLASMA/NDDL/base/NDDL3Tree.tokens deleted file mode 100644 index af8553397..000000000 --- a/src/PLASMA/NDDL/base/NDDL3Tree.tokens +++ /dev/null @@ -1,182 +0,0 @@ -EXPONENT=28 -FLOAT_SUFFIX=29 -CONSTRUCTOR_INVOCATION=6 -OCTAL_ESC=24 -T__93=93 -T__94=94 -T__91=91 -T__92=92 -T__90=90 -INCLUDE=21 -PREDICATE_INSTANCE=9 -COMMENT=30 -T__99=99 -T__98=98 -T__97=97 -T__96=96 -T__95=95 -T__80=80 -T__81=81 -T__82=82 -T__83=83 -LINE_COMMENT=31 -INT=17 -T__85=85 -T__84=84 -METHOD_CALL=7 -T__87=87 -T__86=86 -T__89=89 -T__88=88 -T__71=71 -WS=20 -T__72=72 -VARIABLE=11 -T__70=70 -T__76=76 -FUNCTION_CALL=14 -T__75=75 -T__74=74 -T__73=73 -CONSTRUCTOR=5 -T__79=79 -T__78=78 -T__77=77 -T__68=68 -T__69=69 -T__66=66 -T__67=67 -T__64=64 -T__65=65 -INT_SUFFIX=27 -T__62=62 -T__63=63 -FLOAT=18 -TOKEN_RELATION=10 -T__61=61 -T__60=60 -EXPRESSION_ENFORCE=12 -T__55=55 -ESCAPE_SEQUENCE=22 -T__56=56 -T__57=57 -T__58=58 -T__51=51 -T__52=52 -T__53=53 -T__54=54 -T__107=107 -T__108=108 -T__59=59 -T__103=103 -T__104=104 -T__105=105 -T__106=106 -IDENT=16 -DIGIT=26 -T__50=50 -T__42=42 -T__43=43 -T__40=40 -T__41=41 -T__46=46 -T__47=47 -T__44=44 -T__45=45 -T__48=48 -T__49=49 -UNICODE_ESC=23 -HEX_DIGIT=25 -T__102=102 -T__101=101 -T__100=100 -T__32=32 -T__33=33 -T__34=34 -EXPRESSION_RETURN=13 -T__35=35 -T__36=36 -CLOSE=15 -T__37=37 -NDDL=8 -T__38=38 -T__39=39 -CONSTRAINT_INSTANTIATION=4 -STRING=19 -'>='=70 -'contained_by'=82 -'paralleled_by'=96 -'=='=66 -'string'=56 -'enforce'=63 -'fact'=59 -'parallels'=95 -'>'=69 -'||'=64 -'this'=45 -'&&'=65 -';'=37 -'typedef'=36 -'ends_after'=87 -'+'=72 -'.'=46 -'starts'=97 -'rejectable'=57 -'contains'=83 -'true'=102 -'contains_end'=84 -'else'=77 -'equals'=92 -'condition'=60 -'starts_after'=98 -'extends'=49 -'action'=51 -'{'=33 -'-inf'=106 -'equal'=91 -'goal'=58 -'int'=53 -'if'=76 -'('=41 -':'=62 -'-'=73 -','=34 -'inf'=104 -'in'=47 -'starts_during'=101 -']'=39 -'enum'=32 -'foreach'=78 -'filter'=40 -'class'=48 -'new'=44 -'ends'=86 -'effect'=61 -'meets'=93 -'-inff'=107 -'='=43 -'::'=52 -'ends_after_start'=88 -')'=42 -'bool'=55 -'ends_before'=89 -'predicate'=50 -'any'=80 -'super'=75 -'after'=79 -'float'=54 -'starts_before_end'=100 -'}'=35 -'contains_start'=85 -'met_by'=94 -'inff'=105 -'close'=108 -'before'=81 -'<='=71 -'!='=67 -'false'=103 -'<'=68 -'ends_during'=90 -'starts_before'=99 -'*'=74 -'['=38 diff --git a/src/PLASMA/NDDL/base/Nddl.hh b/src/PLASMA/NDDL/base/Nddl.hh index e41437040..e16835e06 100644 --- a/src/PLASMA/NDDL/base/Nddl.hh +++ b/src/PLASMA/NDDL/base/Nddl.hh @@ -17,7 +17,7 @@ namespace EUROPA { /** * @brief Allocator function to be implemented by code generated from the model. */ - SchemaId loadSchema(const SchemaId& schema, const RuleSchemaId& ruleSchema); + SchemaId loadSchema(const SchemaId schema, const RuleSchemaId ruleSchema); } } diff --git a/src/PLASMA/NDDL/base/NddlRules.cc b/src/PLASMA/NDDL/base/NddlRules.cc index 5cfe069eb..bcf5c0b46 100644 --- a/src/PLASMA/NDDL/base/NddlRules.cc +++ b/src/PLASMA/NDDL/base/NddlRules.cc @@ -8,29 +8,13 @@ * @author Conor McGann * @date December, 2004 */ +using namespace EUROPA; namespace NDDL { - /** - * @brief Strip out values delimited in the string. Return by ref to avoid - * unnecessary copying. - */ - const std::list& listFromString(const std::string& str, bool isNumeric){ - static const std::string sl_delimiter("$"); - static std::list sl_values; - sl_values.clear(); - std::vector tokens; - tokenize(str, tokens, sl_delimiter); - for(std::vector::const_iterator it = tokens.begin(); it != tokens.end(); ++it){ - if(isNumeric) - sl_values.push_back(toValue(*it)); - else - sl_values.push_back(LabelStr(*it)); - } - return sl_values; - } - TokenId allocateOnSameObject(const TokenId& master, const LabelStr& predicateSuffix, const LabelStr& relationToMaster){ - std::string tokenType = master->getBaseObjectType().toString() + "." + predicateSuffix.toString(); +TokenId allocateOnSameObject(const TokenId master, const std::string& predicateSuffix, + const std::string& relationToMaster){ + std::string tokenType = master->getBaseObjectType() + "." + predicateSuffix; TokenId slave = master->getPlanDatabase()->createSlaveToken(master, tokenType, relationToMaster); return slave; } diff --git a/src/PLASMA/NDDL/base/NddlRules.hh b/src/PLASMA/NDDL/base/NddlRules.hh index fd94013ed..f3c859f50 100644 --- a/src/PLASMA/NDDL/base/NddlRules.hh +++ b/src/PLASMA/NDDL/base/NddlRules.hh @@ -9,7 +9,7 @@ namespace NDDL { /**************** SUPPORT FOR INTEGRATION TO RULES ENGINE *********************/ -#define localVar(domain, name, guarded) addVariable(domain, guarded, LabelStr(#name)) +#define localVar(domain, name, guarded) addVariable(domain, guarded, #name) #define ruleVariable(domain) addVariable(domain, false, makeImplicitVariableName()) @@ -26,16 +26,13 @@ namespace NDDL { #define predicateVariable(domain) allocateVariable(getPlanDatabase()->getConstraintEngine(), m_pseudoVariables, domain, getId()) - /** - * @brief Function to detokenize a delimited list into a list. List is an internal static - * and is reset each time. - */ - const std::list& listFromString(const std::string& str, bool isNumeric); /** * @brief Function to allocate a token on the same object as the master */ - TokenId allocateOnSameObject(const TokenId& parent, const LabelStr& predicateSuffix, const LabelStr& relationToMaster); +EUROPA::TokenId allocateOnSameObject(const EUROPA::TokenId parent, + const std::string& predicateSuffix, + const std::string& relationToMaster); /** * Macro declaration and definition for the Rule which provides a factory @@ -45,8 +42,8 @@ namespace NDDL { class RuleName: public Rule {\ public:\ friend class RuleInstanceName;\ - RuleName(): Rule(LabelStr(#Predicate), LabelStr(#Source)){}\ - RuleInstanceId createInstance(const TokenId& token, const PlanDatabaseId& planDb, const RulesEngineId &rulesEngine) const{\ + RuleName(): Rule(#Predicate, #Source){}\ + RuleInstanceId createInstance(const TokenId token, const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const{\ RuleInstanceName *foo = new RuleInstanceName(m_id, token, planDb);\ foo->setRulesEngine(rulesEngine);\ return foo->getId();\ @@ -56,9 +53,9 @@ namespace NDDL { /** * Called within the context of a rule */ -#define slave(klass, nddl_type, name, relation) addSlave(new klass(m_token, LabelStr(#nddl_type), relation, true), LabelStr(#name)); +#define slave(klass, nddl_type, name, relation) addSlave(new klass(m_token, #nddl_type, relation, true), #name); -#define localSlave(predicate, name, relation) addSlave(allocateOnSameObject(m_token, #predicate, relation), LabelStr(#name)); +#define localSlave(predicate, name, relation) addSlave(allocateOnSameObject(m_token, #predicate, relation), #name); /** * Called within the context of a rule, for a subgoal to be restricted to the same object as the parent @@ -67,14 +64,14 @@ namespace NDDL { #define sameObject(objectVar, label) {\ std::vector objectVar##label##vars;\ objectVar##label##vars.push_back(var(getId(), #objectVar));\ - objectVar##label##vars.push_back(getSlave(LabelStr(#label))->getObject());\ + objectVar##label##vars.push_back(getSlave(#label)->getObject());\ rule_constraint(eq,objectVar##label##vars);\ } #define constrainObject(objectVar, suffix, label) {\ std::vector objectVar##label##vars;\ objectVar##label##vars.push_back(varFromObject(std::string(#objectVar), std::string(#suffix)));\ - objectVar##label##vars.push_back(getSlave(LabelStr(#label))->getObject());\ + objectVar##label##vars.push_back(getSlave(#label)->getObject());\ rule_constraint(eq,objectVar##label##vars);\ } @@ -95,7 +92,7 @@ getPlanDatabase()->makeObjectVariableFromType(#type, name, !guarded && leaveOpen */ #define completeObjectParam(type, name)\ {\ - getPlanDatabase()->makeObjectVariableFromType(LabelStr(#type), name);\ + getPlanDatabase()->makeObjectVariableFromType(#type, name);\ } /** @@ -103,13 +100,13 @@ getPlanDatabase()->makeObjectVariableFromType(#type, name, !guarded && leaveOpen */ #define token_constraint(name, vars)\ {\ - ConstraintId c0 = m_planDatabase->getConstraintEngine()->createConstraint(LabelStr(#name),vars);\ + ConstraintId c0 = m_planDatabase->getConstraintEngine()->createConstraint(#name,vars);\ m_standardConstraints.insert(c0);\ } #define rule_constraint(name, vars)\ {\ - addConstraint(LabelStr(#name), vars);\ + addConstraint(#name, vars);\ } /** @@ -118,11 +115,11 @@ getPlanDatabase()->makeObjectVariableFromType(#type, name, !guarded && leaveOpen #define meets(origin, target) relation(concurrent, origin, end, target, start) #define met_by(origin, target) relation(concurrent, target, end, origin, start) -#define contains(origin, target)\ -{\ - relation(precedes, origin, start, target, start)\ - relation(precedes, target, end, origin, end)\ -} +// #define contains(origin, target)\ +// {\ +// relation(precedes, origin, start, target, start)\ +// relation(precedes, target, end, origin, end)\ +// } #define contained_by(origin, target)\ {\ relation(precedes, target, start, origin, start)\ @@ -164,12 +161,12 @@ getPlanDatabase()->makeObjectVariableFromType(#type, name, !guarded && leaveOpen relation(concurrent, origin, start, target, start)\ relation(concurrent, origin, end, target, end)\ } -#define equal(origin, target) equals(origin, target) +//#define equal(origin, target) equals(origin, target) #define relation(relationname, origin, originvar, target, targetvar) {\ std::vector origin##target##vars;\ - origin##target##vars.push_back(getSlave(LabelStr(#origin))->originvar());\ - origin##target##vars.push_back(getSlave(LabelStr(#target))->targetvar());\ + origin##target##vars.push_back(getSlave(#origin)->originvar());\ + origin##target##vars.push_back(getSlave(#target)->targetvar());\ rule_constraint(relationname,origin##target##vars);\ } diff --git a/src/PLASMA/NDDL/base/NddlToken.cc b/src/PLASMA/NDDL/base/NddlToken.cc index 72cbfdae2..6e19cec55 100644 --- a/src/PLASMA/NDDL/base/NddlToken.cc +++ b/src/PLASMA/NDDL/base/NddlToken.cc @@ -1,32 +1,39 @@ #include "NddlToken.hh" #include "Utils.hh" #include "Object.hh" + +using namespace EUROPA; namespace NDDL { - NddlToken::NddlToken(const PlanDatabaseId& planDatabase, const LabelStr& predicateName, const bool& rejectable, const bool& isFact, const bool& close) +NddlToken::NddlToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const bool& rejectable, + const bool& _isFact, const bool& _close) : EUROPA::IntervalToken(planDatabase, predicateName, rejectable, - isFact, + _isFact, IntervalIntDomain(), IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), EUROPA::Token::noObject(), - false) { - commonInit(close); - } + false), + state(), object(), tStart(), tEnd(), tDuration() { + commonInit(_close); +} - NddlToken::NddlToken(const TokenId& master, const LabelStr& predicateName, const LabelStr& relation, const bool& close) - : EUROPA::IntervalToken(master, +NddlToken::NddlToken(const TokenId _master, const std::string& predicateName, + const std::string& relation, const bool& _close) + : EUROPA::IntervalToken(_master, relation, predicateName, IntervalIntDomain(), IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), EUROPA::Token::noObject(), - false) { - commonInit(close); - } + false), + state(), object(), tStart(), tEnd(), tDuration() { + commonInit(_close); +} void NddlToken::handleDefaults(const bool&) { } @@ -42,7 +49,7 @@ namespace NDDL { } // ConstrainedVariableId NddlToken::var(const std::string& name) const { -// return getVariable(LabelStr(name)); +// return getVariable(std::string(name)); // } } // namespace NDDL diff --git a/src/PLASMA/NDDL/base/NddlToken.hh b/src/PLASMA/NDDL/base/NddlToken.hh index 55a39087c..24aa297d3 100644 --- a/src/PLASMA/NDDL/base/NddlToken.hh +++ b/src/PLASMA/NDDL/base/NddlToken.hh @@ -17,19 +17,24 @@ namespace NDDL { * @brief Constructor for goal tokens. * @see PLASMA::IntervalToken */ - NddlToken(const PlanDatabaseId& planDatabase, const LabelStr& predicateName, const bool& rejectable = false, const bool& isFact = false, const bool& close = false); + NddlToken(const EUROPA::PlanDatabaseId planDatabase, + const std::string& predicateName, + const bool& rejectable = false, const bool& isFact = false, + const bool& close = false); /** * @brief Constructor for subgoal tokens. * @see PLASMA::IntervalToken */ - NddlToken(const TokenId& master, const LabelStr& predicateName, const LabelStr& relation, const bool& close = false); - - StateVarId state; /**getSlave(LabelStr(name)); + TokenId tok(const RuleInstanceId rule, const std::string name) { + return rule->getSlave(name); } - ConstrainedVariableId var(const RuleInstanceId& entity, const std::string name) { - return entity->getVariable(LabelStr(name)); + ConstrainedVariableId var(const RuleInstanceId entity, const std::string name) { + return entity->getVariable(name); } - ConstrainedVariableId var(const TokenId& entity, const std::string name) { - return entity->getVariable(LabelStr(name)); + ConstrainedVariableId var(const TokenId entity, const std::string name) { + return entity->getVariable(name); } }//namespace diff --git a/src/PLASMA/NDDL/base/NddlUtils.hh b/src/PLASMA/NDDL/base/NddlUtils.hh index aa2ad267b..3d3fb6f38 100644 --- a/src/PLASMA/NDDL/base/NddlUtils.hh +++ b/src/PLASMA/NDDL/base/NddlUtils.hh @@ -21,18 +21,19 @@ namespace NDDL { * Used in rule firing and generating pseudo variables on tokens. They cannot be specified. */ template - ConstrainedVariableId allocateVariable(const ConstraintEngineId& ce, - std::vector& vars, + EUROPA::ConstrainedVariableId allocateVariable(const EUROPA::ConstraintEngineId ce, + std::vector& vars, const ELEMENT_TYPE& domain, - const EntityId& parent){ + const EUROPA::EntityId parent){ + using namespace EUROPA; std::stringstream sstr; sstr << "PSEDUO_VARIABLE_" << vars.size(); ConstrainedVariableId var = (new Variable< ELEMENT_TYPE >(ce, domain, false, false, - LabelStr(sstr.str()), + sstr.str(), parent))->getId(); vars.push_back(var); return var; @@ -41,9 +42,9 @@ namespace NDDL { /** * Should all be moved to the rule instance class. */ - TokenId tok(const RuleInstanceId& rule, const std::string name) ; - ConstrainedVariableId var(const RuleInstanceId& entity, const std::string name) ; - ConstrainedVariableId var(const TokenId& entity, const std::string name) ; +EUROPA::TokenId tok(const EUROPA::RuleInstanceId rule, const std::string name) ; +EUROPA::ConstrainedVariableId var(const EUROPA::RuleInstanceId entity, const std::string name) ; +EUROPA::ConstrainedVariableId var(const EUROPA::TokenId entity, const std::string name) ; } @@ -55,11 +56,11 @@ namespace NDDL { #define DECLARE_DEFAULT_OBJECT_FACTORY(Factory, Klass)\ class Factory: public ObjectFactory{\ public:\ - Factory(const LabelStr& name): ObjectFactory(name) {}\ + Factory(const std::string& name): ObjectFactory(name) {}\ private:\ - ObjectId createInstance(const PlanDatabaseId& planDb,\ - const LabelStr& objectType, \ - const LabelStr& objectName,\ + ObjectId createInstance(const PlanDatabaseId planDb,\ + const std::string& objectType, \ + const std::string& objectName,\ const std::vector& arguments) const {\ check_error(arguments.empty());\ Id instance = (new Klass(planDb, objectType, objectName))->getId();\ @@ -76,13 +77,13 @@ private:\ #define DECLARE_TOKEN_FACTORY(klass, predicateName) \ class Factory: public TokenFactory { \ public: \ - Factory() : TokenFactory(LabelStr(#predicateName)) { \ + Factory() : TokenFactory(#predicateName) { \ } \ - TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable = false, bool isFact = false) const { \ + TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, bool rejectable = false, bool isFact = false) const { \ TokenId token = (new klass(planDb, name, rejectable, isFact, true))->getId(); \ return(token); \ } \ - TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const { \ + TokenId createInstance(const TokenId master, const std::string& name, const std::string& relation) const { \ TokenId token = (new klass(master, name, relation, true))->getId(); \ return(token); \ } \ diff --git a/src/PLASMA/NDDL/base/antlr/NDDL3.g b/src/PLASMA/NDDL/base/antlr/NDDL3.g index b3c021037..8d727fc03 100644 --- a/src/PLASMA/NDDL/base/antlr/NDDL3.g +++ b/src/PLASMA/NDDL/base/antlr/NDDL3.g @@ -26,7 +26,7 @@ tokens { @parser::includes { #include "NddlInterpreter.hh" - +#include "PathDefs.hh" using namespace EUROPA; @@ -62,7 +62,8 @@ static void newNDDL3ParserFree(pNDDL3Parser ctx) { @lexer::includes { -#include "NddlInterpreter.hh" +#include "NddlInterpreter.hh" +#include "PathDefs.hh" using namespace EUROPA; diff --git a/src/PLASMA/NDDL/base/antlr/NDDL3Tree.g b/src/PLASMA/NDDL/base/antlr/NDDL3Tree.g index 8a1a8d384..841d5c083 100644 --- a/src/PLASMA/NDDL/base/antlr/NDDL3Tree.g +++ b/src/PLASMA/NDDL/base/antlr/NDDL3Tree.g @@ -18,7 +18,9 @@ options { #include "Debug.hh" #include "Domains.hh" #include "NddlInterpreter.hh" +#include "PathDefs.hh" +#include using namespace EUROPA; } @@ -117,7 +119,7 @@ nddl enumDefinition returns [Expr* result] @init { - std::vector values; + std::vector values; } : ^('enum' name=IDENT enumValues[values]) { @@ -126,7 +128,7 @@ enumDefinition returns [Expr* result] } ; -enumValues[std::vector& values] +enumValues[std::vector& values] : ^('{' (v=IDENT {values.push_back(c_str($v.text->chars));})+ ) ; @@ -167,7 +169,7 @@ baseDomain[const DataType* baseType] returns [Domain* result] ConstrainedVariableId value = data.getValue(); if (!baseType->isAssignableFrom(value->getDataType())) { reportSemanticError(CTX, - "Can't assign "+value->toString()+" to "+baseType->getName().toString()); + "Can't assign "+value->toString()+" to "+baseType->getName()); } result = value->lastDomain().copy(); @@ -267,8 +269,8 @@ valueSet returns [Expr* result] !elementType->isAssignableFrom(newElementType)) { reportSemanticError(CTX, "Incompatible types in value set: "+ - elementType->toString(values.front())+"("+elementType->getName().toString()+") "+ - newElementType->toString(v)+"("+newElementType->getName().toString()+")" + elementType->toString(values.front())+"("+elementType->getName()+") "+ + newElementType->toString(v)+"("+newElementType->getName()+")" ); } } @@ -339,8 +341,8 @@ numericInterval returns [Expr* result] edouble ub = upper->getSingletonValue(); Domain* baseDomain; - if (lower->getTypeName().toString()=="float" || - upper->getTypeName().toString()=="float") + if (lower->getTypeName()=="float" || + upper->getTypeName()=="float") baseDomain = new IntervalDomain(lb,ub); else baseDomain = new IntervalIntDomain((eint)lb,(eint)ub); @@ -528,7 +530,7 @@ constructorArgument[std::vector& argNames,std::vector& { const char* varName = c_str($argName.text->chars); argNames.push_back(varName); - argTypes.push_back(argType->getName().toString()); + argTypes.push_back(argType->getName()); CTX->SymbolTable->addLocalVar(varName,argType->getId()); } ; @@ -569,7 +571,7 @@ tokenType[ObjectType* objType] : ^(kind=('predicate' | 'action') ttName=IDENT { - tokenTypeName = objType->getName().toString() + "." + c_str($ttName.text->chars); + tokenTypeName = objType->getName() + "." + c_str($ttName.text->chars); tokenType = new InterpretedTokenType(objType->getId(),tokenTypeName,c_str($kind.text->chars)); pushContext(CTX,new NddlTokenSymbolTable(CTX->SymbolTable,tokenType->getId(),objType->getId())); } @@ -604,7 +606,7 @@ tokenParameter[InterpretedTokenType* tokenType] returns [Expr* result] { const std::vector& vars=child->getChildren(); for (unsigned int i=0;i(vars[i]); + ExprVarDeclaration* vd = boost::polymorphic_cast(vars[i]); tokenType->addArg(vd->getDataType(),vd->getName()); } result = child; @@ -810,7 +812,7 @@ predicateInstance returns [PredicateInstanceRef* pi] (ann=tokenAnnotation { annotation = c_str($ann.text->chars); })? ) { - pi = new PredicateInstanceRef(tokenType,tokenStr.c_str(),name,annotation); + pi = new PredicateInstanceRef(tokenType,tokenStr.c_str(),(name == NULL ? "" : name),(annotation == NULL ? "" : annotation)); if (name != NULL) CTX->SymbolTable->addLocalToken(name,tokenType); } @@ -828,7 +830,7 @@ predicateVarRef returns [PredicateInstanceRef* pi] if (tokenType.isNoId()) reportSemanticError(CTX,std::string(varName)+" is an undefined token"); - pi = new PredicateInstanceRef(tokenType,NULL,varName,""); + pi = new PredicateInstanceRef(tokenType,"",varName,""); } ; @@ -1026,7 +1028,7 @@ enforceExpression returns [Expr* result] con = new ExprConstant(dom->getTypeName().c_str(), dom); args.push_back(value); args.push_back(con); - result = new ExprConstraint("eq", args, NULL); + result = new ExprConstraint("eq", args, ""); } else { result = value; } diff --git a/src/PLASMA/NDDL/component/Interpreter.cc b/src/PLASMA/NDDL/component/Interpreter.cc index 9ca30341b..d640faec0 100644 --- a/src/PLASMA/NDDL/component/Interpreter.cc +++ b/src/PLASMA/NDDL/component/Interpreter.cc @@ -24,65 +24,74 @@ #include "ObjectType.hh" #include "Schema.hh" #include "TokenVariable.hh" +#include "CESchema.hh" #include "NddlRules.hh" #include "NddlUtils.hh" +#include +#include -namespace EUROPA { - - // TODO: keep using pdbClient? - const DbClientId& getPDB(EvalContext& context) - { - // TODO: Add this behavior to EvalContext instead? - DbClient* dbClient = (DbClient*)context.getElement("DbClient"); - if (dbClient != NULL) - return dbClient->getId(); +#include +#include - PlanDatabase* pdb = (PlanDatabase*)context.getElement("PlanDatabase"); - check_error(pdb != NULL,"Could not find Plan Database in eval context"); - return pdb->getClient(); - } - - const SchemaId& getSchema(EvalContext& context) - { - /* TODO why doesn't this work??? - Schema* schema = (Schema*)context.getElement("Schema"); - check_error(schema != NULL,"Could not find Schema in eval context"); - return schema->getId(); - */ - return getPDB(context)->getSchema(); - } +namespace EUROPA { - // TODO: move this to the eval contexts to make it cleaner - void makeConstraint(EvalContext& context, - const LabelStr& name, - const std::vector& vars, - const char* violationExpl) - { - PlanDatabase* pdb = (PlanDatabase*)(context.getElement("PlanDatabase")); - ConstraintId c = pdb->getClient()->createConstraint(name.c_str(), vars, violationExpl); - debugMsg("Interpreter","Added Constraint : " << c->toString()); +namespace { +// TODO: keep using pdbClient? +const DbClientId getPDB(EvalContext& context) +{ + // TODO: Add this behavior to EvalContext instead? + DbClient* dbClient = reinterpret_cast(context.getElement("DbClient")); + if (dbClient != NULL) + return dbClient->getId(); + + PlanDatabase* pdb = reinterpret_cast(context.getElement("PlanDatabase")); + check_error(pdb != NULL,"Could not find Plan Database in eval context"); + return pdb->getClient(); +} - InterpretedRuleInstance* rule = (InterpretedRuleInstance*)(context.getElement("RuleInstance")); - if (rule != NULL) { - rule->addConstraint(c); - debugMsg("Interpreter:InterpretedRule","Added Constraint : " << c->toString()); - return; - } +const SchemaId getSchema(EvalContext& context) +{ + /* TODO why doesn't this work??? + Schema* schema = (Schema*)context.getElement("Schema"); + check_error(schema != NULL,"Could not find Schema in eval context"); + return schema->getId(); + */ + return getPDB(context)->getSchema(); +} - Token* t = (Token*)(context.getElement("Token")); - if (t != NULL) { - t->addStandardConstraint(c); - debugMsg("Interpreter:InterpretedToken","Added Constraint : " << c->toString()); - return; - } +// TODO: move this to the eval contexts to make it cleaner +void makeConstraint(EvalContext& context, + const std::string& name, + const std::vector& vars, + const std::string& violationExpl) +{ + PlanDatabase* pdb = reinterpret_cast(context.getElement("PlanDatabase")); + ConstraintId c = pdb->getClient()->createConstraint(name.c_str(), vars, violationExpl); + debugMsg("Interpreter","Added Constraint : " << c->toString()); + + InterpretedRuleInstance* rule = + reinterpret_cast(context.getElement("RuleInstance")); + if (rule != NULL) { + rule->addConstraint(c); + debugMsg("Interpreter:InterpretedRule","Added Constraint : " << c->toString()); + return; + } + + Token* t = reinterpret_cast(context.getElement("Token")); + if (t != NULL) { + t->addStandardConstraint(c); + debugMsg("Interpreter:InterpretedToken","Added Constraint : " << c->toString()); + return; } +} +} /* * ExprConstant */ - ExprConstant::ExprConstant(const char* type, const Domain* domain) + ExprConstant::ExprConstant(const std::string& type, const Domain* domain) : m_type(type) , m_domain(domain) { @@ -98,13 +107,14 @@ namespace EUROPA { return m_domain->getDataType(); } - std::string getAutoName(const char* prefix) - { - static int cnt = 0; - std::stringstream sstr; - sstr << prefix << ++cnt; - return sstr.str(); - } +namespace { +std::string getAutoName(const std::string& prefix) { + static int cnt = 0; + std::stringstream sstr; + sstr << prefix << ++cnt; + return sstr.str(); +} +} DataRef ExprConstant::eval(EvalContext& context) const { @@ -146,48 +156,50 @@ namespace EUROPA { std::string ExprConstant::getConstantValue() const { - std::ostringstream os; - std::string typeName(m_type.c_str()); - - // TODO: this is a hack, where is this being used? - if (m_domain->isSingleton()) { - if (typeName == IntDT::NAME()) - os << eint(cast_int((m_domain->getSingletonValue()))); - else if (typeName == FloatDT::NAME()) - os << m_domain->getSingletonValue(); - else if (typeName == StringDT::NAME()) - os << LabelStr(m_domain->getSingletonValue()).toString(); - else - os << "CONST_" << typeName << " " << m_domain->toString(); - } + std::ostringstream os; + std::string typeName(m_type.c_str()); + + // TODO: this is a hack, where is this being used? + if (m_domain->isSingleton()) { + if (typeName == IntDT::NAME()) + os << eint(cast_int((m_domain->getSingletonValue()))); + else if (typeName == FloatDT::NAME()) + os << m_domain->getSingletonValue(); + else if (typeName == StringDT::NAME()) + os << LabelStr(m_domain->getSingletonValue()).toString(); else - os << "CONST_" << typeName << " " << m_domain->toString(); + os << "CONST_" << typeName << " " << m_domain->toString(); + } + else + os << "CONST_" << typeName << " " << m_domain->toString(); - return os.str(); + return os.str(); } - /* - * ExprVarRef - */ - ExprVarRef::ExprVarRef(const char* varName, const DataTypeId& type) +/* + * ExprVarRef + */ +ExprVarRef::ExprVarRef(const std::string& varName, const DataTypeId type) : m_varName(varName) , m_varType(type) - { - tokenize(m_varName,m_vars,"."); + , m_parentName() + , m_vars() +{ + tokenize(m_varName,m_vars,"."); - if (m_vars.size() > 1) { - m_parentName = m_vars[0]; - m_varName = m_varName.substr(m_parentName.length()+1); - m_vars.erase(m_vars.begin()); - debugMsg("Interpreter:ExprVarRef","Split " << varName << " into " << m_parentName << " and " << m_varName); - } - else { - m_parentName = ""; - debugMsg("Interpreter:ExprVarRef","Didn't split " << varName); - } + if (m_vars.size() > 1) { + m_parentName = m_vars[0]; + m_varName = m_varName.substr(m_parentName.length()+1); + m_vars.erase(m_vars.begin()); + debugMsg("Interpreter:ExprVarRef","Split " << varName << " into " << m_parentName << " and " << m_varName); + } + else { + m_parentName = ""; + debugMsg("Interpreter:ExprVarRef","Didn't split " << varName); } +} ExprVarRef::~ExprVarRef() { @@ -198,66 +210,65 @@ namespace EUROPA { return m_varType; } - DataRef ExprVarRef::eval(EvalContext& context) const - { - ConstrainedVariableId var; +DataRef ExprVarRef::eval(EvalContext& context) const { + ConstrainedVariableId var; - if (m_parentName == "") { - var = context.getVar(m_varName.c_str()); - if (var.isNoId()) { - // If var evaluates to a token, return state var. - TokenId tok = context.getToken(m_varName.c_str()); - if (tok.isNoId()) { - check_runtime_error(!var.isNoId(),std::string("Couldn't find variable or token '" )+m_varName+"' in Evaluation Context"); - return DataRef::null; - } - var = tok->getState(); - } + if (m_parentName == "") { + var = context.getVar(m_varName.c_str()); + if (var.isNoId()) { + // If var evaluates to a token, return state var. + TokenId tok = context.getToken(m_varName.c_str()); + if (tok.isNoId()) { + check_runtime_error(!var.isNoId(),std::string("Couldn't find variable or token '" )+m_varName+"' in Evaluation Context"); + return DataRef::null; + } + var = tok->getState(); } - else { - TokenId tok = context.getToken(m_parentName.c_str()); - if (tok.isNoId()) { - var = context.getVar(m_parentName.c_str()); - if (var.isNoId()) { - check_runtime_error(ALWAYS_FAILS,std::string("Couldn't find variable or token '")+m_parentName+"' in Evaluation Context"); - return DataRef::null; - } - } - - // TODO: this isn't pretty, have the different EvalContexts perform the lookup - // TODO: is this really still necessary?, code in "else" block should work in ruleInstance context as well - RuleInstanceEvalContext *riec = dynamic_cast(&context); - if (riec != NULL) { - if (tok.isId()) - var = riec->getRuleInstance()->varfromtok(tok,m_varName); - else - var = riec->getRuleInstance()->varFromObject(m_parentName,m_varName,false); - } - else { - std::string varName=m_vars[0]; - unsigned int idx = 0; - - if (tok.isId()) { - var = tok->getVariable(varName,false); - idx++; - } - - for (;idxderivedDomain().isSingleton(),varName+" must be singleton to be able to get to "+m_vars[idx]); - ObjectId object = Entity::getTypedEntity(var->derivedDomain().getSingletonValue()); - var = object->getVariable(object->getName().toString()+"."+m_vars[idx]); - varName += "." + m_vars[idx]; - - if (var.isNoId()) - check_runtime_error(ALWAYS_FAILS,std::string("Couldn't find variable ")+m_vars[idx]+ - " in object \""+object->getName().toString()+"\" of type "+object->getType().toString()); - } - } + } + else { + TokenId tok = context.getToken(m_parentName.c_str()); + if (tok.isNoId()) { + var = context.getVar(m_parentName.c_str()); + if (var.isNoId()) { + check_runtime_error(ALWAYS_FAILS,std::string("Couldn't find variable or token '")+m_parentName+"' in Evaluation Context"); + return DataRef::null; + } } - return DataRef(var); + // TODO: this isn't pretty, have the different EvalContexts perform the lookup + // TODO: is this really still necessary?, code in "else" block should work in ruleInstance context as well + RuleInstanceEvalContext *riec = dynamic_cast(&context); + if (riec != NULL) { + if (tok.isId()) + var = riec->getRuleInstance()->varfromtok(tok,m_varName); + else + var = riec->getRuleInstance()->varFromObject(m_parentName,m_varName,false); + } + else { + std::string varName=m_vars[0]; + unsigned int idx = 0; + + if (tok.isId()) { + var = tok->getVariable(varName,false); + idx++; + } + + for (;idxderivedDomain().isSingleton(),varName+" must be singleton to be able to get to "+m_vars[idx]); + ObjectId object = Entity::getTypedEntity(var->derivedDomain().getSingletonValue()); + var = object->getVariable(object->getName()+"."+m_vars[idx]); + varName += "." + m_vars[idx]; + + if (var.isNoId()) + check_runtime_error(ALWAYS_FAILS,std::string("Couldn't find variable ")+m_vars[idx]+ + " in object \""+object->getName()+"\" of type "+object->getType()); + } + } } + return DataRef(var); +} + std::string ExprVarRef::toString() const { if (m_parentName.size()==0) @@ -270,8 +281,8 @@ namespace EUROPA { /* * ExprNewObject */ - ExprNewObject::ExprNewObject(const LabelStr& objectType, - const LabelStr& objectName, + ExprNewObject::ExprNewObject(const std::string& objectType, + const std::string& objectName, const std::vector& argExprs) : m_objectType(objectType) , m_objectName(objectName) @@ -298,9 +309,9 @@ namespace EUROPA { ConstrainedVariableId thisVar = context.getVar("this"); ObjectId thisObject = (thisVar.isId() ? Entity::getTypedEntity(thisVar->derivedDomain().getSingletonValue()) : ObjectId::noId()); - std::string prefix = (thisObject.isId() ? thisObject->getName().toString() + "." : ""); + std::string prefix = (thisObject.isId() ? thisObject->getName() + "." : ""); - LabelStr name(prefix+m_objectName.toString()); + std::string name(prefix+m_objectName); DbClientId pdb = getPDB(context); ObjectId newObject = pdb->createObject( m_objectType.c_str(), @@ -318,7 +329,7 @@ namespace EUROPA { { std::ostringstream os; - os << "{NEW_OBJECT " << m_objectName.toString() << "(" << m_objectType.toString() << ") "; + os << "{NEW_OBJECT " << m_objectName << "(" << m_objectType << ") "; for (unsigned int i =0; i < m_argExprs.size();i++) { if (i>0) @@ -366,10 +377,17 @@ namespace EUROPA { return m_value->eval(context); } - CExprFunction::CExprFunction(const CFunctionId& func, const std::vector& args) + CExprFunction::CExprFunction(const CFunctionId func, const std::vector& args) : m_func(func) , m_args(args) { + checkError(func.isValid(), "Constructed with invalid function pointer."); + for(std::vector::const_iterator it = m_args.begin(); + it != m_args.end(); ++it) { + checkError((*it) != NULL, "Constructed CFunction " << func->getName() << + " with a null argument at position " << + std::distance::const_iterator>(m_args.begin(), it)); + } } void CExprFunction::checkType() @@ -383,7 +401,7 @@ namespace EUROPA { std::string variable = createVariableName(); // TODO: CFunction should know how to eval itself - ExprVarDeclaration* var = new ExprVarDeclaration(variable.c_str(), getDataType(), NULL, false); + ExprVarDeclaration* var = new ExprVarDeclaration(variable, getDataType(), NULL, false); DataRef output = var->eval(context); Expr* varRef = new ExprVarRef(variable.c_str(), getDataType()); @@ -401,10 +419,12 @@ namespace EUROPA { std::string CExprFunction::toString() const { std::string args = ""; - for (unsigned int i = 0; i < m_args.size(); i++) - args += m_args[i]->toString() + std::string("_"); + for (unsigned int i = 0; i < m_args.size(); i++) { + checkError(m_args[i] != NULL, "??"); + args += m_args[i]->toString() + std::string("_"); + } - return m_func->getName().toString() + "__" + args + "_"; + return m_func->getName() + "__" + args + "_"; } CExprBinary::CExprBinary(std::string op, CExpr* lhs, CExpr* rhs) @@ -462,11 +482,13 @@ namespace EUROPA { } } - bool isTimepoint(DataRef var) { - ConstrainedVariable *cvar = var.getValue(); - return dynamic_cast< TokenVariable* >(cvar) != NULL - && (cvar->getName().toString() == "end" || cvar->getName().toString() == "start"); - } +namespace { +bool isTimepoint(DataRef var) { + ConstrainedVariable *cvar = var.getValue(); + return dynamic_cast< TokenVariable* >(cvar) != NULL + && (cvar->getName() == "end" || cvar->getName() == "start"); +} +} bool CExprBinary::isSingleton() { return false; @@ -481,12 +503,12 @@ namespace EUROPA { std::string constraint = "", returnType = ""; bool flipArguments = false; if (hasReturnValue()) { - if (m_operator == "==") { constraint = "testEQ"; returnType = "bool"; } - if (m_operator == "<=") { constraint = "testLEQ"; returnType = "bool"; } - if (m_operator == ">=") { constraint = "testLEQ"; returnType = "bool"; flipArguments = true; } - if (m_operator == "!=") { constraint = "testNEQ"; returnType = "bool"; } - if (m_operator == ">") { constraint = "TestLessThan"; returnType = "bool"; flipArguments = true; } - if (m_operator == "<") { constraint = "TestLessThan"; returnType = "bool"; } + if (m_operator == "==") { constraint = "testEq"; returnType = "bool"; } + if (m_operator == "<=") { constraint = "testLeq"; returnType = "bool"; } + if (m_operator == ">=") { constraint = "testLeq"; returnType = "bool"; flipArguments = true; } + if (m_operator == "!=") { constraint = "testNeq"; returnType = "bool"; } + if (m_operator == ">") { constraint = "testLessThan"; returnType = "bool"; flipArguments = true; } + if (m_operator == "<") { constraint = "testLessThan"; returnType = "bool"; } if (m_operator == "+") { constraint = "addEq"; } if (m_operator == "-") { constraint = "addEq"; } if (m_operator == "*") { constraint = "mulEq"; } @@ -549,7 +571,7 @@ namespace EUROPA { std::string variable = this->createVariableName(); //Declare the implicit return variable - ExprVarDeclaration* var = new ExprVarDeclaration(variable.c_str(), data, NULL, false); + ExprVarDeclaration* var = new ExprVarDeclaration(variable, data, NULL, false); output = var->eval(context); delete var; @@ -622,12 +644,12 @@ namespace EUROPA { return "BadExpression"; } - ExprConstraint::ExprConstraint(const char* name,const std::vector& args, const char* violationExpl) + ExprConstraint::ExprConstraint(const std::string& name,const std::vector& args, const std::string& violationExpl) : m_name(name) , m_args(args) , m_violationExpl("") { - if (violationExpl != NULL) + if (!violationExpl.empty()) m_violationExpl = violationExpl; } @@ -638,164 +660,158 @@ namespace EUROPA { m_args.clear(); } - std::string varsToString(const std::vector& vars) - { - std::ostringstream os; - for (unsigned int i=0; i < vars.size(); i++) { - if (i>0) os << ","; - os << vars[i]->toString(); - } - - return os.str(); +DataRef ExprConstraint::eval(EvalContext& context) const +{ + std::vector vars; + for (unsigned int i=0; i < m_args.size(); i++) { + DataRef arg = m_args[i]->eval(context); + vars.push_back(arg.getValue()); } - DataRef ExprConstraint::eval(EvalContext& context) const - { - std::vector vars; - for (unsigned int i=0; i < m_args.size(); i++) { - DataRef arg = m_args[i]->eval(context); - vars.push_back(arg.getValue()); - } + makeConstraint(context,m_name,vars,m_violationExpl.c_str()); - makeConstraint(context,m_name,vars,m_violationExpl.c_str()); + return DataRef::null; +} - return DataRef::null; - } +std::string ExprConstraint::toString() const +{ + std::stringstream os; - std::string ExprConstraint::toString() const - { - std::stringstream os; + os << "{CONSTRAINT:" << m_name.c_str() << " ("; - os << "{CONSTRAINT:" << m_name.c_str() << " ("; + for (unsigned int i=0;itoString() << " "; + os << ") " << m_violationExpl << "}"; - for (unsigned int i=0;itoString() << " "; - os << ") " << m_violationExpl << "}"; + return os.str(); +} - return os.str(); - } +namespace { +bool isClass(EvalContext& ctx,const std::string& className) { + return getSchema(ctx)->isObjectType(className); +} - bool isClass(EvalContext& ctx,const LabelStr& className) - { - return getSchema(ctx)->isObjectType(className); - } // see ModelAccessor.isConstrained in Nddl compiler - bool isConstrained(EvalContext& context, const LabelStr& predicateInstance) - { - unsigned int tokenCnt = predicateInstance.countElements("."); - - // If the predicate is not qualified that means it belongs to the object in scope - if (tokenCnt == 1) - return true; +bool isConstrained(EvalContext& context, const std::string& predicateInstance){ + unsigned long tokenCnt = + std::count(predicateInstance.begin(), predicateInstance.end(), '.') + 1; - // If the prefix is a class, it means it can be any object instance, so it must not be constrained - LabelStr prefix(predicateInstance.getElement(0,".")); - if (!isClass(context,prefix)) - return true; + // If the predicate is not qualified that means it belongs to the object in scope + if (tokenCnt == 1) + return true; - return false; - } + // If the prefix is a class, it means it can be any object instance, so it must not be constrained + std::string prefix(predicateInstance.substr(0, predicateInstance.find('.'))); + if (!isClass(context,prefix)) + return true; - LabelStr checkPredicateType(EvalContext& ctx,const LabelStr& type) - { - check_runtime_error(getSchema(ctx)->isPredicate(type),type.toString()+" is not a Type"); - return type; - } + return false; +} - LabelStr getObjectVarClass(EvalContext& ctx,const LabelStr& className,const LabelStr& var) - { - const SchemaId& schema = getSchema(ctx); - check_runtime_error(schema->hasMember(className,var),className.toString()+" has no member called "+var.toString()); - return schema->getMemberType(className,var); - } +std::string checkPredicateType(EvalContext& ctx,const std::string& type) { + check_runtime_error(getSchema(ctx)->isPredicate(type),type+" is not a Type"); + return type; +} - LabelStr getTokenVarClass(EvalContext& ctx,const LabelStr& className,const LabelStr& predName,const LabelStr& var) - { - if (strcmp(var.c_str(),"object") == 0) // is it the object variable? - return className; - else { // look through the parameters to the token - const SchemaId& schema = getSchema(ctx); - if (schema->hasMember(predName,var)) - return schema->getMemberType(predName,var); - } +std::string getObjectVarClass(EvalContext& ctx,const std::string& className,const std::string& var) { + const SchemaId schema = getSchema(ctx); + check_runtime_error(schema->hasMember(className,var),className+" has no member called "+var); + return schema->getMemberType(className,var); +} - // if everything else fails, see if it's an object member - return getObjectVarClass(ctx,className,var); +std::string getTokenVarClass(EvalContext& ctx,const std::string& className,const std::string& predName,const std::string& var){ + if (strcmp(var.c_str(),"object") == 0) // is it the object variable? + return className; + else { // look through the parameters to the token + const SchemaId schema = getSchema(ctx); + if (schema->hasMember(predName,var)) + return schema->getMemberType(predName,var); } + // if everything else fails, see if it's an object member + return getObjectVarClass(ctx,className,var); +} + /* * figures out the type of a predicate given an instance * */ - LabelStr predicateInstanceToType( - EvalContext& ctx, - const char* predicateName, - const char* predicateInstance) - { - // see ModelAccessor.getSlaveObjectType() in NDDL compiler - ConstrainedVariableId obj = ctx.getVar("object"); - check_error(obj.isId(),"Failed to find 'object' var in predicateInstanceToType()"); - const char* className = obj->baseDomain().getTypeName().c_str(); - LabelStr str(predicateInstance); - - unsigned int tokenCnt = str.countElements("."); - - if (tokenCnt == 1) { - std::string retval = std::string(className)+"."+predicateInstance; - return checkPredicateType(ctx,LabelStr(retval)); - } - else if (tokenCnt == 2) { - LabelStr prefix(str.getElement(0,".")); - LabelStr suffix(str.getElement(1,".")); - - if (prefix.toString() == "object") { - std::string retval = std::string(className)+"."+suffix.toString(); - return checkPredicateType(ctx,LabelStr(retval.c_str())); - } - else if (isClass(ctx,prefix)) { - return checkPredicateType(ctx,LabelStr(predicateInstance)); - } - else { - ConstrainedVariableId var = ctx.getVar(prefix.c_str()); - if (var.isId()) { - std::string clazz = var->baseDomain().getTypeName().c_str(); - return checkPredicateType(ctx,clazz+"."+suffix.toString()); - } - else { - LabelStr clazz = getTokenVarClass(ctx,className,predicateName,prefix); - std::string retval = clazz.toString()+"."+suffix.toString(); - return checkPredicateType(ctx,LabelStr(retval.c_str())); - } - } +std::string predicateInstanceToType( + EvalContext& ctx, + const std::string& predicateName, + const std::string& predicateInstance){ + // see ModelAccessor.getSlaveObjectType() in NDDL compiler + ConstrainedVariableId obj = ctx.getVar("object"); + check_error(obj.isId(),"Failed to find 'object' var in predicateInstanceToType()"); + const std::string& className = obj->baseDomain().getTypeName().c_str(); + std::string str(predicateInstance); + + unsigned long tokenCnt = std::count(str.begin(), str.end(), '.') + 1; + + if (tokenCnt == 1) { + std::string retval = std::string(className)+"."+predicateInstance; + return checkPredicateType(ctx,std::string(retval)); + } + else if (tokenCnt == 2) { + std::string prefix(str.substr(0, str.find('.'))); + std::string suffix(str.substr(str.find('.') + 1)); + + if (prefix == "object") { + std::string retval = std::string(className)+"."+suffix; + return checkPredicateType(ctx,std::string(retval.c_str())); + } + else if (isClass(ctx,prefix)) { + return checkPredicateType(ctx,std::string(predicateInstance)); + } + else { + ConstrainedVariableId var = ctx.getVar(prefix.c_str()); + if (var.isId()) { + std::string clazz = var->baseDomain().getTypeName().c_str(); + return checkPredicateType(ctx,clazz+"."+suffix); } else { - LabelStr var = str.getElement(0,"."); - LabelStr clazz; - ConstrainedVariableId v = ctx.getVar(var.c_str()); - if (v.isId()) - clazz = v->baseDomain().getTypeName().c_str(); - else - clazz = getTokenVarClass(ctx,className,predicateName,var); + std::string clazz = getTokenVarClass(ctx,className,predicateName,prefix); + std::string retval = clazz+"."+suffix; + return checkPredicateType(ctx,retval.c_str()); + } + } + } + else { + std::vector contents; + boost::split(contents, str, boost::is_any_of(".")); + + std::string var = contents[0];//str.substr(0, str.find('.')); - for (unsigned int i=1;ibaseDomain().getTypeName().c_str(); + else + clazz = getTokenVarClass(ctx,className,predicateName,var); - LabelStr predicate = str.getElement(tokenCnt-1,"."); - std::string retval = clazz.toString() + "." + predicate.toString(); - return checkPredicateType(ctx,LabelStr(retval)); - } + for(std::vector::const_iterator it = contents.begin() + 1; + it != (contents.begin() + (contents.size() - 1)); ++it) { + clazz = getObjectVarClass(ctx, clazz, *it); + } + std::string predicate = contents.back(); + std::string retval = clazz + "." + predicate; + return checkPredicateType(ctx,retval); } +} +} - PredicateInstanceRef::PredicateInstanceRef(const TokenTypeId& tokenType, const char* predInstance, const char* predName, const char* annotation) - : m_tokenType(tokenType) - , m_predicateInstance(predInstance != NULL ? predInstance : "") - , m_predicateName(predName != NULL ? predName : "") +PredicateInstanceRef::PredicateInstanceRef(const TokenTypeId tokenType, + const std::string& predInstance, + const std::string& predName, + const std::string& annotation) + : m_tokenType(tokenType) + , m_predicateInstance(predInstance) + , m_predicateName(predName) + , m_attributes(0) { m_attributes=0; - if (annotation != NULL) { + if (!annotation.empty()) { std::string str = annotation; if (str=="condition") m_attributes |= PSTokenType::CONDITION; @@ -812,87 +828,94 @@ namespace EUROPA { // TODO: passing relation doesn't seem like a good idea, since a token may have more than one relation to its // master. However, MatchingEngine matches on that, so keeping it for now. - TokenId PredicateInstanceRef::getToken(EvalContext& context, const char* relationName, bool isFact, bool isRejectable) - { - TokenId result; - if (m_predicateInstance.length() == 0) { - result = context.getToken(m_predicateName.c_str()); - } - else { - InterpretedRuleInstance* rule = (InterpretedRuleInstance*)(context.getElement("RuleInstance")); - if (rule != NULL) { - result = createSubgoal(context,rule,relationName); - result->addAttributes(m_attributes); - } - else - result = createGlobalToken(context, isFact, isRejectable); - } - - //TODO: In the future, this might be a hook into the NDDL error reporting system. - checkError(result != TokenId() && result.isId(), "Error, no token " << m_predicateInstance << " " - << m_predicateName << " in relation: " << relationName << "."); - return result; +TokenId PredicateInstanceRef::getToken(EvalContext& context, const std::string& relationName, bool isFact, bool isRejectable) +{ + TokenId result; + if (m_predicateInstance.length() == 0) { + result = context.getToken(m_predicateName.c_str()); + } + else { + InterpretedRuleInstance* rule = reinterpret_cast(context.getElement("RuleInstance")); + if (rule != NULL) { + result = createSubgoal(context,rule,relationName); + result->addAttributes(m_attributes); + } + else + result = createGlobalToken(context, isFact, isRejectable); } - TokenId PredicateInstanceRef::createGlobalToken(EvalContext& context, bool isFact, bool isRejectable) - { - debugMsg("Interpreter:createToken", "creating Token:" << m_predicateInstance << " " << m_predicateName); + //TODO: In the future, this might be a hook into the NDDL error reporting system. + checkError(result != TokenId() && result.isId(), "Error, no token " << m_predicateInstance << " " + << m_predicateName << " in relation: " << relationName << "."); + return result; +} - // The type may be qualified with an object name, in which case we should get the - // object and specify it. We will also have to generate the appropriate type designation - // by extracting the class from the object - ObjectId object; - const char* tokenType = DbClientTransactionPlayer::getObjectAndType(getSchema(context),getPDB(context),m_predicateInstance.c_str(),object); - const char* tokenName = (m_predicateName.length()>0 ? m_predicateName.c_str() : NULL); +TokenId PredicateInstanceRef::createGlobalToken(EvalContext& context, bool isFact, + bool isRejectable) { + debugMsg("Interpreter:createToken", + "creating Token:" << m_predicateInstance << " " << m_predicateName); - TokenId token = getPDB(context)->createToken(tokenType,tokenName,isRejectable,isFact); + // The type may be qualified with an object name, in which case we should get the + // object and specify it. We will also have to generate the appropriate type designation + // by extracting the class from the object + ObjectId object; + const std::string tokenType = + DbClientTransactionPlayer::getObjectAndType(getSchema(context),getPDB(context), + m_predicateInstance,object); + const std::string tokenName = m_predicateName; - if (object.isId()) { - // We restrict the base domain permanently since the name is specifically mentioned on creation - token->getObject()->restrictBaseDomain(object->getThis()->baseDomain()); - } + TokenId token = getPDB(context)->createToken(tokenType,tokenName,isRejectable,isFact); - debugMsg("Interpreter:createToken", "created Token:" << tokenName - << " of type " << tokenType - << " isFact:" << isFact - << " isRejectable:" << isRejectable - ); - - return token; + if (object.isId()) { + // We restrict the base domain permanently since the name is specifically mentioned on creation + token->getObject()->restrictBaseDomain(object->getThis()->baseDomain()); } - TokenId PredicateInstanceRef::createSubgoal(EvalContext& context, InterpretedRuleInstance* rule, const char* relationName) - { - // TODO: cache this? new parser is able to pass this in, do it when nddl-xml is gone. - LabelStr predicateType = predicateInstanceToType(context,m_predicateName.c_str(),m_predicateInstance.c_str()); - debugMsg("Interpreter:InterpretedRule","Creating subgoal " << predicateType.c_str() << ":" << m_predicateName); + debugMsg("Interpreter:createToken", "created Token:" << tokenName + << " of type " << tokenType + << " isFact:" << isFact + << " isRejectable:" << isRejectable + ); - LabelStr predicateName(m_predicateName); // TODO: auto-generate name if not provided? - LabelStr predicateInstance(m_predicateInstance); - bool constrained = isConstrained(context,predicateInstance); - ConstrainedVariableId owner; - if (constrained) { - unsigned int tokenCnt = predicateInstance.countElements("."); - if (tokenCnt == 1) - owner = context.getVar("object"); - else - owner = context.getVar(predicateInstance.getElement(0,".").c_str()); - } + return token; +} - TokenId slave = rule->createSubgoal( - predicateName, - predicateType, - predicateInstance, - relationName, - constrained, - owner - ); +TokenId PredicateInstanceRef::createSubgoal(EvalContext& context, + InterpretedRuleInstance* rule, + const std::string& relationName) { + // TODO: cache this? new parser is able to pass this in, do it when nddl-xml is gone. + std::string predicateType = predicateInstanceToType(context,m_predicateName.c_str(), + m_predicateInstance.c_str()); + debugMsg("Interpreter:InterpretedRule", + "Creating subgoal " << predicateType.c_str() << ":" << m_predicateName); + + std::string predicateName(m_predicateName); // TODO: auto-generate name if not provided? + std::string predicateInstance(m_predicateInstance); + bool constrained = isConstrained(context,predicateInstance); + ConstrainedVariableId owner; + if (constrained) { + unsigned long tokenCnt = + std::count(predicateInstance.begin(), predicateInstance.end(), '.') + 1; + if (tokenCnt == 1) + owner = context.getVar("object"); + else + owner = context.getVar(predicateInstance.substr(0,predicateInstance.find('.')).c_str()); + } - context.addToken(predicateName.c_str(),slave); - debugMsg("Interpreter:InterpretedRule","Created subgoal " << predicateType.toString() << ":" << m_predicateName); + TokenId slave = rule->createSubgoal( + predicateName, + predicateType, + predicateInstance, + relationName, + constrained, + owner + ); - return slave; - } + context.addToken(predicateName.c_str(),slave); + debugMsg("Interpreter:InterpretedRule","Created subgoal " << predicateType << ":" << m_predicateName); + + return slave; +} int PredicateInstanceRef::getAttributes( ) const { @@ -904,7 +927,7 @@ namespace EUROPA { return m_tokenType; } - ExprRelation::ExprRelation(const char* relation, + ExprRelation::ExprRelation(const std::string& relation, PredicateInstanceRef* origin, const std::vector& targets) : m_relation(relation) @@ -913,7 +936,7 @@ namespace EUROPA { { if (m_origin == NULL) { // TODO: may want to provide the actual token type at some point - m_origin = new PredicateInstanceRef(TokenTypeId::noId(),NULL,"this",""); + m_origin = new PredicateInstanceRef(TokenTypeId::noId(),"","this",""); } } @@ -939,110 +962,111 @@ namespace EUROPA { std::vector vars;\ vars.push_back(origin->originvar()); \ vars.push_back(target->targetvar()); \ - makeConstraint(context,LabelStr(#relationname), vars, NULL); \ + makeConstraint(context,#relationname, vars, ""); \ } #define makeStrictPrecedenceRelation(origin, originvar, target, targetvar) { \ - PlanDatabase* db = (PlanDatabase*)(context.getElement("PlanDatabase"));\ + PlanDatabase* db = reinterpret_cast(context.getElement("PlanDatabase"));\ std::vector vars; \ ConstrainedVariableId var = (new Variable(db->getConstraintEngine(), IntervalIntDomain(1, PLUS_INFINITY)))->getId(); \ vars.push_back(origin->originvar()); \ vars.push_back(var); \ vars.push_back(target->targetvar()); \ - makeConstraint(context, "temporalDistance", vars, NULL); \ + makeConstraint(context, "temporalDistance", vars, ""); \ } - void createRelation(EvalContext& context, - const char* relationName, - TokenId origin, - TokenId target) - { - // Allen Relations according to EUROPA - // See ConstraintLibraryReference on the wiki - if (strcmp(relationName,"meets") == 0) { - makeRelation(concurrent, origin, end, target, start); - } - else if (strcmp(relationName,"met_by") == 0) { - makeRelation(concurrent, target, end, origin, start); - } - else if (strcmp(relationName,"contains") == 0) { - makeRelation(precedes, origin, start, target, start); - makeRelation(precedes, target, end, origin, end); - makeRelation(leq, target, duration, origin, duration); - } - else if (strcmp(relationName,"contained_by") == 0) { - makeRelation(precedes, target, start, origin, start); - makeRelation(precedes, origin, end, target, end); - makeRelation(leq, origin, duration, target, duration); - } - else if (strcmp(relationName,"before") == 0) { - makeRelation(precedes, origin, end, target, start); - } - else if (strcmp(relationName,"after") == 0) { - makeRelation(precedes, target, end, origin, start); - } - else if (strcmp(relationName,"starts") == 0) { - makeRelation(concurrent, origin, start, target, start); - } - else if (strcmp(relationName,"ends") == 0) { - makeRelation(concurrent, target, end, origin, end); - } - else if (strcmp(relationName, "parallels") == 0) { - makeRelation(precedes, origin, start, target, start); - makeRelation(precedes, origin, end, target, end); - } - else if (strcmp(relationName, "paralleled_by") == 0) { - makeRelation(precedes, target, start, origin, start); - makeRelation(precedes, target, end, origin, end); - } - else if (strcmp(relationName,"ends_after") == 0) { - makeStrictPrecedenceRelation(target, end, origin, end); - } - else if (strcmp(relationName,"ends_before") == 0) { - makeStrictPrecedenceRelation(origin, end, target, end); - } - else if (strcmp(relationName,"ends_after_start") == 0) { - makeStrictPrecedenceRelation(target, start, origin, end); - } - else if (strcmp(relationName,"starts_before_end") == 0) { - makeStrictPrecedenceRelation(origin, start, target, end); - } - else if (strcmp(relationName,"starts_during") == 0) { - makeRelation(precedes, target, start, origin, start); - makeStrictPrecedenceRelation(origin, start, target, end); - } - else if (strcmp(relationName,"ends_during") == 0) { - makeStrictPrecedenceRelation(target, start, origin, end); - makeRelation(precedes, origin, end, target, end); - } - else if (strcmp(relationName,"contains_start") == 0) { - makeRelation(precedes, origin, start, target, start); - makeStrictPrecedenceRelation(target, start, origin, end); - } - else if (strcmp(relationName,"contains_end") == 0) { - makeStrictPrecedenceRelation(origin, start, target, end); - makeRelation(precedes, origin, end, target, end); - } - else if (strcmp(relationName,"starts_after") == 0) { - makeStrictPrecedenceRelation(target, start, origin, start); - } - else if (strcmp(relationName,"starts_before") == 0) { - makeStrictPrecedenceRelation(origin, start, target, start); - } - else if (strcmp(relationName,"equals") == 0) { - makeRelation(concurrent, origin, start, target, start); - makeRelation(concurrent, target, end, origin, end); - makeRelation(eq, origin, duration, target, duration); - } - else { - check_runtime_error(strcmp(relationName,"any") == 0,std::string("Unrecognized relation:")+relationName); - } +namespace { +void createRelation(EvalContext& context, + const std::string& relationName, + TokenId origin, + TokenId target) { + // Allen Relations according to EUROPA + // See ConstraintLibraryReference on the wiki + if (relationName == "meets") { + makeRelation(concurrent, origin, end, target, start); + } + else if (relationName == "met_by") { + makeRelation(concurrent, target, end, origin, start); } + else if (relationName == "contains") { + makeRelation(precedes, origin, start, target, start); + makeRelation(precedes, target, end, origin, end); + makeRelation(leq, target, duration, origin, duration); + } + else if (relationName == "contained_by") { + makeRelation(precedes, target, start, origin, start); + makeRelation(precedes, origin, end, target, end); + makeRelation(leq, origin, duration, target, duration); + } + else if (relationName == "before") { + makeRelation(precedes, origin, end, target, start); + } + else if (relationName == "after") { + makeRelation(precedes, target, end, origin, start); + } + else if (relationName == "starts") { + makeRelation(concurrent, origin, start, target, start); + } + else if (relationName == "ends") { + makeRelation(concurrent, target, end, origin, end); + } + else if (relationName == "parallels") { + makeRelation(precedes, origin, start, target, start); + makeRelation(precedes, origin, end, target, end); + } + else if (relationName == "paralleled_by") { + makeRelation(precedes, target, start, origin, start); + makeRelation(precedes, target, end, origin, end); + } + else if (relationName == "ends_after") { + makeStrictPrecedenceRelation(target, end, origin, end); + } + else if (relationName == "ends_before") { + makeStrictPrecedenceRelation(origin, end, target, end); + } + else if (relationName == "ends_after_start") { + makeStrictPrecedenceRelation(target, start, origin, end); + } + else if (relationName == "starts_before_end") { + makeStrictPrecedenceRelation(origin, start, target, end); + } + else if (relationName == "starts_during") { + makeRelation(precedes, target, start, origin, start); + makeStrictPrecedenceRelation(origin, start, target, end); + } + else if (relationName == "ends_during") { + makeStrictPrecedenceRelation(target, start, origin, end); + makeRelation(precedes, origin, end, target, end); + } + else if (relationName == "contains_start") { + makeRelation(precedes, origin, start, target, start); + makeStrictPrecedenceRelation(target, start, origin, end); + } + else if (relationName == "contains_end") { + makeStrictPrecedenceRelation(origin, start, target, end); + makeRelation(precedes, origin, end, target, end); + } + else if (relationName == "starts_after") { + makeStrictPrecedenceRelation(target, start, origin, start); + } + else if (relationName == "starts_before") { + makeStrictPrecedenceRelation(origin, start, target, start); + } + else if (relationName == "equals") { + makeRelation(concurrent, origin, start, target, start); + makeRelation(concurrent, target, end, origin, end); + makeRelation(eq, origin, duration, target, duration); + } + else { + check_runtime_error(relationName == "any",std::string("Unrecognized relation:")+relationName); + } +} +} DataRef ExprRelation::eval(EvalContext& context) const { - const char* relationName = m_relation.c_str(); + const std::string& relationName = m_relation.c_str(); TokenId origin = m_origin->getToken(context,"any"); // This will create a subgoal if necessary for (unsigned int i=0;igetRhs() != NULL) { DataRef rhs = m_guard->getRhs()->eval(context); - context.getRuleInstance()->addChildRule( - new InterpretedRuleInstance( - context.getRuleInstance()->getId(), - lhs.getValue(), - rhs.getValue()->lastDomain(), - isOpEquals, - m_ifBody - ) - ); - + std::vector vars; + getVariableReferences(m_guard, context, vars); + InterpretedRuleInstance* iri = + new InterpretedRuleInstance(context.getRuleInstance()->getId(), + lhs.getValue(), + rhs.getValue()->lastDomain(), + isOpEquals, + vars, + m_ifBody); + context.getRuleInstance()->addChildRule(iri); + if (m_elseBody.size() > 0) { - context.getRuleInstance()->addChildRule( - new InterpretedRuleInstance( - context.getRuleInstance()->getId(), - lhs.getValue(), - rhs.getValue()->lastDomain(), - !isOpEquals, - m_elseBody - ) - ); - } - - debugMsg("Interpreter:InterpretedRule","Evaluated IF " << m_guard->toString()); + InterpretedRuleInstance* elseBody = + new InterpretedRuleInstance( + context.getRuleInstance()->getId(), + lhs.getValue(), + rhs.getValue()->lastDomain(), + !isOpEquals, + vars, + m_elseBody); + context.getRuleInstance()->addChildRule(elseBody); + } + + debugMsg("Interpreter:InterpretedRule","Evaluated simple IF " << m_guard->toString()); } else { + // std::vector vars; + // getVariableReferences(m_guard, context, vars); + // condDebugMsg(!vars.empty(), "Interpreter:evalIf", + // "For " << toString() << ", have the following variables: "); + // for(std::vector::const_iterator it = vars.begin(); it != vars.end(); + // ++it) { + // debugMsg("Interpreter:evalIf", (*it)->toLongString()); + // } + checkRuntimeError(ALWAYS_FAILS, "Didn't expect to get here.") context.getRuleInstance()->addChildRule( - new InterpretedRuleInstance( - context.getRuleInstance()->getId(), - makeScope(lhs.getValue()), - isOpEquals, - m_ifBody - ) - ); + new InterpretedRuleInstance( + context.getRuleInstance()->getId(), + makeScope(lhs.getValue()), + isOpEquals, + m_ifBody)); check_runtime_error(m_elseBody.size()==0, "Can't have else body for singleton guard"); - debugMsg("Interpreter:InterpretedRule","Evaluated IF " << m_guard->toString()); + debugMsg("Interpreter:InterpretedRule","Evaluated mult-var IF " << m_guard->toString()); } return DataRef::null; @@ -1170,7 +1202,7 @@ namespace EUROPA { return os.str(); } - ExprLoop::ExprLoop(const char* varName, const char* varValue,const std::vector& loopBody) + ExprLoop::ExprLoop(const std::string& varName, const std::string& varValue,const std::vector& loopBody) : m_varName(varName) , m_varValue(varValue) , m_loopBody(loopBody) @@ -1184,55 +1216,59 @@ namespace EUROPA { m_loopBody.clear(); } - DataRef ExprLoop::doEval(RuleInstanceEvalContext& context) const - { - context.getRuleInstance()->executeLoop(context,m_varName,m_varValue,m_loopBody); - debugMsg("Interpreter:InterpretedRule","Evaluated LOOP " << m_varName.toString() << "," << m_varValue.toString()); - return DataRef::null; - } +DataRef ExprLoop::doEval(RuleInstanceEvalContext& context) const { + context.getRuleInstance()->executeLoop(context,m_varName,m_varValue,m_loopBody); + debugMsg("Interpreter:InterpretedRule", + "Evaluated LOOP " << m_varName << "," << m_varValue); + return DataRef::null; +} /* * InterpretedToken */ - InterpretedToken::InterpretedToken( - const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - const std::vector& body, - const bool& rejectable, - const bool& isFact, - const bool& close) - : IntervalToken(planDatabase, - predicateName, - rejectable, - isFact, - IntervalIntDomain(), // start - IntervalIntDomain(), // end - IntervalIntDomain(1, PLUS_INFINITY), // duration - Token::noObject(), // Object Name - false) - { - commonInit(body, close); - debugMsg("Interpreter:InterpretedToken","Created token(" << getKey() << ") of type:" << predicateName.toString() << " objectVar=" << getVariable("object")->toString()); - } +InterpretedToken::InterpretedToken( + const PlanDatabaseId planDatabase, + const std::string& predicateName, + const std::vector& body, + const bool& rejectable, + const bool& _isFact, + const bool& _close) + : IntervalToken(planDatabase, + predicateName, + rejectable, + _isFact, + IntervalIntDomain(), // start + IntervalIntDomain(), // end + IntervalIntDomain(1, PLUS_INFINITY), // duration + Token::noObject(), // Object Name + false) +{ + commonInit(body, _close); + debugMsg("Interpreter:InterpretedToken", + "Created token(" << getKey() << ") of type:" << predicateName << + " objectVar=" << getVariable("object")->toString()); +} - InterpretedToken::InterpretedToken( - const TokenId& master, - const LabelStr& predicateName, - const LabelStr& relation, - const std::vector& body, - const bool& close) - : IntervalToken(master, +InterpretedToken::InterpretedToken( + const TokenId _master, + const std::string& predicateName, + const std::string& relation, + const std::vector& body, + const bool& _close) + : IntervalToken(_master, relation, predicateName, IntervalIntDomain(), // start IntervalIntDomain(), // end IntervalIntDomain(1, PLUS_INFINITY), // duration Token::noObject(), // Object Name - false) - { - commonInit(body, close); - debugMsg("Interpreter:InterpretedToken","Created slave token(" << getKey() << ") of type:" << predicateName.toString() << " objectVar=" << getVariable("object")->toString()); - } + false) { + commonInit(body, _close); + debugMsg("Interpreter:InterpretedToken", + "Created slave token(" << getKey() << ") of type:" << + predicateName << " objectVar=" << + getVariable("object")->toString()); +} InterpretedToken::~InterpretedToken() { @@ -1255,23 +1291,22 @@ namespace EUROPA { /* * InterpretedTokenType */ - InterpretedTokenType::InterpretedTokenType( - const ObjectTypeId& ot, - const LabelStr& predicateName, - const std::string& kind) - : TokenType(ot,predicateName) - { - // TODO: offer conversion methods in TokenType - int attributes=0; - if (kind=="action") - attributes |= PSTokenType::ACTION; - else if (kind=="predicate") - attributes |= PSTokenType::PREDICATE; - else - std::cerr << "TokenType "<< predicateName.toString() << " unknown kind:" << kind << std::endl; - - addAttributes(attributes); - } +InterpretedTokenType::InterpretedTokenType( + const ObjectTypeId ot, + const std::string& predicateName, + const std::string& kind) + : TokenType(ot,predicateName), m_body(), m_rules() { + // TODO: offer conversion methods in TokenType + int attributes=0; + if (kind=="action") + attributes |= PSTokenType::ACTION; + else if (kind=="predicate") + attributes |= PSTokenType::PREDICATE; + else + std::cerr << "TokenType "<< predicateName << " unknown kind:" << kind << std::endl; + + addAttributes(attributes); +} void InterpretedTokenType::addBodyExpr(Expr* e) { @@ -1304,7 +1339,7 @@ namespace EUROPA { er->populateCausality( this ); } - TokenTypeId InterpretedTokenType::getParentType(const PlanDatabaseId& planDb) const + TokenTypeId InterpretedTokenType::getParentType(const PlanDatabaseId planDb) const { // TODO: cache this? // TODO: drop planDb parameter, ObjectType must be able to answer this without reference to schema @@ -1317,64 +1352,65 @@ namespace EUROPA { * this method takes advantage of that hack to pass the original type up the class hierarchy * a cleaner implementation that explicitly keeps track of the original token type is needed */ - TokenId InterpretedTokenType::createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable, bool isFact) const - { - TokenTypeId parentType = getParentType(planDb); - - TokenId token; - if (parentType.isNoId()) { - token = (new InterpretedToken( - planDb, - name, // Hack! this should be original TokenType passed explicitly - m_body, - rejectable, - isFact, - false))->getId(); - // TODO: this should be done for NativeTokens as well - token->setAttributes(getAttributes()); - } - else { - token = parentType->createInstance(planDb,name,rejectable,isFact); - InterpretedToken* it = dynamic_cast((Token*)token); - if (it != NULL) - it->commonInit(m_body,false); - } - - return token; - } - - TokenId InterpretedTokenType::createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const - { - TokenTypeId parentType = getParentType(master->getPlanDatabase()); - - TokenId token; - if (parentType.isNoId()) { - token = (new InterpretedToken( - master, - name, - relation, - m_body, - false))->getId(); - // TODO: this should be done for all tokens, not just InterpretedTokens - token->setAttributes(getAttributes()); - } - else { - token = parentType->createInstance(master,name,relation); - // TODO: Hack! this makes it impossible to extend native tokens - // class hierarchy needs to be fixed to avoid this cast - InterpretedToken* it = dynamic_cast((Token*)token); - it->commonInit(m_body,false); - } +TokenId InterpretedTokenType::createInstance(const PlanDatabaseId planDb, + const std::string& name, bool rejectable, + bool isFact) const { + TokenTypeId parentType = getParentType(planDb); + + TokenId token; + if (parentType.isNoId()) { + token = (new InterpretedToken( + planDb, + name, // Hack! this should be original TokenType passed explicitly + m_body, + rejectable, + isFact, + false))->getId(); + // TODO: this should be done for NativeTokens as well + token->setAttributes(getAttributes()); + } + else { + token = parentType->createInstance(planDb,name,rejectable,isFact); + InterpretedToken* it = id_cast(token); + if (it != NULL) + it->commonInit(m_body,false); + } + + return token; +} - return token; - } +TokenId InterpretedTokenType::createInstance(const TokenId master, const std::string& name, + const std::string& relation) const { + TokenTypeId parentType = getParentType(master->getPlanDatabase()); + + TokenId token; + if (parentType.isNoId()) { + token = (new InterpretedToken( + master, + name, + relation, + m_body, + false))->getId(); + // TODO: this should be done for all tokens, not just InterpretedTokens + token->setAttributes(getAttributes()); + } + else { + token = parentType->createInstance(master,name,relation); + // TODO: Hack! this makes it impossible to extend native tokens + // class hierarchy needs to be fixed to avoid this cast + InterpretedToken* it = id_cast(token); + it->commonInit(m_body,false); + } + + return token; +} /* * RuleInstanceEvalContext * Puts RuleInstance variables like duration, start, end, in context */ - RuleInstanceEvalContext::RuleInstanceEvalContext(EvalContext* parent, const InterpretedRuleInstanceId& ruleInstance) + RuleInstanceEvalContext::RuleInstanceEvalContext(EvalContext* parent, const InterpretedRuleInstanceId ruleInstance) : EvalContext(parent) , m_ruleInstance(ruleInstance) { @@ -1384,49 +1420,45 @@ namespace EUROPA { { } - void* RuleInstanceEvalContext::getElement(const char* name) const + void* RuleInstanceEvalContext::getElement(const std::string& name) const { std::string str(name); if (str == "RuleInstance") - return (InterpretedRuleInstance*)m_ruleInstance; + return static_cast(m_ruleInstance); if (str == "PlanDatabase") - return (PlanDatabase*)m_ruleInstance->getPlanDatabase(); + return static_cast(m_ruleInstance->getPlanDatabase()); return EvalContext::getElement(name); } - ConstrainedVariableId RuleInstanceEvalContext::getVar(const char* name) - { - ConstrainedVariableId var = m_ruleInstance->getVariable(LabelStr(name)); +ConstrainedVariableId RuleInstanceEvalContext::getVar(const std::string& name) { + ConstrainedVariableId var = m_ruleInstance->getVariable(name); - if (!var.isNoId()) { - debugMsg("Interpreter:EvalContext:RuleInstance","Found var in rule instance:" << name); - return var; - } - else { - debugMsg("Interpreter:EvalContext:RuleInstance","Didn't find var in rule instance:" << name); - return EvalContext::getVar(name); - } + if (!var.isNoId()) { + debugMsg("Interpreter:EvalContext:RuleInstance","Found var in rule instance:" << name); + return var; } - - TokenId RuleInstanceEvalContext::getToken(const char* name) - { - LabelStr ls_name(name); - TokenId tok = m_ruleInstance->getSlave(ls_name); - if (!tok.isNoId()) { - debugMsg("Interpreter:EvalContext:RuleInstance","Found token in rule instance:" << name); - return tok; - } - else { - debugMsg("Interpreter:EvalContext:RuleInstance","Didn't find token in rule instance:" << name); - return EvalContext::getToken(name); - } + else { + debugMsg("Interpreter:EvalContext:RuleInstance","Didn't find var in rule instance:" << name); + return EvalContext::getVar(name); } +} - bool RuleInstanceEvalContext::isClass(const LabelStr& className) const - { - return m_ruleInstance->getPlanDatabase()->getSchema()->isObjectType(className); +TokenId RuleInstanceEvalContext::getToken(const std::string& name) { + TokenId tok = m_ruleInstance->getSlave(name); + if (!tok.isNoId()) { + debugMsg("Interpreter:EvalContext:RuleInstance","Found token in rule instance:" << name); + return tok; + } + else { + debugMsg("Interpreter:EvalContext:RuleInstance","Didn't find token in rule instance:" << name); + return EvalContext::getToken(name); } +} + +bool RuleInstanceEvalContext::isClass(const std::string& className) const { + return m_ruleInstance->getPlanDatabase()->getSchema()->isObjectType(className); +} std::string RuleInstanceEvalContext::toString() const { @@ -1438,7 +1470,7 @@ namespace EUROPA { const std::vector& vars = m_ruleInstance->getToken()->getVariables(); for(std::vector::const_iterator it = vars.begin(); it != vars.end(); ++it){ ConstrainedVariableId var = *it; - os << var->getName().toString() << "," ; + os << var->getName() << "," ; } os << "}" << std::endl; @@ -1449,7 +1481,7 @@ namespace EUROPA { * RuleInstanceEvalContext * Puts Token variables like duration, start, end, in context */ - TokenEvalContext::TokenEvalContext(EvalContext* parent, const TokenId& token) + TokenEvalContext::TokenEvalContext(EvalContext* parent, const TokenId token) : EvalContext(parent) , m_token(token) { @@ -1459,43 +1491,41 @@ namespace EUROPA { { } - TokenId& TokenEvalContext::getToken() { return m_token; } +TokenId TokenEvalContext::getToken() { return m_token; } +TokenId TokenEvalContext::getToken(const std::string&) { return m_token; } - ConstrainedVariableId TokenEvalContext::getVar(const char* name) - { - ConstrainedVariableId var = m_token->getVariable(LabelStr(name)); +ConstrainedVariableId TokenEvalContext::getVar(const std::string& name) { + ConstrainedVariableId var = m_token->getVariable(name); - if (!var.isNoId()) { - debugMsg("Interpreter:EvalContext:Token","Found var in token :" << name); - return var; - } - else - return EvalContext::getVar(name); + if (!var.isNoId()) { + debugMsg("Interpreter:EvalContext:Token","Found var in token :" << name); + return var; } + else + return EvalContext::getVar(name); +} - void* TokenEvalContext::getElement(const char* name) const - { - std::string str(name); - if (str == "Token") - return (Token*)m_token; - if (str == "PlanDatabase") - return (PlanDatabase*)m_token->getPlanDatabase(); +void* TokenEvalContext::getElement(const std::string& name) const { + std::string str(name); + if (str == "Token") + return static_cast(m_token); + if (str == "PlanDatabase") + return static_cast(m_token->getPlanDatabase()); - return EvalContext::getElement(name); - } + return EvalContext::getElement(name); +} - bool TokenEvalContext::isClass(const LabelStr& className) const - { - return m_token->getPlanDatabase()->getSchema()->isObjectType(className); - } +bool TokenEvalContext::isClass(const std::string& className) const { + return m_token->getPlanDatabase()->getSchema()->isObjectType(className); +} /* * InterpretedRuleInstance */ - InterpretedRuleInstance::InterpretedRuleInstance(const RuleId& rule, - const TokenId& token, - const PlanDatabaseId& planDb, + InterpretedRuleInstance::InterpretedRuleInstance(const RuleId rule, + const TokenId token, + const PlanDatabaseId planDb, const std::vector& body) : RuleInstance(rule, token, planDb) , m_body(body) @@ -1503,8 +1533,8 @@ namespace EUROPA { } InterpretedRuleInstance::InterpretedRuleInstance( - const RuleInstanceId& parent, - const ConstrainedVariableId& var, + const RuleInstanceId parent, + const ConstrainedVariableId var, const Domain& domain, const bool positive, const std::vector& body) @@ -1513,8 +1543,19 @@ namespace EUROPA { { } +InterpretedRuleInstance::InterpretedRuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId var, + const Domain& domain, + const bool positive, + const std::vector& guardComponents, + const std::vector& body) + : RuleInstance(parent,var,domain,positive, guardComponents) + , m_body(body) + { + } + InterpretedRuleInstance::InterpretedRuleInstance( - const RuleInstanceId& parent, + const RuleInstanceId parent, const std::vector& vars, const bool positive, const std::vector& body) @@ -1535,7 +1576,7 @@ namespace EUROPA { RuleInstanceEvalContext evalContext(NULL,getId()); debugMsg("Interpreter:InterpretedRule", - "Executing interpreted rule: " << getRule()->getName().toString() << ":" << getRule()->getSource().toString() << + "Executing interpreted rule: " << getRule()->getName() << ":" << getRule()->getSource() << "token: " << m_token->toString()); for(std::vector::const_iterator it = m_body.begin(); it != m_body.end(); ++it) { @@ -1548,160 +1589,153 @@ namespace EUROPA { } debugMsg("Interpreter:InterpretedRule", - "Executed interpreted rule: " << getRule()->getName().toString() << ":" << getRule()->getSource().toString() << + "Executed interpreted rule: " << getRule()->getName() << ":" << getRule()->getSource() << "token: " << m_token->toString()); } - TokenId InterpretedRuleInstance::createSubgoal( - const LabelStr& name, - const LabelStr& predicateType, - const LabelStr& predicateInstance, - const LabelStr& relation, - bool isConstrained, - ConstrainedVariableId& owner) - { - TokenId slave; - - unsigned int tokenCnt = predicateInstance.countElements("."); - bool isOnSameObject = ( - tokenCnt == 1 || - (tokenCnt==2 && (predicateInstance.getElement(0,".").toString() == "object")) - ); - - if (isOnSameObject) { - // TODO: this is to support predicate inheritance - // currently doing the same as the compiler, it'll probably be surprising to the user that - // predicate inheritance will work only if the predicates are on the same object that the rule belongs to - LabelStr suffix = predicateInstance.getElement(tokenCnt-1,"."); - slave = NDDL::allocateOnSameObject(m_token,suffix,relation); - } - else { - slave = m_token->getPlanDatabase()->createSlaveToken(m_token,predicateType,relation); - } - addSlave(slave,name); - - // For qualified names like "object.helloWorld" must add constraint to the object variable on the slave token - // See RuleWriter.allocateSlave in Nddl compiler - if (isConstrained) { - std::vector vars; - - if (tokenCnt <= 2) { - vars.push_back(owner); - } - else { // equivalent of constrainObject() in NddlRules.hh - // TODO: this can be done more efficiently - int cnt = predicateInstance.countElements("."); - std::string ownerName(predicateInstance.getElement(0,".").toString()); - std::string tokenName(predicateInstance.getElement(cnt-1,".").toString()); - std::string fullName = predicateInstance.toString(); - std::string objectPath = fullName.substr( - ownerName.size()+1, - fullName.size()-(ownerName.size()+tokenName.size()+2) - ); - debugMsg("Interpreter:InterpretedRule","Subgoal slave object constraint. fullName=" << fullName << " owner=" << ownerName << " objPath=" << objectPath << " tokenName=" << tokenName); - vars.push_back(varFromObject(owner,objectPath,fullName)); - } +TokenId InterpretedRuleInstance::createSubgoal(const std::string& name, + const std::string& predicateType, + const std::string& predicateInstance, + const std::string& relation, + bool isConstrained, + ConstrainedVariableId owner) { + TokenId slave; + + unsigned long tokenCnt = + std::count(predicateInstance.begin(), predicateInstance.end(), '.') + 1; + bool isOnSameObject = ( + tokenCnt == 1 || + (tokenCnt==2 && (predicateInstance.substr(0,predicateInstance.find('.')) == "object")) + ); + + if (isOnSameObject) { + // TODO: this is to support predicate inheritance + // currently doing the same as the compiler, it'll probably be surprising to the user that + // predicate inheritance will work only if the predicates are on the same object that the rule belongs to + std::string suffix = predicateInstance.substr(predicateInstance.rfind('.') + 1); + slave = NDDL::allocateOnSameObject(m_token,suffix,relation); + } + else { + slave = m_token->getPlanDatabase()->createSlaveToken(m_token,predicateType,relation); + } + addSlave(slave,name); + + // For qualified names like "object.helloWorld" must add constraint to the object variable on the slave token + // See RuleWriter.allocateSlave in Nddl compiler + if (isConstrained) { + std::vector vars; - vars.push_back(slave->getObject()); - addConstraint(LabelStr("eq"),vars); + if (tokenCnt <= 2) { + vars.push_back(owner); } - else { - debugMsg("Interpreter:InterpretedRule",predicateInstance.toString() << " NotConstrained"); + else { // equivalent of constrainObject() in NddlRules.hh + // TODO: this can be done more efficiently + std::string ownerName(predicateInstance.substr(0, predicateInstance.find('.'))); + std::string tokenName(predicateInstance.substr(predicateInstance.rfind('.') + 1)); + std::string fullName = predicateInstance; + std::string objectPath = fullName.substr( + ownerName.size()+1, + fullName.size()-(ownerName.size()+tokenName.size()+2) + ); + debugMsg("Interpreter:InterpretedRule","Subgoal slave object constraint. fullName=" << fullName << " owner=" << ownerName << " objPath=" << objectPath << " tokenName=" << tokenName); + vars.push_back(varFromObject(owner,objectPath,fullName)); } - return slave; + vars.push_back(slave->getObject()); + addConstraint("eq",vars); } - - ConstrainedVariableId InterpretedRuleInstance::addLocalVariable( - const Domain& baseDomain, - bool canBeSpecified, - const LabelStr& name) - { - return addVariable(baseDomain,canBeSpecified,name); + else { + debugMsg("Interpreter:InterpretedRule",predicateInstance << " NotConstrained"); } - ConstrainedVariableId InterpretedRuleInstance::addObjectVariable( - const LabelStr& type, - const ObjectDomain& baseDomain, - bool canBeSpecified, - const LabelStr& name) - { - ConstrainedVariableId localVariable = addVariable(baseDomain,canBeSpecified,name); - getPlanDatabase()->makeObjectVariableFromType(type,localVariable); + return slave; +} - return localVariable; - } +ConstrainedVariableId InterpretedRuleInstance::addLocalVariable(const Domain& baseDomain, + bool canBeSpecified, + const std::string& name) { + return addVariable(baseDomain,canBeSpecified,name); +} - void InterpretedRuleInstance::executeLoop(EvalContext& evalContext, - const LabelStr& loopVarName, - const LabelStr& valueSet, - const std::vector& loopBody) - { - // Create a local domain based on the objects included in the valueSet - ConstrainedVariableId setVar = evalContext.getVar(valueSet.c_str()); - check_error(!setVar.isNoId(),"Loop var can't be NULL"); - const Domain& setVarDomain = setVar->derivedDomain(); - debugMsg("Interpreter:InterpretedRule","set var for loop :" << setVar->toString()); - debugMsg("Interpreter:InterpretedRule","set var domain for loop:" << setVarDomain.toString()); - const ObjectDomain& loopObjectSet = dynamic_cast(setVarDomain); +ConstrainedVariableId InterpretedRuleInstance::addObjectVariable(const std::string& type, + const ObjectDomain& baseDomain, + bool canBeSpecified, + const std::string& name) { + ConstrainedVariableId localVariable = addVariable(baseDomain,canBeSpecified,name); + getPlanDatabase()->makeObjectVariableFromType(type,localVariable); - if (loopObjectSet.isEmpty()) - return; // we're done + return localVariable; +} - // The lock is an assert check really +void InterpretedRuleInstance::executeLoop(EvalContext& evalContext, + const std::string& loopVarName, + const std::string& valueSet, + const std::vector& loopBody) { + // Create a local domain based on the objects included in the valueSet + ConstrainedVariableId setVar = evalContext.getVar(valueSet.c_str()); + check_error(!setVar.isNoId(),"Loop var can't be NULL"); + const Domain& setVarDomain = setVar->derivedDomain(); + debugMsg("Interpreter:InterpretedRule","set var for loop :" << setVar->toString()); + debugMsg("Interpreter:InterpretedRule","set var domain for loop:" << setVarDomain.toString()); + const ObjectDomain& loopObjectSet = dynamic_cast(setVarDomain); + + if (loopObjectSet.isEmpty()) + return; // we're done + + // The lock is an assert check really + { + std::vector loop_vars; + loop_vars.push_back(setVar); + loop_vars.push_back(ruleVariable(loopObjectSet)); + rule_constraint(filterLock, loop_vars); + } + std::list loopObjectSet_values; + loopObjectSet.getValues(loopObjectSet_values); + + // Translate into a set ordered by key to ensure reliable ordering across runs + ObjectSet loopObjectSet_valuesByKey; + for(std::list::iterator it=loopObjectSet_values.begin(); + it!=loopObjectSet_values.end(); ++it) { + ObjectId t = Entity::getTypedEntity(*it); + loopObjectSet_valuesByKey.insert(t); + } + + // iterate over loop collection + for(ObjectSet::const_iterator it=loopObjectSet_valuesByKey.begin() + ;it!=loopObjectSet_valuesByKey.end(); ++it) { + ObjectId loop_var = *it; + check_error(loop_var.isValid()); + + // Allocate a local variable for this singleton object + // see loopVar(Allocation, a); { - std::vector loop_vars; - loop_vars.push_back(setVar); - loop_vars.push_back(ruleVariable(loopObjectSet)); - rule_constraint(filterLock, loop_vars); - } - std::list loopObjectSet_values; - loopObjectSet.getValues(loopObjectSet_values); - - // Translate into a set ordered by key to ensure reliable ordering across runs - ObjectSet loopObjectSet_valuesByKey; - for(std::list::iterator it=loopObjectSet_values.begin(); - it!=loopObjectSet_values.end(); ++it) { - ObjectId t = Entity::getTypedEntity(*it); - loopObjectSet_valuesByKey.insert(t); + ObjectDomain loopVarDomain(setVarDomain.getDataType()); + loopVarDomain.insert(loop_var->getKey()); + loopVarDomain.close(); + // This will automatically put it in the evalContext, since all RuleInstance vars are reachable there + addVariable(loopVarDomain, false, loopVarName); } - // iterate over loop collection - for(ObjectSet::const_iterator it=loopObjectSet_valuesByKey.begin() - ;it!=loopObjectSet_valuesByKey.end(); ++it) { - ObjectId loop_var = *it; - check_error(loop_var.isValid()); - - // Allocate a local variable for this singleton object - // see loopVar(Allocation, a); - { - ObjectDomain loopVarDomain(setVarDomain.getDataType()); - loopVarDomain.insert(loop_var->getKey()); - loopVarDomain.close(); - // This will automatically put it in the evalContext, since all RuleInstance vars are reachable there - addVariable(loopVarDomain, false, loopVarName); - } - - // execute loop body - for (unsigned int i=0; i < loopBody.size(); i++) - loopBody[i]->eval(evalContext); - - clearLoopVar(loopVarName); - } + // execute loop body + for (unsigned int i=0; i < loopBody.size(); i++) + loopBody[i]->eval(evalContext); + + clearLoopVar(loopVarName); } +} /* * InterpretedRuleFactory */ - InterpretedRuleFactory::InterpretedRuleFactory(const LabelStr& predicate, - const LabelStr& source, - const std::vector& body) +InterpretedRuleFactory::InterpretedRuleFactory(const std::string& predicate, + const std::string& source, + const std::vector& body) : Rule(predicate,source) , m_body(body) { debugMsg("InterpretedRuleFactory:InterpretedRuleFactory", - "Instantiating rule for " << source.toString()); + "Instantiating rule for " << source); for(std::vector::const_iterator it = body.begin(); it != body.end(); ++it) { debugMsg("InterpretedRuleFactory:InterpretedRuleFactory", (*it)->toString()); @@ -1717,8 +1751,8 @@ namespace EUROPA { } RuleInstanceId InterpretedRuleFactory::createInstance( - const TokenId& token, - const PlanDatabaseId& planDb, + const TokenId token, + const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const { InterpretedRuleInstance *foo = new InterpretedRuleInstance(m_id, token, planDb, m_body); @@ -1731,7 +1765,7 @@ namespace EUROPA { return m_body; } - ExprTypedef::ExprTypedef(const DataTypeId& baseType, const char* name, Domain* baseDomain) + ExprTypedef::ExprTypedef(const DataTypeId baseType, const std::string& name, Domain* baseDomain) : m_baseType(baseType) , m_name(name) , m_baseDomain(baseDomain) @@ -1745,7 +1779,7 @@ namespace EUROPA { DataRef ExprTypedef::eval(EvalContext& context) const { - const char* name = m_name.c_str(); + const std::string& name = m_name.c_str(); const Domain& domain = *m_baseDomain; debugMsg("Interpreter:typedef","Defining type:" << name); @@ -1771,12 +1805,12 @@ namespace EUROPA { { std::ostringstream os; - os << "TYPEDEF:" << m_baseType->getName().toString() << " -> " << m_name.toString(); + os << "TYPEDEF:" << m_baseType->getName() << " -> " << m_name; return os.str(); } - ExprEnumdef::ExprEnumdef(const char* name, const std::vector& values) + ExprEnumdef::ExprEnumdef(const std::string& name, const std::vector& values) : m_name(name) , m_values(values) { @@ -1786,44 +1820,42 @@ namespace EUROPA { { } - DataRef ExprEnumdef::eval(EvalContext& context) const - { - const char* enumName = m_name.c_str(); - // TODO: hack! drop this after Core.nddl goes away - if (strcmp(enumName,"TokenStates") == 0) { - debugMsg("Interpreter:defineEnumeration","Ignoring redefinition for TokenStates enum"); - return DataRef::null; - } +DataRef ExprEnumdef::eval(EvalContext& context) const { + const std::string& enumName = m_name; + // TODO: hack! drop this after Core.nddl goes away + if (enumName == "TokenStates") { + debugMsg("Interpreter:defineEnumeration","Ignoring redefinition for TokenStates enum"); + return DataRef::null; + } - debugMsg("Interpreter:enumdef","Defining enum:" << enumName); + debugMsg("Interpreter:enumdef","Defining enum:" << enumName); - std::list values; - for(unsigned int i=0;iregisterEnum(enumName,domain); + std::list values; + std::copy(m_values.begin(), m_values.end(), std::back_inserter(values)); - debugMsg("Interpreter:enumdef" - , "Created type factory " << enumName << - " with base domain " << domain.toString()); + EnumeratedDomain domain(SymbolDT::instance(),values); - return DataRef::null; - } + SchemaId schema = getSchema(context); + schema->registerEnum(enumName,domain); + + debugMsg("Interpreter:enumdef" + , "Created type factory " << enumName << + " with base domain " << domain.toString()); + + return DataRef::null; +} std::string ExprEnumdef::toString() const { std::ostringstream os; - os << "ENUMDEF:" << m_name.toString(); + os << "ENUMDEF:" << m_name; return os.str(); } - ExprVarDeclaration::ExprVarDeclaration(const char* name, const DataTypeId& type, Expr* initValue, bool canBeSpecified) + ExprVarDeclaration::ExprVarDeclaration(const std::string& name, const DataTypeId type, Expr* initValue, bool canBeSpecified) : m_name(name) , m_type(type) , m_initValue(initValue) @@ -1837,7 +1869,7 @@ namespace EUROPA { delete m_initValue; } - const LabelStr& ExprVarDeclaration::getName() const { return m_name; } +const std::string& ExprVarDeclaration::getName() const { return m_name; } const DataTypeId ExprVarDeclaration::getDataType() const { return m_type; } const Expr* ExprVarDeclaration::getInitValue() const { return m_initValue; } void ExprVarDeclaration::setInitValue(Expr* iv) { m_initValue = iv; } @@ -1862,120 +1894,117 @@ namespace EUROPA { return DataRef(v); } - ConstrainedVariableId ExprVarDeclaration::makeGlobalVar(EvalContext& context) const - { - const LabelStr& name = getName(); - const LabelStr& type = getDataType()->getName(); - const Expr* initValue = getInitValue(); - const DbClientId& pdb = getPDB(context); - - ConstrainedVariableId v; +ConstrainedVariableId ExprVarDeclaration::makeGlobalVar(EvalContext& context) const { + const std::string& name = getName(); + const std::string& type = getDataType()->getName(); + const Expr* initValue = getInitValue(); + const DbClientId pdb = getPDB(context); - if (initValue != NULL) { - v = pdb->createVariable( - type.c_str(), - initValue->eval(context).getValue()->baseDomain(), // baseDomain - name.c_str(), - false, // isTmpVar - m_canBeSpecified - ); - } - else { - v = pdb->createVariable( - type.c_str(), - name.c_str() - ); - } + ConstrainedVariableId v; - return v; + if (initValue != NULL) { + v = pdb->createVariable( + type.c_str(), + initValue->eval(context).getValue()->baseDomain(), // baseDomain + name.c_str(), + false, // isTmpVar + m_canBeSpecified + ); + } + else { + v = pdb->createVariable( + type.c_str(), + name.c_str() + ); } - ConstrainedVariableId ExprVarDeclaration::makeTokenVar(TokenEvalContext& context) const - { - const LabelStr& parameterName = getName(); - const LabelStr& parameterType = getDataType()->getName(); - const Expr* initValue = getInitValue(); - TokenId token=context.getToken(); - - check_runtime_error(token->getVariable(parameterName,false) == ConstrainedVariableId::noId(), - "Token parameter "+parameterName.toString()+ " already exists!"); - - // This is a hack needed because TokenVariable is parametrized by the domain arg to addParameter - ConstrainedVariableId parameter; - const DataTypeId& parameterDataType = getDataType(); - - // same as completeObjectParam in NddlRules.hh - if(initValue != NULL) { - Domain* bd = parameterDataType->baseDomain().copy(); - ConstrainedVariableId rhs = initValue->eval(context).getValue(); - bd->intersect(rhs->lastDomain()); - parameter = token->addParameter( - *bd, - parameterName - ); - delete bd; - if (context.isClass(parameterName)) - token->getPlanDatabase()->makeObjectVariableFromType(parameterType, parameter); - } - else { - if (context.isClass(parameterType)) { - parameter = token->addParameter( - ObjectDomain(parameterDataType), - parameterName - ); - token->getPlanDatabase()->makeObjectVariableFromType(parameterType, parameter); - } - else { - parameter = token->addParameter( - parameterDataType->baseDomain(), - parameterName - ); - } - } - - debugMsg("Interpreter:InterpretedToken","Token " << token->getPredicateName().toString() << " added Parameter " - << parameter->toString() << " " << parameterName.toString()); + return v; +} - return parameter; +ConstrainedVariableId ExprVarDeclaration::makeTokenVar(TokenEvalContext& context) const { + const std::string& parameterName = getName(); + const std::string& parameterType = getDataType()->getName(); + const Expr* initValue = getInitValue(); + TokenId token=context.getToken(); + + check_runtime_error(token->getVariable(parameterName,false) == ConstrainedVariableId::noId(), + "Token parameter "+parameterName+ " already exists!"); + + // This is a hack needed because TokenVariable is parametrized by the domain arg to addParameter + ConstrainedVariableId parameter; + const DataTypeId parameterDataType = getDataType(); + + // same as completeObjectParam in NddlRules.hh + if(initValue != NULL) { + Domain* bd = parameterDataType->baseDomain().copy(); + ConstrainedVariableId rhs = initValue->eval(context).getValue(); + bd->intersect(rhs->lastDomain()); + parameter = token->addParameter( + *bd, + parameterName + ); + delete bd; + if (context.isClass(parameterName)) + token->getPlanDatabase()->makeObjectVariableFromType(parameterType, parameter); + } + else { + if (context.isClass(parameterType)) { + parameter = token->addParameter( + ObjectDomain(parameterDataType), + parameterName + ); + token->getPlanDatabase()->makeObjectVariableFromType(parameterType, parameter); + } + else { + parameter = token->addParameter( + parameterDataType->baseDomain(), + parameterName + ); + } } - ConstrainedVariableId ExprVarDeclaration::makeRuleVar(RuleInstanceEvalContext& context) const - { - const LabelStr typeName = getDataType()->getName(); + debugMsg("Interpreter:InterpretedToken","Token " << token->getPredicateName() << " added Parameter " + << parameter->toString() << " " << parameterName); - ConstrainedVariableId localVar; - if (context.isClass(typeName)) { - const DataTypeId& dt = context.getRuleInstance()->getPlanDatabase()->getSchema()->getCESchema()->getDataType(typeName.c_str()); - localVar = context.getRuleInstance()->addObjectVariable( - getDataType()->getName(), - ObjectDomain(dt), - m_canBeSpecified, - m_name - ); - } - else { - // TODO: do we really need to pass the base domain? - const Domain& baseDomain = context.getRuleInstance()->getPlanDatabase()->getSchema()->getCESchema()->baseDomain(typeName.c_str()); - localVar = context.getRuleInstance()->addLocalVariable( - baseDomain, - m_canBeSpecified, - m_name - ); - } - - if (m_initValue != NULL) - localVar->restrictBaseDomain(m_initValue->eval(context).getValue()->derivedDomain()); + return parameter; +} - context.addVar(m_name.c_str(),localVar); - debugMsg("Interpreter:InterpretedRule","Added RuleInstance local var:" << localVar->toLongString()); - return localVar; - } +ConstrainedVariableId ExprVarDeclaration::makeRuleVar(RuleInstanceEvalContext& context) const { + const std::string typeName = getDataType()->getName(); + + ConstrainedVariableId localVar; + if (context.isClass(typeName)) { + const DataTypeId dt = context.getRuleInstance()->getPlanDatabase()->getSchema()->getCESchema()->getDataType(typeName.c_str()); + localVar = context.getRuleInstance()->addObjectVariable( + getDataType()->getName(), + ObjectDomain(dt), + m_canBeSpecified, + m_name + ); + } + else { + // TODO: do we really need to pass the base domain? + const Domain& baseDomain = context.getRuleInstance()->getPlanDatabase()->getSchema()->getCESchema()->baseDomain(typeName.c_str()); + localVar = context.getRuleInstance()->addLocalVariable( + baseDomain, + m_canBeSpecified, + m_name + ); + } + + if (m_initValue != NULL) + localVar->restrictBaseDomain(m_initValue->eval(context).getValue()->derivedDomain()); + + context.addVar(m_name.c_str(),localVar); + debugMsg("Interpreter:InterpretedRule","Added RuleInstance local var:" << localVar->toLongString()); + return localVar; +} std::string ExprVarDeclaration::toString() const { std::ostringstream os; - os << m_type->getName().c_str() << " " << m_name.toString(); + os << m_type->getName().c_str() << " " << m_name; if (m_initValue != NULL) os << " " << m_initValue->toString(); @@ -1999,7 +2028,7 @@ namespace EUROPA { DataRef lhs; std::string varNameStr = m_lhs->toString(); - const char* varName = varNameStr.c_str(); // TODO: this is a hack! + const std::string& varName = varNameStr.c_str(); // TODO: this is a hack! ConstrainedVariableId thisVar = context.getVar("this"); // TODO: modify interpreted object constructor to add vars upfront so that this if stmt isn't necessary @@ -2010,14 +2039,14 @@ namespace EUROPA { const Domain& domain = rhsValue->derivedDomain(); ConstrainedVariableId v = object->addVariable(domain,varName); lhs = DataRef(v); - debugMsg("Interpreter:InterpretedObject","Initialized variable:" << object->getName().toString() << "." << varName << " to " << rhsValue->derivedDomain().toString() << " in constructor"); + debugMsg("Interpreter:InterpretedObject","Initialized variable:" << object->getName() << "." << varName << " to " << rhsValue->derivedDomain().toString() << " in constructor"); } else { lhs = m_lhs->eval(context); if (m_rhs != NULL) { DataRef rhs = m_rhs->eval(context); - const DbClientId& pdb = getPDB(context); + const DbClientId pdb = getPDB(context); if (rhs.getValue()->lastDomain().isSingleton()) { pdb->restrict(lhs.getValue(),rhs.getValue()->lastDomain()); @@ -2044,10 +2073,10 @@ namespace EUROPA { } - ExprObjectTypeDeclaration::ExprObjectTypeDeclaration(const LabelStr& name) - : m_name(name) - { - } +ExprObjectTypeDeclaration::ExprObjectTypeDeclaration(const std::string& name) + : m_name(name) +{ +} ExprObjectTypeDeclaration::~ExprObjectTypeDeclaration() { @@ -2072,7 +2101,7 @@ namespace EUROPA { } - ExprObjectTypeDefinition::ExprObjectTypeDefinition(const ObjectTypeId& objType) + ExprObjectTypeDefinition::ExprObjectTypeDefinition(const ObjectTypeId objType) : m_registered(false) , m_objType(objType) { @@ -2082,7 +2111,7 @@ namespace EUROPA { { if (!m_registered) { m_objType->purgeAll(); - delete (ObjectType*)m_objType; + delete static_cast(m_objType); } } @@ -2115,7 +2144,7 @@ namespace EUROPA { return os.str(); } - ExprRuleTypeDefinition::ExprRuleTypeDefinition(const RuleId& rf) + ExprRuleTypeDefinition::ExprRuleTypeDefinition(const RuleId rf) : m_ruleFactory(rf) { } @@ -2126,7 +2155,7 @@ namespace EUROPA { DataRef ExprRuleTypeDefinition::eval(EvalContext& context) const { - RuleSchema* rs = (RuleSchema*)context.getElement("RuleSchema"); + RuleSchema* rs = reinterpret_cast(context.getElement("RuleSchema")); rs->registerRule(m_ruleFactory); return DataRef::null; } @@ -2140,13 +2169,16 @@ namespace EUROPA { return os.str(); } - void evalArgs(EvalContext& context, std::vector& args,const std::vector& argExprs) - { - for (unsigned int i=0;ieval(context).getValue()); - } +namespace { +void evalArgs(EvalContext& context, + std::vector& args, + const std::vector& argExprs) { + for (unsigned int i=0;ieval(context).getValue()); +} +} - ExprMethodCall::ExprMethodCall(const MethodId& m, Expr* varExpr, const std::vector& argExprs) + ExprMethodCall::ExprMethodCall(const MethodId m, Expr* varExpr, const std::vector& argExprs) : m_method(m) , m_varExpr(varExpr) , m_argExprs(argExprs) @@ -2189,7 +2221,7 @@ namespace EUROPA { return os.str(); } - ExprVariableMethod::ExprVariableMethod(const char* name, Expr* varExpr, const std::vector& argExprs) + ExprVariableMethod::ExprVariableMethod(const std::string& name, Expr* varExpr, const std::vector& argExprs) : m_methodName(name) , m_varExpr(varExpr) , m_argExprs(argExprs) @@ -2221,9 +2253,9 @@ namespace EUROPA { return eval(context,var,args); } - DataRef ExprVariableMethod::eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const + DataRef ExprVariableMethod::eval(EvalContext& context, ConstrainedVariableId var, const std::vector& args) const { - std::string method(m_methodName.toString()); + std::string method(m_methodName); DbClientId pdb = getPDB(context); // TODO: keep using db client? if (method=="specify") { @@ -2257,7 +2289,7 @@ namespace EUROPA { return os.str(); } - ExprObjectMethod::ExprObjectMethod(const char* name, Expr* objExpr, const std::vector& argExprs) + ExprObjectMethod::ExprObjectMethod(const std::string& name, Expr* objExpr, const std::vector& argExprs) : m_methodName(name) , m_objExpr(objExpr) , m_argExprs(argExprs) @@ -2286,9 +2318,9 @@ namespace EUROPA { return eval(context,obj,args); } - DataRef ExprObjectMethod::eval(EvalContext& context, ObjectId& obj, const std::vector& args) const + DataRef ExprObjectMethod::eval(EvalContext& context, ObjectId obj, const std::vector& args) const { - std::string method(m_methodName.toString()); + std::string method(m_methodName); DbClientId pdb = getPDB(context); // TODO: keep using db client? StateVarId stateVar = args[0]; @@ -2316,7 +2348,7 @@ namespace EUROPA { return os.str(); } - ExprTokenMethod::ExprTokenMethod(const char* name, const char* tokenName, const std::vector& argExprs) + ExprTokenMethod::ExprTokenMethod(const std::string& name, const std::string& tokenName, const std::vector& argExprs) : m_methodName(name) , m_tokenName(tokenName) , m_argExprs(argExprs) @@ -2340,10 +2372,10 @@ namespace EUROPA { return eval(context,tok,args); } - DataRef ExprTokenMethod::eval(EvalContext& context, TokenId& tok, const std::vector& args) const + DataRef ExprTokenMethod::eval(EvalContext& context, TokenId tok, const std::vector& args) const { checkError(tok.isId(),"Can't evaluate method on null token"); - std::string method(m_methodName.toString()); + std::string method(m_methodName); DbClientId pdb = getPDB(context); // TODO: keep using db client? if (method=="activate") { @@ -2376,7 +2408,7 @@ namespace EUROPA { return os.str(); } - ExprProblemStmt::ExprProblemStmt(const char* name, const std::vector& tokens) + ExprProblemStmt::ExprProblemStmt(const std::string& name, const std::vector& tokens) : m_name(name) , m_tokens(tokens) { @@ -2413,5 +2445,89 @@ namespace EUROPA { return os.str(); } +void getVariableReferences(const Expr* expr, EvalContext& ctx, + std::vector& dest) { + checkError(expr != NULL, "Weird. Expression pointer is null."); + debugMsg("getVariableReferences", "Getting refs from " << expr->toString()); + if(dynamic_cast(expr) != NULL) { + const ExprList* e = dynamic_cast(expr); + for(std::vector::const_iterator it = e->getChildren().begin(); + it != e->getChildren().end(); ++it) { + getVariableReferences(*it, ctx, dest); + } + } + //ExprNoop -> nothing + //What to do about ExprConstructorSuperCall? + else if(dynamic_cast(expr) != NULL) { + //we may want to grab these after all, but for now, do nothing + } + //ExprVarDeclaration -> ? + else if(dynamic_cast(expr) != NULL) { + dest.push_back(dynamic_cast(expr)->eval(ctx).getValue()); + } + //ExprVarRef -> ? + //ExprAssignment -> ? + else if(dynamic_cast(expr) != NULL) { + const ExprConstraint* e = dynamic_cast(expr); + for(std::vector::const_iterator it = e->getArgs().begin(); + it != e->getArgs().end(); ++it) { + getVariableReferences(*it, ctx, dest); + } + } + //ExprTypedef -> nothing + //ExprEnumdef -> nothing + //ExprObjectTypeDeclaration -> nothing + //ExprObjectTypeDefinition -> nothing + //ExprRuleTypeDefinition -> nothing + else if(dynamic_cast(expr) != NULL) { + const ExprMethodCall* e = dynamic_cast(expr); + for(std::vector::const_iterator it = e->getArgs().begin(); + it != e->getArgs().end(); ++it) { + getVariableReferences(*it, ctx, dest); + } + } + //ExprVariableMethod -> ? + //ExprObjectMethod -> ? + //ExprTokenMethod -> ? + //ExprNewObject -> ? + //ExprProblemStatement -> ? + //ExprRelation -> ? + else if(dynamic_cast(expr) != NULL) { + if(dynamic_cast(expr) != NULL) { + const CExprFunction* e = dynamic_cast(expr); + for(std::vector::const_iterator it = e->getArgs().begin(); + it != e->getArgs().end(); ++it) { + getVariableReferences(*it, ctx, dest); + } + } + else if(dynamic_cast(expr) != NULL) { + //not sure this is right + dest.push_back(dynamic_cast(expr)->eval(ctx).getValue()); + } + else if(dynamic_cast(expr) != NULL) { + const CExprBinary* e = dynamic_cast(expr); + getVariableReferences(e->getLhs(), ctx, dest); + getVariableReferences(e->getRhs(), ctx, dest); + } + else { + checkRuntimeError(ALWAYS_FAIL, + "getVariableReferences doesn't know how to with this subclass" << + " of CExpr " << + expr->toString() << " <" << typeid(expr).name() << ">"); + } + } + //RuleExpr -> ? + else if(dynamic_cast(expr) != NULL) { + const ExprIfGuard* e = dynamic_cast(expr); + getVariableReferences(e->getLhs(), ctx, dest); + getVariableReferences(e->getRhs(), ctx, dest); + } + else { + checkRuntimeError(ALWAYS_FAIL, + "getVariableReferences doesn't know how to with this " << + expr->toString() << " <" << typeid(expr).name() << ">"); + } +} + } diff --git a/src/PLASMA/NDDL/component/Interpreter.hh b/src/PLASMA/NDDL/component/Interpreter.hh index e382a329a..4ac4cd79c 100644 --- a/src/PLASMA/NDDL/component/Interpreter.hh +++ b/src/PLASMA/NDDL/component/Interpreter.hh @@ -1,5 +1,5 @@ -#ifndef _H_Interpreter -#define _H_Interpreter +#ifndef H_Interpreter +#define H_Interpreter #include @@ -15,150 +15,159 @@ #include "Rule.hh" #include "RuleInstance.hh" +#include + namespace EUROPA { - class ExprConstant : public Expr - { - public: - ExprConstant(const char* type, const Domain* d); - virtual ~ExprConstant(); +class ExprConstant : public Expr { + public: + ExprConstant(const std::string& type, const Domain* d); + virtual ~ExprConstant(); - virtual DataRef eval(EvalContext& context) const; - virtual const DataTypeId getDataType() const; - virtual std::string toString() const; - std::string getConstantValue() const; + virtual DataRef eval(EvalContext& context) const; + virtual const DataTypeId getDataType() const; + virtual std::string toString() const; + std::string getConstantValue() const; - protected: - LabelStr m_type; - const Domain* m_domain; - }; + protected: + std::string m_type; + const Domain* m_domain; +private: + ExprConstant(const ExprConstant&); + ExprConstant& operator=(const ExprConstant&); +}; class TokenEvalContext; class RuleInstanceEvalContext; - class ExprVarDeclaration : public Expr - { - public: - ExprVarDeclaration(const char* name, const DataTypeId& type, Expr* initValue, bool canBeSpecified); - virtual ~ExprVarDeclaration(); - - virtual DataRef eval(EvalContext& context) const; - virtual const DataTypeId getDataType() const; - virtual std::string toString() const; - - const LabelStr& getName() const; - const Expr* getInitValue() const; - void setInitValue(Expr* iv); - - protected: - LabelStr m_name; - DataTypeId m_type; - Expr* m_initValue; - bool m_canBeSpecified; - - ConstrainedVariableId makeGlobalVar(EvalContext& context) const; - ConstrainedVariableId makeTokenVar(TokenEvalContext& context) const; - ConstrainedVariableId makeRuleVar(RuleInstanceEvalContext& context) const; - }; - - class ExprVarRef : public Expr - { - public: - ExprVarRef(const char* name, const DataTypeId& type); - virtual ~ExprVarRef(); - - virtual DataRef eval(EvalContext& context) const; - virtual const DataTypeId getDataType() const; - virtual std::string toString() const; - - protected: - std::string m_varName; - DataTypeId m_varType; - std::string m_parentName; - std::vector m_vars; - }; - - class ExprAssignment : public Expr - { - public: - ExprAssignment(Expr* lhs, Expr* rhs); - virtual ~ExprAssignment(); - - Expr* getLhs() { return m_lhs; } - Expr* getRhs() { return m_rhs; } - - virtual DataRef eval(EvalContext& context) const; - virtual std::string toString() const; - - protected: - Expr* m_lhs; - Expr* m_rhs; - }; +class ExprVarDeclaration : public Expr { + private: + ExprVarDeclaration(const ExprVarDeclaration&); + ExprVarDeclaration& operator=(const ExprVarDeclaration&); + public: + ExprVarDeclaration(const std::string& name, const DataTypeId type, Expr* initValue, bool canBeSpecified); + virtual ~ExprVarDeclaration(); + + virtual DataRef eval(EvalContext& context) const; + virtual const DataTypeId getDataType() const; + virtual std::string toString() const; + + const std::string& getName() const; + const Expr* getInitValue() const; + void setInitValue(Expr* iv); + + protected: + std::string m_name; + DataTypeId m_type; + Expr* m_initValue; + bool m_canBeSpecified; + + ConstrainedVariableId makeGlobalVar(EvalContext& context) const; + ConstrainedVariableId makeTokenVar(TokenEvalContext& context) const; + ConstrainedVariableId makeRuleVar(RuleInstanceEvalContext& context) const; +}; + +class ExprVarRef : public Expr { + public: + ExprVarRef(const std::string& name, const DataTypeId type); + virtual ~ExprVarRef(); + + virtual DataRef eval(EvalContext& context) const; + virtual const DataTypeId getDataType() const; + virtual std::string toString() const; + + protected: + std::string m_varName; + DataTypeId m_varType; + std::string m_parentName; + std::vector m_vars; +}; + +class ExprAssignment : public Expr { + private: + ExprAssignment(const ExprAssignment&); + ExprAssignment& operator=(const ExprAssignment&); + public: + ExprAssignment(Expr* lhs, Expr* rhs); + virtual ~ExprAssignment(); + + Expr* getLhs() { return m_lhs; } + Expr* getRhs() { return m_rhs; } + + virtual DataRef eval(EvalContext& context) const; + virtual std::string toString() const; + + protected: + Expr* m_lhs; + Expr* m_rhs; +}; class ExprConstraint : public Expr { public: - ExprConstraint(const char* name,const std::vector& args, const char* violationExpl); + ExprConstraint(const std::string& name,const std::vector& args, const std::string& violationExpl); virtual ~ExprConstraint(); virtual DataRef eval(EvalContext& context) const; - const LabelStr getName() const { return m_name; } + const std::string getName() const { return m_name; } const std::vector& getArgs() const { return m_args; } virtual std::string toString() const; protected: - LabelStr m_name; + std::string m_name; std::vector m_args; std::string m_violationExpl; }; - class ExprTypedef : public Expr - { - public: - ExprTypedef(const DataTypeId& baseType, const char* name, Domain* baseDomain); - virtual ~ExprTypedef(); +class ExprTypedef : public Expr { +private: + ExprTypedef(const ExprTypedef&); + ExprTypedef& operator=(const ExprTypedef&); + public: + ExprTypedef(const DataTypeId baseType, const std::string& name, Domain* baseDomain); + virtual ~ExprTypedef(); - virtual DataRef eval(EvalContext& context) const; - virtual std::string toString() const; + virtual DataRef eval(EvalContext& context) const; + virtual std::string toString() const; - protected: - DataTypeId m_baseType; - LabelStr m_name; - Domain* m_baseDomain; - }; + protected: + DataTypeId m_baseType; + std::string m_name; + Domain* m_baseDomain; +}; class ExprEnumdef : public Expr { public: - ExprEnumdef(const char* name, const std::vector& values); + ExprEnumdef(const std::string& name, const std::vector& values); virtual ~ExprEnumdef(); virtual DataRef eval(EvalContext& context) const; virtual std::string toString() const; protected: - LabelStr m_name; - std::vector m_values; + std::string m_name; + std::vector m_values; }; class ExprObjectTypeDeclaration : public Expr { public: - ExprObjectTypeDeclaration(const LabelStr& name); + ExprObjectTypeDeclaration(const std::string& name); virtual ~ExprObjectTypeDeclaration(); virtual DataRef eval(EvalContext& context) const; virtual std::string toString() const; protected: - LabelStr m_name; + std::string m_name; }; class ExprObjectTypeDefinition : public Expr { public: - ExprObjectTypeDefinition(const ObjectTypeId& objType); + ExprObjectTypeDefinition(const ObjectTypeId objType); virtual ~ExprObjectTypeDefinition(); virtual DataRef eval(EvalContext& context) const; @@ -172,7 +181,7 @@ namespace EUROPA { class ExprRuleTypeDefinition : public Expr { public: - ExprRuleTypeDefinition(const RuleId& rf); + ExprRuleTypeDefinition(const RuleId rf); virtual ~ExprRuleTypeDefinition(); virtual DataRef eval(EvalContext& context) const; @@ -182,77 +191,83 @@ namespace EUROPA { const RuleId m_ruleFactory; }; - class ExprMethodCall : public Expr - { - public: - ExprMethodCall(const MethodId& method, Expr* varExpr, const std::vector& argExprs); - virtual ~ExprMethodCall(); - - virtual DataRef eval(EvalContext& context) const; - virtual std::string toString() const; - - protected: - MethodId m_method; - Expr* m_varExpr; - std::vector m_argExprs; - }; - - class ExprVariableMethod : public Expr - { - public: - ExprVariableMethod(const char* name, Expr* varExpr, const std::vector& argExprs); - virtual ~ExprVariableMethod(); - - virtual DataRef eval(EvalContext& context) const; - virtual std::string toString() const; - - protected: - LabelStr m_methodName; - Expr* m_varExpr; - std::vector m_argExprs; - - DataRef eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const; - }; - - class ExprObjectMethod : public Expr - { - public: - ExprObjectMethod(const char* name, Expr* objExpr, const std::vector& argExprs); - virtual ~ExprObjectMethod(); - - virtual DataRef eval(EvalContext& context) const; - virtual std::string toString() const; - - protected: - LabelStr m_methodName; - Expr* m_objExpr; - std::vector m_argExprs; - - DataRef eval(EvalContext& context, ObjectId& var, const std::vector& args) const; - }; +class ExprMethodCall : public Expr { +private: + ExprMethodCall(const ExprMethodCall&); + ExprMethodCall& operator=(const ExprMethodCall&); + public: + ExprMethodCall(const MethodId method, Expr* varExpr, const std::vector& argExprs); + virtual ~ExprMethodCall(); + + virtual DataRef eval(EvalContext& context) const; + virtual std::string toString() const; + virtual const std::vector& getArgs() const {return m_argExprs;} + protected: + MethodId m_method; + Expr* m_varExpr; + std::vector m_argExprs; +}; + +class ExprVariableMethod : public Expr { +private: + ExprVariableMethod(const ExprVariableMethod&); + ExprVariableMethod& operator=(const ExprVariableMethod&); + public: + ExprVariableMethod(const std::string& name, Expr* varExpr, const std::vector& argExprs); + virtual ~ExprVariableMethod(); + + virtual DataRef eval(EvalContext& context) const; + virtual std::string toString() const; + + protected: + std::string m_methodName; + Expr* m_varExpr; + std::vector m_argExprs; + + DataRef eval(EvalContext& context, ConstrainedVariableId var, const std::vector& args) const; +}; + +class ExprObjectMethod : public Expr { +private: + ExprObjectMethod(const ExprObjectMethod&); + ExprObjectMethod& operator=(const ExprObjectMethod&); + public: + ExprObjectMethod(const std::string& name, Expr* objExpr, const std::vector& argExprs); + virtual ~ExprObjectMethod(); + + virtual DataRef eval(EvalContext& context) const; + virtual std::string toString() const; + + protected: + std::string m_methodName; + Expr* m_objExpr; + std::vector m_argExprs; + + DataRef eval(EvalContext& context, ObjectId var, const std::vector& args) const; +}; class ExprTokenMethod : public Expr { public: - ExprTokenMethod(const char* name, const char* tokenName, const std::vector& argExprs); + ExprTokenMethod(const std::string& name, const std::string& tokenName, const std::vector& argExprs); virtual ~ExprTokenMethod(); virtual DataRef eval(EvalContext& context) const; virtual std::string toString() const; protected: - LabelStr m_methodName; - LabelStr m_tokenName; + std::string m_methodName; + std::string m_tokenName; std::vector m_argExprs; - DataRef eval(EvalContext& context, TokenId& tok, const std::vector& args) const; + DataRef eval(EvalContext& context, TokenId tok, const std::vector& args) const; }; class ExprNewObject : public Expr { public: - ExprNewObject(const LabelStr& objectType, - const LabelStr& objectName, + ExprNewObject(const std::string& objectType, + const std::string& objectName, const std::vector& argExprs); virtual ~ExprNewObject(); @@ -262,98 +277,104 @@ namespace EUROPA { virtual std::string toString() const; protected: - LabelStr m_objectType; - LabelStr m_objectName; + std::string m_objectType; + std::string m_objectName; std::vector m_argExprs; }; class InterpretedRuleInstance; - class PredicateInstanceRef - { - public: - PredicateInstanceRef(const TokenTypeId& tokenType, const char* predInstance, const char* predName, const char* annotation); - virtual ~PredicateInstanceRef(); +class PredicateInstanceRef { + public: + PredicateInstanceRef(const TokenTypeId tokenType, const std::string& predInstance, + const std::string& predName, const std::string& annotation); + virtual ~PredicateInstanceRef(); - TokenId getToken(EvalContext& ctx, const char* relationName, bool isFact=false, bool isRejectable=false); - int getAttributes() const; - const TokenTypeId getTokenType(); + TokenId getToken(EvalContext& ctx, const std::string& relationName, bool isFact=false, + bool isRejectable=false); + int getAttributes() const; + const TokenTypeId getTokenType(); - protected: - TokenTypeId m_tokenType; - std::string m_predicateInstance; - std::string m_predicateName; - int m_attributes; + protected: + TokenTypeId m_tokenType; + std::string m_predicateInstance; + std::string m_predicateName; + int m_attributes; - TokenId createSubgoal(EvalContext& ctx, InterpretedRuleInstance* rule, const char* relationName); - TokenId createGlobalToken(EvalContext& context, bool isFact, bool isRejectable); - }; + TokenId createSubgoal(EvalContext& ctx, InterpretedRuleInstance* rule, const std::string& relationName); + TokenId createGlobalToken(EvalContext& context, bool isFact, bool isRejectable); +}; class ExprProblemStmt : public Expr { public: - ExprProblemStmt(const char* name, const std::vector& tokens); + ExprProblemStmt(const std::string& name, const std::vector& tokens); virtual ~ExprProblemStmt(); virtual DataRef eval(EvalContext& context) const; virtual std::string toString() const; protected: - LabelStr m_name; + std::string m_name; std::vector m_tokens; - DataRef eval(EvalContext& context, TokenId& tok, const std::vector& args) const; + DataRef eval(EvalContext& context, TokenId tok, const std::vector& args) const; }; class InterpretedTokenType; - class ExprRelation : public Expr - { - public: - ExprRelation(const char* relation, - PredicateInstanceRef* origin, - const std::vector& targets); - virtual ~ExprRelation(); +class ExprRelation : public Expr { +private: + ExprRelation(const ExprRelation&); + ExprRelation& operator=(const ExprRelation&); + public: + ExprRelation(const std::string& relation, + PredicateInstanceRef* origin, + const std::vector& targets); + virtual ~ExprRelation(); - virtual DataRef eval(EvalContext& context) const; + virtual DataRef eval(EvalContext& context) const; - void populateCausality( InterpretedTokenType* container ); + void populateCausality( InterpretedTokenType* container ); - protected: - LabelStr m_relation; - PredicateInstanceRef* m_origin; - std::vector m_targets; + protected: + std::string m_relation; + PredicateInstanceRef* m_origin; + std::vector m_targets; - }; +}; // Constraint Expressions - class CExpr : public Expr - { - public: - CExpr() : m_count(s_counter++), m_enforceContext(false), m_returnArgument(NULL) {} - virtual ~CExpr() {} - - virtual bool hasReturnValue() const = 0; - virtual void setEnforceContext() { m_enforceContext = true; } - virtual void setViolationMsg(const std::string& msg) { m_violationMsg = msg; } - virtual bool isSingleton() = 0; - virtual bool isSingletonOptimizable() = 0; // TODO: use output node method instead? (ask JRB) - virtual void checkType() = 0; - void setReturnArgument(CExpr *arg) { m_returnArgument = arg; } - - protected: - std::string createVariableName() const; - - static unsigned int s_counter; - unsigned int m_count; - bool m_enforceContext; - std::string m_violationMsg; - CExpr *m_returnArgument; // TODO: generalize this to output node (ask JRB) - }; +class CExpr : public Expr { +private: + CExpr(const CExpr&); + CExpr& operator=(const CExpr&); + public: + CExpr() : m_count(s_counter++), m_enforceContext(false), m_violationMsg(), + m_returnArgument(NULL) {} + virtual ~CExpr() {} + + virtual bool hasReturnValue() const = 0; + virtual void setEnforceContext() { m_enforceContext = true; } + virtual void setViolationMsg(const std::string& msg) { m_violationMsg = msg; } + virtual bool isSingleton() = 0; + virtual bool isSingletonOptimizable() = 0; // TODO: use output node method instead? (ask JRB) + virtual void checkType() = 0; + void setReturnArgument(CExpr *arg) { m_returnArgument = arg; } + + protected: + std::string createVariableName() const; + + static unsigned int s_counter; + unsigned int m_count; + bool m_enforceContext; + std::string m_violationMsg; + CExpr *m_returnArgument; // TODO: generalize this to output node (ask JRB) +}; class CExprFunction : public CExpr { public: - CExprFunction(const CFunctionId& func, const std::vector& args); + CExprFunction(const CFunctionId func, const std::vector& args); virtual ~CExprFunction() { /* TODO: release memory */ } // Expr methods @@ -370,77 +391,89 @@ namespace EUROPA { virtual void checkType(); + virtual const std::vector& getArgs() const {return m_args;} + protected: CFunctionId m_func; std::vector m_args; + private: + CExprFunction() : m_func(), m_args() {} }; - class CExprValue : public CExpr - { - public: - CExprValue(Expr* value); - virtual ~CExprValue() { /* TODO: release memory */ } +class CExprValue : public CExpr { +private: + CExprValue(const CExprValue&); + CExprValue& operator=(const CExprValue&); + public: + CExprValue(Expr* value); + virtual ~CExprValue() { /* TODO: release memory */ } - // Expr methods - virtual DataRef eval(EvalContext& context) const; + // Expr methods + virtual DataRef eval(EvalContext& context) const; - virtual const DataTypeId getDataType() const { return m_value->getDataType(); } + virtual const DataTypeId getDataType() const { return m_value->getDataType(); } - virtual std::string toString() const { return m_value->toString(); } + virtual std::string toString() const { return m_value->toString(); } - // CExpr methods - virtual bool hasReturnValue() const { return true; } - virtual bool isSingleton() { return true; /*TODO:not accurate?*/} - virtual bool isSingletonOptimizable() { return false; } + // CExpr methods + virtual bool hasReturnValue() const { return true; } + virtual bool isSingleton() { return true; /*TODO:not accurate?*/} + virtual bool isSingletonOptimizable() { return false; } - virtual void checkType(); + virtual void checkType(); - protected: - Expr* m_value; - }; + protected: + Expr* m_value; +}; // TODO: this still needs to be broken down more into cleaner pieces - class CExprBinary : public CExpr - { - public: - CExprBinary(std::string op, CExpr* left, CExpr* right); - virtual ~CExprBinary(); +class CExprBinary : public CExpr { + private: + CExprBinary(const CExprBinary&); + CExprBinary& operator=(const CExprBinary&); - // Expr methods - virtual DataRef eval(EvalContext& context) const; + public: + CExprBinary(std::string op, CExpr* left, CExpr* right); + virtual ~CExprBinary(); - virtual const DataTypeId getDataType() const; + // Expr methods + virtual DataRef eval(EvalContext& context) const; - virtual std::string toString() const; + virtual const DataTypeId getDataType() const; - // CExpr methods - virtual bool hasReturnValue() const; + virtual std::string toString() const; - virtual bool isSingleton(); + // CExpr methods + virtual bool hasReturnValue() const; - virtual bool isSingletonOptimizable(); + virtual bool isSingleton(); - virtual void checkType(); + virtual bool isSingletonOptimizable(); - protected: - std::string m_operator; - CExpr *m_lhs, *m_rhs; - }; + virtual void checkType(); + + virtual const CExpr* getLhs() const {return m_lhs;} + virtual const CExpr* getRhs() const {return m_rhs;} + + protected: + std::string m_operator; + CExpr *m_lhs, *m_rhs; +}; // InterpretedToken is the interpreted version of NddlToken class InterpretedToken : public IntervalToken { public: // Same Constructor signatures as NddlToken, TODO: see if both are needed - InterpretedToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + InterpretedToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const std::vector& body, const bool& rejectable = false, const bool& isFact = false, const bool& close = false); - InterpretedToken(const TokenId& master, - const LabelStr& predicateName, - const LabelStr& relation, + InterpretedToken(const TokenId master, + const std::string& predicateName, + const std::string& relation, const std::vector& body, const bool& close = false); @@ -456,60 +489,66 @@ namespace EUROPA { class InterpretedRuleFactory; - class InterpretedTokenType: public TokenType - { - public: - InterpretedTokenType(const ObjectTypeId& ot,const LabelStr& predicateName, const std::string& kind); - virtual ~InterpretedTokenType(); +class InterpretedTokenType: public TokenType { + public: + InterpretedTokenType(const ObjectTypeId ot,const std::string& predicateName, const std::string& kind); + virtual ~InterpretedTokenType(); - void addBodyExpr(Expr* e); - void addRule(InterpretedRuleFactory* rf); + void addBodyExpr(Expr* e); + void addRule(InterpretedRuleFactory* rf); - virtual TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable, bool isFact) const; - virtual TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const; + virtual TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, bool rejectable, bool isFact) const; + virtual TokenId createInstance(const TokenId master, const std::string& name, const std::string& relation) const; - protected: - std::vector m_body; - std::vector m_rules; - TokenTypeId getParentType(const PlanDatabaseId& planDb) const; - void processExpr(Expr* e); + protected: + std::vector m_body; + std::vector m_rules; + TokenTypeId getParentType(const PlanDatabaseId planDb) const; + void processExpr(Expr* e); - friend class ExprRelation; - }; + friend class ExprRelation; +}; - class TokenEvalContext : public EvalContext - { - public: - TokenEvalContext(EvalContext* parent, const TokenId& tok); - virtual ~TokenEvalContext(); +class TokenEvalContext : public EvalContext { + public: + TokenEvalContext(EvalContext* parent, const TokenId tok); + virtual ~TokenEvalContext(); - virtual ConstrainedVariableId getVar(const char* name); + virtual ConstrainedVariableId getVar(const std::string& name); - virtual void* getElement(const char* name) const; + virtual void* getElement(const std::string& name) const; - virtual bool isClass(const LabelStr& className) const; + virtual bool isClass(const std::string& className) const; - TokenId& getToken(); + TokenId getToken(); + TokenId getToken(const std::string& name); - protected: - TokenId m_token; - }; + protected: + TokenId m_token; +}; class InterpretedRuleInstance : public RuleInstance { public: - InterpretedRuleInstance(const RuleId& rule, - const TokenId& token, - const PlanDatabaseId& planDb, + InterpretedRuleInstance(const RuleId rule, + const TokenId token, + const PlanDatabaseId planDb, + const std::vector& body); + + InterpretedRuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId var, + const Domain& domain, + const bool positive, const std::vector& body); - InterpretedRuleInstance(const RuleInstanceId& parent, - const ConstrainedVariableId& var, + InterpretedRuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId var, const Domain& domain, const bool positive, + const std::vector& guardComponents, const std::vector& body); - InterpretedRuleInstance(const RuleInstanceId& parent, + InterpretedRuleInstance(const RuleInstanceId parent, const std::vector& vars, const bool positive, const std::vector& body); @@ -517,27 +556,27 @@ namespace EUROPA { virtual ~InterpretedRuleInstance(); TokenId createSubgoal( - const LabelStr& name, - const LabelStr& predicateType, - const LabelStr& predicateInstance, - const LabelStr& relation, + const std::string& name, + const std::string& predicateType, + const std::string& predicateInstance, + const std::string& relation, bool isConstrained, - ConstrainedVariableId& owner); + ConstrainedVariableId owner); ConstrainedVariableId addLocalVariable( const Domain& baseDomain, bool canBeSpecified, - const LabelStr& name); + const std::string& name); ConstrainedVariableId addObjectVariable( - const LabelStr& type, + const std::string& type, const ObjectDomain& baseDomain, bool canBeSpecified, - const LabelStr& name); + const std::string& name); void executeLoop(EvalContext& evalContext, - const LabelStr& loopVarName, - const LabelStr& valueSet, + const std::string& loopVarName, + const std::string& valueSet, const std::vector& loopBody); @@ -555,11 +594,11 @@ namespace EUROPA { class InterpretedRuleFactory : public Rule { public: - InterpretedRuleFactory(const LabelStr& predicate, const LabelStr& source, const std::vector& ruleBody); + InterpretedRuleFactory(const std::string& predicate, const std::string& source, const std::vector& ruleBody); virtual ~InterpretedRuleFactory(); - virtual RuleInstanceId createInstance(const TokenId& token, - const PlanDatabaseId& planDb, + virtual RuleInstanceId createInstance(const TokenId token, + const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const; const std::vector& getBody() const; @@ -571,17 +610,17 @@ namespace EUROPA { class RuleInstanceEvalContext : public EvalContext { public: - RuleInstanceEvalContext(EvalContext* parent, const InterpretedRuleInstanceId& ruleInstance); + RuleInstanceEvalContext(EvalContext* parent, const InterpretedRuleInstanceId ruleInstance); virtual ~RuleInstanceEvalContext(); - virtual void* getElement(const char* name) const; + virtual void* getElement(const std::string& name) const; - virtual ConstrainedVariableId getVar(const char* name); - virtual InterpretedRuleInstanceId& getRuleInstance() { return m_ruleInstance; } + virtual ConstrainedVariableId getVar(const std::string& name); + virtual InterpretedRuleInstanceId getRuleInstance() { return m_ruleInstance; } - virtual TokenId getToken(const char* name); + virtual TokenId getToken(const std::string& name); - virtual bool isClass(const LabelStr& className) const; + virtual bool isClass(const std::string& className) const; virtual std::string toString() const; @@ -594,77 +633,82 @@ namespace EUROPA { * */ - class RuleExpr : public Expr - { - public: - virtual DataRef eval(EvalContext& context) const - { - RuleInstanceEvalContext* ec = (RuleInstanceEvalContext*)&context; - return doEval(*ec); - } - - virtual DataRef doEval(RuleInstanceEvalContext& context) const = 0; - virtual ~RuleExpr(){} - }; - - class ExprIfGuard : public Expr - { - public: - ExprIfGuard(const char* op, Expr* lhs,Expr* rhs); - virtual ~ExprIfGuard(); - - const std::string& getOperator(); - Expr* getLhs(); - Expr* getRhs(); - - virtual DataRef eval(EvalContext& context) const; - virtual std::string toString() const; - - protected: - const std::string m_op; - Expr* m_lhs; - Expr* m_rhs; - - }; - - class ExprIf : public RuleExpr - { - public: - ExprIf(ExprIfGuard* guard,const std::vector& ifBody, const std::vector& elseBody); - virtual ~ExprIf(); - - virtual DataRef doEval(RuleInstanceEvalContext& context) const; - virtual std::string toString() const; - - protected: - ExprIfGuard* m_guard; - std::vector m_ifBody; - std::vector m_elseBody; - }; +class RuleExpr : public Expr { + public: + virtual DataRef eval(EvalContext& context) const + { + RuleInstanceEvalContext* ec = boost::polymorphic_cast(&context); + return doEval(*ec); + } + + virtual DataRef doEval(RuleInstanceEvalContext& context) const = 0; + virtual ~RuleExpr(){} +}; + +class ExprIfGuard : public Expr { +private: + ExprIfGuard(const ExprIfGuard&); + ExprIfGuard& operator=(const ExprIfGuard&); + public: + ExprIfGuard(const std::string& op, Expr* lhs,Expr* rhs); + virtual ~ExprIfGuard(); + + const std::string& getOperator(); + Expr* getLhs() const; + Expr* getRhs() const; + + virtual DataRef eval(EvalContext& context) const; + virtual std::string toString() const; + + protected: + const std::string m_op; + Expr* m_lhs; + Expr* m_rhs; + +}; + +class ExprIf : public RuleExpr { +private: + ExprIf(const ExprIf&); + ExprIf& operator=(const ExprIf&); + public: + ExprIf(ExprIfGuard* guard,const std::vector& ifBody, const std::vector& elseBody); + virtual ~ExprIf(); + + virtual DataRef doEval(RuleInstanceEvalContext& context) const; + virtual std::string toString() const; + + protected: + ExprIfGuard* m_guard; + std::vector m_ifBody; + std::vector m_elseBody; +}; class ExprLoop : public RuleExpr { public: - ExprLoop(const char* varName, const char* varValue,const std::vector& loopBody); + ExprLoop(const std::string& varName, const std::string& varValue,const std::vector& loopBody); virtual ~ExprLoop(); virtual DataRef doEval(RuleInstanceEvalContext& context) const; protected: - LabelStr m_varName; - LabelStr m_varValue; + std::string m_varName; + std::string m_varValue; std::vector m_loopBody; }; class NativeTokenType: public TokenType { public: - NativeTokenType(const ObjectTypeId& ot,const LabelStr& predicateName) : TokenType(ot,predicateName) {} + NativeTokenType(const ObjectTypeId ot,const std::string& predicateName) : TokenType(ot,predicateName) {} - virtual TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable, bool isFact) const = 0; - virtual TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const = 0; + virtual TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, bool rejectable, bool isFact) const = 0; + virtual TokenId createInstance(const TokenId master, const std::string& name, const std::string& relation) const = 0; }; +void getVariableReferences(const Expr* expr, EvalContext& ctx, std::vector& dest); + } -#endif // _H_Interpreter +#endif // H_Interpreter diff --git a/src/PLASMA/NDDL/component/NddlInterpreter.cc b/src/PLASMA/NDDL/component/NddlInterpreter.cc index 807a1d083..bf6985b8a 100644 --- a/src/PLASMA/NDDL/component/NddlInterpreter.cc +++ b/src/PLASMA/NDDL/component/NddlInterpreter.cc @@ -14,39 +14,50 @@ #include "NDDL3Tree.h" #include "antlr3exception.h" +#include "ConstraintType.hh" +#include "CESchema.hh" #include "Debug.hh" #include "Utils.hh" +#include "PathDefs.hh" + +#include +#include +#include namespace EUROPA { -NddlInterpreter::NddlInterpreter(EngineId& engine) - : m_engine(engine) -{ -} +NddlInterpreter::NddlInterpreter(EngineId engine) + : m_engine(engine), m_filesread(), m_inputstreams() {} NddlInterpreter::~NddlInterpreter() { } -pANTLR3_INPUT_STREAM getInputStream(std::istream& input, const std::string& source, std::string& strInput) -{ - if (source == "") { - // TODO: this is kind of a hack, see if it can be made more robust & efficient - std::istringstream* is = dynamic_cast(&input); - strInput = is->str(); // This makes a copy of the original string that could be avoided - - debugMsg("NddlInterpreter", "INPUT SCRIPT:" << std::endl << strInput); - return antlr3NewAsciiStringInPlaceStream((pANTLR3_UINT8)strInput.c_str(),(ANTLR3_UINT32)strInput.size(),(pANTLR3_UINT8)source.c_str()); - } - else { - return antlr3AsciiFileStreamNew((pANTLR3_UINT8)source.c_str()); +pANTLR3_INPUT_STREAM getInputStream(std::istream& input, const std::string& source, + std::string& strInput) { + if (source == "") { + // TODO: this is kind of a hack, see if it can be made more robust & efficient + std::istringstream* is = dynamic_cast(&input); + if(is != NULL) { + strInput = is->str(); // This makes a copy of the original string that could be avoided + + debugMsg("NddlInterpreter", "INPUT SCRIPT:" << std::endl << strInput); + return antlr3NewAsciiStringInPlaceStream(reinterpret_cast(const_cast(strInput.c_str())), + static_cast(strInput.size()), + reinterpret_cast(const_cast(source.c_str()))); } + } + else { + return antlr3AsciiFileStreamNew(reinterpret_cast(const_cast(source.c_str()))); + } + return NULL; } -bool isFile(const std::string& filename) -{ - struct stat my_stat; - return (stat(filename.c_str(), &my_stat) == 0); +namespace { +bool isFile(const std::string& filename) { + struct stat my_stat; + return (stat(filename.c_str(), &my_stat) == 0); +} } bool NddlInterpreter::queryIncludeGuard(const std::string& f) @@ -70,38 +81,34 @@ void NddlInterpreter::addInputStream(pANTLR3_INPUT_STREAM in) m_inputstreams.push_back(in); } -std::vector NddlInterpreter::getIncludePath() -{ - // TODO: cache this - std::vector includePath; +std::vector NddlInterpreter::getIncludePath() { + // TODO: cache this + std::vector includePath; - // Add overrides from config; - const std::string& configPathStr = getEngine()->getConfig()->getProperty("nddl.includePath"); - if (configPathStr.size() > 0) { - LabelStr configPath=configPathStr; - unsigned int cnt = configPath.countElements(PATH_SEPARATOR_STR.c_str()); - for (unsigned int i=0;igetConfig()->getProperty("nddl.includePath"); + if (configPathStr.size() > 0) { + boost::split(includePath, configPathStr, boost::is_any_of(PATH_SEPARATOR_STR)); + } - // Look in current dir first - includePath.push_back("."); + // Look in current dir first + includePath.push_back("."); - // otherwise, look in include path, starting with $EUROPA_HOME, then $PLASMA_HOME - const char* europaHome = std::getenv("EUROPA_HOME"); - if (europaHome != NULL) - includePath.push_back(std::string(europaHome)+ PATH_STR + "include"); - else // TODO: this should be at least INFO, possibly WARNING - debugMsg("NddlInterpreter","$EUROPA_HOME is not defined, therefore not added to NddlInterpreter include path"); + // otherwise, look in include path, starting with $EUROPA_HOME, then $PLASMA_HOME + const char* europaHome = std::getenv("EUROPA_HOME"); + if (europaHome != NULL) + includePath.push_back(std::string(europaHome)+ PATH_STR + "include"); + else // TODO: this should be at least INFO, possibly WARNING + debugMsg("NddlInterpreter","$EUROPA_HOME is not defined, therefore not added to NddlInterpreter include path"); - const char* plasmaHome = std::getenv("PLASMA_HOME"); - if (plasmaHome != NULL) { - includePath.push_back(std::string(plasmaHome)+ PATH_STR + "src" + PATH_STR + "PLASMA" + PATH_STR + "NDDL" + PATH_STR + "base"); - includePath.push_back(std::string(plasmaHome)+ PATH_STR + "src" + PATH_STR + "PLASMA" + PATH_STR + "Resource" + PATH_STR + "component" + PATH_STR +"NDDL"); - } + const char* plasmaHome = std::getenv("PLASMA_HOME"); + if (plasmaHome != NULL) { + includePath.push_back(std::string(plasmaHome)+ PATH_STR + "src" + PATH_STR + "PLASMA" + PATH_STR + "NDDL" + PATH_STR + "base"); + includePath.push_back(std::string(plasmaHome)+ PATH_STR + "src" + PATH_STR + "PLASMA" + PATH_STR + "Resource" + PATH_STR + "component" + PATH_STR +"NDDL"); + } - // TODO: dump includePath to log - return includePath; + // TODO: dump includePath to log + return includePath; } @@ -146,7 +153,8 @@ std::string NddlInterpreter::interpret(std::istream& ins, const std::string& sou // Build he AST NDDL3Parser_nddl_return result = parser->nddl(parser); - int errorCount = parser->pParser->rec->state->errorCount + lexer->pLexer->rec->state->errorCount; + unsigned int errorCount = parser->pParser->rec->state->errorCount + + lexer->pLexer->rec->state->errorCount; if (errorCount > 0) { // Since errors are no longer printed during parsing, print them here // to debugMsg @@ -191,13 +199,15 @@ std::string NddlInterpreter::interpret(std::istream& ins, const std::string& sou treeParser->nddl(treeParser); // TODO: report treeParser antlr errors the same way we do it for tree builder lexer and parser } - catch (const std::string& error) { - debugMsg("NddlInterpreter:error","nddl parser halted on error:" << symbolTable.getErrors()); + catch (const std::string&) { + debugMsg("NddlInterpreter:error", + "nddl parser halted on error:" << symbolTable.getErrors()); return symbolTable.getErrors(); } catch (const Error& internalError) { symbolTable.reportError(treeParser,internalError.getMsg()); - debugMsg("NddlInterpreter:error","nddl parser halted on error:" << symbolTable.getErrors()); + debugMsg("NddlInterpreter:error", + "nddl parser halted on error:" << symbolTable.getErrors()); return symbolTable.getErrors(); } @@ -221,13 +231,20 @@ std::string NddlInterpreter::interpret(std::istream& ins, const std::string& sou NddlSymbolTable::NddlSymbolTable(NddlSymbolTable* parent) : EvalContext(parent) , m_parentST(parent) + , m_engine() + , m_errors() + , m_localVars() + , m_localTokens() { } -NddlSymbolTable::NddlSymbolTable(const EngineId& engine) +NddlSymbolTable::NddlSymbolTable(const EngineId _engine) : EvalContext(NULL) , m_parentST(NULL) - , m_engine(engine) + , m_engine(_engine) + , m_errors() + , m_localVars() + , m_localTokens() { } @@ -237,7 +254,7 @@ NddlSymbolTable::~NddlSymbolTable() NddlSymbolTable* NddlSymbolTable::getParentST() { return m_parentST; } -const EngineId& NddlSymbolTable::engine() const { return (m_parentST==NULL ? m_engine : m_parentST->engine()); } +const EngineId NddlSymbolTable::engine() const { return (m_parentST==NULL ? m_engine : m_parentST->engine()); } std::vector& NddlSymbolTable::errors() { return (m_parentST==NULL ? m_errors : m_parentST->errors()); } const std::vector& NddlSymbolTable::errors() const { return (m_parentST==NULL ? m_errors : m_parentST->errors()); } @@ -257,7 +274,7 @@ std::string NddlSymbolTable::getErrors() const return os.str(); } -void* NddlSymbolTable::getElement(const char* name) const +void* NddlSymbolTable::getElement(const std::string& name) const { EngineComponent* component = engine()->getComponent(name); @@ -267,64 +284,61 @@ void* NddlSymbolTable::getElement(const char* name) const return EvalContext::getElement(name); } -const PlanDatabaseId& NddlSymbolTable::getPlanDatabase() const +const PlanDatabaseId NddlSymbolTable::getPlanDatabase() const { - return ((PlanDatabase*)getElement("PlanDatabase"))->getId(); + return (reinterpret_cast(getElement("PlanDatabase")))->getId(); } -DataTypeId NddlSymbolTable::getDataType(const char* name) const -{ - CESchemaId ces = ((CESchema*)getElement("CESchema"))->getId(); +DataTypeId NddlSymbolTable::getDataType(const std::string& name) const { + CESchemaId ces = (reinterpret_cast(getElement("CESchema")))->getId(); - if (ces->isDataType(name)) - return ces->getDataType(name); + if (ces->isDataType(name)) + return ces->getDataType(name); - debugMsg("NddlInterpreter:SymbolTable","Unknown type " << name); - return DataTypeId::noId(); + debugMsg("NddlInterpreter:SymbolTable","Unknown type " << name); + return DataTypeId::noId(); } -ObjectTypeId NddlSymbolTable::getObjectType(const char* name) const -{ - if (m_parentST != NULL) - return m_parentST->getObjectType(name); - else { - SchemaId s = ((Schema*)(engine()->getComponent("Schema")))->getId(); +ObjectTypeId NddlSymbolTable::getObjectType(const std::string& name) const { + if (m_parentST != NULL) + return m_parentST->getObjectType(name); + else { + SchemaId s = (boost::polymorphic_cast(engine()->getComponent("Schema")))->getId(); - if (s->isObjectType(name)) - return s->getObjectType(name); - } + if (s->isObjectType(name)) + return s->getObjectType(name); + } - return ObjectTypeId::noId(); + return ObjectTypeId::noId(); } -TokenTypeId NddlSymbolTable::getTokenType(const char* name) const -{ - if (m_parentST != NULL) - return m_parentST->getTokenType(name); - else { - SchemaId s = ((Schema*)(engine()->getComponent("Schema")))->getId(); +TokenTypeId NddlSymbolTable::getTokenType(const std::string& name) const { + if (m_parentST != NULL) + return m_parentST->getTokenType(name); + else { + SchemaId s = (boost::polymorphic_cast(engine()->getComponent("Schema")))->getId(); - if (s->isPredicate(name)) - return s->getTokenType(name); - } + if (s->isPredicate(name)) + return s->getTokenType(name); + } - return TokenTypeId::noId(); + return TokenTypeId::noId(); } -void NddlSymbolTable::addLocalVar(const char* name,const DataTypeId& type) +void NddlSymbolTable::addLocalVar(const std::string& name,const DataTypeId type) { m_localVars[name]=type; debugMsg("NddlSymbolTable:addLocalVar","Added local var "+std::string(name)); } -void NddlSymbolTable::addLocalToken(const char* name,const TokenTypeId& type) +void NddlSymbolTable::addLocalToken(const std::string& name,const TokenTypeId type) { m_localTokens[name]=type; debugMsg("NddlSymbolTable:addLocalToken","Added local token "+std::string(name)); } -DataTypeId NddlSymbolTable::getTypeForVar(const char* name) +DataTypeId NddlSymbolTable::getTypeForVar(const std::string& name) { if (m_localVars.find(name) != m_localVars.end()) return m_localVars[name]; @@ -337,7 +351,7 @@ DataTypeId NddlSymbolTable::getTypeForVar(const char* name) return DataTypeId::noId(); } -DataTypeId NddlSymbolTable::getTypeForVar(const char* qualifiedName,std::string& errorMsg) +DataTypeId NddlSymbolTable::getTypeForVar(const std::string& qualifiedName,std::string& errorMsg) { std::string parentName; std::vector vars; @@ -385,13 +399,13 @@ DataTypeId NddlSymbolTable::getTypeForVar(const char* qualifiedName,std::string& else { dt = tt->getArgType(vars[idx].c_str()); if (dt.isNoId()) { - errorMsg = curVarName+"("+tt->getPredicateName().toString()+") doesn't have a parameter called "+vars[idx]; + errorMsg = curVarName+"("+tt->getPredicateName()+") doesn't have a parameter called "+vars[idx]; return dt; } curVarName = vars[idx]; idx++; } - curVarType = dt->getName().toString(); + curVarType = dt->getName(); for (;idxgetName().toString(); + curVarType = dt->getName(); } } @@ -415,7 +429,7 @@ DataTypeId NddlSymbolTable::getTypeForVar(const char* qualifiedName,std::string& } -TokenTypeId NddlSymbolTable::getTypeForToken(const char* name) +TokenTypeId NddlSymbolTable::getTypeForToken(const std::string& name) { if (m_localTokens.find(name) != m_localTokens.end()) return m_localTokens[name]; @@ -432,112 +446,110 @@ TokenTypeId NddlSymbolTable::getTypeForToken(const char* name) } -TokenTypeId NddlSymbolTable::getTypeForToken(const char* qualifiedName,std::string& errorMsg) -{ - std::string parentName; - std::string tokenType; - std::vector vars; - std::string fullName(qualifiedName); - tokenize(fullName,vars,"."); +TokenTypeId NddlSymbolTable::getTypeForToken(const std::string& qualifiedName, + std::string& errorMsg) { + std::string parentName; + std::string tokenType; + std::vector vars; + std::string fullName(qualifiedName); + tokenize(fullName,vars,"."); - if (vars.size() > 1) { - parentName = vars[0]; - vars.erase(vars.begin()); - fullName = fullName.substr(parentName.length()+1); + if (vars.size() > 1) { + parentName = vars[0]; + vars.erase(vars.begin()); + fullName = fullName.substr(parentName.length()+1); - tokenType = vars.back(); - vars.erase(--vars.end()); - fullName = fullName.substr(0,fullName.length()-(tokenType.length())); + tokenType = vars.back(); + vars.erase(--vars.end()); + fullName = fullName.substr(0,fullName.length()-(tokenType.length())); - debugMsg("NddlSymbolTable:getTypeForToken","Split " << qualifiedName - << " into " << parentName - << " , " << tokenType - << " and " << fullName); - } - else { - parentName = ""; - debugMsg("NddlSymbolTable:getTypeForToken","Didn't split " << qualifiedName); - } + debugMsg("NddlSymbolTable:getTypeForToken","Split " << qualifiedName + << " into " << parentName + << " , " << tokenType + << " and " << fullName); + } + else { + parentName = ""; + debugMsg("NddlSymbolTable:getTypeForToken","Didn't split " << qualifiedName); + } - TokenTypeId tt; + TokenTypeId tt; - if (parentName == "") { - tt = getTokenType(qualifiedName); - if (tt.isNoId()) - errorMsg = fullName + " is not a predicate type"; + if (parentName == "") { + tt = getTokenType(qualifiedName); + if (tt.isNoId()) + errorMsg = fullName + " is not a predicate type"; + return tt; + } + else { + DataTypeId dt; + ObjectTypeId ot = getObjectType(parentName.c_str()); + if (ot.isId()) { + if (vars.size() > 1) { + errorMsg = std::string(qualifiedName)+" is not a predicate type"; return tt; + } + return getTokenType(qualifiedName); } else { - DataTypeId dt; - ObjectTypeId ot = getObjectType(parentName.c_str()); - if (ot.isId()) { - if (vars.size() > 1) { - errorMsg = std::string(qualifiedName)+" is not a predicate type"; - return tt; - } - return getTokenType(qualifiedName); - } - else { - dt = getTypeForVar(parentName.c_str()); - if (dt.isNoId()) { - errorMsg = parentName + " is not defined"; - return tt; - } - ot = getObjectType(dt->getName().c_str()); - if (ot.isNoId()) { - errorMsg = parentName+"("+dt->getName().c_str()+") is not a reference to an object"; - return tt; - } - } - - std::string curVarName=parentName; - std::string curVarType = dt->getName().toString(); - unsigned int idx = 0; - for (;idxgetMemberType(vars[idx].c_str()); - if (dt.isNoId()) { - errorMsg = curVarName+"("+curVarType+") doesn't have a member called "+vars[idx]; - return TokenTypeId::noId(); - } - - ot = getObjectType(dt->getName().c_str()); - if (ot.isNoId()) { - errorMsg = curVarName+"("+curVarType+") is not a reference to an object"; - return TokenTypeId::noId(); - } - - curVarName = vars[idx]; - curVarType = dt->getName().toString(); - } + dt = getTypeForVar(parentName.c_str()); + if (dt.isNoId()) { + errorMsg = parentName + " is not defined"; + return tt; + } + ot = getObjectType(dt->getName().c_str()); + if (ot.isNoId()) { + errorMsg = parentName+"("+dt->getName().c_str()+") is not a reference to an object"; + return tt; + } + } - tokenType = ot->getName().toString()+"."+tokenType; - debugMsg("NddlSymbolTable:getTypeForToken","looking for tokenType " << tokenType); - return getTokenType(tokenType.c_str()); + std::string curVarName=parentName; + std::string curVarType = dt->getName(); + unsigned int idx = 0; + for (;idxgetMemberType(vars[idx].c_str()); + if (dt.isNoId()) { + errorMsg = curVarName+"("+curVarType+") doesn't have a member called "+vars[idx]; + return TokenTypeId::noId(); + } + + ot = getObjectType(dt->getName().c_str()); + if (ot.isNoId()) { + errorMsg = curVarName+"("+curVarType+") is not a reference to an object"; + return TokenTypeId::noId(); + } + + curVarName = vars[idx]; + curVarType = dt->getName(); } - return tt; + tokenType = ot->getName()+"."+tokenType; + debugMsg("NddlSymbolTable:getTypeForToken","looking for tokenType " << tokenType); + return getTokenType(tokenType.c_str()); + } } -MethodId NddlSymbolTable::getMethod(const char* methodName,Expr* target,const std::vector& args) -{ - if (m_parentST != NULL) - return m_parentST->getMethod(methodName,target,args); +MethodId NddlSymbolTable::getMethod(const std::string& methodName,Expr* target, + const std::vector& args) { + if (m_parentST != NULL) + return m_parentST->getMethod(methodName,target,args); - std::vector argTypes; - for (unsigned int i=0;igetDataType()); + std::vector argTypes; + for (unsigned int i=0;igetDataType()); - DataTypeId targetDataType = (target != NULL ? target->getDataType() : DataTypeId::noId()); - return getPlanDatabase()->getSchema()->getMethod(LabelStr(methodName),targetDataType,argTypes); + DataTypeId targetDataType = (target != NULL ? target->getDataType() : DataTypeId::noId()); + return getPlanDatabase()->getSchema()->getMethod(methodName,targetDataType,argTypes); } -CFunctionId NddlSymbolTable::getCFunction(const char* name,const std::vector& args) +CFunctionId NddlSymbolTable::getCFunction(const std::string& name,const std::vector& args) { if (m_parentST != NULL) return m_parentST->getCFunction(name,args); - CFunctionId f = getPlanDatabase()->getSchema()->getCESchema()->getCFunction(LabelStr(name)); + CFunctionId f = getPlanDatabase()->getSchema()->getCESchema()->getCFunction(name); if (f.isId()) { std::vector argTypes; @@ -550,18 +562,17 @@ CFunctionId NddlSymbolTable::getCFunction(const char* name,const std::vectorgetId(); - Domain* retval = ces->baseDomain(type.c_str()).copy(); - edouble v = getPlanDatabase()->getClient()->createValue(type.c_str(), value); - retval->set(v); + const std::string& value) { + // TODO: only one copy should be kept for each literal, domains should be marked as constant + CESchemaId ces = (reinterpret_cast(getElement("CESchema")))->getId(); + Domain* retval = ces->baseDomain(type.c_str()).copy(); + edouble v = getPlanDatabase()->getClient()->createValue(type.c_str(), value); + retval->set(v); - return retval; + return retval; } -ConstrainedVariableId NddlSymbolTable::getVar(const char* name) +ConstrainedVariableId NddlSymbolTable::getVar(const std::string& name) { if (getPlanDatabase()->isGlobalVariable(name)) return getPlanDatabase()->getGlobalVariable(name); @@ -569,7 +580,7 @@ ConstrainedVariableId NddlSymbolTable::getVar(const char* name) return EvalContext::getVar(name); } -TokenId NddlSymbolTable::getToken(const char* name) +TokenId NddlSymbolTable::getToken(const std::string& name) { if (getPlanDatabase()->isGlobalToken(name)) return getPlanDatabase()->getGlobalToken(name); @@ -577,27 +588,24 @@ TokenId NddlSymbolTable::getToken(const char* name) return EvalContext::getToken(name); } -const LabelStr& NddlSymbolTable::getEnumForValue(const char* value) const -{ - if (m_parentST == NULL) - return getPlanDatabase()->getSchema()->getEnumForValue(LabelStr(value)); +const std::string& NddlSymbolTable::getEnumForValue(const std::string& value) const { + if (m_parentST == NULL) + return getPlanDatabase()->getSchema()->getEnumForValue(LabelStr(value)); - return m_parentST->getEnumForValue(value); + return m_parentST->getEnumForValue(value); } -bool NddlSymbolTable::isEnumValue(const char* value) const -{ - if (m_parentST == NULL) - return getPlanDatabase()->getSchema()->isEnumValue(LabelStr(value)); +bool NddlSymbolTable::isEnumValue(const std::string& value) const { + if (m_parentST == NULL) + return getPlanDatabase()->getSchema()->isEnumValue(LabelStr(value)); - return m_parentST->isEnumValue(value); + return m_parentST->isEnumValue(value); } -Expr* NddlSymbolTable::makeEnumRef(const char* value) const -{ - const LabelStr& enumType = getEnumForValue(value); - EnumeratedDomain* ad = dynamic_cast( - getPlanDatabase()->getSchema()->getCESchema()->baseDomain(enumType.c_str()).copy()); +Expr* NddlSymbolTable::makeEnumRef(const std::string& value) const { + const std::string& enumType = getEnumForValue(value); + EnumeratedDomain* ad = boost::polymorphic_cast( + getPlanDatabase()->getSchema()->getCESchema()->baseDomain(enumType.c_str()).copy()); edouble v = LabelStr(value); ad->set(v); @@ -605,13 +613,12 @@ Expr* NddlSymbolTable::makeEnumRef(const char* value) const } std::string getErrorLocation(pNDDL3Tree treeWalker); -void NddlSymbolTable::reportError(void* tw, const std::string& msg) -{ - pNDDL3Tree treeWalker = (pNDDL3Tree) tw; - addError(getErrorLocation(treeWalker) + "\n" + msg); +void NddlSymbolTable::reportError(void* tw, const std::string& msg) { + pNDDL3Tree treeWalker = reinterpret_cast(tw); + addError(getErrorLocation(treeWalker) + "\n" + msg); } -void NddlSymbolTable::checkConstraint(const char* name,const std::vector& args) +void NddlSymbolTable::checkConstraint(const std::string& name,const std::vector& args) { CESchemaId ceSchema = getPlanDatabase()->getSchema()->getCESchema(); if (!ceSchema->isConstraintType(name)) @@ -625,7 +632,7 @@ void NddlSymbolTable::checkConstraint(const char* name,const std::vector& ctype->checkArgTypes(argTypes); } -void NddlSymbolTable::checkObjectFactory(const char* name, const std::vector& args) +void NddlSymbolTable::checkObjectFactory(const std::string& name, const std::vector& args) { if (!getPlanDatabase()->getSchema()->isObjectType(name)) { throw std::string(name + std::string(" is not a valid object type.")); @@ -654,23 +661,23 @@ NddlClassSymbolTable::~NddlClassSymbolTable() { } -DataTypeId NddlClassSymbolTable::getDataType(const char* name) const +DataTypeId NddlClassSymbolTable::getDataType(const std::string& name) const { - if (m_objectType->getName().toString()==name) + if (m_objectType->getName()==name) return m_objectType->getVarType(); return NddlSymbolTable::getDataType(name); } -ObjectTypeId NddlClassSymbolTable::getObjectType(const char* name) const +ObjectTypeId NddlClassSymbolTable::getObjectType(const std::string& name) const { - if (m_objectType->getName().toString()==name) + if (m_objectType->getName()==name) return m_objectType->getId(); return NddlSymbolTable::getObjectType(name); } -DataTypeId NddlClassSymbolTable::getTypeForVar(const char* varName) +DataTypeId NddlClassSymbolTable::getTypeForVar(const std::string& varName) { DataTypeId dt = m_objectType->getMemberType(varName); if (dt.isId()) @@ -681,8 +688,8 @@ DataTypeId NddlClassSymbolTable::getTypeForVar(const char* varName) NddlTokenSymbolTable::NddlTokenSymbolTable(NddlSymbolTable* parent, - const TokenTypeId& tt, - const ObjectTypeId& ot) + const TokenTypeId tt, + const ObjectTypeId ot) : NddlSymbolTable(parent) , m_tokenType(tt) , m_objectType(ot) @@ -693,7 +700,7 @@ NddlTokenSymbolTable::~NddlTokenSymbolTable() { } -DataTypeId NddlTokenSymbolTable::getTypeForVar(const char* varName) +DataTypeId NddlTokenSymbolTable::getTypeForVar(const std::string& varName) { if (std::string(varName)=="object") return m_objectType->getVarType(); @@ -705,20 +712,20 @@ DataTypeId NddlTokenSymbolTable::getTypeForVar(const char* varName) return NddlSymbolTable::getTypeForVar(varName); } -TokenTypeId NddlTokenSymbolTable::getTokenType(const char* name) const +TokenTypeId NddlTokenSymbolTable::getTokenType(const std::string& name) const { TokenTypeId tt= NddlSymbolTable::getTokenType(name); if (tt.isNoId()) { // Try implicit qualification - std::string qualifiedName = m_objectType->getName().toString()+"."+name; + std::string qualifiedName = m_objectType->getName()+"."+name; tt= NddlSymbolTable::getTokenType(qualifiedName.c_str()); } return tt; } -TokenTypeId NddlTokenSymbolTable::getTypeForToken(const char* name) +TokenTypeId NddlTokenSymbolTable::getTypeForToken(const std::string& name) { if (std::string(name)=="this") return m_tokenType; @@ -728,7 +735,7 @@ TokenTypeId NddlTokenSymbolTable::getTypeForToken(const char* name) -NddlToASTInterpreter::NddlToASTInterpreter(EngineId& engine) +NddlToASTInterpreter::NddlToASTInterpreter(EngineId engine) : NddlInterpreter(engine) { } @@ -737,9 +744,6 @@ NddlToASTInterpreter::~NddlToASTInterpreter() { } -pANTLR3_STRING toVerboseString(pANTLR3_BASE_TREE tree); -pANTLR3_STRING toVerboseStringTree(pANTLR3_BASE_TREE tree); - std::string NddlToASTInterpreter::interpret(std::istream& ins, const std::string& source) { std::string strInput; @@ -767,7 +771,7 @@ std::string NddlToASTInterpreter::interpret(std::istream& ins, const std::string // Warnings, if any, should go here // Calling static helper functions to get a verbose version of AST - const char* ast = (char*)(toVerboseStringTree(result.tree)->chars); + const char* ast = reinterpret_cast(toVerboseStringTree(result.tree)->chars); os << "AST " << ast; debugMsg("NddlToASTInterpreter:interpret",os.str()); @@ -781,129 +785,129 @@ std::string NddlToASTInterpreter::interpret(std::istream& ins, const std::string } // Antlr functions -std::string getErrorLocation(pNDDL3Tree treeWalker) -{ - std::ostringstream os; - - // get location. see displayRecognitionError() in antlr3baserecognizer.c - pANTLR3_BASE_RECOGNIZER rec = treeWalker->pTreeParser->rec; - if (rec->state->exception == NULL) { - antlr3RecognitionExceptionNew(rec); - //rec->state->exception->type = ANTLR3_RECOGNITION_EXCEPTION; - //rec->state->exception->message = (char*)msg.c_str(); - } - //rec->reportError(rec); - - pANTLR3_EXCEPTION ex = rec->state->exception; - if (ex->streamName == NULL) { - if (((pANTLR3_COMMON_TOKEN)(ex->token))->type == ANTLR3_TOKEN_EOF) - os << "-end of input-("; - else - os << "-unknown source-("; - } - else { - pANTLR3_STRING ftext = ex->streamName->to8(ex->streamName); - os << ftext->chars << "("; - } +std::string getErrorLocation(pNDDL3Tree treeWalker) { + std::ostringstream os; + + // get location. see displayRecognitionError() in antlr3baserecognizer.c + pANTLR3_BASE_RECOGNIZER rec = treeWalker->pTreeParser->rec; + if (rec->state->exception == NULL) { + antlr3RecognitionExceptionNew(rec); + //rec->state->exception->type = ANTLR3_RECOGNITION_EXCEPTION; + //rec->state->exception->message = (char*)msg.c_str(); + } + //rec->reportError(rec); + + pANTLR3_EXCEPTION ex = rec->state->exception; + if (ex->streamName == NULL) { + if ((static_cast(ex->token))->type == ANTLR3_TOKEN_EOF) + os << "-end of input-("; + else + os << "-unknown source-("; + } + else { + pANTLR3_STRING ftext = ex->streamName->to8(ex->streamName); + os << ftext->chars << "("; + } - // Next comes the line number - os << "line:" << rec->state->exception->line << ")"; + // Next comes the line number + os << "line:" << rec->state->exception->line << ")"; - pANTLR3_BASE_TREE theBaseTree = (pANTLR3_BASE_TREE)(rec->state->exception->token); - pANTLR3_STRING ttext = theBaseTree->toStringTree(theBaseTree); + pANTLR3_BASE_TREE theBaseTree = static_cast(rec->state->exception->token); + pANTLR3_STRING ttext = theBaseTree->toStringTree(theBaseTree); - os << ", at offset " << theBaseTree->getCharPositionInLine(theBaseTree); - os << ", near " << ttext->chars; + os << ", at offset " << theBaseTree->getCharPositionInLine(theBaseTree); + os << ", near " << ttext->chars; - return os.str(); + return os.str(); } /** * Create a verbose string for a single tree node: * "text":token-type:"file":line:offset-in-line */ -pANTLR3_STRING toVerboseString(pANTLR3_BASE_TREE tree) -{ - if (tree->isNilNode(tree) == ANTLR3_TRUE) - { - pANTLR3_STRING nilNode; - nilNode = tree->strFactory->newPtr(tree->strFactory, (pANTLR3_UINT8)"nil", 3); - return nilNode; - } - - pANTLR3_COMMON_TOKEN ptoken = tree->getToken(tree); - pANTLR3_INPUT_STREAM pstream = ptoken->input; - pANTLR3_STRING string = tree->strFactory->newRaw(tree->strFactory); - - // "text":token-type:"file":line:offset-in-line - string->append8 (string, "\""); // "text" - string->appendS (string, ((pANTLR3_COMMON_TREE)(tree->super))->token-> - getText(((pANTLR3_COMMON_TREE)(tree->super))->token)); - string->append8 (string, "\""); - string->append8 (string, ":"); - string->addi (string, tree->getType(tree)); // type - - // if no file (e.g., root NDDL node), last three items are dropped - if (pstream) { - string->append8 (string, ":"); - string->append8 (string, "\""); // "file", full path - string->appendS(string, pstream->fileName); - string->append8 (string, "\""); - string->append8 (string, ":"); - string->addi (string, tree->getLine(tree)); // line - string->append8 (string, ":"); - string->addi (string, ptoken->charPosition); // offset in line - } - - return string; +pANTLR3_STRING toVerboseString(pANTLR3_BASE_TREE tree) { + if (tree->isNilNode(tree) == ANTLR3_TRUE) + { + pANTLR3_STRING nilNode; + nilNode = tree->strFactory->newPtr(tree->strFactory, + reinterpret_cast(const_cast("nil")), 3); + return nilNode; + } + + pANTLR3_COMMON_TOKEN ptoken = tree->getToken(tree); + pANTLR3_INPUT_STREAM pstream = ptoken->input; + pANTLR3_STRING string = tree->strFactory->newRaw(tree->strFactory); + + // "text":token-type:"file":line:offset-in-line + string->append8 (string, "\""); // "text" + string->appendS (string, (static_cast(tree->super))->token-> + getText((static_cast(tree->super))->token)); + string->append8 (string, "\""); + string->append8 (string, ":"); + string->addi (string, static_cast(tree->getType(tree))); // type + + // if no file (e.g., root NDDL node), last three items are dropped + if (pstream) { + string->append8 (string, ":"); + string->append8 (string, "\""); // "file", full path + string->appendS(string, pstream->fileName); + string->append8 (string, "\""); + string->append8 (string, ":"); + string->addi (string, static_cast(tree->getLine(tree))); // line + string->append8 (string, ":"); + string->addi (string, ptoken->charPosition); // offset in line + } + + return string; } /** Create a verbose string for the whole tree */ -pANTLR3_STRING toVerboseStringTree(pANTLR3_BASE_TREE tree) -{ - pANTLR3_STRING string; - ANTLR3_UINT32 i; - ANTLR3_UINT32 n; - pANTLR3_BASE_TREE t; - - if (tree->children == NULL || tree->children->size(tree->children) == 0) - return toVerboseString(tree); - - /* Need a new string with nothing at all in it. - */ - string = tree->strFactory->newRaw(tree->strFactory); - - if (tree->isNilNode(tree) == ANTLR3_FALSE) - { - string->append8 (string, "("); - string->appendS (string, toVerboseString(tree)); - string->append8 (string, " "); - } - if (tree->children != NULL) - { - n = tree->children->size(tree->children); - - for (i = 0; i < n; i++) - { - t = (pANTLR3_BASE_TREE) tree->children->get(tree->children, i); - - if (i > 0) - { - string->append8(string, " "); - } - string->appendS(string, toVerboseStringTree(t)); - } - } - if (tree->isNilNode(tree) == ANTLR3_FALSE) - { - string->append8(string,")"); - } - - return string; -} - -PSLanguageException::PSLanguageException(const char *fileName, int line, - int offset, int length, const char *message) : + pANTLR3_STRING toVerboseStringTree(pANTLR3_BASE_TREE tree) { + pANTLR3_STRING string; + ANTLR3_UINT32 i; + ANTLR3_UINT32 n; + pANTLR3_BASE_TREE t; + + if (tree->children == NULL || tree->children->size(tree->children) == 0) + return toVerboseString(tree); + + /* Need a new string with nothing at all in it. + */ + string = tree->strFactory->newRaw(tree->strFactory); + + if (tree->isNilNode(tree) == ANTLR3_FALSE) + { + string->append8 (string, "("); + string->appendS (string, toVerboseString(tree)); + string->append8 (string, " "); + } + if (tree->children != NULL) + { + n = tree->children->size(tree->children); + + for (i = 0; i < n; i++) + { + t = static_cast(tree->children->get(tree->children, i)); + + if (i > 0) + { + string->append8(string, " "); + } + string->appendS(string, toVerboseStringTree(t)); + } + } + if (tree->isNilNode(tree) == ANTLR3_FALSE) + { + string->append8(string,")"); + } + + return string; + } + +PSLanguageException::PSLanguageException(const char *fileName, unsigned int line, + int offset, unsigned int length, + const char *message) : + m_fileName(), m_line(line), m_offset(offset), m_length(length), m_message(message) { if (fileName) m_fileName = fileName; else fileName = "No_File"; @@ -935,64 +939,64 @@ ostream &operator<<(ostream &os, const PSLanguageExceptionList &ex) { } -void reportParserError(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames) { - pANTLR3_EXCEPTION ex = recognizer->state->exception; +void reportParserError(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *) { + pANTLR3_EXCEPTION ex = recognizer->state->exception; - const char *fileName = NULL; - if (ex->streamName) - fileName = (const char *)(ex->streamName->to8(ex->streamName)->chars); + const char *fileName = NULL; + if (ex->streamName) + fileName = reinterpret_cast(ex->streamName->to8(ex->streamName)->chars); - int line = recognizer->state->exception->line; - const char* message = static_cast(recognizer->state->exception->message); + unsigned int line = recognizer->state->exception->line; + const char* message = static_cast(recognizer->state->exception->message); - int offset = -1; // to signal something is wrong (like recognizer type) - int length = 0; // in case there is no token - if (recognizer->type == ANTLR3_TYPE_PARSER) { - offset = recognizer->state->exception->charPositionInLine; + int offset = -1; // to signal something is wrong (like recognizer type) + unsigned int length = 0; // in case there is no token + if (recognizer->type == ANTLR3_TYPE_PARSER) { + offset = recognizer->state->exception->charPositionInLine; - // Look for a token - pANTLR3_COMMON_TOKEN token = (pANTLR3_COMMON_TOKEN)(recognizer->state->exception->token); - line = token->getLine(token); - pANTLR3_STRING text = token->getText(token); - if (text != NULL) { - // It looks like when an extra token is present, message is - // empty and the token points to the actual thing. When a token - // is missing, the token text contains the message and the length - // is irrelevant - if (message == NULL || !message[0]) - length = text->len; - message = (const char *)(text->chars); - } - } + // Look for a token + pANTLR3_COMMON_TOKEN token = static_cast(recognizer->state->exception->token); + line = token->getLine(token); + pANTLR3_STRING text = token->getText(token); + if (text != NULL) { + // It looks like when an extra token is present, message is + // empty and the token points to the actual thing. When a token + // is missing, the token text contains the message and the length + // is irrelevant + if (message == NULL || !message[0]) + length = text->len; + message = reinterpret_cast(text->chars); + } + } - PSLanguageException exception(fileName, line, offset, length, message); + PSLanguageException exception(fileName, line, offset, length, message); - pANTLR3_PARSER parser = (pANTLR3_PARSER) recognizer->super; - pNDDL3Parser ctx = (pNDDL3Parser) parser->super; - std::vector *errors = ctx->parserErrors; - errors->push_back(exception); + pANTLR3_PARSER parser = static_cast(recognizer->super); + pNDDL3Parser ctx = static_cast(parser->super); + std::vector *errors = ctx->parserErrors; + errors->push_back(exception); - // std::cout << errors->size() << "; " << (*errors)[errors->size()-1]; + // std::cout << errors->size() << "; " << (*errors)[errors->size()-1]; } -void reportLexerError(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames) { - pANTLR3_LEXER lexer = (pANTLR3_LEXER)(recognizer->super); - pANTLR3_EXCEPTION ex = lexer->rec->state->exception; +void reportLexerError(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *) { + pANTLR3_LEXER lexer = static_cast(recognizer->super); + pANTLR3_EXCEPTION ex = lexer->rec->state->exception; - const char *fileName = NULL; - if (ex->streamName) - fileName = (const char *)(ex->streamName->to8(ex->streamName)->chars); + const char *fileName = NULL; + if (ex->streamName) + fileName = reinterpret_cast(ex->streamName->to8(ex->streamName)->chars); - int line = recognizer->state->exception->line; - const char* message = static_cast(recognizer->state->exception->message); - int offset = ex->charPositionInLine+1; + unsigned int line = recognizer->state->exception->line; + const char* message = static_cast(recognizer->state->exception->message); + int offset = ex->charPositionInLine+1; - PSLanguageException exception(fileName, line, offset, 1, message); + PSLanguageException exception(fileName, line, offset, 1, message); - pNDDL3Lexer ctx = (pNDDL3Lexer) lexer->ctx; - std::vector *errors = ctx->lexerErrors; - errors->push_back(exception); + pNDDL3Lexer ctx = static_cast(lexer->ctx); + std::vector *errors = ctx->lexerErrors; + errors->push_back(exception); - // std::cout << errors->size() << "; " << (*errors)[errors->size()-1]; + // std::cout << errors->size() << "; " << (*errors)[errors->size()-1]; } } diff --git a/src/PLASMA/NDDL/component/NddlInterpreter.hh b/src/PLASMA/NDDL/component/NddlInterpreter.hh index 05bf41c57..becb495a6 100644 --- a/src/PLASMA/NDDL/component/NddlInterpreter.hh +++ b/src/PLASMA/NDDL/component/NddlInterpreter.hh @@ -14,92 +14,96 @@ namespace EUROPA { -class NddlSymbolTable : public EvalContext -{ -public: - NddlSymbolTable(const EngineId& engine); - NddlSymbolTable(NddlSymbolTable* parent); - virtual ~NddlSymbolTable(); +class NddlSymbolTable : public EvalContext { +private: + NddlSymbolTable(const NddlSymbolTable&); + NddlSymbolTable& operator=(const NddlSymbolTable&); + public: + NddlSymbolTable(const EngineId engine); + NddlSymbolTable(NddlSymbolTable* parent); + virtual ~NddlSymbolTable(); - NddlSymbolTable* getParentST(); + NddlSymbolTable* getParentST(); - const PlanDatabaseId& getPlanDatabase() const; + const PlanDatabaseId getPlanDatabase() const; - virtual void addLocalVar(const char* name,const DataTypeId& type); - virtual void addLocalToken(const char* name,const TokenTypeId& type); + virtual void addLocalVar(const std::string& name,const DataTypeId type); + virtual void addLocalToken(const std::string& name,const TokenTypeId type); - virtual DataTypeId getDataType(const char* name) const; - virtual ObjectTypeId getObjectType(const char* name) const; - virtual TokenTypeId getTokenType(const char* name) const; + virtual DataTypeId getDataType(const std::string& name) const; + virtual ObjectTypeId getObjectType(const std::string& name) const; + virtual TokenTypeId getTokenType(const std::string& name) const; - virtual DataTypeId getTypeForVar(const char* name); - virtual DataTypeId getTypeForVar(const char* qualifiedName,std::string& errorMsg); + virtual DataTypeId getTypeForVar(const std::string& name); + virtual DataTypeId getTypeForVar(const std::string& qualifiedName,std::string& errorMsg); - virtual TokenTypeId getTypeForToken(const char* name); - virtual TokenTypeId getTypeForToken(const char* qualifiedName,std::string& errorMsg); + virtual TokenTypeId getTypeForToken(const std::string& name); + virtual TokenTypeId getTypeForToken(const std::string& qualifiedName,std::string& errorMsg); - virtual MethodId getMethod(const char* methodName,Expr* target,const std::vector& args); + virtual MethodId getMethod(const std::string& methodName,Expr* target,const std::vector& args); - virtual CFunctionId getCFunction(const char* name, const std::vector& args); + virtual CFunctionId getCFunction(const std::string& name, const std::vector& args); - Domain* makeNumericDomainFromLiteral(const std::string& type,const std::string& value); + Domain* makeNumericDomainFromLiteral(const std::string& type,const std::string& value); - void checkConstraint(const char* name,const std::vector& args); - void checkObjectFactory(const char* name,const std::vector& args); + void checkConstraint(const std::string& name,const std::vector& args); + void checkObjectFactory(const std::string& name,const std::vector& args); - // Error reporting methods - void reportError(void* treeWalker, const std::string& msg); - void addError(const std::string& msg); - std::string getErrors() const; + // Error reporting methods + void reportError(void* treeWalker, const std::string& msg); + void addError(const std::string& msg); + std::string getErrors() const; - // EvalContext methods - virtual ConstrainedVariableId getVar(const char* name); - virtual TokenId getToken(const char* name); - virtual void* getElement(const char* name) const; + // EvalContext methods + virtual ConstrainedVariableId getVar(const std::string& name); + virtual TokenId getToken(const std::string& name); + virtual void* getElement(const std::string& name) const; - // Enum support methods - bool isEnumValue(const char* value) const; - const LabelStr& getEnumForValue(const char* value) const; - Expr* makeEnumRef(const char* value) const; + // Enum support methods + bool isEnumValue(const std::string& value) const; + const std::string& getEnumForValue(const std::string& value) const; + Expr* makeEnumRef(const std::string& value) const; -protected: - NddlSymbolTable* m_parentST; + protected: + NddlSymbolTable* m_parentST; - EngineId m_engine; - std::vector m_errors; - std::map m_localVars; - std::map m_localTokens; + EngineId m_engine; + std::vector m_errors; + std::map m_localVars; + std::map m_localTokens; - const EngineId& engine() const; - std::vector& errors(); - const std::vector& errors() const; + const EngineId engine() const; + std::vector& errors(); + const std::vector& errors() const; }; -class NddlClassSymbolTable : public NddlSymbolTable -{ -public: - NddlClassSymbolTable(NddlSymbolTable* parent, ObjectType* ot); - virtual ~NddlClassSymbolTable(); +class NddlClassSymbolTable : public NddlSymbolTable { + private: + NddlClassSymbolTable(const NddlClassSymbolTable&); + NddlClassSymbolTable& operator=(const NddlClassSymbolTable&); + public: + NddlClassSymbolTable(NddlSymbolTable* parent, ObjectType* ot); + virtual ~NddlClassSymbolTable(); - virtual DataTypeId getDataType(const char* name) const; - virtual ObjectTypeId getObjectType(const char* name) const; + virtual DataTypeId getDataType(const std::string& name) const; + virtual ObjectTypeId getObjectType(const std::string& name) const; - virtual DataTypeId getTypeForVar(const char* varName); + virtual DataTypeId getTypeForVar(const std::string& varName); -protected: - ObjectType* m_objectType; // Object type being declared + protected: + ObjectType* m_objectType; // Object type being declared }; class NddlTokenSymbolTable : public NddlSymbolTable { public: - NddlTokenSymbolTable(NddlSymbolTable* parent, const TokenTypeId& tt, const ObjectTypeId& ot); + NddlTokenSymbolTable(NddlSymbolTable* parent, const TokenTypeId tt, const ObjectTypeId ot); virtual ~NddlTokenSymbolTable(); - virtual DataTypeId getTypeForVar(const char* varName); - virtual TokenTypeId getTokenType(const char* name) const; + virtual DataTypeId getTypeForVar(const std::string& varName); + virtual TokenTypeId getTokenType(const std::string& name) const; - virtual TokenTypeId getTypeForToken(const char* name); + virtual TokenTypeId getTypeForToken(const std::string& name); protected: TokenTypeId m_tokenType; @@ -109,7 +113,7 @@ protected: class NddlInterpreter : public LanguageInterpreter { public: - NddlInterpreter(EngineId& engine); + NddlInterpreter(EngineId engine); virtual ~NddlInterpreter(); virtual std::string interpret(std::istream& input, const std::string& source); @@ -130,42 +134,41 @@ protected: class NddlToASTInterpreter : public NddlInterpreter { public: - NddlToASTInterpreter(EngineId& engine); + NddlToASTInterpreter(EngineId engine); virtual ~NddlToASTInterpreter(); virtual std::string interpret(std::istream& input, const std::string& source); }; -class PSLanguageException -{ -public: - PSLanguageException(const char *fileName, int line, int offset, int length, - const char *message); - friend ostream &operator<<(ostream &, const PSLanguageException &); - /** Prepare this exception for shipping with AST */ - std::string asString() const; - - const std::string& getFileName() const { return m_fileName; } - int getLine() const { return m_line; } - int getOffset() const { return m_offset; } - int getLength() const { return m_length; } - const std::string& getMessage() const { return m_message; } -protected: - std::string m_fileName; - int m_line; - int m_offset; - int m_length; - std::string m_message; +class PSLanguageException { + public: + PSLanguageException(const char *fileName, unsigned int line, int offset, + unsigned int length, const char *message); + friend ostream &operator<<(ostream &, const PSLanguageException &); + /** Prepare this exception for shipping with AST */ + std::string asString() const; + + const std::string& getFileName() const { return m_fileName; } + unsigned int getLine() const { return m_line; } + int getOffset() const { return m_offset; } + unsigned int getLength() const { return m_length; } + const std::string& getMessage() const { return m_message; } + protected: + std::string m_fileName; + unsigned int m_line; + int m_offset; + unsigned int m_length; + std::string m_message; }; class PSLanguageExceptionList { public: - PSLanguageExceptionList(const std::vector& exceptions); - friend std::ostream &operator<<(std::ostream &, const PSLanguageExceptionList &); - int getExceptionCount() const { return m_exceptions.size(); } - const PSLanguageException& getException(int index) const { - return m_exceptions[index]; - } + PSLanguageExceptionList(const std::vector& exceptions); + friend std::ostream &operator<<(std::ostream &, const PSLanguageExceptionList &); + long getExceptionCount() const { return static_cast(m_exceptions.size()); } + const PSLanguageException& getException(int index) const { + return m_exceptions[static_cast(index)]; + } protected: std::vector m_exceptions; }; diff --git a/src/PLASMA/NDDL/component/NddlTestEngine.cc b/src/PLASMA/NDDL/component/NddlTestEngine.cc index 2d3393a3c..3cfeb80cb 100644 --- a/src/PLASMA/NDDL/component/NddlTestEngine.cc +++ b/src/PLASMA/NDDL/component/NddlTestEngine.cc @@ -30,14 +30,14 @@ NddlTestEngine::~NddlTestEngine() doShutdown(); } -void NddlTestEngine::createModules() -{ - addModule((new ModuleConstraintEngine())->getId()); - addModule((new ModuleConstraintLibrary())->getId()); - addModule((new ModulePlanDatabase())->getId()); - addModule((new ModuleRulesEngine())->getId()); - addModule((new ModuleTemporalNetwork())->getId()); - addModule((new ModuleNddl())->getId()); +void NddlTestEngine::createModules() { + using namespace EUROPA; + addModule((new ModuleConstraintEngine())->getId()); + addModule((new ModuleConstraintLibrary())->getId()); + addModule((new ModulePlanDatabase())->getId()); + addModule((new ModuleRulesEngine())->getId()); + addModule((new ModuleTemporalNetwork())->getId()); + addModule((new ModuleNddl())->getId()); } int NddlTestEngine::run(int argc, const char** argv) @@ -54,34 +54,36 @@ int NddlTestEngine::run(int argc, const char** argv) return run(txSource,language); } -int NddlTestEngine::run(const char* txSource, const char* language) -{ - try { - PlanDatabase* planDatabase = (PlanDatabase*) getComponent("PlanDatabase"); - planDatabase->getClient()->enableTransactionLogging(); +int NddlTestEngine::run(const char* txSource, const char* language) { + using namespace EUROPA; + try { + PlanDatabase* planDatabase = + boost::polymorphic_cast(getComponent("PlanDatabase")); + planDatabase->getClient()->enableTransactionLogging(); - std::string result = executeScript(language,txSource,true /*isFile*/); - if (result.size()>0) { - std::cerr << "Unexpected error(s) executing script:" << txSource << std::endl; - std::cerr << result; - return -1; - } + std::string result = executeScript(language,txSource,true /*isFile*/); + if (result.size()>0) { + std::cerr << "Unexpected error(s) executing script:" << txSource << std::endl; + std::cerr << result; + return -1; + } - ConstraintEngine* ce EUROPA_ATTRIBUTE_UNUSED = (ConstraintEngine*)getComponent("ConstraintEngine"); - assert(ce->constraintConsistent()); + ConstraintEngine* ce EUROPA_ATTRIBUTE_UNUSED = + boost::polymorphic_cast(getComponent("ConstraintEngine")); + assert(ce->constraintConsistent()); - PlanDatabaseWriter::write(planDatabase->getId(), std::cout); - std::cout << "Finished\n"; - return 0; - } - catch (PSLanguageExceptionList& errors) { - std::cerr << "Unexpected error(s) executing script:" << txSource << std::endl; - for (int i=0;igetId(), std::cout); + std::cout << "Finished\n"; + return 0; + } + catch (PSLanguageExceptionList& errors) { + std::cerr << "Unexpected error(s) executing script:" << txSource << std::endl; + for (int i=0;i& tokens = listFromString(tokenizedString, false); - CPPUNIT_ASSERT(tokens.size() == 4); - std::string newString; - for(std::list::const_iterator it = tokens.begin(); it != tokens.end(); ++it){ - LabelStr value(*it); - newString += value.toString() + "$"; - } - CPPUNIT_ASSERT(newString == tokenizedString); - - std::string numberStr("1$2.45$3.04$-8.9$"); - const std::list& numbers= listFromString(numberStr, true); - edouble sum = 0; - - for(std::list::const_iterator it = numbers.begin(); it != numbers.end(); ++it){ - edouble number = *it; - sum += number; - } - CPPUNIT_ASSERT(numbers.size() == 4); - CPPUNIT_ASSERT(sum == (1 + 2.45 + 3.04 - 8.9)); - return true; - } -}; - -void NDDLModuleTests::utilitiesTests() -{ - UtilitiesTest::test(); -} NddlTest::NddlTest(const std::string& testName, @@ -63,6 +32,7 @@ NddlTest::NddlTest(const std::string& testName, , m_nddlFile(nddlFile) , m_result(result) , m_setBaseline(setBaseline) + , m_engine(NULL) { } @@ -107,6 +77,7 @@ std::string NddlTest::toString() const } +namespace { std::string readLine(std::ifstream& inFile) { std::string retval; @@ -154,11 +125,13 @@ std::string readTestResult(std::ifstream& inFile) return retval; } +} ErrorCheckingTests::ErrorCheckingTests(const std::string& testFilename,bool setBaseline) : CppUnit::TestSuite() , m_testFilename(testFilename) , m_setBaseline(setBaseline) + , m_tests() { readTests(); diff --git a/src/PLASMA/NDDL/test/nddl-test-module.hh b/src/PLASMA/NDDL/test/nddl-test-module.hh index d22a99812..cf0187339 100644 --- a/src/PLASMA/NDDL/test/nddl-test-module.hh +++ b/src/PLASMA/NDDL/test/nddl-test-module.hh @@ -9,7 +9,6 @@ class NDDLModuleTests : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(NDDLModuleTests); CPPUNIT_TEST(syntaxTests); - CPPUNIT_TEST(utilitiesTests); CPPUNIT_TEST_SUITE_END(); public: @@ -22,7 +21,6 @@ public: } void syntaxTests(); - void utilitiesTests(); }; class NddlTest : public CppUnit::TestFixture @@ -47,6 +45,9 @@ protected: std::string m_result; bool m_setBaseline; NddlTestEngine* m_engine; +private: + NddlTest(const NddlTest&); + NddlTest& operator=(const NddlTest&); }; class ErrorCheckingTests : public CppUnit::TestSuite diff --git a/src/PLASMA/PlanDatabase/CMakeLists.txt b/src/PLASMA/PlanDatabase/CMakeLists.txt index b0d8c3cc4..6fab8ed0f 100644 --- a/src/PLASMA/PlanDatabase/CMakeLists.txt +++ b/src/PLASMA/PlanDatabase/CMakeLists.txt @@ -1,8 +1,8 @@ include(EuropaModule) -#no way to make these transitive yet set(internal_dependencies ConstraintEngine Utils TinyXml) +# set(internal_dependencies ConstraintEngine) set(root_sources ModulePlanDatabase.cc) -set(base_sources CommonAncestorConstraint.cc DbClient.cc DefaultTemporalAdvisor.cc HasAncestorConstraint.cc MergeMemento.cc Method.cc Object.cc ObjectTokenRelation.cc ObjectType.cc PDBInterpreter.cc PSPlanDatabaseListener.cc PlanDatabase.cc PlanDatabaseListener.cc PlanDatabaseWriter.cc Schema.cc StackMemento.cc Token.cc TokenFactory.cc TokenType.cc TokenTypeMgr.cc UnifyMemento.cc) +set(base_sources CommonAncestorConstraint.cc DbClient.cc DefaultTemporalAdvisor.cc HasAncestorConstraint.cc MergeMemento.cc Method.cc Object.cc ObjectTokenRelation.cc ObjectType.cc PDBInterpreter.cc PSPlanDatabaseListener.cc PlanDatabase.cc PlanDatabaseListener.cc PlanDatabaseWriter.cc Schema.cc StackMemento.cc Token.cc TokenFactory.cc TokenType.cc TokenTypeMgr.cc UnifyMemento.cc DbClientListener.cc) set(component_sources DbClientTransactionLog.cc DbClientTransactionPlayer.cc EventToken.cc IntervalToken.cc Methods.cc Timeline.cc) set(test_sources module-tests.cc db-test-module.cc) diff --git a/src/PLASMA/PlanDatabase/ModulePlanDatabase.cc b/src/PLASMA/PlanDatabase/ModulePlanDatabase.cc index 6b7250b9a..941369a43 100644 --- a/src/PLASMA/PlanDatabase/ModulePlanDatabase.cc +++ b/src/PLASMA/PlanDatabase/ModulePlanDatabase.cc @@ -10,13 +10,11 @@ #include "Token.hh" #include "Methods.hh" #include "Propagators.hh" +#include "CESchema.hh" -namespace EUROPA { +#include - static bool & planDatabaseInitialized() { - static bool sl_alreadyDone(false); - return sl_alreadyDone; - } +namespace EUROPA { ModulePlanDatabase::ModulePlanDatabase() : Module("PlanDatabase") @@ -30,21 +28,16 @@ namespace EUROPA { void ModulePlanDatabase::initialize() { - if(planDatabaseInitialized()) - return; - - planDatabaseInitialized() = true; } void ModulePlanDatabase::uninitialize() { - planDatabaseInitialized() = false; } class NddlXmlTxnInterpreter : public LanguageInterpreter { public: - NddlXmlTxnInterpreter(const DbClientId& client) : m_interpreter(client) {} + NddlXmlTxnInterpreter(const DbClientId client) : m_interpreter(client) {} virtual ~NddlXmlTxnInterpreter() {} virtual std::string interpret(std::istream& input, const std::string& source); @@ -52,66 +45,66 @@ namespace EUROPA { DbClientTransactionPlayer m_interpreter; }; - std::string NddlXmlTxnInterpreter::interpret(std::istream& input, const std::string& script) + std::string NddlXmlTxnInterpreter::interpret(std::istream& input, const std::string&) { m_interpreter.play(input); return ""; } - void ModulePlanDatabase::initialize(EngineId engine) - { - ConstraintEngine* ce = (ConstraintEngine*)engine->getComponent("ConstraintEngine"); - CESchema* ceSchema = (CESchema*)engine->getComponent("CESchema"); - - new DefaultPropagator("PlanDatabaseSystemPropagator", ce->getId(), SYSTEM_PRIORITY); - REGISTER_SYSTEM_CONSTRAINT(ceSchema,ObjectTokenRelation, "ObjectTokenRelation", "PlanDatabaseSystemPropagator"); - - REGISTER_CONSTRAINT(ceSchema,CommonAncestorConstraint, "commonAncestor", "Default"); - REGISTER_CONSTRAINT(ceSchema,HasAncestorConstraint, "hasAncestor", "Default"); - - Schema* schema = new Schema("EngineSchema",ceSchema->getId()); // TODO: use engine name - schema->registerEnum("TokenStates",StateDomain()); - engine->addComponent("Schema",schema); - - ObjectType* ot; - const char* rootObjType = Schema::rootObject().c_str(); - - ot = new ObjectType(rootObjType,ObjectTypeId::noId(),true /*isNative*/); - schema->registerObjectType(ot->getId()); - - ot = new ObjectType("Timeline",ot->getId(),true /*isNative*/); - ot->addObjectFactory((new TimelineObjectFactory(ot->getId()))->getId()); - schema->registerObjectType(ot->getId()); - - // Exported Methods - schema->registerMethod((new PDBClose())->getId()); - schema->registerMethod((new SpecifyVariable())->getId()); - schema->registerMethod((new ResetVariable())->getId()); - schema->registerMethod((new CloseVariable())->getId()); - schema->registerMethod((new ConstrainToken())->getId()); - schema->registerMethod((new FreeToken())->getId()); - schema->registerMethod((new ActivateToken())->getId()); - schema->registerMethod((new MergeToken())->getId()); - schema->registerMethod((new RejectToken())->getId()); - schema->registerMethod((new CancelToken())->getId()); - schema->registerMethod((new CloseClass())->getId()); - - PlanDatabase* pdb = new PlanDatabase(ce->getId(), schema->getId()); - engine->addComponent("PlanDatabase",pdb); - - engine->addLanguageInterpreter("nddl-xml-txn", new NddlXmlTxnInterpreter(pdb->getClient())); - } - - void ModulePlanDatabase::uninitialize(EngineId engine) - { - LanguageInterpreter* old = engine->removeLanguageInterpreter("nddl-xml-txn"); - if (old) - delete old; - - PlanDatabase* pdb = (PlanDatabase*)engine->removeComponent("PlanDatabase"); - delete pdb; +void ModulePlanDatabase::initialize(EngineId engine) { + ConstraintEngine* ce = + boost::polymorphic_cast(engine->getComponent("ConstraintEngine")); + CESchema* ceSchema = boost::polymorphic_cast(engine->getComponent("CESchema")); + + new DefaultPropagator("PlanDatabaseSystemPropagator", ce->getId(), SYSTEM_PRIORITY); + REGISTER_SYSTEM_CONSTRAINT(ceSchema,ObjectTokenRelation, "ObjectTokenRelation", "PlanDatabaseSystemPropagator"); + + REGISTER_CONSTRAINT_TYPE(ceSchema,CommonAncestorCT, "commonAncestor", "Default"); + REGISTER_CONSTRAINT_TYPE(ceSchema,HasAncestorCT, "hasAncestor", "Default"); + + Schema* schema = new Schema("EngineSchema",ceSchema->getId()); // TODO: use engine name + schema->registerEnum("TokenStates",StateDomain()); + engine->addComponent("Schema",schema); + + ObjectType* ot; + const char* rootObjType = Schema::rootObject().c_str(); + + ot = new ObjectType(rootObjType,ObjectTypeId::noId(),true /*isNative*/); + schema->registerObjectType(ot->getId()); + + ot = new ObjectType("Timeline",ot->getId(),true /*isNative*/); + ot->addObjectFactory((new TimelineObjectFactory(ot->getId()))->getId()); + schema->registerObjectType(ot->getId()); + + // Exported Methods + schema->registerMethod((new PDBClose())->getId()); + schema->registerMethod((new SpecifyVariable())->getId()); + schema->registerMethod((new ResetVariable())->getId()); + schema->registerMethod((new CloseVariable())->getId()); + schema->registerMethod((new ConstrainToken())->getId()); + schema->registerMethod((new FreeToken())->getId()); + schema->registerMethod((new ActivateToken())->getId()); + schema->registerMethod((new MergeToken())->getId()); + schema->registerMethod((new RejectToken())->getId()); + schema->registerMethod((new CancelToken())->getId()); + schema->registerMethod((new CloseClass())->getId()); + + PlanDatabase* pdb = new PlanDatabase(ce->getId(), schema->getId()); + engine->addComponent("PlanDatabase",pdb); + + engine->addLanguageInterpreter("nddl-xml-txn", new NddlXmlTxnInterpreter(pdb->getClient())); +} - Schema* schema = (Schema*)engine->removeComponent("Schema"); - delete schema; - } +void ModulePlanDatabase::uninitialize(EngineId engine) { + LanguageInterpreter* old = engine->removeLanguageInterpreter("nddl-xml-txn"); + if (old) + delete old; + + PlanDatabase* pdb = + boost::polymorphic_cast(engine->removeComponent("PlanDatabase")); + delete pdb; + + Schema* schema = boost::polymorphic_cast(engine->removeComponent("Schema")); + delete schema; +} } diff --git a/src/PLASMA/PlanDatabase/ModulePlanDatabase.hh b/src/PLASMA/PlanDatabase/ModulePlanDatabase.hh index 5a9323f6c..c8c758d3b 100644 --- a/src/PLASMA/PlanDatabase/ModulePlanDatabase.hh +++ b/src/PLASMA/PlanDatabase/ModulePlanDatabase.hh @@ -1,6 +1,6 @@ -#ifndef _H_ModulePlanDatabase -#define _H_ModulePlanDatabase +#ifndef H_ModulePlanDatabase +#define H_ModulePlanDatabase #include "Module.hh" @@ -29,4 +29,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_ModulePlanDatabase */ +#endif /* #ifndef H_ModulePlanDatabase */ diff --git a/src/PLASMA/PlanDatabase/PlanDatabaseDefs.hh b/src/PLASMA/PlanDatabase/PlanDatabaseDefs.hh index 8e7859f69..28760ac22 100644 --- a/src/PLASMA/PlanDatabase/PlanDatabaseDefs.hh +++ b/src/PLASMA/PlanDatabase/PlanDatabaseDefs.hh @@ -1,9 +1,9 @@ -#ifndef _H_PlanDatabaseDefs -#define _H_PlanDatabaseDefs +#ifndef H_PlanDatabaseDefs +#define H_PlanDatabaseDefs #include "ConstraintEngineDefs.hh" #include "Entity.hh" -#include "Variable.hh" + namespace EUROPA { @@ -39,15 +39,6 @@ namespace EUROPA { class PlanDatabaseListener; typedef Id PlanDatabaseListenerId; - template class TokenVariable; - class StateDomain; - typedef Id< TokenVariable > StateVarId; - - typedef Id< Variable > TimeVarId; - typedef Id< TokenVariable > TempVarId; - - class ObjectDomain; - typedef Id< TokenVariable > ObjectVarId; class Schema; typedef Id SchemaId; diff --git a/src/PLASMA/PlanDatabase/PlanDatabaseVarDefs.hh b/src/PLASMA/PlanDatabase/PlanDatabaseVarDefs.hh new file mode 100644 index 000000000..1eed4a5ec --- /dev/null +++ b/src/PLASMA/PlanDatabase/PlanDatabaseVarDefs.hh @@ -0,0 +1,21 @@ +#ifndef PLANDATABASEVARDEFS_H_ +#define PLANDATABASEVARDEFS_H_ + +#include "Id.hh" +#include "Variable.hh" + +namespace EUROPA { + template class TokenVariable; + class StateDomain; + typedef Id< TokenVariable > StateVarId; + + typedef Id< Variable > TimeVarId; + typedef Id< TokenVariable > TempVarId; + + class ObjectDomain; + typedef Id< TokenVariable > ObjectVarId; + + +} + +#endif /* PLANDATABASEVARDEFS_H_ */ diff --git a/src/PLASMA/PlanDatabase/base/CommonAncestorConstraint.cc b/src/PLASMA/PlanDatabase/base/CommonAncestorConstraint.cc index d1de0229a..949c7b668 100644 --- a/src/PLASMA/PlanDatabase/base/CommonAncestorConstraint.cc +++ b/src/PLASMA/PlanDatabase/base/CommonAncestorConstraint.cc @@ -1,18 +1,19 @@ #include "CommonAncestorConstraint.hh" #include "Object.hh" +#include "CESchema.hh" namespace EUROPA{ - CommonAncestorConstraint::CommonAncestorConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) +CommonAncestorConstraint::CommonAncestorConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_first(static_cast(getCurrentDomain(variables[0]))), m_second(static_cast(getCurrentDomain(variables[1]))), m_restrictions(static_cast(getCurrentDomain(variables[2]))) { - check_error(variables.size() == 3); - } + check_error(variables.size() == 3); +} CommonAncestorConstraint::~CommonAncestorConstraint(){} @@ -30,15 +31,15 @@ namespace EUROPA{ apply(m_second, m_first); } - void CommonAncestorConstraint::handleExecute(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType){ + void CommonAncestorConstraint::handleExecute(const ConstrainedVariableId, + unsigned int, + const DomainListener::ChangeType&){ handleExecute(); } - bool CommonAncestorConstraint::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType){ + bool CommonAncestorConstraint::canIgnore(const ConstrainedVariableId, + unsigned int argIndex, + const DomainListener::ChangeType&){ check_error(argIndex <= 2); return (!m_first.isSingleton() && !m_second.isSingleton()); } @@ -61,7 +62,7 @@ namespace EUROPA{ singletonAncestors.push_back(singletonObject); // Has at least one, itself - const DataTypeId& dt = m_constraintEngine->getCESchema()->getDataType(singletonObject->getRootType().c_str()); + const DataTypeId dt = m_constraintEngine->getCESchema()->getDataType(singletonObject->getRootType().c_str()); ObjectDomain setOfAncestors(dt,singletonAncestors); //std::cout << ", " << setOfAncestors ; @@ -84,7 +85,7 @@ namespace EUROPA{ check_error(candidate.isValid()); candidate->getAncestors(candidatesAncestors); candidatesAncestors.push_back(candidate); - const DataTypeId& candidateRootDT = m_constraintEngine->getCESchema()->getDataType(candidate->getRootType().c_str()); + const DataTypeId candidateRootDT = m_constraintEngine->getCESchema()->getDataType(candidate->getRootType().c_str()); ObjectDomain od(candidateRootDT,candidatesAncestors); //std::cout << "Candidate " << candidate->getName().toString() << " has ancestors " << od << std::endl; od.intersect(setOfAncestors); diff --git a/src/PLASMA/PlanDatabase/base/CommonAncestorConstraint.hh b/src/PLASMA/PlanDatabase/base/CommonAncestorConstraint.hh index 2afe61be9..2ea7274f9 100644 --- a/src/PLASMA/PlanDatabase/base/CommonAncestorConstraint.hh +++ b/src/PLASMA/PlanDatabase/base/CommonAncestorConstraint.hh @@ -1,5 +1,5 @@ -#ifndef _H_CommonAncestorConstraint -#define _H_CommonAncestorConstraint +#ifndef H_CommonAncestorConstraint +#define H_CommonAncestorConstraint /** * @file CommonAncestor.hh @@ -9,46 +9,50 @@ #include "PlanDatabaseDefs.hh" #include "Constraint.hh" +#include "ConstraintTypeChecking.hh" namespace EUROPA { - /** - * @brief Requires that the first and second objects have a common ancestor that is - * contained in the restricted set. - * - * The semantics for this are such that: - * exists f in m_first AND - * exists s in m_second AND - * exists r in m_restrictions - * such that: - * ancestor(r, f) AND - * ancestor(r, s). - */ - class CommonAncestorConstraint: public Constraint - { - public: - - CommonAncestorConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - ~CommonAncestorConstraint(); - - void handleExecute(); - - void handleExecute(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); - - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); - private: - void apply(ObjectDomain& singleton, ObjectDomain& other); - ObjectDomain& m_first; /*!< The first object set */ - ObjectDomain& m_second; /*!< The second object set */ - const ObjectDomain& m_restrictions; /*!& variables); + + ~CommonAncestorConstraint(); + + void handleExecute(); + + void handleExecute(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); + + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); + private: + void apply(ObjectDomain& singleton, ObjectDomain& other); + ObjectDomain& m_first; /*!< The first object set */ + ObjectDomain& m_second; /*!< The second object set */ + const ObjectDomain& m_restrictions; /*!, All > > CommonAncestorCT; + } #endif diff --git a/src/PLASMA/PlanDatabase/base/DbClient.cc b/src/PLASMA/PlanDatabase/base/DbClient.cc index 602443f5a..2d3252303 100644 --- a/src/PLASMA/PlanDatabase/base/DbClient.cc +++ b/src/PLASMA/PlanDatabase/base/DbClient.cc @@ -4,6 +4,8 @@ #include #include +#include + #include "Debug.hh" #include "Entity.hh" #include "Utils.hh" @@ -27,36 +29,36 @@ namespace EUROPA { - const char* DELIMITER = ":"; /*!< Used for delimiting streamed output */ - - DbClient::DbClient(const PlanDatabaseId& db) - : m_id((DbClient*)this), m_deleted(false), m_transactionLoggingEnabled(false) { - check_error(db.isValid()); - m_planDb = db; - } +DbClient::DbClient(const PlanDatabaseId db) + : m_id(this), m_planDb(db), m_keysOfTokensCreated(), m_listeners(), + m_deleted(false), m_transactionLoggingEnabled(false) { + check_error(db.isValid()); +} DbClient::~DbClient(){ m_deleted = true; m_id.remove(); } - const DbClientId& DbClient::getId() const{return m_id;} + const DbClientId DbClient::getId() const{return m_id;} - const CESchemaId& DbClient::getCESchema() const + const CESchemaId DbClient::getCESchema() const { return m_planDb->getConstraintEngine()->getCESchema(); } - const SchemaId& DbClient::getSchema() const + const SchemaId DbClient::getSchema() const { return m_planDb->getSchema(); } ConstrainedVariableId - DbClient::createVariable(const char* typeName, const Domain& baseDomain, const char* name, bool isTmpVar, bool canBeSpecified) + DbClient::createVariable(const std::string& typeName, const Domain& baseDomain, const std::string& name, bool isTmpVar, bool canBeSpecified) { - ConstrainedVariableId variable = m_planDb->getConstraintEngine()->createVariable(typeName, baseDomain, isTmpVar, canBeSpecified, name); + ConstrainedVariableId variable = + m_planDb->getConstraintEngine()->createVariable(typeName, baseDomain, isTmpVar, + canBeSpecified, name); if (m_planDb->getSchema()->isObjectType(typeName) && !variable->isClosed()) { m_planDb->makeObjectVariableFromType(typeName, variable); } @@ -71,7 +73,7 @@ namespace EUROPA { } ConstrainedVariableId - DbClient::createVariable(const char* typeName, const char* name, bool isTmpVar) + DbClient::createVariable(const std::string& typeName, const std::string& name, bool isTmpVar) { ConstrainedVariableId variable = m_planDb->getConstraintEngine()->createVariable(typeName, isTmpVar, true, name); if (m_planDb->getSchema()->isObjectType(typeName)) { @@ -89,31 +91,31 @@ namespace EUROPA { return variable; } - void DbClient::deleteVariable(const ConstrainedVariableId& var) { - if(isGlobalVariable(var->getName())) - m_planDb->unregisterGlobalVariable(var); - publish(notifyVariableDeleted(var)); - delete (ConstrainedVariable*) var; - } +void DbClient::deleteVariable(const ConstrainedVariableId var) { + if(isGlobalVariable(var->getName())) + m_planDb->unregisterGlobalVariable(var); + publish(notifyVariableDeleted(var)); + delete static_cast(var); +} - ObjectId DbClient::createObject(const char* type, const char* name){ - static const std::vector noArguments; - ObjectId object = m_planDb->createObject(type, name, noArguments); - debugMsg("DbClient:createObject", object->toLongString()); - publish(notifyObjectCreated(object)); - return object; - } +ObjectId DbClient::createObject(const std::string& type, const std::string& name){ + static const std::vector noArguments; + ObjectId object = m_planDb->createObject(type, name, noArguments); + debugMsg("DbClient:createObject", object->toLongString()); + publish(notifyObjectCreated(object)); + return object; +} - ObjectId DbClient::createObject(const char* type, const char* name, const std::vector& arguments){ + ObjectId DbClient::createObject(const std::string& type, const std::string& name, const std::vector& arguments){ ObjectId object = m_planDb->createObject(type, name, arguments); debugMsg("DbClient:createObject", object->toLongString()); publish(notifyObjectCreated(object, arguments)); return object; } - void DbClient::deleteObject(const ObjectId& obj) { + void DbClient::deleteObject(const ObjectId obj) { publish(notifyObjectDeleted(obj)); - delete (Object*) obj; + delete static_cast(obj); } void DbClient::close(){ @@ -122,15 +124,15 @@ namespace EUROPA { publish(notifyClosed()); } - void DbClient::close(const char* objectType) { + void DbClient::close(const std::string& objectType) { debugMsg("DbClient:close", "Closing:"+std::string(objectType)); m_planDb->close(objectType); debugMsg("DbClient:close", "Closed:"+std::string(objectType)); publish(notifyClosed(objectType)); } - TokenId DbClient::createToken(const char* tokenType, - const char* tokenName, + TokenId DbClient::createToken(const std::string& tokenType, + const std::string& tokenName, bool rejectable, bool isFact) { TokenId token = allocateToken(tokenType, tokenName, rejectable, isFact); @@ -139,48 +141,48 @@ namespace EUROPA { return(token); } - void DbClient::deleteToken(const TokenId& token, const std::string& name) { - check_error(token.isValid()); - checkError(token->isInactive() || token->isFact(), - "Attempted to delete active, non-fact token " << token->toLongString()); - if(isGlobalToken(token->getName())) - m_planDb->unregisterGlobalToken(token); - publish(notifyTokenDeleted(token, name)); - - //the keys are only recorded if logging is enabled - //this may not be the right thing... - if(!m_keysOfTokensCreated.empty()) { - if(m_keysOfTokensCreated.back() == token->getKey()) { - debugMsg("DbClient:deleteToken", - "Removing token key " << m_keysOfTokensCreated.back()); - m_keysOfTokensCreated.pop_back(); - } - checkError(std::find(m_keysOfTokensCreated.begin(), m_keysOfTokensCreated.end(), - token->getKey()) == m_keysOfTokensCreated.end(), - "Attempted to delete " << token->toString() << " out of order."); +void DbClient::deleteToken(const TokenId token, const std::string& name) { + check_error(token.isValid()); + checkError(token->isInactive() || token->isFact(), + "Attempted to delete active, non-fact token " << token->toLongString()); + if(isGlobalToken(token->getName())) + m_planDb->unregisterGlobalToken(token); + publish(notifyTokenDeleted(token, name)); + + //the keys are only recorded if logging is enabled + //this may not be the right thing... + if(!m_keysOfTokensCreated.empty()) { + if(m_keysOfTokensCreated.back() == token->getKey()) { + debugMsg("DbClient:deleteToken", + "Removing token key " << m_keysOfTokensCreated.back()); + m_keysOfTokensCreated.pop_back(); } - delete (Token*) token; + checkError(std::find(m_keysOfTokensCreated.begin(), m_keysOfTokensCreated.end(), + token->getKey()) == m_keysOfTokensCreated.end(), + "Attempted to delete " << token->toString() << " out of order."); } + delete static_cast(token); +} - void DbClient::constrain(const ObjectId& object, const TokenId& predecessor, const TokenId& successor){ + void DbClient::constrain(const ObjectId object, const TokenId predecessor, const TokenId successor){ object->constrain(predecessor, successor); debugMsg("DbClient:constrain", predecessor->toString() << " before " << successor->toString()); publish(notifyConstrained(object, predecessor, successor)); } - void DbClient::free(const ObjectId& object, const TokenId& predecessor, const TokenId& successor){ + void DbClient::free(const ObjectId object, const TokenId predecessor, const TokenId successor){ object->free(predecessor, successor); debugMsg("DbClient:free", predecessor->toString() << " before " << successor->toString()); publish(notifyFreed(object, predecessor, successor)); } - void DbClient::activate(const TokenId& token){ + void DbClient::activate(const TokenId token){ token->activate(); debugMsg("DbClient:activate", token->toString()); publish(notifyActivated(token)); } - void DbClient::merge(const TokenId& token, const TokenId& activeToken){ + void DbClient::merge(const TokenId token, const TokenId activeToken){ static unsigned int sl_counter(0); sl_counter++; checkError(token.isValid(), token << ":" << sl_counter); @@ -189,14 +191,14 @@ namespace EUROPA { publish(notifyMerged(token, activeToken)); } - void DbClient::reject(const TokenId& token){ + void DbClient::reject(const TokenId token){ check_error(token.isValid()); token->reject(); debugMsg("DbClient:reject", token->toString()); publish(notifyRejected(token)); } - void DbClient::cancel(const TokenId& token){ + void DbClient::cancel(const TokenId token){ check_error(token.isValid()); publish(notifyCancelled(token)); @@ -226,9 +228,9 @@ namespace EUROPA { debugMsg("DbClient:cancel", token->toString()); } - ConstraintId DbClient::createConstraint(const char* name, + ConstraintId DbClient::createConstraint(const std::string& name, const std::vector& scope, - const char* violationExpl) + const std::string& violationExpl) { // Use the constraint library factories to create the constraint @@ -238,32 +240,32 @@ namespace EUROPA { return constraint; } - void DbClient::deleteConstraint(const ConstraintId& c) + void DbClient::deleteConstraint(const ConstraintId c) { publish(notifyConstraintDeleted(c)); m_planDb->getConstraintEngine()->deleteConstraint(c); } - void DbClient::restrict(const ConstrainedVariableId& variable, const Domain& domain){ + void DbClient::restrict(const ConstrainedVariableId variable, const Domain& domain){ debugMsg("DbClient:restrict", variable->toLongString() << " to " << domain.toString()); variable->restrictBaseDomain(domain); publish(notifyVariableRestricted(variable)); } - void DbClient::specify(const ConstrainedVariableId& variable, edouble value){ + void DbClient::specify(const ConstrainedVariableId variable, edouble value){ debugMsg("DbClient:specify", "before:" << variable->toLongString() << " to " << variable->toString(value)); variable->specify(value); debugMsg("DbClient:specify", "after:" << variable->toLongString()); publish(notifyVariableSpecified(variable)); } - void DbClient::close(const ConstrainedVariableId& variable){ + void DbClient::close(const ConstrainedVariableId variable){ debugMsg("DbClient:close", "Closing:"+variable->toLongString()); variable->close(); debugMsg("DbClient:close", "Closed:"+variable->toLongString()); publish(notifyVariableClosed(variable)); } - void DbClient::reset(const ConstrainedVariableId& variable){ + void DbClient::reset(const ConstrainedVariableId variable){ debugMsg("DbClient:reset","before:" << variable->toLongString()); variable->reset(); debugMsg("DbClient:reset", "after:" << variable->toLongString()); @@ -277,20 +279,19 @@ namespace EUROPA { } - ObjectId DbClient::getObject(const char* name) const {return m_planDb->getObject(name);} + ObjectId DbClient::getObject(const std::string& name) const {return m_planDb->getObject(name);} /** * @brief Traverse the path and obtain the right token */ - TokenId DbClient::getTokenByPath(const std::vector& relativePath) const + TokenId DbClient::getTokenByPath(const std::vector& relativePath) const { check_error(isTransactionLoggingEnabled()); check_error(!relativePath.empty()); check_error(!m_keysOfTokensCreated.empty()); - check_error(relativePath[0] >= 0); // Can never be a valid path // Quick check for the root of the path - if((unsigned)relativePath[0] >= m_keysOfTokensCreated.size()) // Cannot be a path for a token with this key set + if(relativePath[0] >= m_keysOfTokensCreated.size()) // Cannot be a path for a token with this key set return TokenId::noId(); // Obtain the root token key using the first element in the path to index the tokenKeys. @@ -312,29 +313,29 @@ namespace EUROPA { return(rootToken); } - const ConstrainedVariableId DbClient::getGlobalVariable(const LabelStr& varName) const{ + const ConstrainedVariableId DbClient::getGlobalVariable(const std::string& varName) const{ return m_planDb->getGlobalVariable(varName); } - bool DbClient::isGlobalVariable(const LabelStr& varName) const { + bool DbClient::isGlobalVariable(const std::string& varName) const { return m_planDb->isGlobalVariable(varName); } - const TokenId DbClient::getGlobalToken(const LabelStr& name) const{ + const TokenId DbClient::getGlobalToken(const std::string& name) const{ return m_planDb->getGlobalToken(name); } - bool DbClient::isGlobalToken(const LabelStr& name) const { + bool DbClient::isGlobalToken(const std::string& name) const { return m_planDb->isGlobalToken(name); } /** * @brief Build the path from the bottom up, and return it from the top down. */ - std::vector DbClient::getPathByToken(const TokenId& targetToken) const + std::vector DbClient::getPathByToken(const TokenId targetToken) const { check_error(isTransactionLoggingEnabled()); - std::list path; // Used to build up the path from the bottom up. + std::list path; // Used to build up the path from the bottom up. TokenId master = targetToken->master(); TokenId slave = targetToken; @@ -342,7 +343,7 @@ namespace EUROPA { while(!master.isNoId()){ int slavePosition = master->getSlavePosition(slave); check_error(slavePosition >= 0); - path.push_front(slavePosition); + path.push_front(static_cast(slavePosition)); slave = slave->master(); master = master->master(); } @@ -356,27 +357,27 @@ namespace EUROPA { int indexOfMaster = -1; for(unsigned int i=0; i< m_keysOfTokensCreated.size(); i++) if(m_keysOfTokensCreated[i] == keyOfMaster){ - indexOfMaster = i; + indexOfMaster = static_cast(i); break; } check_error(indexOfMaster >= 0); // Now push the key for the root and generate path going from top down - path.push_front(indexOfMaster); + path.push_front(static_cast(indexOfMaster)); - std::vector pathAsVector; - for(std::list::const_iterator it = path.begin(); it != path.end(); ++it) + std::vector pathAsVector; + for(std::list::const_iterator it = path.begin(); it != path.end(); ++it) pathAsVector.push_back(*it); return pathAsVector; } - std::string DbClient::getPathAsString(const TokenId& targetToken) const { + std::string DbClient::getPathAsString(const TokenId targetToken) const { check_error(isTransactionLoggingEnabled()); - const std::vector path = getPathByToken(targetToken); + const std::vector path = getPathByToken(targetToken); std::stringstream s; - std::vector::const_iterator it = path.begin(); + std::vector::const_iterator it = path.begin(); s << *it; for(++it ; it != path.end() ; ++it) { s << "." << *it; @@ -388,7 +389,7 @@ namespace EUROPA { return m_planDb->getConstraintEngine()->getVariable(index); } - unsigned int DbClient::getIndexByVariable(const ConstrainedVariableId& var){ + unsigned int DbClient::getIndexByVariable(const ConstrainedVariableId var){ return m_planDb->getConstraintEngine()->getIndex(var); } @@ -396,16 +397,16 @@ namespace EUROPA { return m_planDb->getConstraintEngine()->getConstraint(index); } - unsigned int DbClient::getIndexByConstraint(const ConstraintId& constr) { + unsigned int DbClient::getIndexByConstraint(const ConstraintId constr) { return m_planDb->getConstraintEngine()->getIndex(constr); } - void DbClient::notifyAdded(const DbClientListenerId& listener){ + void DbClient::notifyAdded(const DbClientListenerId listener){ check_error(m_listeners.find(listener) == m_listeners.end()); m_listeners.insert(listener); } - void DbClient::notifyRemoved(const DbClientListenerId& listener){ + void DbClient::notifyRemoved(const DbClientListenerId listener){ check_error(m_listeners.find(listener) != m_listeners.end()); if(!m_deleted){ m_listeners.erase(listener); @@ -420,8 +421,8 @@ namespace EUROPA { return m_planDb->hasTokenTypes(); } - TokenId DbClient::allocateToken(const char* tokenType, - const char* tokenName, + TokenId DbClient::allocateToken(const std::string& tokenType, + const std::string& tokenName, bool rejectable, bool isFact) { checkError(supportsAutomaticAllocation(), "Cannot allocate tokens from the schema."); @@ -449,12 +450,12 @@ namespace EUROPA { bool DbClient::isTransactionLoggingEnabled() const { return m_transactionLoggingEnabled; } - edouble DbClient::createValue(const char* typeName, const std::string& value) + edouble DbClient::createValue(const std::string& typeName, const std::string& value) { return m_planDb->getConstraintEngine()->createValue(typeName,value); } - PSPlanDatabaseClientImpl::PSPlanDatabaseClientImpl(const DbClientId& c) + PSPlanDatabaseClientImpl::PSPlanDatabaseClientImpl(const DbClientId c) : m_client(c) { } @@ -462,7 +463,7 @@ namespace EUROPA { PSVariable* PSPlanDatabaseClientImpl::createVariable(const std::string& typeName, const std::string& name, bool isTmpVar) { ConstrainedVariableId var = m_client->createVariable(typeName.c_str(),name.c_str(),isTmpVar); - return dynamic_cast((ConstrainedVariable*)var); + return dynamic_cast(static_cast(var)); } void PSPlanDatabaseClientImpl::deleteVariable(PSVariable* var) @@ -473,7 +474,7 @@ namespace EUROPA { PSObject* PSPlanDatabaseClientImpl::createObject(const std::string& type, const std::string& name) { ObjectId obj = m_client->createObject(type.c_str(),name.c_str()); - return dynamic_cast((Object*)obj); + return dynamic_cast(static_cast(obj)); } //PSObject* PSPlanDatabaseClientImpl::createObject(const std::string& type, const std::string& name, const PSList& arguments){} @@ -486,7 +487,7 @@ namespace EUROPA { PSToken* PSPlanDatabaseClientImpl::createToken(const std::string& predicateName, bool rejectable, bool isFact) { TokenId tok = m_client->createToken(predicateName.c_str(),NULL, rejectable,isFact); - return dynamic_cast((Token*)tok); + return dynamic_cast(static_cast(tok)); } void PSPlanDatabaseClientImpl::deleteToken(PSToken* token) @@ -531,7 +532,7 @@ namespace EUROPA { idScope.push_back(toId(scope.get(i))); ConstraintId c = m_client->createConstraint(name.c_str(),idScope); - return dynamic_cast((Constraint*)c); + return dynamic_cast(static_cast(c)); } void PSPlanDatabaseClientImpl::deleteConstraint(PSConstraint* c) @@ -566,21 +567,21 @@ namespace EUROPA { ConstrainedVariableId PSPlanDatabaseClientImpl::toId(PSVariable* v) { - return dynamic_cast(v)->getId(); + return boost::polymorphic_cast(v)->getId(); } ConstraintId PSPlanDatabaseClientImpl::toId(PSConstraint* c) { - return dynamic_cast(c)->getId(); + return boost::polymorphic_cast(c)->getId(); } ObjectId PSPlanDatabaseClientImpl::toId(PSObject* o) { - return dynamic_cast(o)->getId(); + return boost::polymorphic_cast(o)->getId(); } TokenId PSPlanDatabaseClientImpl::toId(PSToken* t) { - return dynamic_cast(t)->getId(); + return boost::polymorphic_cast(t)->getId(); } } diff --git a/src/PLASMA/PlanDatabase/base/DbClient.hh b/src/PLASMA/PlanDatabase/base/DbClient.hh index a6b5ebb6f..613a3c613 100644 --- a/src/PLASMA/PlanDatabase/base/DbClient.hh +++ b/src/PLASMA/PlanDatabase/base/DbClient.hh @@ -1,9 +1,8 @@ -#ifndef _H_DbClient -#define _H_DbClient +#ifndef H_DbClient +#define H_DbClient #include "PlanDatabaseDefs.hh" #include "PSPlanDatabase.hh" -#include "Variable.hh" #include /** @@ -30,61 +29,58 @@ namespace EUROPA { */ class DbClient { public: - const DbClientId& getId() const; + const DbClientId getId() const; /** * @brief Create a variable - * @param type The type for the variable. + * @param typeName The type for the variable. * @param baseDomain The base domain of the new variable. * @param name The name for the variable. Must be unique. * @return The Id of the variable created. Will error out rather than return a noId. */ - ConstrainedVariableId createVariable(const char* typeName, const Domain& baseDomain, const char* name, bool isTmpVar = false, bool canBeSpecified=true); + ConstrainedVariableId createVariable(const std::string& typeName, const Domain& baseDomain, const std::string& name, bool isTmpVar = false, bool canBeSpecified=true); /** * @brief Create a variable - * @param type The type for the variable. + * @param typeName The type for the variable. * @param name The name for the variable. Must be unique. * @return The Id of the variable created. Will error out rather than return a noId. */ - ConstrainedVariableId createVariable(const char* typeName, const char* name, bool isTmpVar = false); + ConstrainedVariableId createVariable(const std::string& typeName, + const std::string& name, bool isTmpVar = false); /** * @brief Delete a variable. By way of symmetry with createVariable(). */ - void deleteVariable(const ConstrainedVariableId& var); + void deleteVariable(const ConstrainedVariableId var); /** * @brief Create an object instance in the dabatase. - * @param key The expected key value for the object. This is used as a check to ensure we are creating values - * in the order we expect. * @param type The type of instance to create. Must match a name in the Schema. The daatabase must be open for * creation of instances of this type. * @param name The name for the instance. Must be unique. * @return The Id of the object created. Will error out rather than return a noId. */ - ObjectId createObject(const char* type, const char* name); + ObjectId createObject(const std::string& type, const std::string& name); /** * @brief Create an object instance in the dabatase, with a call to a specialized constructor - * @param key The expected key value for the object. This is used as a check to ensure we are creating values - * in the order we expect. * @param type The type of instance to create. Must match a name in the Schema. The database must be open for * creation of instances of this type. * @param name The name for the instance. Must be unique. * @param arguments A vector of name/value pairs used to invoke a particular constructor. * @return The Id of the object created. Will error out rather than return a noId. */ - ObjectId createObject(const char* type, const char* name, const std::vector& arguments); + ObjectId createObject(const std::string& type, const std::string& name, const std::vector& arguments); /** * @brief Delete an object. By way of symmetry with createObject(). */ - void deleteObject(const ObjectId& obj); + void deleteObject(const ObjectId obj); /** * @brief Close the database. This will prohibit any further insertion of objects. - * @see close(const char* objectType) + * @see close(const std::string& objectType) */ void close(); @@ -92,67 +88,65 @@ namespace EUROPA { * @brief Close the database for further creation of any objects of a given type. Not supported yet. There is no * implementation for this yet, since we are not really supporting incremental closure of objects at this time. */ - void close(const char* objectType); + void close(const std::string& objectType); /** * @brief Constructs a Token instance. - * @param predicateName The name of the predicate for which this token is an instance. Must match a name in the + * @param tokenType The name of the predicate for which this token is an instance. Must match a name in the * schema. * @return The Id of the token created. Will error out rather than return a noId. */ - TokenId createToken(const char* tokenType, - const char* tokenName = NULL, + TokenId createToken(const std::string& tokenType, + const std::string& tokenName = "", bool rejectable = false, bool isFact = false); /** * @brief Deletes a token instance. By way of symmetry with createToken(). */ - void deleteToken(const TokenId& token, const std::string& name = ""); + void deleteToken(const TokenId token, const std::string& name = ""); /** * @brief imposes a constraint such that token comes before successor, on the given object. - * @param object + * @param object The object to constrain to. * @param predecessor The token to be the predecessor * @param successor The token to be the successor. If 0, the Token is constrained to succeed all * other ordered tokens. - * @return The resulting 'precedes' constraint */ - void constrain(const ObjectId& object, const TokenId& predecessor, const TokenId& successor); + void constrain(const ObjectId object, const TokenId predecessor, const TokenId successor); /** * @brief Frees any constraints imposed on a Token arising from calls to constrain. * @param object The object to which the token has been constrained. * @param predecessor The token that is the predecessor * @param successor The token that is the successor. - * @param constraint The constraint to be removed. */ - void free(const ObjectId& object, const TokenId& predecessor, const TokenId& successor); + void free(const ObjectId object, const TokenId predecessor, const TokenId successor); /** * @brief Activate the given token * @param token The token to be activated. It must be inactive. */ - void activate(const TokenId& token); + void activate(const TokenId token); /** * @brief Merge the given token * @param token The token to be merged. It must be inactive. - * @param activeTokenKey The token to be merged onto. + * @param activeToken The token to be merged onto. */ - void merge(const TokenId& token, const TokenId& activeToken); + void merge(const TokenId token, const TokenId activeToken); /** * @brief Reject the given token * @param token The token to be rejected. It must be inactive. */ - void reject(const TokenId& token); + void reject(const TokenId token); /** * @brief Cancel restriction to Token Variables state through activate, merge, or reject * @param token The target token */ - void cancel(const TokenId& token); + void cancel(const TokenId token); /** * @brief The initial state may include constraints, even if the planner does not express any decisions @@ -160,9 +154,9 @@ namespace EUROPA { * @param name The name of the constraint to be created * @param scope The variables to provide the scope of the constraint. */ - ConstraintId createConstraint(const char* name, + ConstraintId createConstraint(const std::string& name, const std::vector& scope, - const char* violationExpl=NULL); + const std::string& violationExpl=""); /** * @brief Construction of a unary constraint. @@ -170,22 +164,22 @@ namespace EUROPA { * ¶m var the target variable. * @param domain The domain to restrict against. */ - ConstraintId createConstraint(const char* name, - const ConstrainedVariableId& variable, + ConstraintId createConstraint(const std::string& name, + const ConstrainedVariableId variable, const Domain& domain); /** * @brief Delete a constraint. By way of symmetry with createConstraint(). */ - void deleteConstraint(const ConstraintId& constr); + void deleteConstraint(const ConstraintId constr); /** * @brief Restricts the base domain of a variable * @param variable The variable to be restricted - * @param value The new base domain of the variable. + * @param domain The new base domain of the variable. * @see getEntityByKey */ - void restrict(const ConstrainedVariableId& variable, const Domain& domain); + void restrict(const ConstrainedVariableId variable, const Domain& domain); /** * @brief Binds the value of a variable @@ -195,19 +189,19 @@ namespace EUROPA { * value to specify. * @see getEntityByKey */ - void specify(const ConstrainedVariableId& variable, edouble value); + void specify(const ConstrainedVariableId variable, edouble value); /** * @brief Close the domains of a dynamic variable. * @param variable The dynamic variable to be closed.= */ - void close(const ConstrainedVariableId& variable); + void close(const ConstrainedVariableId variable); /** * @brief resets the specified domain of the target variable to its base domain * @param variable The variable to be reset */ - void reset(const ConstrainedVariableId& variable); + void reset(const ConstrainedVariableId variable); /*!< Support for interaction with ConsistencyManagement */ @@ -222,31 +216,31 @@ namespace EUROPA { * @brief Lookup an object by name. It is an error if the object is not present. * @return The requested object */ - ObjectId getObject(const char* name) const; + ObjectId getObject(const std::string& name) const; /** * @brief Lookup a global variable by name. It is an error if not present - * @retrun The requested variable. + * @return The requested variable. */ - const ConstrainedVariableId getGlobalVariable(const LabelStr& varName) const; + const ConstrainedVariableId getGlobalVariable(const std::string& varName) const; /** * @brief Test if a global exists for a given name * @return true if present, otherwise false */ - bool isGlobalVariable(const LabelStr& varName) const; + bool isGlobalVariable(const std::string& varName) const; /** * @brief Lookup a global token by name. It is an error if not present - * @retrun The requested token. + * @return The requested token. */ - const TokenId getGlobalToken(const LabelStr& name) const; + const TokenId getGlobalToken(const std::string& name) const; /** * @brief Test if a global exists for a given name * @return true if present, otherwise false */ - bool isGlobalToken(const LabelStr& name) const; + bool isGlobalToken(const std::string& name) const; /** * @brief Retrieve token defined by a particular path from a root token. Transaction Logging must be enabled. @@ -257,7 +251,7 @@ namespace EUROPA { * @see Token::getChild(int slavePosition) * @see enableTransactionLogging */ - TokenId getTokenByPath(const std::vector& relativePath) const; + TokenId getTokenByPath(const std::vector& relativePath) const; /** * @brief Retrieve the relative path for obtaining the target token from a given root token. @@ -267,7 +261,7 @@ namespace EUROPA { * @see getTokenByPath * @see enableTransactionLogging */ - std::vector getPathByToken(const TokenId& targetToken) const; + std::vector getPathByToken(const TokenId targetToken) const; /** * @brief Retrieve the relative path for obtaining the target token from a given root token. @@ -277,7 +271,7 @@ namespace EUROPA { * @see getPathByToken * @see enableTransactionLogging */ - std::string getPathAsString(const TokenId& targetToken) const; + std::string getPathAsString(const TokenId targetToken) const; /** * @brief Retrieve a constrained variable of any type based on its 'index' @@ -288,21 +282,21 @@ namespace EUROPA { * @brief Retrieve an index for a variable. Required for logging. Tricks will have to be done to make * this fast! */ - unsigned int getIndexByVariable(const ConstrainedVariableId& var); + unsigned int getIndexByVariable(const ConstrainedVariableId var); ConstraintId getConstraintByIndex(unsigned int index); - unsigned int getIndexByConstraint(const ConstraintId& constr); + unsigned int getIndexByConstraint(const ConstraintId constr); /** * @brief Adds a listener to operations invoked on the client */ - void notifyAdded(const DbClientListenerId& listener); + void notifyAdded(const DbClientListenerId listener); /** * @brief Removes a listener */ - void notifyRemoved(const DbClientListenerId& listener); + void notifyRemoved(const DbClientListenerId listener); /** @@ -337,23 +331,23 @@ namespace EUROPA { /** * @brief Create a value for a string */ - edouble createValue(const char* typeName, const std::string& value); + edouble createValue(const std::string& typeName, const std::string& value); // Temporarily exposing these to remove singletons, need to review DbClient concept in general - const CESchemaId& getCESchema() const; - const SchemaId& getSchema() const; + const CESchemaId getCESchema() const; + const SchemaId getSchema() const; private: friend class PlanDatabase; - DbClient(const PlanDatabaseId& db); + DbClient(const PlanDatabaseId db); ~DbClient(); DbClient(); /* NO IMPL */ DbClient(const DbClient&); /* NO IMPL */ /*!< Helper methods */ - TokenId allocateToken(const char* tokenType, - const char* tokenName, + TokenId allocateToken(const std::string& tokenType, + const std::string& tokenName, bool rejectable, bool isFact=false); @@ -368,7 +362,7 @@ namespace EUROPA { class PSPlanDatabaseClientImpl : public PSPlanDatabaseClient { public: - PSPlanDatabaseClientImpl(const DbClientId& c); + PSPlanDatabaseClientImpl(const DbClientId c); virtual PSVariable* createVariable(const std::string& typeName, const std::string& name, bool isTmpVar); virtual void deleteVariable( PSVariable* var); diff --git a/src/PLASMA/PlanDatabase/base/DbClientListener.cc b/src/PLASMA/PlanDatabase/base/DbClientListener.cc new file mode 100644 index 000000000..67aa2fab6 --- /dev/null +++ b/src/PLASMA/PlanDatabase/base/DbClientListener.cc @@ -0,0 +1,29 @@ +#include "DbClientListener.hh" + +namespace EUROPA { +void DbClientListener::notifyObjectCreated(const ObjectId) {} +void DbClientListener::notifyObjectCreated(const ObjectId, + const std::vector&){} +void DbClientListener::notifyObjectDeleted(const ObjectId) {} +void DbClientListener::notifyClosed(){} +void DbClientListener::notifyClosed(const std::string&){} +void DbClientListener::notifyTokenCreated(const TokenId){} +void DbClientListener::notifyTokenDeleted(const TokenId, const std::string&){} +void DbClientListener::notifyConstrained(const ObjectId, const TokenId, + const TokenId){} +void DbClientListener::notifyFreed(const ObjectId, const TokenId, + const TokenId){} +void DbClientListener::notifyActivated(const TokenId){} +void DbClientListener::notifyMerged(const TokenId, const TokenId){} +void DbClientListener::notifyMerged(const TokenId){} +void DbClientListener::notifyRejected(const TokenId){} +void DbClientListener::notifyCancelled(const TokenId){} +void DbClientListener::notifyConstraintCreated(const ConstraintId){} +void DbClientListener::notifyConstraintDeleted(const ConstraintId){} +void DbClientListener::notifyVariableCreated(const ConstrainedVariableId){} +void DbClientListener::notifyVariableDeleted(const ConstrainedVariableId){} +void DbClientListener::notifyVariableSpecified(const ConstrainedVariableId){} +void DbClientListener::notifyVariableRestricted(const ConstrainedVariableId){} +void DbClientListener::notifyVariableClosed(const ConstrainedVariableId){} +void DbClientListener::notifyVariableReset(const ConstrainedVariableId){} +} diff --git a/src/PLASMA/PlanDatabase/base/DbClientListener.hh b/src/PLASMA/PlanDatabase/base/DbClientListener.hh index b968c0c8e..9b1091118 100644 --- a/src/PLASMA/PlanDatabase/base/DbClientListener.hh +++ b/src/PLASMA/PlanDatabase/base/DbClientListener.hh @@ -1,5 +1,5 @@ -#ifndef _H_DbClientListener -#define _H_DbClientListener +#ifndef H_DbClientListener +#define H_DbClientListener #include "PlanDatabaseDefs.hh" #include "DbClient.hh" @@ -24,36 +24,36 @@ namespace EUROPA { m_id.remove(); } - const DbClientListenerId& getId() const {return m_id;} + const DbClientListenerId getId() const {return m_id;} - virtual void notifyObjectCreated(const ObjectId& object) {} - virtual void notifyObjectCreated(const ObjectId& object, const std::vector& arguments){} - virtual void notifyObjectDeleted(const ObjectId& object) {} - virtual void notifyClosed(){} - virtual void notifyClosed(const LabelStr& objectType){} - virtual void notifyTokenCreated(const TokenId& token){} - virtual void notifyTokenDeleted(const TokenId& token, const std::string& name){} - virtual void notifyConstrained(const ObjectId& object, const TokenId& predecessor, const TokenId& successor){} - virtual void notifyFreed(const ObjectId& object, const TokenId& predecessor, const TokenId& successor){} - virtual void notifyActivated(const TokenId& token){} - virtual void notifyMerged(const TokenId& token, const TokenId& activeToken){} - virtual void notifyMerged(const TokenId& token){} - virtual void notifyRejected(const TokenId& token){} - virtual void notifyCancelled(const TokenId& token){} - virtual void notifyConstraintCreated(const ConstraintId& constraint){} - virtual void notifyConstraintDeleted(const ConstraintId& constraint){} - virtual void notifyVariableCreated(const ConstrainedVariableId& variable){} - virtual void notifyVariableDeleted(const ConstrainedVariableId& variable){} - virtual void notifyVariableSpecified(const ConstrainedVariableId& variable){} - virtual void notifyVariableRestricted(const ConstrainedVariableId& variable){} - virtual void notifyVariableClosed(const ConstrainedVariableId& variable){} - virtual void notifyVariableReset(const ConstrainedVariableId& variable){} + virtual void notifyObjectCreated(const ObjectId object); + virtual void notifyObjectCreated(const ObjectId object, const std::vector& arguments); + virtual void notifyObjectDeleted(const ObjectId object); + virtual void notifyClosed(); + virtual void notifyClosed(const std::string& objectType); + virtual void notifyTokenCreated(const TokenId token); + virtual void notifyTokenDeleted(const TokenId token, const std::string& name); + virtual void notifyConstrained(const ObjectId object, const TokenId predecessor, const TokenId successor); + virtual void notifyFreed(const ObjectId object, const TokenId predecessor, const TokenId successor); + virtual void notifyActivated(const TokenId token); + virtual void notifyMerged(const TokenId token, const TokenId activeToken); + virtual void notifyMerged(const TokenId token); + virtual void notifyRejected(const TokenId token); + virtual void notifyCancelled(const TokenId token); + virtual void notifyConstraintCreated(const ConstraintId constraint); + virtual void notifyConstraintDeleted(const ConstraintId constraint); + virtual void notifyVariableCreated(const ConstrainedVariableId variable); + virtual void notifyVariableDeleted(const ConstrainedVariableId variable); + virtual void notifyVariableSpecified(const ConstrainedVariableId variable); + virtual void notifyVariableRestricted(const ConstrainedVariableId variable); + virtual void notifyVariableClosed(const ConstrainedVariableId variable); + virtual void notifyVariableReset(const ConstrainedVariableId variable); private: DbClientListenerId m_id; protected: - DbClientListener(const DbClientId& client):m_id(this), m_client(client){m_client->notifyAdded(m_id);} + DbClientListener(const DbClientId client):m_id(this), m_client(client){m_client->notifyAdded(m_id);} DbClientId m_client; }; } #endif diff --git a/src/PLASMA/PlanDatabase/base/DefaultTemporalAdvisor.cc b/src/PLASMA/PlanDatabase/base/DefaultTemporalAdvisor.cc index cbb40377b..638fef34e 100644 --- a/src/PLASMA/PlanDatabase/base/DefaultTemporalAdvisor.cc +++ b/src/PLASMA/PlanDatabase/base/DefaultTemporalAdvisor.cc @@ -11,7 +11,7 @@ */ namespace EUROPA { - DefaultTemporalAdvisor::DefaultTemporalAdvisor(const ConstraintEngineId& ce): m_id(this), m_ce(ce){ + DefaultTemporalAdvisor::DefaultTemporalAdvisor(const ConstraintEngineId ce): m_id(this), m_ce(ce){ // std::cout << "Default Advisor being constructed" << m_id << std::endl; } @@ -20,7 +20,7 @@ namespace EUROPA { m_id.remove(); } - bool DefaultTemporalAdvisor::canPrecede(const TokenId& first, const TokenId& second){ + bool DefaultTemporalAdvisor::canPrecede(const TokenId first, const TokenId second){ // std::cout << "DefaultTemporalAdvisor canPrecede (" << first->getKey() << ") and (" << second->getKey() << ")" << std::endl; eint earliest_end = cast_int(first->end()->getDerivedDomain().getLowerBound()); @@ -29,11 +29,11 @@ namespace EUROPA { return (earliest_end <= latest_start); } - bool DefaultTemporalAdvisor::canPrecede(const TimeVarId& first, const TimeVarId& second) { + bool DefaultTemporalAdvisor::canPrecede(const TimeVarId first, const TimeVarId second) { return first->getDerivedDomain().getLowerBound() <= second->getDerivedDomain().getUpperBound(); } - bool DefaultTemporalAdvisor::canFitBetween(const TokenId& token, const TokenId& predecessor, const TokenId& successor){ + bool DefaultTemporalAdvisor::canFitBetween(const TokenId token, const TokenId predecessor, const TokenId successor){ check_error(token.isValid()); check_error(predecessor.isValid()); check_error(successor.isValid()); @@ -52,51 +52,53 @@ namespace EUROPA { } - /** - * @brief Trivially return true since basic domain intersection tests have been done in - * the plan database already - */ - bool DefaultTemporalAdvisor::canBeConcurrent(const TokenId& first, const TokenId& second){ - return true; - } +/** + * @brief Trivially return true since basic domain intersection tests have been done in + * the plan database already + */ +bool DefaultTemporalAdvisor::canBeConcurrent(const TokenId, const TokenId){ + return true; +} + + const TemporalAdvisorId DefaultTemporalAdvisor::getId() const {return m_id;} - const TemporalAdvisorId& DefaultTemporalAdvisor::getId() const {return m_id;} - - /** - * @brief Default return that the distance is infinite - */ - const IntervalIntDomain DefaultTemporalAdvisor::getTemporalDistanceDomain(const TimeVarId& first, - const TimeVarId& second, - const bool exact){ - if( first->getExternalEntity().isNoId() - || - second->getExternalEntity().isNoId() ) - { - eint f_lb = cast_int(first->getDerivedDomain().getLowerBound()); - eint f_ub = cast_int(first->getDerivedDomain().getUpperBound()); +/** + * @brief Default return that the distance is infinite + */ +const IntervalIntDomain DefaultTemporalAdvisor::getTemporalDistanceDomain(const TimeVarId first, + const TimeVarId second, + const bool){ + if( first->getExternalEntity().isNoId() + || + second->getExternalEntity().isNoId() ) + { + eint f_lb = cast_int(first->getDerivedDomain().getLowerBound()); + eint f_ub = cast_int(first->getDerivedDomain().getUpperBound()); - eint s_lb = cast_int(second->getDerivedDomain().getLowerBound()); - eint s_ub = cast_int(second->getDerivedDomain().getUpperBound()); + eint s_lb = cast_int(second->getDerivedDomain().getLowerBound()); + eint s_ub = cast_int(second->getDerivedDomain().getUpperBound()); - eint min_distance = -g_infiniteTime(); + eint min_distance = MINUS_INFINITY;//-g_infiniteTime(); - if( s_lb > -g_infiniteTime() && f_ub < g_infiniteTime() ) { - min_distance = std::max( min_distance, s_lb - f_ub ); - } + // if( s_lb > -g_infiniteTime() && f_ub < g_infiniteTime() ) { + if( s_lb > MINUS_INFINITY && f_ub < PLUS_INFINITY ) { + min_distance = std::max( min_distance, s_lb - f_ub ); + } - eint max_distance = g_infiniteTime(); + eint max_distance = PLUS_INFINITY;//g_infiniteTime(); - if( f_lb > -g_infiniteTime() && s_ub < g_infiniteTime() ) { - max_distance = std::min( max_distance, s_ub - f_lb ); - } - - return(IntervalIntDomain( min_distance, max_distance )); - } + // if( f_lb > -g_infiniteTime() && s_ub < g_infiniteTime() ) { + if( f_lb > MINUS_INFINITY && s_ub < PLUS_INFINITY) { + max_distance = std::min( max_distance, s_ub - f_lb ); + } - return(IntervalIntDomain(-g_infiniteTime(), g_infiniteTime())); + return(IntervalIntDomain( min_distance, max_distance )); } - void DefaultTemporalAdvisor::getTemporalDistanceDomains(const ConstrainedVariableId& first, + return(IntervalIntDomain(MINUS_INFINITY, PLUS_INFINITY)); +} + + void DefaultTemporalAdvisor::getTemporalDistanceDomains(const ConstrainedVariableId first, const std::vector& seconds, std::vector& domains){ @@ -105,7 +107,7 @@ namespace EUROPA { } } - void DefaultTemporalAdvisor::getTemporalDistanceSigns(const ConstrainedVariableId& first, + void DefaultTemporalAdvisor::getTemporalDistanceSigns(const ConstrainedVariableId first, const std::vector& seconds, std::vector& lbs, diff --git a/src/PLASMA/PlanDatabase/base/DefaultTemporalAdvisor.hh b/src/PLASMA/PlanDatabase/base/DefaultTemporalAdvisor.hh index d17ee4141..b087e7f38 100644 --- a/src/PLASMA/PlanDatabase/base/DefaultTemporalAdvisor.hh +++ b/src/PLASMA/PlanDatabase/base/DefaultTemporalAdvisor.hh @@ -1,5 +1,5 @@ -#ifndef _H_DefaultTemporalAdvisor -#define _H_DefaultTemporalAdvisor +#ifndef H_DefaultTemporalAdvisor +#define H_DefaultTemporalAdvisor #include "PlanDatabaseDefs.hh" #include "TemporalAdvisor.hh" @@ -14,30 +14,30 @@ namespace EUROPA{ public: - DefaultTemporalAdvisor(const ConstraintEngineId& ce); + DefaultTemporalAdvisor(const ConstraintEngineId ce); virtual ~DefaultTemporalAdvisor(); - virtual bool canPrecede(const TokenId& first, const TokenId& second); - virtual bool canPrecede(const TimeVarId& first, const TimeVarId& second); - virtual bool canFitBetween(const TokenId& token, const TokenId& predecessor, - const TokenId& successor); - virtual bool canBeConcurrent(const TokenId& first, const TokenId& second); - virtual const IntervalIntDomain getTemporalDistanceDomain(const TimeVarId& first, - const TimeVarId& second, + virtual bool canPrecede(const TokenId first, const TokenId second); + virtual bool canPrecede(const TimeVarId first, const TimeVarId second); + virtual bool canFitBetween(const TokenId token, const TokenId predecessor, + const TokenId successor); + virtual bool canBeConcurrent(const TokenId first, const TokenId second); + virtual const IntervalIntDomain getTemporalDistanceDomain(const TimeVarId first, + const TimeVarId second, const bool exact); - virtual void getTemporalDistanceDomains(const ConstrainedVariableId& first, + virtual void getTemporalDistanceDomains(const ConstrainedVariableId first, const std::vector& seconds, std::vector& domains); - virtual void getTemporalDistanceSigns(const ConstrainedVariableId& first, + virtual void getTemporalDistanceSigns(const ConstrainedVariableId first, const std::vector& seconds, std::vector& lbs, std::vector& ubs); virtual unsigned int mostRecentRepropagation() const; - const TemporalAdvisorId& getId() const; + const TemporalAdvisorId getId() const; protected: TemporalAdvisorId m_id; const ConstraintEngineId m_ce; diff --git a/src/PLASMA/PlanDatabase/base/HasAncestorConstraint.cc b/src/PLASMA/PlanDatabase/base/HasAncestorConstraint.cc index 50330fdbe..406b8b6d7 100644 --- a/src/PLASMA/PlanDatabase/base/HasAncestorConstraint.cc +++ b/src/PLASMA/PlanDatabase/base/HasAncestorConstraint.cc @@ -1,11 +1,12 @@ #include "HasAncestorConstraint.hh" #include "Object.hh" +#include "CESchema.hh" namespace EUROPA{ - HasAncestorConstraint::HasAncestorConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + HasAncestorConstraint::HasAncestorConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_first(static_cast(getCurrentDomain(variables[0]))), @@ -23,22 +24,22 @@ namespace EUROPA{ apply(); } - void HasAncestorConstraint::handleExecute(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType){ - handleExecute(); - } - - bool HasAncestorConstraint::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType){ - check_error(argIndex <= 1); - - if(m_first.isOpen() || m_restrictions.isOpen()) - return true; +void HasAncestorConstraint::handleExecute(const ConstrainedVariableId, + unsigned int, + const DomainListener::ChangeType&){ + handleExecute(); +} - return (false); - } +bool HasAncestorConstraint::canIgnore(const ConstrainedVariableId, + unsigned int argIndex, + const DomainListener::ChangeType&){ + check_error(argIndex <= 1); + + if(m_first.isOpen() || m_restrictions.isOpen()) + return true; + + return (false); +} void HasAncestorConstraint::apply() { @@ -56,7 +57,7 @@ namespace EUROPA{ allAncestors.unique(); ObjectId object = allAncestors.front(); - const DataTypeId& dt = m_constraintEngine->getCESchema()->getDataType(object->getRootType().c_str()); + const DataTypeId dt = m_constraintEngine->getCESchema()->getDataType(object->getRootType().c_str()); ObjectDomain setOfAncestors(dt,allAncestors); // Prune this set for those elements in the set of restrictions imposed setOfAncestors.intersect(m_restrictions); @@ -70,8 +71,8 @@ namespace EUROPA{ candidate->getAncestors(candidatesAncestors); bool removeCandidate = true; for(std::list::const_iterator it1 = candidatesAncestors.begin(); it1 != candidatesAncestors.end(); ++it1){ - ObjectId object = *it1; - if(setOfAncestors.isMember(object)){ // Found common ancestor + ObjectId ancestor = *it1; + if(setOfAncestors.isMember(ancestor)){ // Found common ancestor removeCandidate = false; break; } diff --git a/src/PLASMA/PlanDatabase/base/HasAncestorConstraint.hh b/src/PLASMA/PlanDatabase/base/HasAncestorConstraint.hh index 6ef977506..1698cde0d 100644 --- a/src/PLASMA/PlanDatabase/base/HasAncestorConstraint.hh +++ b/src/PLASMA/PlanDatabase/base/HasAncestorConstraint.hh @@ -1,38 +1,41 @@ -#ifndef _H_HasAncestorConstraint -#define _H_HasAncestorConstraint +#ifndef H_HasAncestorConstraint +#define H_HasAncestorConstraint #include "PlanDatabaseDefs.hh" #include "Constraint.hh" +#include "ConstraintTypeChecking.hh" namespace EUROPA { - /** - * @brief Requires that both objects are singletons before it will execute - */ - class HasAncestorConstraint: public Constraint - { - public: +class ObjectDomain; +/** + * @brief Requires that both objects are singletons before it will execute + */ +class HasAncestorConstraint: public Constraint +{ + public: - HasAncestorConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + HasAncestorConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); - ~HasAncestorConstraint(); + ~HasAncestorConstraint(); - void handleExecute(); + void handleExecute(); - void handleExecute(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); + void handleExecute(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); - private: - void apply(); - ObjectDomain& m_first; - const ObjectDomain& m_restrictions; /*!, All > > HasAncestorCT; } #endif diff --git a/src/PLASMA/PlanDatabase/base/MergeMemento.cc b/src/PLASMA/PlanDatabase/base/MergeMemento.cc index 513245cad..3489bd3c2 100644 --- a/src/PLASMA/PlanDatabase/base/MergeMemento.cc +++ b/src/PLASMA/PlanDatabase/base/MergeMemento.cc @@ -8,33 +8,9 @@ namespace EUROPA{ - /** - * @brief Helper method to lookup a replacement for a variable or use the one u r given. - * - * The need for this arises out of Token merging where we want to migrate any constraints on - * a Token being merged to its active token. Thus, any variables of the Token being merged which - * participate in a constraint shall be replaced with the equivalent variable in the active - * token. - * @param lookup A lookup table for variable in the merged token to corresponding variable in the active Token. - * The key is a double, which is the encoding of the variable Id. - * @param var The variable to be replaced, if found. It may not be in the map, indicating it is not a variable of the - * merged token. - * @return Variable Id Entry in lookup table if the given token is part of the token being merged, - * otherwise returns var. - * @todo The algorithm for splitting is very sub-optimal in the non-chronological case. Consider in the future - * an algorithm to migrate consequenecs rather than force additional splits. This is similar to deactivation - * of a token in its simple, robust, and potentially inefficient treatment of such non-chronological retractions. - */ -// ConstrainedVariableId checkForReplacement(const std::map& lookup, const ConstrainedVariableId& var){ -// std::map::const_iterator it = lookup.find((edouble) var); -// if(it == lookup.end()) -// return var; -// else -// return (it->second); -// } - - MergeMemento::MergeMemento(const TokenId& inactiveToken, const TokenId& activeToken) - :m_inactiveToken(inactiveToken), m_activeToken(activeToken), m_undoing(false){ + MergeMemento::MergeMemento(const TokenId inactiveToken, const TokenId activeToken) + :m_inactiveToken(inactiveToken), m_activeToken(activeToken), + m_deactivatedConstraints(), m_newConstraints(), m_undoing(false){ checkError(inactiveToken.isValid(), inactiveToken); checkError(activeToken.isValid(), activeToken); @@ -50,10 +26,10 @@ namespace EUROPA{ std::set deactivatedConstraints; //Exclude this for the state variable, which will necessarily conflict with the target active token - for(unsigned int i=1; igetKey()) == varMap.end()); + for(unsigned long i=1; igetKey()) == varMap.end()); // Add to the map to support lookup and store all constraints on any variables - varMap.insert(std::make_pair((eint) inactiveVariables[i]->getKey(), activeVariables[i])); + varMap.insert(std::make_pair(inactiveVariables[i]->getKey(), activeVariables[i])); inactiveVariables[i]->constraints(deactivatedConstraints); // i.e. not a state variable @@ -117,12 +93,12 @@ namespace EUROPA{ m_undoing = false; } - void MergeMemento::handleAdditionOfInactiveConstraint(const ConstraintId& constraint){ + void MergeMemento::handleAdditionOfInactiveConstraint(const ConstraintId constraint){ debugMsg("europa:merging:handleAdditionOfInactiveConstraint", constraint->toString()); migrateConstraint(constraint); } - void MergeMemento::handleRemovalOfInactiveConstraint(const ConstraintId& constraint){ + void MergeMemento::handleRemovalOfInactiveConstraint(const ConstraintId constraint){ check_error(m_deactivatedConstraints.size() + m_inactiveToken->getVariables().size() >= m_newConstraints.size()); checkError(!constraint->isActive(), constraint->toString()); @@ -157,7 +133,7 @@ namespace EUROPA{ } } - void MergeMemento::migrateConstraint(const ConstraintId& constraint){ + void MergeMemento::migrateConstraint(const ConstraintId constraint){ checkError(constraint.isValid(), constraint); checkError(m_activeToken.isValid(), m_activeToken); checkError(m_activeToken->isActive(), m_activeToken->toString()); diff --git a/src/PLASMA/PlanDatabase/base/MergeMemento.hh b/src/PLASMA/PlanDatabase/base/MergeMemento.hh index 6fa37a9d0..450a51509 100644 --- a/src/PLASMA/PlanDatabase/base/MergeMemento.hh +++ b/src/PLASMA/PlanDatabase/base/MergeMemento.hh @@ -1,12 +1,8 @@ -#ifndef _H_MergeMemento -#define _H_MergeMemento +#ifndef H_MergeMemento +#define H_MergeMemento +#include "ConstraintEngineDefs.hh" #include "PlanDatabaseDefs.hh" -#include "Token.hh" -//#include "TokenVariable.hh" -#include "LabelStr.hh" -#include "Constraint.hh" -#include "ConstrainedVariable.hh" #include #include @@ -17,26 +13,26 @@ namespace EUROPA{ virtual ~MergeMemento(); protected: friend class UnifyMemento; - MergeMemento(const TokenId& inactiveToken, const TokenId& activeToken); + MergeMemento(const TokenId inactiveToken, const TokenId activeToken); void undo(bool activeTokenDeleted); /** * @brief A constraint has been placed on the variable of a merged token. This will in practice occur if * constraints are posted in guards on slaves introduced outside of the guard */ - void handleAdditionOfInactiveConstraint(const ConstraintId& constraint); + void handleAdditionOfInactiveConstraint(const ConstraintId constraint); /** * @brief A Constraint may have been placed on a variable of an INACTIVE token priot to merging. * It must be possible to undo this decision, which will require removal of equivalent constraint which * was created on the active token. */ - void handleRemovalOfInactiveConstraint(const ConstraintId& constraint); + void handleRemovalOfInactiveConstraint(const ConstraintId constraint); /** * @brief Helper method to migrate a constraint to the active token. Will not migrate constraints impacting state variable */ - void migrateConstraint(const ConstraintId& constraint); + void migrateConstraint(const ConstraintId constraint); const TokenId m_inactiveToken; const TokenId m_activeToken; diff --git a/src/PLASMA/PlanDatabase/base/Method.cc b/src/PLASMA/PlanDatabase/base/Method.cc index f7bb68805..9c7a68fb6 100644 --- a/src/PLASMA/PlanDatabase/base/Method.cc +++ b/src/PLASMA/PlanDatabase/base/Method.cc @@ -20,12 +20,12 @@ Method::~Method() m_id.remove(); } -const MethodId& Method::getId() const +const MethodId Method::getId() const { return m_id; } -const LabelStr& Method::getName() const +const std::string& Method::getName() const { return m_name; } diff --git a/src/PLASMA/PlanDatabase/base/Method.hh b/src/PLASMA/PlanDatabase/base/Method.hh index 3bbff9377..d7a62fdee 100644 --- a/src/PLASMA/PlanDatabase/base/Method.hh +++ b/src/PLASMA/PlanDatabase/base/Method.hh @@ -8,7 +8,6 @@ #ifndef METHOD_HH_ #define METHOD_HH_ -#include "LabelStr.hh" #include "ConstraintEngineDefs.hh" #include "PDBInterpreter.hh" #include @@ -24,20 +23,20 @@ public: Method(const char* name); virtual ~Method(); - const MethodId& getId() const; + const MethodId getId() const; - const LabelStr& getName() const; + const std::string& getName() const; virtual DataRef eval(EvalContext& context, const std::vector& args) const = 0; virtual const std::vector& getSignature() = 0; - virtual const DataTypeId& getReturnType() = 0; + virtual const DataTypeId getReturnType() = 0; virtual std::string toString() const; protected: MethodId m_id; - LabelStr m_name; + std::string m_name; }; } diff --git a/src/PLASMA/PlanDatabase/base/Object.cc b/src/PLASMA/PlanDatabase/base/Object.cc index 6b8556ab7..4ccd7ce6c 100644 --- a/src/PLASMA/PlanDatabase/base/Object.cc +++ b/src/PLASMA/PlanDatabase/base/Object.cc @@ -9,7 +9,8 @@ #include "Domains.hh" #include "Utils.hh" #include "Debug.hh" -#include "EntityIterator.hh" +#include "CESchema.hh" +#include "PSVarValue.hh" #include #include @@ -19,9 +20,18 @@ */ namespace EUROPA { - Object::Object(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open) - : m_id(this), m_type(type), m_name(name), m_planDatabase(planDatabase), - m_state(INCOMPLETE), m_lastOrderingChoiceCount(0), +Object::Object(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open) + : m_id(this), m_parent(), m_type(type), m_name(name), + m_planDatabase(planDatabase), + m_state(INCOMPLETE), + m_components(), + m_tokens(), + m_variables(), + m_explicitConstraints(), + m_lastOrderingChoiceCount(0), + m_constraintsByTokenKey(), + m_constraintsByKeyPair(), + m_keyPairsByConstraintKey(), m_thisVar((new Variable< ObjectDomain>(m_planDatabase->getConstraintEngine(), ObjectDomain(m_planDatabase->getSchema()->getCESchema()->getDataType(type.c_str()), m_id)))->getId()) { @@ -30,18 +40,26 @@ namespace EUROPA { close(); } - Object::Object(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open) + Object::Object(const ObjectId parent, const std::string& type, const std::string& localName, bool open) : m_id(this), m_parent(parent), m_type(type), - m_name(std::string(parent->getName().toString() + "." + localName.toString())), + m_name(std::string(parent->getName() + "." + localName)), m_planDatabase(parent->getPlanDatabase()), m_state(INCOMPLETE), + m_components(), + m_tokens(), + m_variables(), + m_explicitConstraints(), + m_lastOrderingChoiceCount(0), + m_constraintsByTokenKey(), + m_constraintsByKeyPair(), + m_keyPairsByConstraintKey(), m_thisVar((new Variable< ObjectDomain>(m_planDatabase->getConstraintEngine(), ObjectDomain(m_planDatabase->getSchema()->getCESchema()->getDataType(type.c_str()),m_id)))->getId()) { check_error(m_parent.isValid()); check_error(m_planDatabase->getSchema()->canContain(parent->getType(), type, localName), - "Object " + parent->getName().toString() + - " cannot contain " + localName.toString() + " of type " + type.toString()); + "Object " + parent->getName() + + " cannot contain " + localName + " of type " + type); parent->add(m_id); if (!open) @@ -56,12 +74,14 @@ namespace EUROPA { m_id.remove(); } +void Object::constructor(const std::vector&) {} + /* * Hack! Code generation currently skips the factories and directly calls the constructor that specifies the parent, * so this is necessary for the interpreter to provide the same behavior * Everybody should be going through the factories */ - void Object::setParent(const ObjectId& parent) + void Object::setParent(const ObjectId parent) { m_parent = parent; m_parent->add(m_id); @@ -102,20 +122,20 @@ namespace EUROPA { Entity::handleDiscard(); } - const ObjectId& Object::getId() const { + const ObjectId Object::getId() const { return(m_id); } - const ObjectId& Object::getParent() const { + const ObjectId Object::getParent() const { return(m_parent); } - const LabelStr& Object::getType() const { - return(m_type); - } +const std::string& Object::getType() const { + return(m_type); +} - const LabelStr Object::getRootType() const { - LabelStr rootType = getType(); + const std::string Object::getRootType() const { + std::string rootType = getType(); while(m_planDatabase->getSchema()->hasParent(rootType)) rootType = m_planDatabase->getSchema()->getParent(rootType); @@ -125,15 +145,15 @@ namespace EUROPA { - const LabelStr& Object::getName() const { - return(m_name); - } +const std::string& Object::getName() const { + return(m_name); +} - const PlanDatabaseId& Object::getPlanDatabase() const { + const PlanDatabaseId Object::getPlanDatabase() const { return(m_planDatabase); } - const ConstrainedVariableId& Object::getThis() const { + const ConstrainedVariableId Object::getThis() const { return m_thisVar; } @@ -145,30 +165,30 @@ namespace EUROPA { return(m_variables); } - void Object::add(const ObjectId& component) { + void Object::add(const ObjectId component) { check_error(m_components.find(component) == m_components.end()); check_error(component->getPlanDatabase() == m_planDatabase); check_error(component->getParent() == m_id); m_components.insert(component); } - void Object::remove(const ObjectId& component) { + void Object::remove(const ObjectId component) { check_error(!Entity::isPurging()); check_error(m_components.find(component) != m_components.end()); m_components.erase(component); } - void Object::add(const TokenId& token) { + void Object::add(const TokenId token) { check_error(isComplete()); - debugMsg("Object:add:token", "Adding token " << token->getPredicateName().toString() << "(" << token->getKey() << ")"); + debugMsg("Object:add:token", "Adding token " << token->getPredicateName() << "(" << token->getKey() << ")"); m_tokens.insert(token); m_planDatabase->notifyAdded(m_id, token); } - void Object::remove(const TokenId& token) { + void Object::remove(const TokenId token) { check_error(token.isValid()); - debugMsg("Object:remove:token", "Removing token " << token->getPredicateName().toString() << "(" << token->getKey() << ") from " << toString()); + debugMsg("Object:remove:token", "Removing token " << token->getPredicateName() << "(" << token->getKey() << ") from " << toString()); check_error(isValid()); check_error(!Entity::isPurging()); @@ -193,7 +213,8 @@ namespace EUROPA { debugMsg("Object:remove:token", "Also removing " << constraint->toString()); // If the constraint is a precedence constraint, the additional cleanup required - std::map::iterator pos = m_keyPairsByConstraintKey.find(constraint->getKey()); + std::map >::iterator pos = + m_keyPairsByConstraintKey.find(constraint->getKey()); if(pos != m_keyPairsByConstraintKey.end()) removePrecedenceConstraint(constraint); } @@ -225,101 +246,100 @@ namespace EUROPA { return(m_tokens); } - bool Object::hasToken(const TokenId& token) const { + bool Object::hasToken(const TokenId token) const { return m_tokens.find(token) != m_tokens.end() && token->getObject()->lastDomain().isSingleton(); } - void Object::getOrderingChoices( const TokenId& token, + void Object::getOrderingChoices( const TokenId token, std::vector< std::pair >& results, #ifdef _MSC_VER - unsigned int limit + unsigned long limit #else - unsigned int limit + unsigned long limit #endif ) { check_error(limit > 0, "Cannot set limit to less than 1."); results.push_back(std::make_pair(token, token)); } - unsigned int Object::countOrderingChoices(const TokenId& token, unsigned int limit){ - std::vector< std::pair > results; - getOrderingChoices(token, results, limit); - m_lastOrderingChoiceCount = results.size(); - return m_lastOrderingChoiceCount; - } +unsigned long Object::countOrderingChoices(const TokenId token, unsigned long limit){ + std::vector< std::pair > results; + getOrderingChoices(token, results, limit); + m_lastOrderingChoiceCount = results.size(); + return m_lastOrderingChoiceCount; +} - unsigned int Object::lastOrderingChoiceCount(const TokenId& token) const{ return m_lastOrderingChoiceCount; } +unsigned long Object::lastOrderingChoiceCount(const TokenId) const{ + return m_lastOrderingChoiceCount; +} - void Object::getTokensToOrder(std::vector& results) {} +void Object::getTokensToOrder(std::vector&) {} bool Object::hasTokensToOrder() const { return(false); } - void Object::constrain(const TokenId& predecessor, const TokenId& successor){ + void Object::constrain(const TokenId predecessor, const TokenId successor){ constrain(predecessor, successor, true); } - void Object::constrain(const TokenId& predecessor, const TokenId& successor, bool isExplicit) { - check_error(predecessor.isValid()); - checkError(predecessor->isActive(), predecessor->toString() << ": " << predecessor->getState()->toString()); - check_error(successor.isValid()); - checkError(successor->isActive(), successor->toString() << ": " << successor->getState()->toString()); +void Object::constrain(const TokenId predecessor, const TokenId successor, bool isExplicit) { + check_error(predecessor.isValid()); + checkError(predecessor->isActive(), predecessor->toString() << ": " << predecessor->getState()->toString()); + check_error(successor.isValid()); + checkError(successor->isActive(), successor->toString() << ": " << successor->getState()->toString()); - check_error(!isConstrainedToPrecede(predecessor, successor), - "Attempted to constrain previously constrained tokens."); + check_error(!isConstrainedToPrecede(predecessor, successor), + "Attempted to constrain previously constrained tokens."); - // Post constraints on object variable, predecessor only in event they are equal - constrainToThisObjectAsNeeded(predecessor); + // Post constraints on object variable, predecessor only in event they are equal + constrainToThisObjectAsNeeded(predecessor); - debugMsg("Object:constrain", - "Constraining " << predecessor->toString() << " to be before " << successor->toString() << - (isExplicit ? " explicitly." : " implicitly.")); - int encodedKey = makeKey(predecessor, successor); + debugMsg("Object:constrain", + "Constraining " << predecessor->toString() << " to be before " << successor->toString() << + (isExplicit ? " explicitly." : " implicitly.")); + std::pair encodedKey = std::make_pair(predecessor->getKey(), + successor->getKey()); - condDebugMsg(m_constraintsByKeyPair.find(encodedKey) != m_constraintsByKeyPair.end(), "Object:makeKey", - "Collision detected for " << predecessor->toString() << " and " << successor->toString() << - " with " << encodedKey); + ConstraintId constraint; - ConstraintId constraint; + // If successor is not noId then add the precede constraint. + if (predecessor != successor) { + constrainToThisObjectAsNeeded(successor); // Also constrain successor if necessary - // If successor is not noId then add the precede constraint. - if (predecessor != successor) { - constrainToThisObjectAsNeeded(successor); // Also constrain successor if necessary + // Create the precedence constraint + std::vector vars; + vars.push_back(predecessor->end()); + vars.push_back(successor->start()); + constraint = getPlanDatabase()->getConstraintEngine()->createConstraint( + "precedes", + vars); - // Create the precedence constraint - std::vector vars; - vars.push_back(predecessor->end()); - vars.push_back(successor->start()); - constraint = getPlanDatabase()->getConstraintEngine()->createConstraint( - LabelStr("precedes"), - vars); + // Store for bi-directional access by encoded key pair and constraint + m_constraintsByKeyPair.insert(std::make_pair(encodedKey, constraint)); + m_keyPairsByConstraintKey.insert(std::make_pair(constraint->getKey(), encodedKey)); - // Store for bi-directional access by encoded key pair and constraint - m_constraintsByKeyPair.insert(std::pair(encodedKey, constraint)); - m_keyPairsByConstraintKey.insert(std::make_pair(constraint->getKey(), encodedKey)); + // Store for access by token + m_constraintsByTokenKey.insert(std::make_pair(predecessor->getKey(), constraint)); + m_constraintsByTokenKey.insert(std::make_pair(successor->getKey(), constraint)); + } - // Store for access by token - m_constraintsByTokenKey.insert(std::make_pair(predecessor->getKey(), constraint)); - m_constraintsByTokenKey.insert(std::make_pair(successor->getKey(), constraint)); - } + if(isExplicit) + m_explicitConstraints.insert(constraint.isId() ? constraint->getKey() : predecessor->getKey()); - if(isExplicit) - m_explicitConstraints.insert(constraint.isId() ? constraint->getKey() : predecessor->getKey()); + m_planDatabase->notifyConstrained(m_id, predecessor, successor); + check_error(isValid()); - m_planDatabase->notifyConstrained(m_id, predecessor, successor); - check_error(isValid()); - - if (getPlanDatabase()->getConstraintEngine()->getAutoPropagation()) - getPlanDatabase()->getConstraintEngine()->propagate(); + if (getPlanDatabase()->getConstraintEngine()->getAutoPropagation()) + getPlanDatabase()->getConstraintEngine()->propagate(); - } +} - void Object::free(const TokenId& predecessor, const TokenId& successor){ + void Object::free(const TokenId predecessor, const TokenId successor){ free(predecessor, successor, true); } - void Object::free(const TokenId& predecessor, const TokenId& successor, bool isExplicit) { + void Object::free(const TokenId predecessor, const TokenId successor, bool isExplicit) { check_error(!Entity::isPurging()); check_error(predecessor.isValid()); check_error(successor.isValid()); @@ -370,10 +390,10 @@ namespace EUROPA { delete this; } - const ConstrainedVariableId& Object::getVariable(const LabelStr& name) const { + const ConstrainedVariableId Object::getVariable(const std::string& name) const { for (std::vector::const_iterator it = m_variables.begin(); it != m_variables.end(); ++it) { - const ConstrainedVariableId& var = *it; + const ConstrainedVariableId var = *it; check_error(var.isValid()); if (var->getName() == name) return(var); @@ -384,8 +404,8 @@ namespace EUROPA { ConstrainedVariableId Object::getVariable(const std::vector& path) const { unsigned int index = path[0]; - checkError(index >= 0 && index < m_variables.size(), - "index of " << index << " out of bounds for " << getName().toString()); + checkError(index < m_variables.size(), + "index of " << index << " out of bounds for " << getName()); ConstrainedVariableId var = m_variables[index]; if(path.size() > 1){ @@ -413,7 +433,7 @@ namespace EUROPA { * Will only delete a constraint if there is exactly one constraint for this token and it is * there through implication, rather explicit user action. */ - void Object::clean(const TokenId& token) { + void Object::clean(const TokenId token) { check_error(token.isValid()); // Find the first constraint on this token @@ -436,16 +456,17 @@ namespace EUROPA { * Implementation relies on the internal store of constraints by token key. There will * be at least one constraint present for this token for it to be true. */ - bool Object::isConstrainedToThisObject(const TokenId& token) const { + bool Object::isConstrainedToThisObject(const TokenId token) const { check_error(token.isValid()); // Must be at least one entry for this token return m_constraintsByTokenKey.find(token->getKey()) != m_constraintsByTokenKey.end(); } - ConstraintId Object::getPrecedenceConstraint(const TokenId& predecessor, const TokenId& successor) const{ - int encodedKey = makeKey(predecessor, successor); - std::multimap::const_iterator it = m_constraintsByKeyPair.find(encodedKey); + ConstraintId Object::getPrecedenceConstraint(const TokenId predecessor, const TokenId successor) const{ + std::pair encodedKey = std::make_pair(predecessor->getKey(), successor->getKey()); + std::multimap, ConstraintId>::const_iterator it = + m_constraintsByKeyPair.find(encodedKey); while(it != m_constraintsByKeyPair.end() && it->first == encodedKey){ ConstraintId constraint = it->second; if(constraint->getScope()[0] == predecessor->end() && @@ -460,14 +481,14 @@ namespace EUROPA { /** * Use encoded lookup */ - bool Object::isConstrainedToPrecede(const TokenId& predecessor, const TokenId& successor) const{ + bool Object::isConstrainedToPrecede(const TokenId predecessor, const TokenId successor) const{ return getPrecedenceConstraint(predecessor, successor).isId(); } /** * Get all constraints for this token. And the accompanying encoded key pair */ - void Object::getPrecedenceConstraints(const TokenId& token, + void Object::getPrecedenceConstraints(const TokenId token, std::vector& results) const{ check_error(isValid()); check_error(results.empty()); @@ -480,7 +501,7 @@ namespace EUROPA { bool singletonFound = false; while(it != m_constraintsByTokenKey.end() && it->first == token->getKey()){ ConstraintId constraint = it->second; - std::map::const_iterator pos = m_keyPairsByConstraintKey.find(constraint->getKey()); + std::map >::const_iterator pos = m_keyPairsByConstraintKey.find(constraint->getKey()); if(pos == m_keyPairsByConstraintKey.end()){ check_error(singletonFound == false, "Can only find one singleton constraint per token."); @@ -493,7 +514,7 @@ namespace EUROPA { } - bool Object::hasExplicitConstraint(const TokenId& token) const { + bool Object::hasExplicitConstraint(const TokenId token) const { // Get all the constraints for this token std::vector constraints; getPrecedenceConstraints(token, constraints); @@ -515,7 +536,7 @@ namespace EUROPA { return m_explicitConstraints.find(token->getKey()) != m_explicitConstraints.end(); } - bool Object::canBeCompared(const EntityId& entity) const { + bool Object::canBeCompared(const EntityId entity) const { return(ObjectId::convertable(entity)); } @@ -526,7 +547,7 @@ namespace EUROPA { } } - void Object::clean(const ConstraintId& constraint, eint tokenKey) { + void Object::clean(const ConstraintId constraint, eint tokenKey) { // Remove the entry in the predecessor list if necessary std::multimap::iterator it = m_constraintsByTokenKey.find(tokenKey); while(it != m_constraintsByTokenKey.end() && it->first == tokenKey && it->second != constraint) @@ -535,24 +556,24 @@ namespace EUROPA { m_constraintsByTokenKey.erase(it); } - void Object::constrainToThisObjectAsNeeded(const TokenId& token) { + void Object::constrainToThisObjectAsNeeded(const TokenId token) { check_error(token.isValid()); check_error(token->isActive()); check_error(token->getObject()->lastDomain().isMember(getKey()), - "Cannot assign token " + token->getPredicateName().toString() + " to object " + getName().toString() + ", it is not part of derived domain."); + "Cannot assign token " + token->getPredicateName() + " to object " + getName() + ", it is not part of derived domain."); // Place this token on the object. We use a constraint since token assignment is done by specifying // the object variable. This only needs to be done once, so test first if it has already been constrained if (!isConstrainedToThisObject(token)) { ConstraintId thisObject = - getPlanDatabase()->getConstraintEngine()->createConstraint(LabelStr("eq"), + getPlanDatabase()->getConstraintEngine()->createConstraint("eq", makeScope(token->getObject(), m_thisVar)); m_constraintsByTokenKey.insert(std::make_pair(token->getKey(), thisObject)); } } - void Object::freeImplicitConstraints(const TokenId& token){ + void Object::freeImplicitConstraints(const TokenId token){ // Get all the constraints for this token std::vector constraints; getPrecedenceConstraints(token, constraints); @@ -583,10 +604,13 @@ namespace EUROPA { check_error(Entity::getEntity(it->first).isValid()); } - for(std::multimap::const_iterator it = m_constraintsByKeyPair.begin(); + for(std::multimap, ConstraintId>::const_iterator it = + m_constraintsByKeyPair.begin(); it != m_constraintsByKeyPair.end(); ++it){ - checkError(it->second.isValid(), "Invalid constraint for key pair " << LabelStr(it->first).toString()); + checkError(it->second.isValid(), + "Invalid constraint for key pair <" << it->first.first << " " << + it->first.second << ">"); checkError(m_keyPairsByConstraintKey.find(it->second->getKey())->second == it->first, "Lookup should be symmetric."); } @@ -594,74 +618,73 @@ namespace EUROPA { return true; } - ConstrainedVariableId Object::addVariable(const Domain& baseDomain, const char* name){ - std::string varTypeName = ""; - Schema::NameValueVector members = m_planDatabase->getSchema()->getMembers(m_type); - for (unsigned int i = 0; i < members.size(); i++) { - debugMsg("Object:typeForNewMember", "member [" << members[i].first.c_str() << ", " << members[i].second.c_str() << "]"); - if (strcmp( members[i].second.c_str(), name) == 0 ) { - varTypeName = members[i].first.c_str(); - } - } +ConstrainedVariableId Object::addVariable(const Domain& baseDomain, const std::string& name){ + std::string varTypeName = ""; + Schema::NameValueVector members = m_planDatabase->getSchema()->getMembers(m_type); + for (unsigned int i = 0; i < members.size(); i++) { + debugMsg("Object:typeForNewMember", "member [" << members[i].first.c_str() << ", " << members[i].second.c_str() << "]"); + if (members[i].second.c_str() == name) { + varTypeName = members[i].first.c_str(); + } + } - if (varTypeName == "") { - varTypeName = baseDomain.getTypeName().c_str(); - } + if (varTypeName == "") { + varTypeName = baseDomain.getTypeName().c_str(); + } - const Domain& typeDomain = m_planDatabase->getConstraintEngine()->getCESchema()->baseDomain(varTypeName.c_str()); - check_error(baseDomain.isSubsetOf(typeDomain), "Variable " + std::string(name) + " of type " + - varTypeName.c_str() +" can not be set to " + baseDomain.toString()); + const Domain& typeDomain = m_planDatabase->getConstraintEngine()->getCESchema()->baseDomain(varTypeName.c_str()); + check_error(baseDomain.isSubsetOf(typeDomain), "Variable " + std::string(name) + " of type " + + varTypeName.c_str() +" can not be set to " + baseDomain.toString()); - check_error(!isComplete(), - "Cannot add variable " + std::string(name) + - " after completing object construction for " + m_name.toString()); + check_error(!isComplete(), + "Cannot add variable " + std::string(name) + + " after completing object construction for " + m_name); - check_error(m_planDatabase->getSchema()->canContain(m_type, varTypeName.c_str(), name), - "Cannot add a variable " + std::string(name) + " of type " + - baseDomain.getTypeName().toString() + - " to objects of type " + m_type.toString()); + check_error(m_planDatabase->getSchema()->canContain(m_type, varTypeName.c_str(), name), + "Cannot add a variable " + std::string(name) + " of type " + + baseDomain.getTypeName() + + " to objects of type " + m_type); - if (!baseDomain.isSubsetOf(typeDomain)) { - return ConstrainedVariableId::noId(); - } + if (!baseDomain.isSubsetOf(typeDomain)) { + return ConstrainedVariableId::noId(); + } - std::string fullVariableName(m_name.toString() + "." + name); + std::string fullVariableName(m_name + "." + name); - ConstrainedVariableId id = - m_planDatabase->getConstraintEngine()->createVariable( - varTypeName.c_str(), - baseDomain, - false, // TODO: Should this be considered internal, I think so? - true, - fullVariableName.c_str(), - m_id, - m_variables.size() - ); + ConstrainedVariableId id = + m_planDatabase->getConstraintEngine()->createVariable( + varTypeName.c_str(), + baseDomain, + false, // TODO: Should this be considered internal, I think so? + true, + fullVariableName.c_str(), + m_id, + static_cast(m_variables.size())); - m_variables.push_back(id); + m_variables.push_back(id); - return(id); - } + return(id); +} - void Object::notifyOrderingRequired(const TokenId& token){ + void Object::notifyOrderingRequired(const TokenId token){ m_planDatabase->notifyOrderingRequired(m_id, token); } - void Object::notifyOrderingNoLongerRequired(const TokenId& token){ + void Object::notifyOrderingNoLongerRequired(const TokenId token){ m_planDatabase->notifyOrderingNoLongerRequired(m_id, token); } /** Stubs for notification handlers **/ - void Object::notifyMerged(const TokenId& token){} + void Object::notifyMerged(const TokenId){} - void Object::notifyRejected(const TokenId& token){} + void Object::notifyRejected(const TokenId){} - void Object::notifyDeleted(const TokenId& token){ + void Object::notifyDeleted(const TokenId token){ remove(token); } @@ -687,21 +710,19 @@ namespace EUROPA { // The old toString method std::string Object::toLongString() const { std::stringstream sstr; - sstr << getType().toString() << ":" << getName().toString(); + sstr << getType() << ":" << getName(); return sstr.str(); } - - int Object::makeKey(const TokenId& a, const TokenId& b){ - return (cast_int(a->getKey()) << 16) ^ cast_int(b->getKey()); - } - - void Object::removePrecedenceConstraint(const ConstraintId& constraint){ + void Object::removePrecedenceConstraint(const ConstraintId constraint){ TokenId predecessor = constraint->getScope()[0]->parent(); TokenId successor = constraint->getScope()[1]->parent(); - int encodedKey = makeKey(predecessor, successor); - std::multimap::iterator it = m_constraintsByKeyPair.find(encodedKey); + std::pair encodedKey = std::make_pair(predecessor->getKey(), + successor->getKey()); + std::multimap, ConstraintId>::iterator it = + m_constraintsByKeyPair.find(encodedKey); + while(it != m_constraintsByKeyPair.end() && it->first == encodedKey){ ConstraintId c = it->second; if(c == constraint){ @@ -732,46 +753,44 @@ namespace EUROPA { std::string Object::getObjectType() const { - return getType().toString(); + return getType(); } - PSList Object::getMemberVariables() - { - PSList retval; - const std::vector& vars = getVariables(); - for(std::vector::const_iterator it = vars.begin(); it != vars.end(); - ++it) { - ConstrainedVariableId id = *it; - retval.push_back((PSVariable *) id); - } - - return retval; - } - - PSVariable* Object::getMemberVariable(const std::string& name) { - LabelStr realName(name); - PSVariable* retval = NULL; - const std::vector& vars = getVariables(); - for(std::vector::const_iterator it = vars.begin(); it != vars.end(); - ++it) { - ConstrainedVariableId id = *it; - if(id->getName() == realName) { - retval = (PSVariable*) id; - break; - } - } - return retval; - } - - PSList Object::getTokens() const { - PSList retval; - const TokenSet& t = tokens(); - for(TokenSet::const_iterator it = t.begin(); it != t.end(); ++it) { - TokenId id = *it; - retval.push_back((PSToken *) id); - } - return retval; +PSList Object::getMemberVariables() { + PSList retval; + const std::vector& vars = getVariables(); + for(std::vector::const_iterator it = vars.begin(); it != vars.end(); + ++it) { + ConstrainedVariableId id = *it; + retval.push_back(id_cast(id)); + } + + return retval; +} + +PSVariable* Object::getMemberVariable(const std::string& name) { + PSVariable* retval = NULL; + const std::vector& vars = getVariables(); + for(std::vector::const_iterator it = vars.begin(); it != vars.end(); + ++it) { + ConstrainedVariableId id = *it; + if(id->getName() == name) { + retval = id_cast(id); + break; + } } + return retval; +} + +PSList Object::getTokens() const { + PSList retval; + const TokenSet& t = tokens(); + for(TokenSet::const_iterator it = t.begin(); it != t.end(); ++it) { + TokenId id = *it; + retval.push_back(id_cast(id)); + } + return retval; +} void Object::addPrecedence(PSToken* pred,PSToken* succ) @@ -800,7 +819,7 @@ namespace EUROPA { return dynamic_cast(entity); } - ObjectDT::ObjectDT(const char* name) + ObjectDT::ObjectDT(const std::string& name) : DataType(name) { m_baseDomain = new ObjectDomain(getId()); @@ -817,7 +836,8 @@ namespace EUROPA { edouble ObjectDT::createValue(const std::string& value) const { - return LabelStr(value); + checkRuntimeError(ALWAYS_FAIL, "This should never get called."); + return 0.0;//LabelStr(value); } std::string ObjectDT::toString(edouble value) const @@ -834,13 +854,13 @@ namespace EUROPA { } - ObjectDomain::ObjectDomain(const DataTypeId& dt) + ObjectDomain::ObjectDomain(const DataTypeId dt) : EnumeratedDomain(dt) { check_error(!isNumeric()); } - ObjectDomain::ObjectDomain(const DataTypeId& dt, const std::list& initialValues) + ObjectDomain::ObjectDomain(const DataTypeId dt, const std::list& initialValues) : EnumeratedDomain(dt) { check_error(!isNumeric()); @@ -852,7 +872,7 @@ namespace EUROPA { close(); } - ObjectDomain::ObjectDomain(const DataTypeId& dt, const ObjectId& initialValue) + ObjectDomain::ObjectDomain(const DataTypeId dt, const ObjectId initialValue) : EnumeratedDomain(dt, initialValue->getKey()) { check_error(!isNumeric()); @@ -862,7 +882,7 @@ namespace EUROPA { : EnumeratedDomain(org){ check_error(org.isEmpty() || Entity::getTypedEntity(org.getLowerBound()).isValid(), "Attempted to construct an object domain with values of non-object type " + - org.getTypeName().toString()); + org.getTypeName()); } bool ObjectDomain::convertToMemberValue(const std::string& strValue, edouble& dblValue) const{ @@ -905,7 +925,7 @@ namespace EUROPA { return(ptr); } - bool ObjectDomain::isMember(const ObjectId& obj) const { + bool ObjectDomain::isMember(const ObjectId obj) const { return isMember(obj->getKey()); } bool ObjectDomain::isMember(edouble value) const { @@ -913,7 +933,7 @@ namespace EUROPA { } - void ObjectDomain::remove(const ObjectId& obj) { + void ObjectDomain::remove(const ObjectId obj) { remove(obj->getKey()); } void ObjectDomain::remove(edouble value) { diff --git a/src/PLASMA/PlanDatabase/base/Object.hh b/src/PLASMA/PlanDatabase/base/Object.hh index 350fd95fe..ea5f158d5 100644 --- a/src/PLASMA/PlanDatabase/base/Object.hh +++ b/src/PLASMA/PlanDatabase/base/Object.hh @@ -1,5 +1,5 @@ -#ifndef _H_Object -#define _H_Object +#ifndef H_Object +#define H_Object /** * @file Object.hh @@ -10,8 +10,7 @@ #include "PlanDatabaseDefs.hh" -#include "LabelStr.hh" -#include "Variable.hh" +#include "PlanDatabaseVarDefs.hh" #include "Domains.hh" #include "PSPlanDatabase.hh" @@ -35,50 +34,50 @@ namespace EUROPA { COMPLETE /**< All variables have been added. */ }; - Object(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open = false); + Object(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open = false); - Object(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open = false); + Object(const ObjectId parent, const std::string& type, const std::string& localName, bool open = false); virtual ~Object(); - virtual void constructor(const std::vector& arguments) {} + virtual void constructor(const std::vector& arguments); /** * @brief Add a variable as a member to the object. This is used when building the object * and cannot be called once the specific object instance has been closed. * @param baseDomain The base domain to use to populate the variable * @param name The member name - * @error If a variable of the given type with the given name cannot be added * @see Scheme::hasMember, Schema::canContain, Object::close() */ - virtual ConstrainedVariableId addVariable(const Domain& baseDomain, const char* name); + virtual ConstrainedVariableId addVariable(const Domain& baseDomain, const std::string& name); - const ObjectId& getId() const; + const ObjectId getId() const; - const ObjectId& getParent() const; + const ObjectId getParent() const; - const PlanDatabaseId& getPlanDatabase() const; + const PlanDatabaseId getPlanDatabase() const; /** * @brief Access a variable which includes this object only. */ - const ConstrainedVariableId& getThis() const; + const ConstrainedVariableId getThis() const; /** * @brief Access the type name for which this object is an instance + * TODO: have this return the type */ - const LabelStr& getType() const; + const std::string& getType() const; /** * @brief Access the root type in the class hierarchy starting from this instance */ - const LabelStr getRootType() const; + const std::string getRootType() const; /** * @brief Access the instance name of this object. * Instance names include the full path, delimited by ':' in the composition hierarchy. */ - virtual const LabelStr& getName() const; + virtual const std::string& getName() const; @@ -104,7 +103,7 @@ namespace EUROPA { * @brief Test if the given token is actually assigned to this object. * @see constrain */ - virtual bool hasToken(const TokenId& token) const; + virtual bool hasToken(const TokenId token) const; /** * @brief Get all possible active tokens on this object which may be used to order the given token. @@ -112,12 +111,12 @@ namespace EUROPA { * @param results Will be populated with the choices for constraining this token. * @see constrain */ - virtual void getOrderingChoices( const TokenId& token, + virtual void getOrderingChoices( const TokenId token, std::vector< std::pair< TokenId, TokenId > >& results, #ifdef _MSC_VER - unsigned int limit = UINT_MAX //std::numeric_limits::max() + unsigned long limit = UINT_MAX //std::numeric_limits::max() #else - unsigned int limit = std::numeric_limits::max() + unsigned long limit = std::numeric_limits::max() #endif ); /** @@ -125,14 +124,14 @@ namespace EUROPA { * @param token The Token for which we want to count possible choices * @param limit The max we don't want to count past */ - unsigned int countOrderingChoices(const TokenId& token, unsigned int limit); + unsigned long countOrderingChoices(const TokenId token, unsigned long limit); /** * @brief Retrieve the last computed value when a call was made to countOrderingChoices. * @param token The token for which we want choice count. * @return The last value obtained from countOrderingChoices */ - unsigned int lastOrderingChoiceCount(const TokenId& token) const; + unsigned long lastOrderingChoiceCount(const TokenId token) const; /** * @brief Get all possible active tokens on this object which require ordering. @@ -150,20 +149,20 @@ namespace EUROPA { * @brief imposes a constraint such that token comes before successor. May additinally impose * the constraint that the object variable of each token is restricted to this object. We do not restrict * the case where predecessor == successor. This will simply constrain the token to this object. - * @param token The token to be the predecessor + * @param predecessor The token to be the predecessor * @param successor The token to be the successor. * @see free */ - virtual void constrain(const TokenId& predecessor, const TokenId& successor); + virtual void constrain(const TokenId predecessor, const TokenId successor); /** * @brief Removes the specific constraint which must have been created by calling 'constrain'. May * additionally remove implied constraints to constrain tokens to an object. - * @param token The token that is the predecessor + * @param predecessor The token that is the predecessor * @param successor The token that is the successor * @see constrain */ - virtual void free(const TokenId& predecessor, const TokenId& successor); + virtual void free(const TokenId predecessor, const TokenId successor); /** * @brief Get the collection of all member variables of this object in the order in which they @@ -172,17 +171,17 @@ namespace EUROPA { const std::vector& getVariables() const; /** - * @brief Obtain a variable by name. Variable names must be unique within the context of an object. + * @brief Obtain a variable by name. Variable names must be unique within the context + * of an object. Fails with an error if a variable of the given name cannot be + * found. * @param name The name for the requested variable. - * @error Will fail if a variable of the given name cannot be found */ - const ConstrainedVariableId& getVariable(const LabelStr& name) const; + const ConstrainedVariableId getVariable(const std::string& name) const; /** * @brief Obtain the variable by traversing a path. Requires that all contained members along the way - * are singletons. + * are singletons. Error: Will fail if there are non-singleton fields or the path is not correct. * @param path The index based path for traversing objects structures. - * @error Will fail if there are non-singleton fields or the path is not correct. */ ConstrainedVariableId getVariable(const std::vector& path) const; @@ -205,7 +204,7 @@ namespace EUROPA { * @param token The token of interest. * @return true if constrain(token) has been called. Othwerwise false. */ - bool isConstrainedToThisObject(const TokenId& token) const; + bool isConstrainedToThisObject(const TokenId token) const; /** @@ -213,34 +212,34 @@ namespace EUROPA { * @param predecessor Candidate token constrained to precede successor * @param successor Candidate token constrained to succeed predecessor */ - bool isConstrainedToPrecede(const TokenId& predecessor, const TokenId& successor) const; + bool isConstrainedToPrecede(const TokenId predecessor, const TokenId successor) const; /** * @brief Tests if the given entity can be compared to an object */ - bool canBeCompared(const EntityId& entity) const; + bool canBeCompared(const EntityId entity) const; /** * @brief Notify the object that a token that might have been added to this object has been merged. */ - virtual void notifyMerged(const TokenId& token); + virtual void notifyMerged(const TokenId token); /** * @brief Notify the object that a token that might have been added to this object has been rejected. */ - virtual void notifyRejected(const TokenId& token); + virtual void notifyRejected(const TokenId token); /** * @brief Notify the object that a token that might have been added to this object has been deleted */ - virtual void notifyDeleted(const TokenId& token); + virtual void notifyDeleted(const TokenId token); /* * Hack! Code generation currently skips the factories and directly calls the constructor that specifies the parent, * so this is necessary for the interpreter to provide the same behavior * Everybody should be going through the factories */ - void setParent(const ObjectId& parent); + void setParent(const ObjectId parent); /** @@ -251,9 +250,9 @@ namespace EUROPA { std::string toLongString() const; // Looking for pairwise precedence constraints - ConstraintId getPrecedenceConstraint(const TokenId& predecessor, const TokenId& successor) const; + ConstraintId getPrecedenceConstraint(const TokenId predecessor, const TokenId successor) const; - void getPrecedenceConstraints(const TokenId& token, std::vector& results) const; + void getPrecedenceConstraints(const TokenId token, std::vector& results) const; // PS Methods: virtual const std::string& getEntityType() const; @@ -277,33 +276,33 @@ namespace EUROPA { */ void handleDiscard(); - Object(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool hasVariables, bool notify); + Object(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool hasVariables, bool notify); // Calls for managing object - token connections friend class ObjectTokenRelation; - virtual void add(const TokenId& token); - virtual void remove(const TokenId& token); + virtual void add(const TokenId token); + virtual void remove(const TokenId token); // Calls for managing object composition - virtual void add(const ObjectId& component); - virtual void remove(const ObjectId& component); + virtual void add(const ObjectId component); + virtual void remove(const ObjectId component); void cascadeDelete(); /** * @brief Determine if this token participates in any explicit constraints on the timeline */ - bool hasExplicitConstraint(const TokenId& token) const; + bool hasExplicitConstraint(const TokenId token) const; /** * @brief Remove constraints added implicitly which include this token. * @see free, constrain */ - void freeImplicitConstraints(const TokenId& token); + void freeImplicitConstraints(const TokenId token); // Other utilities bool isValid() const; - void notifyOrderingRequired(const TokenId& token); - void notifyOrderingNoLongerRequired(const TokenId& token); + void notifyOrderingRequired(const TokenId token); + void notifyOrderingNoLongerRequired(const TokenId token); /** * @brief Provides the meat of the constrain behaviour. Allows for useage internally @@ -312,7 +311,7 @@ namespace EUROPA { * @param successor The token to be ordered second * @param isExplicit true if the source is outside the elements of the plan database, false. */ - void constrain(const TokenId& predecessor, const TokenId& successor, bool isExplicit); + void constrain(const TokenId predecessor, const TokenId successor, bool isExplicit); /** * @brief Provides the meat of the free behaviour. Allows for useage internally @@ -321,19 +320,14 @@ namespace EUROPA { * @param successor The token to be ordered second * @param isExplicit true if the source is outside the elements of the plan database, false. */ - void free(const TokenId& predecessor, const TokenId& successor, bool isExplicit); + void free(const TokenId predecessor, const TokenId successor, bool isExplicit); - void removePrecedenceConstraint(const ConstraintId& constraint); - - /** - * @brief Utility to generate a hashkey for a token pair - */ - static int makeKey(const TokenId& a, const TokenId& b); + void removePrecedenceConstraint(const ConstraintId constraint); ObjectId m_id; ObjectId m_parent; - LabelStr m_type; - LabelStr m_name; + std::string m_type; + std::string m_name; const PlanDatabaseId m_planDatabase; State m_state; ObjectSet m_components; @@ -341,17 +335,17 @@ namespace EUROPA { std::vector m_variables; std::set m_explicitConstraints; /*!< Stores list of explicitly posted constraints to order tokens. Either the key of the constraint is stored, or in cases where it is a straight assignment of a token, the key of the token is stored. */ - unsigned int m_lastOrderingChoiceCount; /*!< The last computed count of ordering choices */ + unsigned long m_lastOrderingChoiceCount; /*!< The last computed count of ordering choices */ std::multimap m_constraintsByTokenKey; /**< All Precedence Constraints by Token Key */ - std::multimap m_constraintsByKeyPair; /**< Precedence Constraints by encoded key pair */ - std::map m_keyPairsByConstraintKey; /**< Reverse lookup to obtain the key pair */ + std::multimap, ConstraintId> m_constraintsByKeyPair; /**< Precedence Constraints by encoded key pair */ + std::map > m_keyPairsByConstraintKey; /**< Reverse lookup to obtain the key pair */ ConstrainedVariableId m_thisVar; /**< Used to constrain against */ private: - void clean(const TokenId& token); - void clean(const ConstraintId& constraint, eint tokenKey); - void constrainToThisObjectAsNeeded(const TokenId& token); + void clean(const TokenId token); + void clean(const ConstraintId constraint, eint tokenKey); + void constrainToThisObjectAsNeeded(const TokenId token); Object(const Object&); /**< NO IMPL - Prevent use of copy constructor. */ }; @@ -360,7 +354,7 @@ namespace EUROPA { class ObjectDT : public DataType { public: - ObjectDT(const char* name); + ObjectDT(const std::string& name); virtual ~ObjectDT(); virtual bool isNumeric() const; @@ -374,9 +368,9 @@ namespace EUROPA { class ObjectDomain: public EnumeratedDomain { public: - ObjectDomain(const DataTypeId& dt); - ObjectDomain(const DataTypeId& dt, const std::list& initialValues); - ObjectDomain(const DataTypeId& dt, const ObjectId& initialValue); + ObjectDomain(const DataTypeId dt); + ObjectDomain(const DataTypeId dt, const std::list& initialValues); + ObjectDomain(const DataTypeId dt, const ObjectId initialValue); ObjectDomain(const Domain& org); /** @@ -401,10 +395,10 @@ namespace EUROPA { virtual std::string toString() const; std::string toString(edouble value) const; - void remove(const ObjectId& obj); + void remove(const ObjectId obj); void remove(edouble value); - bool isMember(const ObjectId& obj) const; + bool isMember(const ObjectId obj) const; bool isMember(edouble value) const; //because of the reference-casting rules... }; } diff --git a/src/PLASMA/PlanDatabase/base/ObjectTokenRelation.cc b/src/PLASMA/PlanDatabase/base/ObjectTokenRelation.cc index b886d2904..34ce16645 100644 --- a/src/PLASMA/PlanDatabase/base/ObjectTokenRelation.cc +++ b/src/PLASMA/PlanDatabase/base/ObjectTokenRelation.cc @@ -12,12 +12,13 @@ */ namespace EUROPA { - ObjectTokenRelation::ObjectTokenRelation(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + ObjectTokenRelation::ObjectTokenRelation(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_token(variables[STATE_VAR]->parent()), + m_notifiedObjects(), m_currentDomain(static_cast(getCurrentDomain(variables[OBJECT_VAR]))){ check_error(m_token.isValid()); check_error(variables[OBJECT_VAR]->parent() == m_token); @@ -56,17 +57,17 @@ namespace EUROPA { check_error(isValid()); } - void ObjectTokenRelation::handleExecute(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType){ + void ObjectTokenRelation::handleExecute(const ConstrainedVariableId, + unsigned int, + const DomainListener::ChangeType&){ handleExecute(); } /** * Will handle changes immediately as long as the domain is open */ - bool ObjectTokenRelation::canIgnore(const ConstrainedVariableId& variable, - int argIndex, + bool ObjectTokenRelation::canIgnore(const ConstrainedVariableId variable, + unsigned int, const DomainListener::ChangeType& changeType){ if(m_currentDomain.isOpen()) @@ -131,7 +132,7 @@ namespace EUROPA { // Remove token from objects where the domain has been restricted, and was previously notifed, // or where the Token is now inactive - bool isActive = m_token->isActive(); + bool active = m_token->isActive(); unsigned int startIndex = 0; @@ -145,7 +146,7 @@ namespace EUROPA { ObjectId object = *it; - if(!isActive || !m_currentDomain.isMember(object)){ + if(!active || !m_currentDomain.isMember(object)){ debugMsg("ObjectTokenRelation:notifyRemovals", "Removing " << m_token->toString() << " from " << object->toString()); object->remove(m_token); m_notifiedObjects.erase(object); @@ -167,11 +168,11 @@ namespace EUROPA { }*/ } - const std::vector& ObjectTokenRelation::getModifiedVariables(const ConstrainedVariableId& variable) const - { - static std::vector s_emptyScope; - return s_emptyScope; - } +const std::vector& +ObjectTokenRelation::getModifiedVariables(const ConstrainedVariableId) const { + static std::vector s_emptyScope; + return s_emptyScope; +} const std::vector& ObjectTokenRelation::getModifiedVariables() const { diff --git a/src/PLASMA/PlanDatabase/base/ObjectTokenRelation.hh b/src/PLASMA/PlanDatabase/base/ObjectTokenRelation.hh index 3580d4a91..44d1e41b9 100644 --- a/src/PLASMA/PlanDatabase/base/ObjectTokenRelation.hh +++ b/src/PLASMA/PlanDatabase/base/ObjectTokenRelation.hh @@ -1,5 +1,5 @@ -#ifndef _H_ObjectTokenRelation -#define _H_ObjectTokenRelation +#ifndef H_ObjectTokenRelation +#define H_ObjectTokenRelation #include "PlanDatabaseDefs.hh" #include "DomainListener.hh" @@ -7,6 +7,7 @@ namespace EUROPA { +class ObjectDomain; /** * @brief Responsible for managing the relationship between objects and tokens through propagation of changes * in Token.state and Token.object. @@ -20,25 +21,25 @@ namespace EUROPA class ObjectTokenRelation : public Constraint { public: - ObjectTokenRelation(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + ObjectTokenRelation(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); ~ObjectTokenRelation(); void handleExecute(); - void handleExecute(const ConstrainedVariableId& variable, - int argIndex, + void handleExecute(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); // This constraint doesn't modify any variables through inference - virtual const std::vector& getModifiedVariables(const ConstrainedVariableId& variable) const; + virtual const std::vector& getModifiedVariables(const ConstrainedVariableId variable) const; virtual const std::vector& getModifiedVariables() const; private: diff --git a/src/PLASMA/PlanDatabase/base/ObjectType.cc b/src/PLASMA/PlanDatabase/base/ObjectType.cc index 9d7362682..e73485177 100644 --- a/src/PLASMA/PlanDatabase/base/ObjectType.cc +++ b/src/PLASMA/PlanDatabase/base/ObjectType.cc @@ -10,66 +10,67 @@ #include #include "Debug.hh" #include "PlanDatabase.hh" +#include "CESchema.hh" + +#include +#include +#include namespace EUROPA { -ObjectType::ObjectType(const char* name, const ObjectTypeId& parent, bool isNative) +ObjectType::ObjectType(const std::string& name, const ObjectTypeId parent, bool _isNative) : m_id(this) , m_varType((new ObjectDT(name))->getId()) , m_name(name) , m_parent(parent) - , m_isNative(isNative) + , m_isNative(_isNative) + , m_objectFactories(), + m_tokenTypes(), + m_members() { } -ObjectType::~ObjectType() -{ - // TODO: enable this when Schema API is cleaned up to reflect the fact that object factories and token factories are owned by the object type - // purgeAll(); - delete (ObjectDT*)m_varType; - m_id.remove(); +ObjectType::~ObjectType() { + // TODO: enable this when Schema API is cleaned up to reflect the fact that object factories and token factories are owned by the object type + // purgeAll(); + delete id_cast(m_varType); + m_id.remove(); } -const DataTypeId& ObjectType::getVarType() const +const DataTypeId ObjectType::getVarType() const { return m_varType; } -void ObjectType::purgeAll() -{ - for(std::map::const_iterator it = m_objectFactories.begin(); it != m_objectFactories.end(); ++it) - delete (ObjectFactory*) it->second; - m_objectFactories.clear(); - - for(std::map::const_iterator it = m_tokenTypes.begin(); it != m_tokenTypes.end(); ++it) - delete (TokenType*) it->second; - m_tokenTypes.clear(); +void ObjectType::purgeAll() { + cleanup(m_objectFactories); + cleanup(m_tokenTypes); } -const ObjectTypeId& ObjectType::getId() const +const ObjectTypeId ObjectType::getId() const { return m_id; } -const LabelStr& ObjectType::getName() const -{ - return m_name; +const std::string& ObjectType::getName() const { + return m_name; } const std::string& ObjectType::getNameString() const { - return m_name.toString(); + return m_name; } -const ObjectTypeId& ObjectType::getParent() const +const ObjectTypeId ObjectType::getParent() const { return m_parent; } const std::string& ObjectType::getParentName() const { - if (m_parent.isNoId()) - return ""; - return m_parent->getNameString(); + static std::string empty_string; + if (m_parent.isNoId()) + return empty_string; + return m_parent->getNameString(); } const std::map& ObjectType::getMembers() const @@ -85,12 +86,11 @@ PSList ObjectType::getMemberNames() const { return retval; } -const std::map& ObjectType::getObjectFactories() const -{ - return m_objectFactories; +const std::map& ObjectType::getObjectFactories() const { + return m_objectFactories; } -const std::map& ObjectType::getTokenTypes() const +const std::map& ObjectType::getTokenTypes() const { return m_tokenTypes; } @@ -100,12 +100,12 @@ bool ObjectType::isNative() const return m_isNative; } -void ObjectType::addMember(const DataTypeId& type, const char* name) +void ObjectType::addMember(const DataTypeId type, const std::string& name) { m_members[name] = type; } -const DataTypeId& ObjectType::getMemberType(const char* name) const +const DataTypeId ObjectType::getMemberType(const std::string& name) const { std::map::const_iterator it = m_members.find(name); @@ -125,133 +125,141 @@ PSDataType* ObjectType::getMemberTypeRef(const std::string& name) const { return getMemberType(name.c_str()); } -void ObjectType::addObjectFactory(const ObjectFactoryId& factory) -{ - // TODO: allow redefinition of old one - m_objectFactories[(edouble)(factory->getSignature())] = factory; +void ObjectType::addObjectFactory(const ObjectFactoryId factory) { + // TODO: allow redefinition of old one + m_objectFactories[factory->getSignature()] = factory; } -void ObjectType::addTokenType(const TokenTypeId& factory) -{ - // TODO: allow redefinition of old one - m_tokenTypes[(edouble)(factory->getSignature())] = factory; +void ObjectType::addTokenType(const TokenTypeId factory) { + // TODO: allow redefinition of old one + m_tokenTypes[factory->getSignature()] = factory; } -const TokenTypeId& ObjectType::getTokenType(const LabelStr& signature) const -{ - check_error(signature.getElement(0,".")==getName(), - "Can't look for a token factory I don't own"); - - std::map::const_iterator it = m_tokenTypes.find((edouble)signature); - if (it != m_tokenTypes.end()) - return it->second; - - if (m_parent.isId()) { - std::string parentSignature = m_parent->getName().toString()+"."+signature.getElement(1,".").toString(); - return m_parent->getTokenType(parentSignature); - } +const TokenTypeId ObjectType::getTokenType(const std::string& signature) const { + check_error(boost::starts_with(signature, getName()), + "Can't look for a token factory I don't own"); + + std::map::const_iterator it = + m_tokenTypes.find(signature); + if (it != m_tokenTypes.end()) + return it->second; + + if (m_parent.isId()) { + std::string parentSignature = m_parent->getName()+"."+ + signature.substr(signature.find('.') + 1); + return m_parent->getTokenType(parentSignature); + } - return TokenTypeId::noId(); + return TokenTypeId::noId(); } PSList ObjectType::getPredicates() const { - PSList retval; - for (std::map::const_iterator it = m_tokenTypes.begin(); it != m_tokenTypes.end(); ++it) { - retval.push_back(it->second); - } - return retval; + PSList retval; + for (std::map::const_iterator it = m_tokenTypes.begin(); + it != m_tokenTypes.end(); ++it) { + retval.push_back(it->second); + } + return retval; } PSList ObjectType::getPSTokenTypesByAttr( int attrMask ) const { - PSList retval; - for (std::map::const_iterator it = m_tokenTypes.begin(); it != m_tokenTypes.end(); ++it) { - if( it->second->hasAttributes( attrMask ) ) - retval.push_back(it->second); - } - return retval; + PSList retval; + for (std::map::const_iterator it = m_tokenTypes.begin(); + it != m_tokenTypes.end(); ++it) { + if( it->second->hasAttributes( attrMask ) ) + retval.push_back(it->second); + } + return retval; } -const TokenTypeId& ObjectType::getParentType(const TokenTypeId& type) const +const TokenTypeId ObjectType::getParentType(const TokenTypeId type) const { if (m_parent.isId()) { - std::string parentSignature = m_parent->getName().toString()+"."+type->getPredicateName().toString(); + std::string parentSignature = m_parent->getName()+"."+type->getPredicateName(); return m_parent->getTokenType(parentSignature); } return TokenTypeId::noId(); } -std::string ObjectType::toString() const -{ - std::ostringstream os; - std::string extends = (m_parent.isId() ? std::string("extends ")+m_parent->getName().c_str() : ""); +std::string ObjectType::toString() const { + std::ostringstream os; + std::string extends = (m_parent.isId() ? std::string("extends ")+m_parent->getName().c_str() : ""); - os << "class " << m_name.c_str() << " extends " << extends << " {" << std::endl; + os << "class " << m_name.c_str() << " extends " << extends << " {" << std::endl; - { - std::map::const_iterator it = m_members.begin(); - for(;it != m_members.end(); ++it) - os << " " - << it->second->getName().toString() /*type*/ << " " - << it->first/*name*/ - << std::endl; - } + { + std::map::const_iterator it = m_members.begin(); + for(;it != m_members.end(); ++it) + os << " " + << it->second->getName() /*type*/ << " " + << it->first/*name*/ + << std::endl; + } - os << std::endl; + os << std::endl; - { - std::map::const_iterator it = m_objectFactories.begin(); - for(;it != m_objectFactories.end(); ++it) - os << " " << it->second->getSignature().c_str() << std::endl; - } + { + std::map::const_iterator it = m_objectFactories.begin(); + for(;it != m_objectFactories.end(); ++it) + os << " " << it->second->getSignature().c_str() << std::endl; + } - os << std::endl; + os << std::endl; - { - std::map::const_iterator it = m_tokenTypes.begin(); - for(;it != m_tokenTypes.end(); ++it) { - TokenTypeId tokenType = it->second; - os << " " << tokenType->getSignature().c_str(); - std::map::const_iterator paramIt = tokenType->getArgs().begin(); - for(;paramIt != tokenType->getArgs().end();++paramIt) - os<< " " << paramIt->second->getName().c_str() /*type*/ << "->" << paramIt->first.c_str()/*name*/; - os << std::endl; - } + { + std::map::const_iterator it = m_tokenTypes.begin(); + for(;it != m_tokenTypes.end(); ++it) { + TokenTypeId tokenType = it->second; + os << " " << tokenType->getSignature().c_str(); + std::map::const_iterator paramIt = tokenType->getArgs().begin(); + for(;paramIt != tokenType->getArgs().end();++paramIt) + os<< " " << paramIt->second->getName().c_str() /*type*/ << "->" << paramIt->first.c_str()/*name*/; + os << std::endl; } + } - os << "}" << std::endl; + os << "}" << std::endl; - return os.str(); + return os.str(); } static const char* TYPE_DELIMITER = ":"; /*!< Used to delimit types in the factory signature*/ - ObjectFactory::ObjectFactory(const LabelStr& signature) - : m_id(this), m_signature(signature){ +ObjectFactory::ObjectFactory(const std::string& signature) + : m_id(this), m_signature(signature), m_signatureTypes() { - debugMsg("ObjectFactory:ObjectFactory", "Creating factory " << signature.toString()); + debugMsg("ObjectFactory:ObjectFactory", "Creating factory " << signature); - // Now we want to populate the signature types - unsigned int count = signature.countElements(TYPE_DELIMITER); - for(unsigned int i=0;i& ObjectFactory::getSignatureTypes() const {return m_signatureTypes;} + +ObjectId ObjectFactory::makeNewObject(const PlanDatabaseId, + const std::string&, + const std::string&, + const std::vector&) const { + return ObjectId::noId(); +} + +void ObjectFactory::evalConstructorBody(ObjectId, + const std::vector&) const { +} - const std::vector& ObjectFactory::getSignatureTypes() const {return m_signatureTypes;} ObjectTypeMgr::ObjectTypeMgr() - : m_id(this) + : m_id(this), m_objTypes(), m_factories() { } @@ -261,168 +269,161 @@ std::string ObjectType::toString() const m_id.remove(); } - const ObjectTypeMgrId& ObjectTypeMgr::getId() const + const ObjectTypeMgrId ObjectTypeMgr::getId() const { return m_id; } - void ObjectTypeMgr::purgeAll(){ - debugMsg("ObjectFactory:purgeAll", "Purging all"); - - // TODO: this should be done by the object types - std::set alreadyDeleted; - for(std::map::const_iterator it = m_factories.begin(); it != m_factories.end(); ++it) { - if(alreadyDeleted.find(it->second) == alreadyDeleted.end()) { - alreadyDeleted.insert((ObjectFactory*)it->second); - delete (ObjectFactory*) it->second; - } +void ObjectTypeMgr::purgeAll(){ + debugMsg("ObjectFactory:purgeAll", "Purging all"); + + // TODO: this should be done by the object types + std::set alreadyDeleted; + for(std::map::const_iterator it = m_factories.begin(); it != m_factories.end(); ++it) { + if(alreadyDeleted.find(it->second) == alreadyDeleted.end()) { + alreadyDeleted.insert(static_cast(it->second)); + delete static_cast(it->second); } - m_factories.clear(); - - std::map::iterator it = m_objTypes.begin(); - for(;it != m_objTypes.end();++it) - delete (ObjectType*)it->second; - m_objTypes.clear(); } + m_factories.clear(); + + cleanup(m_objTypes); +} - void ObjectTypeMgr::registerObjectType(const ObjectTypeId& objType) +void ObjectTypeMgr::registerObjectType(const ObjectTypeId objType) { + // TODO: instead of keeping separate map, we should probably just delegate to the ObjectType { - // TODO: instead of keeping separate map, we should probably just delegate to the ObjectType - { - std::map::const_iterator it = objType->getObjectFactories().begin(); - for(;it != objType->getObjectFactories().end(); ++it) - registerFactory(it->second); - } - - m_objTypes[objType->getName().getKey()] = objType; - - debugMsg("Schema:registerObjectType","Registered object type:" << std::endl << objType->toString()); + std::map::const_iterator it = objType->getObjectFactories().begin(); + for(;it != objType->getObjectFactories().end(); ++it) + registerFactory(it->second); } - const ObjectTypeId& ObjectTypeMgr::getObjectType(const LabelStr& objType) const - { - std::map::const_iterator it = m_objTypes.find((edouble)objType); + m_objTypes[objType->getName()] = objType; - if (it == m_objTypes.end()) - return ObjectTypeId::noId(); - else - return it->second; - } + debugMsg("Schema:registerObjectType", + "Registered object type:" << std::endl << objType->toString()); +} - std::vector ObjectTypeMgr::getAllObjectTypes() const - { - std::vector retval; - for(std::map::const_iterator it = m_objTypes.begin(); it != m_objTypes.end(); ++it) { - retval.push_back(it->second); - } +const ObjectTypeId ObjectTypeMgr::getObjectType(const std::string& objType) const { + std::map::const_iterator it = + m_objTypes.find(objType); - return retval; + return (it == m_objTypes.end() ? ObjectTypeId::noId() : it->second); +} + +std::vector ObjectTypeMgr::getAllObjectTypes() const { + std::vector retval; + for(std::map::const_iterator it = m_objTypes.begin(); + it != m_objTypes.end(); ++it) { + retval.push_back(it->second); } - LabelStr ObjectTypeMgr::makeFactoryName(const LabelStr& objectType, const std::vector& arguments){ - std::string signature = objectType.toString(); + return retval; +} + + std::string ObjectTypeMgr::makeFactoryName(const std::string& objectType, const std::vector& arguments){ + std::string signature = objectType; debugMsg("ObjectFactory:makeFactoryName", "Making factory name " << signature); // Iterate over the argument types and compose full signature for(std::vector::const_iterator it = arguments.begin(); it != arguments.end(); ++it){ - signature = signature + TYPE_DELIMITER + (*it)->getTypeName().toString(); + signature = signature + TYPE_DELIMITER + (*it)->getTypeName(); } return signature; } - /** - * We must consider the possibility that the precise signature will not be registered, but a more abstracted signature may - * work. For example. Suppose we have the following: Foo:int:float:Bar:Bing as a signature for a Foo factory. We are presented with - * Foo:int:int:Bar:Bong where Bong extends Bing. We should permit a match under such circumstances. - * - * Matching rules for argument types: - * matches(int, float) - * matches(descendant, ancestor) - * matches(x, x) - */ - ObjectFactoryId ObjectTypeMgr::getFactory(const SchemaId& schema, - const LabelStr& objectType, - const std::vector& arguments, - const bool doCheckError) - { - // Build the full signature for the factory - LabelStr factoryName = makeFactoryName(objectType,arguments); - - debugMsg("ObjectFactory:getFactory", "looking for factory " << factoryName.toString()); - - - - // Try to find a hit straight off - std::map::const_iterator it = m_factories.find(factoryName.getKey()); - - // If we have a hit, return it - if(it != m_factories.end()) - return it->second; - - // Otherwise, loop over all factories, and test for a match - for(it = m_factories.begin(); it != m_factories.end(); ++it){ - ObjectFactoryId factory = it->second; - const std::vector& signatureTypes = factory->getSignatureTypes(); - - // if there is no hit for the object type, move on immediately - if(!schema->isA(objectType, signatureTypes[0])) - continue; - - if (signatureTypes[0].c_str() != objectType.c_str()) - continue; - - // If the argument length does not match the signature, which includes the extra for the class - if(signatureTypes.size() - arguments.size() != 1) - continue; - - // Now do a type by type comparison - bool found = true; - for (unsigned int j=1;jisType(arguments[j-1]->getTypeName()) && - schema->isType(signatureTypes[j])){ - if(!schema->isA(arguments[j-1]->getTypeName(), signatureTypes[j])){ - found = false; - break; - } - } - else if(arguments[j-1]->getTypeName() != signatureTypes[j]){ - found = false; - break; - } - } +/** + * We must consider the possibility that the precise signature will not be registered, but a more abstracted signature may + * work. For example. Suppose we have the following: Foo:int:float:Bar:Bing as a signature for a Foo factory. We are presented with + * Foo:int:int:Bar:Bong where Bong extends Bing. We should permit a match under such circumstances. + * + * Matching rules for argument types: + * matches(int, float) + * matches(descendant, ancestor) + * matches(x, x) + */ +ObjectFactoryId ObjectTypeMgr::getFactory(const SchemaId schema, + const std::string& objectType, + const std::vector& arguments, + const bool doCheckError) { + // Build the full signature for the factory + std::string factoryName = makeFactoryName(objectType,arguments); + + debugMsg("ObjectFactory:getFactory", "looking for factory " << factoryName); + + - if(found){ - // Cache for next time and return - m_factories.insert(std::pair(factoryName, factory)); - return factory; + // Try to find a hit straight off + std::map::const_iterator it = m_factories.find(factoryName); + + // If we have a hit, return it + if(it != m_factories.end()) + return it->second; + + // Otherwise, loop over all factories, and test for a match + for(it = m_factories.begin(); it != m_factories.end(); ++it){ + ObjectFactoryId factory = it->second; + const std::vector& signatureTypes = factory->getSignatureTypes(); + + // if there is no hit for the object type, move on immediately + if(!schema->isA(objectType, signatureTypes[0])) + continue; + + if (signatureTypes[0].c_str() != objectType.c_str()) + continue; + + // If the argument length does not match the signature, which includes the extra for the class + if(signatureTypes.size() - arguments.size() != 1) + continue; + + // Now do a type by type comparison + bool found = true; + for (unsigned int j=1;jisType(arguments[j-1]->getTypeName()) && + schema->isType(signatureTypes[j])){ + if(!schema->isA(arguments[j-1]->getTypeName(), signatureTypes[j])){ + found = false; + break; + } + } + else if(arguments[j-1]->getTypeName() != signatureTypes[j]){ + found = false; + break; } } - // At this point, we should have a hit - if (doCheckError) - check_error(ALWAYS_FAILS, "Factory '" + factoryName.toString() + "' is not registered."); - return ObjectFactoryId::noId(); + if(found){ + // Cache for next time and return + m_factories.insert(std::make_pair(factoryName, factory)); + return factory; + } } - void ObjectTypeMgr::registerFactory(const ObjectFactoryId& factory){ - check_error(factory.isValid()); - - debugMsg("ObjectFactory:registerFactory", "Registering factory with signature " << factory->getSignature().toString()); + // At this point, we should have a hit + if (doCheckError) + check_error(ALWAYS_FAILS, "Factory '" + factoryName + "' is not registered."); + return ObjectFactoryId::noId(); +} - if(m_factories.find(factory->getSignature().getKey()) != m_factories.end()){ - ObjectFactoryId oldFactory = m_factories.find(factory->getSignature().getKey())->second; - m_factories.erase(factory->getSignature().getKey()); - delete (ObjectFactory*) oldFactory; - debugMsg("ObjectFactory:registerFactory", "Over-riding registeration for factory with signature " << factory->getSignature().toString()); - } +void ObjectTypeMgr::registerFactory(const ObjectFactoryId factory) { + check_error(factory.isValid()); - // Ensure it is not present already - check_error(m_factories.find(factory->getSignature().getKey()) == m_factories.end()); - m_factories.insert(std::make_pair(factory->getSignature().getKey(), factory)); + debugMsg("ObjectFactory:registerFactory", + "Registering factory with signature " << factory->getSignature()); + if(m_factories.find(factory->getSignature()) != m_factories.end()){ + ObjectFactoryId oldFactory = m_factories.find(factory->getSignature())->second; + m_factories.erase(factory->getSignature()); + delete static_cast(oldFactory); + debugMsg("ObjectFactory:registerFactory", "Over-riding registeration for factory with signature " << factory->getSignature()); } + // Ensure it is not present already + check_error(m_factories.find(factory->getSignature()) == m_factories.end()); + m_factories.insert(std::make_pair(factory->getSignature(), factory)); +} + /* * InterpretedObjectFactory @@ -435,18 +436,18 @@ std::string ObjectType::toString() const class ObjectEvalContext : public EvalContext { public: - ObjectEvalContext(EvalContext* parent, const ObjectId& objInstance); + ObjectEvalContext(EvalContext* parent, const ObjectId objInstance); virtual ~ObjectEvalContext(); - virtual ConstrainedVariableId getVar(const char* name); + virtual ConstrainedVariableId getVar(const std::string& name); - virtual void* getElement(const char* name) const; + virtual void* getElement(const std::string& name) const; protected: ObjectId m_obj; }; - ObjectEvalContext::ObjectEvalContext(EvalContext* parent, const ObjectId& objInstance) + ObjectEvalContext::ObjectEvalContext(EvalContext* parent, const ObjectId objInstance) : EvalContext(parent) , m_obj(objInstance) { @@ -456,12 +457,12 @@ std::string ObjectType::toString() const { } - ConstrainedVariableId ObjectEvalContext::getVar(const char* name) + ConstrainedVariableId ObjectEvalContext::getVar(const std::string& name) { - if (strcmp(name,"this") == 0) + if (name == "this") return m_obj->getThis(); - ConstrainedVariableId var = m_obj->getVariable(m_obj->getName().toString()+"."+name); + ConstrainedVariableId var = m_obj->getVariable(m_obj->getName()+"."+name); if (!var.isNoId()) { debugMsg("Interpreter:EvalContext:Object","Found var in object instance:" << name); @@ -473,17 +474,16 @@ std::string ObjectType::toString() const } } - void* ObjectEvalContext::getElement(const char* name) const - { - if (std::string(name)=="PlanDatabase") - return (PlanDatabase*)m_obj->getPlanDatabase(); - - return EvalContext::getElement(name); - } +void* ObjectEvalContext::getElement(const std::string& name) const { + if (std::string(name)=="PlanDatabase") + return static_cast(m_obj->getPlanDatabase()); + + return EvalContext::getElement(name); +} InterpretedObjectFactory::InterpretedObjectFactory( - const ObjectTypeId& objType, - const LabelStr& signature, + const ObjectTypeId objType, + const std::string& signature, const std::vector& constructorArgNames, const std::vector& constructorArgTypes, ExprConstructorSuperCall* superCallExpr, @@ -495,7 +495,8 @@ std::string ObjectType::toString() const , m_constructorArgTypes(constructorArgTypes) , m_superCallExpr(superCallExpr) , m_constructorBody(constructorBody) - , m_canMakeNewObject(canMakeNewObject) + , m_canMakeNewObject(canMakeNewObject), + m_evalContext(NULL) { if (!m_canMakeNewObject && m_superCallExpr==NULL) { m_superCallExpr = new ExprConstructorSuperCall(objType->getParent()->getName(),std::vector()); @@ -515,26 +516,27 @@ std::string ObjectType::toString() const class ObjectFactoryEvalContext : public EvalContext { public: - ObjectFactoryEvalContext(const PlanDatabaseId& planDb, + ObjectFactoryEvalContext(const PlanDatabaseId planDb, const std::vector& argNames, const std::vector& argTypes, const std::vector& args); virtual ~ObjectFactoryEvalContext(); - virtual void* getElement(const char* name) const; + virtual void* getElement(const std::string& name) const; protected: PlanDatabaseId m_planDb; std::vector m_tmpVars; }; - ObjectFactoryEvalContext::ObjectFactoryEvalContext(const PlanDatabaseId& planDb, + ObjectFactoryEvalContext::ObjectFactoryEvalContext(const PlanDatabaseId planDb, const std::vector& argNames, const std::vector& argTypes, const std::vector& args) : EvalContext(NULL) // TODO: should pass in eval context from outside to have access to globals , m_planDb(planDb) + , m_tmpVars() { debugMsg("ObjectFactoryEvalContext", ">> "); @@ -562,34 +564,32 @@ std::string ObjectType::toString() const } } - void* ObjectFactoryEvalContext::getElement(const char* name) const - { - if (std::string(name)=="PlanDatabase") - return (PlanDatabase*)m_planDb; - - return EvalContext::getElement(name); - } +void* ObjectFactoryEvalContext::getElement(const std::string& name) const { + if (std::string(name)=="PlanDatabase") + return static_cast(m_planDb); + return EvalContext::getElement(name); +} ObjectId InterpretedObjectFactory::createInstance( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { check_runtime_error(checkArgs(arguments)); - debugMsg("InterpretedObjectFactory:createInstance", "Creating instance for type " << objectType.toString() << " with name " << objectName.toString()); + debugMsg("InterpretedObjectFactory:createInstance", "Creating instance for type " << objectType << " with name " << objectName); ObjectId instance = makeNewObject(planDb, objectType, objectName,arguments); evalConstructorBody(instance,arguments); instance->close(); - debugMsg("InterpretedObjectFactory:createInstance", "Created instance " << instance->toString() << " for type " << objectType.toString() << " with name " << objectName.toString()); + debugMsg("InterpretedObjectFactory:createInstance", "Created instance " << instance->toString() << " for type " << objectType << " with name " << objectName); return instance; } - bool InterpretedObjectFactory::checkArgs(const std::vector& arguments) const + bool InterpretedObjectFactory::checkArgs(const std::vector&) const { // TODO: implement this. is this even necessary?, parser should take care of it return true; @@ -603,20 +603,20 @@ std::string ObjectType::toString() const * */ ObjectId InterpretedObjectFactory::makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { // go up the hierarchy and give the parents a chance to create the object, this allows native classes to be exported // TODO: some effort can be saved by keeping track of whether a class has a native ancestor different from Object. // If it doesn't, the object can be created right away and this traversal up the hierarchy can be skipped if (m_canMakeNewObject) { - debugMsg("Interpreter:InterpretedObject","Created Object:" << objectName.toString() << " type:" << objectType.toString()); + debugMsg("Interpreter:InterpretedObject","Created Object:" << objectName << " type:" << objectType); return (new Object(planDb, objectType, objectName,true))->getId(); } else { - check_error(m_superCallExpr != NULL, std::string("Failed to find factory for object ") + objectName.toString() + " of type "+objectType.toString()); + check_error(m_superCallExpr != NULL, std::string("Failed to find factory for object ") + objectName + " of type "+objectType); ObjectFactoryEvalContext evalContext( planDb, @@ -643,7 +643,7 @@ std::string ObjectType::toString() const } void InterpretedObjectFactory::evalConstructorBody( - ObjectId& instance, + ObjectId instance, const std::vector& arguments) const { // TODO: should pass in eval context from outside to have access to globals @@ -664,7 +664,7 @@ std::string ObjectType::toString() const // Initialize any variables that were not explicitly initialized const Schema::NameValueVector& members = instance->getPlanDatabase()->getSchema()->getMembers(m_className); for (unsigned int i=0; i < members.size(); i++) { - std::string varName = instance->getName().toString() + "." + members[i].second.toString(); + std::string varName = instance->getName() + "." + members[i].second; if (instance->getVariable(varName) == ConstrainedVariableId::noId()) { const Domain& baseDomain = instance->getPlanDatabase()->getConstraintEngine()->getCESchema()->baseDomain(members[i].first.c_str()); @@ -672,7 +672,7 @@ std::string ObjectType::toString() const baseDomain, members[i].second.c_str() ); - debugMsg("Interpreter:InterpretedObject","Used default initializer for " << m_className.toString() << "." << members[i].second.toString()); + debugMsg("Interpreter:InterpretedObject","Used default initializer for " << m_className << "." << members[i].second); } } @@ -683,7 +683,7 @@ std::string ObjectType::toString() const /* * ExprConstructorSuperCall */ - ExprConstructorSuperCall::ExprConstructorSuperCall(const LabelStr& superClassName, const std::vector& argExprs) + ExprConstructorSuperCall::ExprConstructorSuperCall(const std::string& superClassName, const std::vector& argExprs) : m_superClassName(superClassName) , m_argExprs(argExprs) { diff --git a/src/PLASMA/PlanDatabase/base/ObjectType.hh b/src/PLASMA/PlanDatabase/base/ObjectType.hh index 77c3487ee..6651d645a 100644 --- a/src/PLASMA/PlanDatabase/base/ObjectType.hh +++ b/src/PLASMA/PlanDatabase/base/ObjectType.hh @@ -11,8 +11,6 @@ #include #include -#include "LabelStr.hh" - #include "PDBInterpreter.hh" #include "TokenType.hh" @@ -42,28 +40,28 @@ public: class ObjectType: public PSObjectType { public: - ObjectType(const char* name, const ObjectTypeId& parent, bool isNative=false); + ObjectType(const std::string& name, const ObjectTypeId parent, bool isNative=false); virtual ~ObjectType(); - const ObjectTypeId& getId() const; + const ObjectTypeId getId() const; - const DataTypeId& getVarType() const; // Data type for a variable that holds a reference to an object + const DataTypeId getVarType() const; // Data type for a variable that holds a reference to an object - virtual const LabelStr& getName() const; - virtual const ObjectTypeId& getParent() const; + virtual const std::string& getName() const; + virtual const ObjectTypeId getParent() const; virtual bool isNative() const; - virtual void addMember(const DataTypeId& type, const char* name); // TODO: use DataType instead + virtual void addMember(const DataTypeId type, const std::string& name); // TODO: use DataType instead virtual const std::map& getMembers() const; - virtual const DataTypeId& getMemberType(const char* name) const; + virtual const DataTypeId getMemberType(const std::string& name) const; - virtual void addObjectFactory(const ObjectFactoryId& factory); - virtual const std::map& getObjectFactories() const; + virtual void addObjectFactory(const ObjectFactoryId factory); + virtual const std::map& getObjectFactories() const; - virtual void addTokenType(const TokenTypeId& factory); - virtual const std::map& getTokenTypes() const; - virtual const TokenTypeId& getTokenType(const LabelStr& signature) const; - virtual const TokenTypeId& getParentType(const TokenTypeId& factory) const; + virtual void addTokenType(const TokenTypeId factory); + virtual const std::map& getTokenTypes() const; + virtual const TokenTypeId getTokenType(const std::string& signature) const; + virtual const TokenTypeId getParentType(const TokenTypeId factory) const; virtual std::string toString() const; @@ -81,12 +79,12 @@ public: protected: ObjectTypeId m_id; DataTypeId m_varType; - LabelStr m_name; + std::string m_name; ObjectTypeId m_parent; bool m_isNative; - std::map m_objectFactories; - std::map m_tokenTypes; - std::map m_members; + std::map m_objectFactories; + std::map m_tokenTypes; + std::map m_members; }; @@ -100,10 +98,10 @@ public: ObjectTypeMgr(); virtual ~ObjectTypeMgr(); - const ObjectTypeMgrId& getId() const; + const ObjectTypeMgrId getId() const; - void registerObjectType(const ObjectTypeId& objType); - const ObjectTypeId& getObjectType(const LabelStr& objType) const; + void registerObjectType(const ObjectTypeId objType); + const ObjectTypeId getObjectType(const std::string& objType) const; std::vector getAllObjectTypes() const; /** @@ -112,17 +110,17 @@ public: * @param arguments The sequence of name/value pairs to be passed as arguments for construction of the object * @return A ':' deliimited string of ::..: */ - static LabelStr makeFactoryName(const LabelStr& objectType, const std::vector& arguments); + static std::string makeFactoryName(const std::string& objectType, const std::vector& arguments); /** * @brief Obtain the factory based on the type of object to create and the types of the arguments to the constructor */ - ObjectFactoryId getFactory(const SchemaId& schema, const LabelStr& objectType, const std::vector& arguments, const bool doCheckError = true); + ObjectFactoryId getFactory(const SchemaId schema, const std::string& objectType, const std::vector& arguments, const bool doCheckError = true); /** * @brief Add a factory to provide instantiation of particular concrete types based on a label. */ - void registerFactory(const ObjectFactoryId& factory); + void registerFactory(const ObjectFactoryId factory); /** * @brief Delete all meta-data stored. @@ -131,8 +129,8 @@ public: protected: ObjectTypeMgrId m_id; - std::map m_objTypes; - std::map m_factories; // TODO: should delegate to object types instead + std::map m_objTypes; + std::map m_factories; // TODO: should delegate to object types instead }; /** @@ -140,30 +138,31 @@ protected: */ class ObjectFactory{ public: - ObjectFactory(const LabelStr& signature); + ObjectFactory(const std::string& signature); virtual ~ObjectFactory(); - const ObjectFactoryId& getId() const; + const ObjectFactoryId getId() const; /** * @brief Return the type for which this factory is registered. */ - const LabelStr& getSignature() const; + const std::string& getSignature() const; /** - * @brief Retreive the type signature as a vector of types + * @brief Retreive the type signature as a vector of type names. + * TODO: re-write this so it actually returns DataTypes. */ - const std::vector& getSignatureTypes() const; + const std::vector& getSignatureTypes() const; /** * @brief Create a root object instance - * @see DbClient::createObject(const LabelStr& type, const LabelStr& name) + * @see DbClient::createObject(const std::string& type, const std::string& name) * for the interpreted version createInstance = makeObject + evalConstructorBody */ - virtual ObjectId createInstance(const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + virtual ObjectId createInstance(const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const = 0; @@ -175,39 +174,40 @@ public: * @brief makes an instance of a new object, this is purely construction, initialization happens in evalConstructorBody */ virtual ObjectId makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, - const std::vector& arguments) const { return ObjectId::noId(); }; + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, + const std::vector& arguments) const; /** * @brief The body of the constructor after the object is created * any operations done by createInstance to the object after it is created must be done by this method * so that calls to "super()" in subclasses can be supported correctly */ - virtual void evalConstructorBody(ObjectId& instance, const std::vector& arguments) const {}; + virtual void evalConstructorBody(ObjectId instance, + const std::vector& arguments) const; private: ObjectFactoryId m_id; - LabelStr m_signature; - std::vector m_signatureTypes; + std::string m_signature; + std::vector m_signatureTypes; }; // Call to super inside a constructor class ExprConstructorSuperCall : public Expr { public: - ExprConstructorSuperCall(const LabelStr& superClassName, + ExprConstructorSuperCall(const std::string& superClassName, const std::vector& argExprs); virtual ~ExprConstructorSuperCall(); virtual DataRef eval(EvalContext& context) const; - const LabelStr& getSuperClassName() const { return m_superClassName; } + const std::string& getSuperClassName() const { return m_superClassName; } void evalArgs(EvalContext& context, std::vector& arguments) const; protected: - LabelStr m_superClassName; + std::string m_superClassName; std::vector m_argExprs; }; @@ -215,8 +215,8 @@ class InterpretedObjectFactory : public ObjectFactory { public: InterpretedObjectFactory( - const ObjectTypeId& objType, - const LabelStr& signature, + const ObjectTypeId objType, + const std::string& signature, const std::vector& constructorArgNames, const std::vector& constructorArgTypes, ExprConstructorSuperCall* superCallExpr, @@ -229,38 +229,41 @@ class InterpretedObjectFactory : public ObjectFactory protected: // createInstance = makeNewObject + evalConstructorBody virtual ObjectId createInstance( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const; // Any exported C++ classes must register a factory for each C++ constructor // and override this method to call the C++ constructor virtual ObjectId makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const; virtual void evalConstructorBody( - ObjectId& instance, + ObjectId instance, const std::vector& arguments) const; bool checkArgs(const std::vector& arguments) const; - LabelStr m_className; + std::string m_className; std::vector m_constructorArgNames; std::vector m_constructorArgTypes; ExprConstructorSuperCall* m_superCallExpr; std::vector m_constructorBody; bool m_canMakeNewObject; mutable EvalContext* m_evalContext; +private: + InterpretedObjectFactory(const InterpretedObjectFactory&); + InterpretedObjectFactory& operator=(const InterpretedObjectFactory&); }; class NativeObjectFactory : public InterpretedObjectFactory { public: - NativeObjectFactory(const ObjectTypeId& objType, const LabelStr& signature) + NativeObjectFactory(const ObjectTypeId objType, const std::string& signature) : InterpretedObjectFactory( objType, // objType signature, // signature @@ -277,9 +280,9 @@ class NativeObjectFactory : public InterpretedObjectFactory protected: virtual ObjectId makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const = 0; }; diff --git a/src/PLASMA/PlanDatabase/base/PDBInterpreter.cc b/src/PLASMA/PlanDatabase/base/PDBInterpreter.cc index ed7869e75..51c7d90c5 100644 --- a/src/PLASMA/PlanDatabase/base/PDBInterpreter.cc +++ b/src/PLASMA/PlanDatabase/base/PDBInterpreter.cc @@ -26,7 +26,7 @@ namespace EUROPA { { } - DataRef::DataRef(const ConstrainedVariableId& v) + DataRef::DataRef(const ConstrainedVariableId v) : m_value(v) { } @@ -35,13 +35,13 @@ namespace EUROPA { { } - const ConstrainedVariableId& DataRef::getValue() { return m_value; } + const ConstrainedVariableId DataRef::getValue() { return m_value; } /* * EvalContext */ EvalContext::EvalContext(EvalContext* parent) - : m_parent(parent) + : m_parent(parent), m_variables(), m_tokens() { } @@ -49,13 +49,13 @@ namespace EUROPA { { } - void EvalContext::addVar(const char* name,const ConstrainedVariableId& v) + void EvalContext::addVar(const std::string& name,const ConstrainedVariableId v) { m_variables[name] = v; debugMsg("Interpreter:EvalContext","Added var:" << name << " to EvalContext"); } - ConstrainedVariableId EvalContext::getVar(const char* name) + ConstrainedVariableId EvalContext::getVar(const std::string& name) { std::map::iterator it = m_variables.find(name); @@ -68,12 +68,12 @@ namespace EUROPA { return ConstrainedVariableId::noId(); } - void EvalContext::addToken(const char* name,const TokenId& t) + void EvalContext::addToken(const std::string& name,const TokenId t) { m_tokens[name] = t; } - TokenId EvalContext::getToken(const char* name) + TokenId EvalContext::getToken(const std::string& name) { std::map::iterator it = m_tokens.find(name); @@ -86,6 +86,8 @@ namespace EUROPA { return TokenId::noId(); } +void* EvalContext::getElement(const std::string&) const {return NULL;} + std::string EvalContext::toString() const { std::ostringstream os; @@ -104,7 +106,7 @@ namespace EUROPA { std::map::const_iterator tokenIt = m_tokens.begin(); os << " tokens {"; for (;tokenIt != m_tokens.end();++tokenIt) - os << tokenIt->first << " " << tokenIt->second->getPredicateName().toString() << ","; + os << tokenIt->first << " " << tokenIt->second->getPredicateName() << ","; os << " }" << std::endl; if (m_parent == NULL) @@ -123,24 +125,23 @@ namespace EUROPA { return "Expr"; } - ExprList::ExprList() - { - } +ExprList::ExprList() : m_children() {} ExprList::~ExprList() { - for (unsigned int i=0;i::iterator it = m_children.begin(); it != m_children.end(); + ++it) + delete *it; } - const std::vector& ExprList::getChildren() { return m_children; } + const std::vector& ExprList::getChildren() const { return m_children; } DataRef ExprList::eval(EvalContext& context) const { DataRef result; - - for (unsigned int i=0;ieval(context); + for(std::vector::const_iterator it = m_children.begin(); + it != m_children.end(); ++it) + result = (*it)->eval(context); return result; } @@ -154,8 +155,9 @@ namespace EUROPA { { std::ostringstream os; - for (unsigned int i=0;itoString() << std::endl; + for(std::vector::const_iterator it = m_children.begin(); + it != m_children.end(); ++it) + os << (*it)->toString() << std::endl; return os.str(); } @@ -169,10 +171,9 @@ namespace EUROPA { { } - DataRef ExprNoop::eval(EvalContext& context) const - { - std::cout << "Noop:" << m_str << std::endl; - return DataRef::null; - } +DataRef ExprNoop::eval(EvalContext&) const { + std::cout << "Noop:" << m_str << std::endl; + return DataRef::null; +} } diff --git a/src/PLASMA/PlanDatabase/base/PDBInterpreter.hh b/src/PLASMA/PlanDatabase/base/PDBInterpreter.hh index bd40f99a7..153330e5b 100644 --- a/src/PLASMA/PlanDatabase/base/PDBInterpreter.hh +++ b/src/PLASMA/PlanDatabase/base/PDBInterpreter.hh @@ -1,7 +1,7 @@ -#ifndef _H_PDBInterpreter -#define _H_PDBInterpreter +#ifndef H_PDBInterpreter +#define H_PDBInterpreter -#include "ConstrainedVariable.hh" +#include "ConstraintEngineDefs.hh" #include "PlanDatabaseDefs.hh" #include #include @@ -15,10 +15,10 @@ namespace EUROPA { { public : DataRef(); - DataRef(const ConstrainedVariableId& v); + DataRef(const ConstrainedVariableId v); virtual ~DataRef(); - const ConstrainedVariableId& getValue(); + const ConstrainedVariableId getValue(); static DataRef null; @@ -26,27 +26,29 @@ namespace EUROPA { ConstrainedVariableId m_value; }; - class EvalContext - { - public: - EvalContext(EvalContext* parent); - virtual ~EvalContext(); +class EvalContext { + public: + EvalContext(EvalContext* parent); + virtual ~EvalContext(); - virtual void addVar(const char* name,const ConstrainedVariableId& v); - virtual ConstrainedVariableId getVar(const char* name); + virtual void addVar(const std::string& name,const ConstrainedVariableId v); + virtual ConstrainedVariableId getVar(const std::string& name); - virtual void addToken(const char* name,const TokenId& t); - virtual TokenId getToken(const char* name); + virtual void addToken(const std::string& name,const TokenId t); + virtual TokenId getToken(const std::string& name); - virtual void* getElement(const char* name) const { return NULL; } + virtual void* getElement(const std::string& name) const; - virtual std::string toString() const; + virtual std::string toString() const; - protected: - EvalContext* m_parent; - std::map m_variables; - std::map m_tokens; - }; + protected: + EvalContext* m_parent; + std::map m_variables; + std::map m_tokens; + private: + EvalContext(const EvalContext&); + EvalContext& operator=(const EvalContext&); +}; class Expr { @@ -67,7 +69,7 @@ namespace EUROPA { virtual DataRef eval(EvalContext& context) const; void addChild(Expr* child); - const std::vector& getChildren(); + const std::vector& getChildren() const; virtual std::string toString() const; @@ -91,4 +93,4 @@ namespace EUROPA { } -#endif // _H_PDBInterpreter +#endif // H_PDBInterpreter diff --git a/src/PLASMA/PlanDatabase/base/PSPlanDatabase.hh b/src/PLASMA/PlanDatabase/base/PSPlanDatabase.hh index 77df439bb..654406180 100644 --- a/src/PLASMA/PlanDatabase/base/PSPlanDatabase.hh +++ b/src/PLASMA/PlanDatabase/base/PSPlanDatabase.hh @@ -1,17 +1,17 @@ -#ifndef _H_PSPlanDatabase -#define _H_PSPlanDatabase +#ifndef H_PSPlanDatabase +#define H_PSPlanDatabase #include "PSConstraintEngine.hh" #include "ConstraintEngineDefs.hh" -#include "TokenType.hh" -#include "ObjectType.hh" namespace EUROPA { enum PSTokenState { INACTIVE,ACTIVE,MERGED,REJECTED }; - class PSObject; - class PSToken; - class PSPlanDatabaseClient; +class PSObject; +class PSObjectType; +class PSToken; +class PSTokenType; +class PSPlanDatabaseClient; class PSSchema : public EngineComponent { @@ -19,7 +19,7 @@ namespace EUROPA { // TODO: flesh this interface out virtual ~PSSchema() {} virtual PSList getAllPredicates() const = 0; - virtual PSList getMembers(const std::string& objectType) const = 0; + virtual PSList getObjectMembers(const std::string& objectType) const = 0; virtual bool hasMember(const std::string& parentType, const std::string& memberName) const = 0; virtual PSList getAllPSObjectTypes() const = 0; diff --git a/src/PLASMA/PlanDatabase/base/PSPlanDatabaseListener.cc b/src/PLASMA/PlanDatabase/base/PSPlanDatabaseListener.cc index 6b477de11..ba74a3ad8 100644 --- a/src/PLASMA/PlanDatabase/base/PSPlanDatabaseListener.cc +++ b/src/PLASMA/PlanDatabase/base/PSPlanDatabaseListener.cc @@ -4,41 +4,52 @@ namespace EUROPA { +void PSPlanDatabaseListener::notifyAdded(PSObject*) {} +void PSPlanDatabaseListener::notifyRemoved(PSObject*) {} +void PSPlanDatabaseListener::notifyActivated(PSToken*) {} +void PSPlanDatabaseListener::notifyDeactivated(PSToken*) {} +void PSPlanDatabaseListener::notifyRejected(PSToken*) {} +void PSPlanDatabaseListener::notifyMerged(PSToken*) {} +void PSPlanDatabaseListener::notifySplit(PSToken*) {} +void PSPlanDatabaseListener::notifyAdded(PSObject*, PSToken*) {} +void PSPlanDatabaseListener::notifyRemoved(PSObject*, PSToken*) {} + + // Methods to convert notifications involving internal Europa types to notifications involving 'PS' types: -void PSPlanDatabaseListener::notifyAdded(const ObjectId& object) { - notifyAdded((PSObject *) object); +void PSPlanDatabaseListener::notifyAdded(const ObjectId object) { + notifyAdded(id_cast(object)); } -void PSPlanDatabaseListener::notifyRemoved(const ObjectId& object) { - notifyRemoved((PSObject *) object); +void PSPlanDatabaseListener::notifyRemoved(const ObjectId object) { + notifyRemoved(id_cast(object)); } -void PSPlanDatabaseListener::notifyActivated(const TokenId& token) { - notifyActivated((PSToken *) token); +void PSPlanDatabaseListener::notifyActivated(const TokenId token) { + notifyActivated(id_cast(token)); } -void PSPlanDatabaseListener::notifyDeactivated(const TokenId& token) { - notifyDeactivated((PSToken *) token); +void PSPlanDatabaseListener::notifyDeactivated(const TokenId token) { + notifyDeactivated(id_cast(token)); } -void PSPlanDatabaseListener::notifyRejected(const TokenId& token) { - notifyRejected((PSToken *) token); +void PSPlanDatabaseListener::notifyRejected(const TokenId token) { + notifyRejected(id_cast(token)); } -void PSPlanDatabaseListener::notifyMerged(const TokenId& token) { - notifyMerged((PSToken *) token); +void PSPlanDatabaseListener::notifyMerged(const TokenId token) { + notifyMerged(id_cast(token)); } -void PSPlanDatabaseListener::notifySplit(const TokenId& token) { - notifySplit((PSToken *) token); +void PSPlanDatabaseListener::notifySplit(const TokenId token) { + notifySplit(id_cast(token)); } -void PSPlanDatabaseListener::notifyAdded(const ObjectId& object, const TokenId& token) { - notifyAdded((PSObject *) object, (PSToken *) token); +void PSPlanDatabaseListener::notifyAdded(const ObjectId object, const TokenId token) { + notifyAdded(id_cast(object), id_cast(token)); } -void PSPlanDatabaseListener::notifyRemoved(const ObjectId& object, const TokenId& token) { - notifyRemoved((PSObject *) object, (PSToken *) token); +void PSPlanDatabaseListener::notifyRemoved(const ObjectId object, const TokenId token) { + notifyRemoved(id_cast(object), id_cast(token)); } diff --git a/src/PLASMA/PlanDatabase/base/PSPlanDatabaseListener.hh b/src/PLASMA/PlanDatabase/base/PSPlanDatabaseListener.hh index f6c4b80d4..01d965d11 100644 --- a/src/PLASMA/PlanDatabase/base/PSPlanDatabaseListener.hh +++ b/src/PLASMA/PlanDatabase/base/PSPlanDatabaseListener.hh @@ -1,5 +1,5 @@ -#ifndef _H_PSPlanDatabaseListener -#define _H_PSPlanDatabaseListener +#ifndef H_PSPlanDatabaseListener +#define H_PSPlanDatabaseListener #include "PlanDatabaseListener.hh" #include "PSPlanDatabase.hh" @@ -24,48 +24,48 @@ namespace EUROPA { * Constraint.hh and ConstrainedVariable.hh above (forewarned is forearmed!) */ - class PSPlanDatabaseListener : public PlanDatabaseListener { - public: - virtual ~PSPlanDatabaseListener() {} +class PSPlanDatabaseListener : public PlanDatabaseListener { + public: + virtual ~PSPlanDatabaseListener() {} - /* The subset of notifications available through PSEngine interface */ - virtual void notifyAdded(PSObject* object) {} - virtual void notifyRemoved(PSObject* object) {} - virtual void notifyActivated(PSToken* token) {} - virtual void notifyDeactivated(PSToken* token) {} - virtual void notifyRejected(PSToken* token) {} - virtual void notifyMerged(PSToken* token) {} - virtual void notifySplit(PSToken* token) {} - virtual void notifyAdded(PSObject* object, PSToken* token) {} - virtual void notifyRemoved(PSObject* object, PSToken* token) {} + /* The subset of notifications available through PSEngine interface */ + virtual void notifyAdded(PSObject* object); + virtual void notifyRemoved(PSObject* object); + virtual void notifyActivated(PSToken* token); + virtual void notifyDeactivated(PSToken* token); + virtual void notifyRejected(PSToken* token); + virtual void notifyMerged(PSToken* token); + virtual void notifySplit(PSToken* token); + virtual void notifyAdded(PSObject* object, PSToken* token); + virtual void notifyRemoved(PSObject* object, PSToken* token); - private: + private: - /* We override these base class methods (called by PlanDatabase) - * to call the above PS interface versions of the same methods. - */ - virtual void notifyAdded(const ObjectId& object); - virtual void notifyRemoved(const ObjectId& object); - virtual void notifyActivated(const TokenId& token); - virtual void notifyDeactivated(const TokenId& token); - virtual void notifyRejected(const TokenId& token); - virtual void notifyMerged(const TokenId& token); - virtual void notifySplit(const TokenId& token); - virtual void notifyAdded(const ObjectId& object, const TokenId& token); - virtual void notifyRemoved(const ObjectId& object, const TokenId& token); + /* We override these base class methods (called by PlanDatabase) + * to call the above PS interface versions of the same methods. + */ + virtual void notifyAdded(const ObjectId object); + virtual void notifyRemoved(const ObjectId object); + virtual void notifyActivated(const TokenId token); + virtual void notifyDeactivated(const TokenId token); + virtual void notifyRejected(const TokenId token); + virtual void notifyMerged(const TokenId token); + virtual void notifySplit(const TokenId token); + virtual void notifyAdded(const ObjectId object, const TokenId token); + virtual void notifyRemoved(const ObjectId object, const TokenId token); - /* These methods are likely unnecessary to a user. We override the base - * class version only to make private (they still don't do anything) - */ - virtual void notifyAdded(const TokenId& token) {} - virtual void notifyRemoved(const TokenId& token) {} - virtual void notifyReinstated(const TokenId& token) {} - virtual void notifyConstrained(const ObjectId& object, const TokenId& predecessor, const TokenId& successor) {} - virtual void notifyFreed(const ObjectId& object, const TokenId& predecessor, const TokenId& successor) {} - virtual void notifyCommitted(const TokenId& token) {} - virtual void notifyTerminated(const TokenId& token) {} - }; + /* These methods are likely unnecessary to a user. We override the base + * class version only to make private (they still don't do anything) + */ + virtual void notifyAdded(const TokenId) {} + virtual void notifyRemoved(const TokenId) {} + virtual void notifyReinstated(const TokenId) {} + virtual void notifyConstrained(const ObjectId, const TokenId, const TokenId) {} + virtual void notifyFreed(const ObjectId, const TokenId, const TokenId) {} + virtual void notifyCommitted(const TokenId) {} + virtual void notifyTerminated(const TokenId) {} +}; } -#endif // _H_PSPlanDatabaseListener +#endif // H_PSPlanDatabaseListener diff --git a/src/PLASMA/PlanDatabase/base/PlanDatabase.cc b/src/PLASMA/PlanDatabase/base/PlanDatabase.cc index af7b54afc..f516e13a5 100644 --- a/src/PLASMA/PlanDatabase/base/PlanDatabase.cc +++ b/src/PLASMA/PlanDatabase/base/PlanDatabase.cc @@ -11,7 +11,6 @@ #include "Utils.hh" #include "ConstraintEngine.hh" #include "ConstraintType.hh" -#include "LabelStr.hh" #include "Entity.hh" #include "Debug.hh" #include "Utils.hh" @@ -48,7 +47,7 @@ namespace EUROPA{ private: friend class PlanDatabase; // Only one, since use of this listener is only for internal data synch for plandb. - ObjectVariableListener(const ConstrainedVariableId& objectVar, const PlanDatabaseId& planDb) + ObjectVariableListener(const ConstrainedVariableId objectVar, const PlanDatabaseId planDb) : ConstrainedVariableListener(objectVar), m_planDb(planDb){} const PlanDatabaseId m_planDb; @@ -61,12 +60,30 @@ namespace EUROPA{ } - PlanDatabase::PlanDatabase(const ConstraintEngineId& constraintEngine, const SchemaId& schema) + PlanDatabase::PlanDatabase(const ConstraintEngineId constraintEngine, const SchemaId schema) : m_id(this) , m_constraintEngine(constraintEngine) , m_schema(schema) + , m_temporalAdvisor() + , m_client() + , m_psClient(NULL) , m_state(OPEN) + , m_tokens() + , m_objects() + , m_globalTokens() + , m_globalVariables() , m_deleted(false) + , m_listeners() + , m_objectsByName() + , m_objectsByPredicate() + , m_objectsByType() + , m_closedObjectTypes() + , m_globalVarsByName() + , m_globalTokensByName() + , m_tokensToOrder() + , m_activeTokensByPredicate() + , m_objectVariablesByObjectType() + { check_error(m_constraintEngine.isValid()); check_error(m_schema.isValid()); @@ -82,17 +99,17 @@ namespace EUROPA{ purge(); if (!m_temporalAdvisor.isNoId()) - delete (TemporalAdvisor*) m_temporalAdvisor; + delete static_cast(m_temporalAdvisor); // Delete the client check_error(m_client.isValid()); - delete (DbClient*) m_client; + delete static_cast(m_client); delete m_psClient; // Delete all object variable listeners: for(ObjVarsByObjType_CI it = m_objectVariablesByObjectType.begin(); it != m_objectVariablesByObjectType.end(); ++it) - delete (ObjectVariableListener*) it->second.second; + delete static_cast(it->second.second); m_id.remove(); } @@ -137,32 +154,32 @@ namespace EUROPA{ Entity::garbageCollect(); } - void PlanDatabase::notifyAdded(const ObjectId& object){ + void PlanDatabase::notifyAdded(const ObjectId object){ check_error(!Entity::isPurging(), "Should not be in this method if in purgeMode."); check_error(object.isValid()); check_error(!isClosed(object->getType()), - "Cannot add object " + object->getName().toString() + - " if type " + object->getType().toString() + " is already closed."); + "Cannot add object " + object->getName() + + " if type " + object->getType() + " is already closed."); check_error(m_objects.find(object) == m_objects.end(), - "Object with the name " + object->getName().toString() + " already added."); + "Object with the name " + object->getName() + " already added."); - check_error(m_objectsByName.find(object->getName().getKey()) == m_objectsByName.end(), - "Object with the name " + object->getName().toString() + " already added."); + check_error(m_objectsByName.find(object->getName()) == m_objectsByName.end(), + "Object with the name " + object->getName() + " already added."); m_objects.insert(object); // Cache by name - m_objectsByName.insert(std::make_pair(object->getName().getKey(), object)); + m_objectsByName.insert(std::make_pair(object->getName(), object)); // Now cache by type - LabelStr type = object->getType(); - m_objectsByType.insert(std::make_pair(type.getKey(), object)); + std::string type = object->getType(); + m_objectsByType.insert(std::make_pair(type, object)); while(m_schema->hasParent(type)){ type = m_schema->getParent(type); - m_objectsByType.insert(std::make_pair(type.getKey(), object)); + m_objectsByType.insert(std::make_pair(type, object)); } // Now we must push the insertion to any connected variables. @@ -178,26 +195,26 @@ namespace EUROPA{ publish(notifyAdded(object)); debugMsg("PlanDatabase:notifyAdded:Object", - object->getType().toString() << CLASS_DELIMITER << object->getName().toString() << " (" << object->getKey() << ")"); + object->getType() << CLASS_DELIMITER << object->getName() << " (" << object->getKey() << ")"); } - void PlanDatabase::notifyRemoved(const ObjectId& object){ + void PlanDatabase::notifyRemoved(const ObjectId object){ check_error(!Entity::isPurging()); check_error(object.isValid()); check_error(m_objects.find(object) != m_objects.end()); - check_error(m_objectsByName.find(object->getName().getKey()) != m_objectsByName.end()); + check_error(m_objectsByName.find(object->getName()) != m_objectsByName.end()); // Clean up cached values m_objects.erase(object); - m_objectsByName.erase(object->getName().getKey()); - for(std::multimap::iterator it = m_objectsByPredicate.begin(); it != m_objectsByPredicate.end();){ + m_objectsByName.erase(object->getName()); + for(std::multimap::iterator it = m_objectsByPredicate.begin(); it != m_objectsByPredicate.end();){ if(it->second == object) m_objectsByPredicate.erase(it++); else ++it; } - for(std::multimap::iterator it = m_objectsByType.begin(); it != m_objectsByType.end();){ + for(std::multimap::iterator it = m_objectsByType.begin(); it != m_objectsByType.end();){ if(it->second == object) m_objectsByType.erase(it++); else @@ -216,10 +233,10 @@ namespace EUROPA{ publish(notifyRemoved(object)); debugMsg("PlanDatabase:notifyRemoved:Object", - object->getType().toString() << CLASS_DELIMITER << object->getName().toString() << " (" << object->getKey() << ")"); + object->getType() << CLASS_DELIMITER << object->getName() << " (" << object->getKey() << ")"); } - void PlanDatabase::notifyAdded(const TokenId& token){ + void PlanDatabase::notifyAdded(const TokenId token){ check_error(m_tokens.find(token) == m_tokens.end()); m_tokens.insert(token); publish(notifyAdded(token)); @@ -227,7 +244,7 @@ namespace EUROPA{ debugMsg("PlanDatabase:notifyAdded:Token", token->toString()); } - void PlanDatabase::notifyRemoved(const TokenId& token){ + void PlanDatabase::notifyRemoved(const TokenId token){ check_error(!Entity::isPurging()); check_error(m_tokens.find(token) != m_tokens.end()); @@ -239,29 +256,29 @@ namespace EUROPA{ publish(notifyRemoved(token)); debugMsg("PlanDatabase:notifyRemoved:Token", - token->getPredicateName().toString() << " (" << token->getKey() << ")"); + token->getPredicateName() << " (" << token->getKey() << ")"); } - void PlanDatabase::notifyAdded(const ObjectId& object, const TokenId& token){ + void PlanDatabase::notifyAdded(const ObjectId object, const TokenId token){ publish(notifyAdded(object, token)); debugMsg("PlanDatabase:notifyAdded:Object:Token", token->toString() << " added to " << object->toString()); } - void PlanDatabase::notifyRemoved(const ObjectId& object, const TokenId& token){ + void PlanDatabase::notifyRemoved(const ObjectId object, const TokenId token){ publish(notifyRemoved(object,token)); debugMsg("PlanDatabase:notifyRemoved:Object:Token", token->toString() << " removed from " << object->toString()); } - void PlanDatabase::notifyAdded(const PlanDatabaseListenerId& listener){ + void PlanDatabase::notifyAdded(const PlanDatabaseListenerId listener){ check_error(listener.isValid()); check_error(find(m_listeners.begin(), m_listeners.end(), listener) == m_listeners.end()); m_listeners.push_back(listener); } - void PlanDatabase::notifyRemoved(const PlanDatabaseListenerId& listener){ + void PlanDatabase::notifyRemoved(const PlanDatabaseListenerId listener){ if(!m_deleted) { debugMsg("PlanDatabase:notifyRemoved:Listener", "Not in PlanDatabase destructor, so erasing " << listener); @@ -275,25 +292,25 @@ namespace EUROPA{ } } - const PlanDatabaseId& PlanDatabase::getId() const {return m_id;} + const PlanDatabaseId PlanDatabase::getId() const {return m_id;} - const ConstraintEngineId& PlanDatabase::getConstraintEngine() const {return m_constraintEngine;} + const ConstraintEngineId PlanDatabase::getConstraintEngine() const {return m_constraintEngine;} - const SchemaId& PlanDatabase::getSchema() const {return m_schema;} + const SchemaId PlanDatabase::getSchema() const {return m_schema;} - const TemporalAdvisorId& PlanDatabase::getTemporalAdvisor() { + const TemporalAdvisorId PlanDatabase::getTemporalAdvisor() { if (m_temporalAdvisor.isNoId()) { m_temporalAdvisor = (new DefaultTemporalAdvisor(m_constraintEngine))->getId(); } return m_temporalAdvisor; } - void PlanDatabase::setTemporalAdvisor(const TemporalAdvisorId& temporalAdvisor) { + void PlanDatabase::setTemporalAdvisor(const TemporalAdvisorId temporalAdvisor) { check_error(m_temporalAdvisor.isNoId()); m_temporalAdvisor = temporalAdvisor; } - const DbClientId& PlanDatabase::getClient() const { + const DbClientId PlanDatabase::getClient() const { return m_client; } @@ -301,16 +318,16 @@ namespace EUROPA{ return m_objects; } - bool PlanDatabase::hasObjectInstances(const LabelStr& objectType) const { - check_error(m_schema->isObjectType(objectType)); +bool PlanDatabase::hasObjectInstances(const std::string& objectType) const { + check_error(m_schema->isObjectType(objectType)); - std::multimap::const_iterator it = m_objectsByType.find(objectType.getKey()); + std::multimap::const_iterator it = m_objectsByType.find(objectType); - return (it != m_objectsByType.end() && it->first == objectType.getKey()); - } + return (it != m_objectsByType.end() && it->first == objectType); +} - void PlanDatabase::registerGlobalVariable(const ConstrainedVariableId& var){ - const LabelStr& varName = var->getName(); + void PlanDatabase::registerGlobalVariable(const ConstrainedVariableId var){ + const std::string& varName = var->getName(); checkError(!isGlobalVariable(varName), var->toString() << " is not unique."); m_globalVariables.insert(var); m_globalVarsByName.insert(std::make_pair(varName, var)); @@ -319,8 +336,8 @@ namespace EUROPA{ debugMsg("PlanDatabase:registerGlobalVariable", "Registered " << var->toString()); } - void PlanDatabase::unregisterGlobalVariable(const ConstrainedVariableId& var) { - const LabelStr& varName = var->getName(); + void PlanDatabase::unregisterGlobalVariable(const ConstrainedVariableId var) { + const std::string& varName = var->getName(); checkError(isGlobalVariable(varName), var->toString() << " is not a global variable."); m_globalVariables.erase(var); m_globalVarsByName.erase(varName); @@ -333,56 +350,57 @@ namespace EUROPA{ return m_globalVariables; } - const ConstrainedVariableId& PlanDatabase::getGlobalVariable(const LabelStr& varName) const{ - checkError(isGlobalVariable(varName), "No variable with name='" << varName.toString() << "' is present."); + const ConstrainedVariableId PlanDatabase::getGlobalVariable(const std::string& varName) const{ + checkError(isGlobalVariable(varName), + "No variable with name='" << varName << "' is present."); return m_globalVarsByName.find(varName)->second; } - bool PlanDatabase::isGlobalVariable(const LabelStr& varName) const{ + bool PlanDatabase::isGlobalVariable(const std::string& varName) const{ return (m_globalVarsByName.find(varName) != m_globalVarsByName.end()); } - void PlanDatabase::registerGlobalToken(const TokenId& t){ - const LabelStr& name = t->getName(); - checkError(!isGlobalToken(name), name.toString() << " is not unique. Can't register global token"); + void PlanDatabase::registerGlobalToken(const TokenId t){ + const std::string& name = t->getName(); + checkError(!isGlobalToken(name), name << " is not unique. Can't register global token"); m_globalTokens.insert(t); m_globalTokensByName.insert(std::make_pair(name, t)); checkError(isGlobalToken(name), t->toLongString() << " is not registered after all. This cannot be!."); - debugMsg("PlanDatabase:registerGlobalToken", "Registered " << name.toString()); + debugMsg("PlanDatabase:registerGlobalToken", "Registered " << name); } - void PlanDatabase::unregisterGlobalToken(const TokenId& t) { - const LabelStr& name = t->getName(); - checkError(isGlobalToken(name), name.toString() << " is not a global token."); + void PlanDatabase::unregisterGlobalToken(const TokenId t) { + const std::string& name = t->getName(); + checkError(isGlobalToken(name), name << " is not a global token."); m_globalTokens.erase(t); m_globalTokensByName.erase(name); - checkError(!isGlobalToken(name), name.toString() << " failed to un-register."); + checkError(!isGlobalToken(name), name << " failed to un-register."); debugMsg("PlanDatabase:unregisterGlobalToken", - "Un-registered " << name.toString()); + "Un-registered " << name); } const TokenSet& PlanDatabase::getGlobalTokens() const { return m_globalTokens; } - const TokenId& PlanDatabase::getGlobalToken(const LabelStr& name) const{ - checkError(isGlobalToken(name), "No global token with name='" << name.toString() << "' is registered."); + const TokenId PlanDatabase::getGlobalToken(const std::string& name) const{ + checkError(isGlobalToken(name), "No global token with name='" << name << "' is registered."); return m_globalTokensByName.find(name)->second; } - bool PlanDatabase::isGlobalToken(const LabelStr& name) const{ + bool PlanDatabase::isGlobalToken(const std::string& name) const{ return (m_globalTokensByName.find(name) != m_globalTokensByName.end()); } - bool PlanDatabase::hasCompatibleTokens(const TokenId& inactiveToken){ + bool PlanDatabase::hasCompatibleTokens(const TokenId inactiveToken){ if(countCompatibleTokens(inactiveToken, 1) > 0) return true; else return false; } - void PlanDatabase::getCompatibleTokens(const TokenId& inactiveToken, + void PlanDatabase::getCompatibleTokens(const TokenId inactiveToken, std::vector& results, unsigned int limit, bool useExactTest) { @@ -396,7 +414,7 @@ namespace EUROPA{ "PlanDatabase:getCompatibleTokens", "No candidates to evaluate for " << inactiveToken->toString()); const std::vector& inactiveTokenVariables = inactiveToken->getVariables(); - int variableCount = inactiveTokenVariables.size(); + unsigned long variableCount = inactiveTokenVariables.size(); unsigned int choiceCount = 0; // Used for comparison against given limit @@ -411,14 +429,14 @@ namespace EUROPA{ // Validate expectation about being active and predicate being the same check_error(m_schema->isA(candidate->getPredicateName(), inactiveToken->getPredicateName()), - candidate->getPredicateName().toString() + " is not a " + inactiveToken->getPredicateName().toString()); + candidate->getPredicateName() + " is not a " + inactiveToken->getPredicateName()); check_error(candidate->isActive(), "Should not be trying to merge an active token."); const std::vector& candidateTokenVariables = candidate->getVariables(); // Check assumption that the set of variables is the same - checkError(candidateTokenVariables.size() == (unsigned int) variableCount, + checkError(candidateTokenVariables.size() == static_cast(variableCount), "Candidate token (" << candidate->getKey() << ") has " << candidateTokenVariables.size() << " variables, while inactive token (" << inactiveToken->getKey() << ") has " << variableCount); @@ -432,7 +450,7 @@ namespace EUROPA{ check_error(inactiveTokenVariables[0] == inactiveToken->getState(), "We expect the first var to be the state var, which we must skip."); - for(int i=1;ilastDomain(); const Domain& domB = candidateTokenVariables[i]->lastDomain(); @@ -451,14 +469,14 @@ namespace EUROPA{ if(!isCompatible) { debugMsg("PlanDatabase:getCompatibleTokens", "EXCLUDING (" << candidate->getKey() << ")" << - "VAR=" << candidateTokenVariables[i]->getName().toString() << + "VAR=" << candidateTokenVariables[i]->getName() << "(" << candidateTokenVariables[i]->getKey() << ") " << "Cannot intersect " << domA.toString() << " with " << domB.toString()); break; } debugMsg("PlanDatabase:getCompatibleTokens", - "VAR=" << candidateTokenVariables[i]->getName().toString() << + "VAR=" << candidateTokenVariables[i]->getName() << "(" << candidateTokenVariables[i]->getKey() << ") " << "Can intersect " << domA.toString() << " with " << domB.toString()); } @@ -484,31 +502,31 @@ namespace EUROPA{ } } -// void PlanDatabase::getCompatibleTokens(const TokenId& inactiveToken, +// void PlanDatabase::getCompatibleTokens(const TokenId inactiveToken, // std::vector& results, // eint limit, // bool useExactTest) { // getCompatibleTokens(inactiveToken, results, cast_int(limit), useExactTest); // } - void PlanDatabase::getCompatibleTokens(const TokenId& inactiveToken, + void PlanDatabase::getCompatibleTokens(const TokenId inactiveToken, std::vector& results) { getCompatibleTokens(inactiveToken, results, std::numeric_limits::max(), false); } - unsigned int PlanDatabase::countCompatibleTokens(const TokenId& inactiveToken, - unsigned int limit, - bool useExactTest){ - std::vector results; - getCompatibleTokens(inactiveToken, results, limit, useExactTest); - return results.size(); - } +unsigned long PlanDatabase::countCompatibleTokens(const TokenId inactiveToken, + unsigned int limit, + bool useExactTest){ + std::vector results; + getCompatibleTokens(inactiveToken, results, limit, useExactTest); + return results.size(); +} const std::map >& PlanDatabase::getTokensToOrder(){ return m_tokensToOrder; } - void PlanDatabase::getOrderingChoices(const TokenId& tokenToOrder, + void PlanDatabase::getOrderingChoices(const TokenId tokenToOrder, std::vector< OrderingChoice >& results, unsigned int limit){ if(!m_constraintEngine->propagate()) @@ -542,14 +560,14 @@ namespace EUROPA{ checkError(results.size() <= limit, "Cutoff must be enforced."); } - unsigned int PlanDatabase::countOrderingChoices(const TokenId& token, - unsigned int limit){ + unsigned long PlanDatabase::countOrderingChoices(const TokenId token, + unsigned long limit){ if(!m_constraintEngine->propagate()) return 0; std::list objects; token->getObject()->lastDomain().getValues(objects); - unsigned int choiceCount = 0; + unsigned long choiceCount = 0; for(std::list::const_iterator it = objects.begin(); it != objects.end(); ++it){ ObjectId object = Entity::getTypedEntity(*it); choiceCount = choiceCount + object->countOrderingChoices(token, limit-choiceCount); @@ -560,11 +578,11 @@ namespace EUROPA{ return choiceCount; } - unsigned int PlanDatabase::lastOrderingChoiceCount(const TokenId& token) const{ + unsigned long PlanDatabase::lastOrderingChoiceCount(const TokenId token) const{ checkError(m_constraintEngine->constraintConsistent(), "Cannot query for ordering choices while database is not constraintConsistent."); std::list objects; - unsigned int choiceCount = 0; + unsigned long choiceCount = 0; token->getObject()->lastDomain().getValues(objects); for(std::list::const_iterator it = objects.begin(); it != objects.end(); ++it){ ObjectId object = Entity::getTypedEntity(*it); @@ -576,40 +594,41 @@ namespace EUROPA{ /** * @todo Really inefficient implementation. Improve later. */ - bool PlanDatabase::hasOrderingChoice(const TokenId& token){ + bool PlanDatabase::hasOrderingChoice(const TokenId token){ if(countOrderingChoices(token, 1) > 0) return true; else return false; } - void PlanDatabase::getObjectsByPredicate(const LabelStr& predicate, std::list& results) { - check_error(results.empty()); - check_error(m_schema->isPredicate(predicate)); +void PlanDatabase::getObjectsByPredicate(const std::string& predicate, + std::list& results) { + check_error(results.empty()); + check_error(m_schema->isPredicate(predicate)); - // First try a cache hit. - for(std::multimap::const_iterator it = m_objectsByPredicate.find(predicate.getKey()); - (it != m_objectsByPredicate.end() && it->first == predicate.getKey()); - ++it){ - results.push_back(it->second); - } + // First try a cache hit. + for(std::multimap::const_iterator it = m_objectsByPredicate.find(predicate); + (it != m_objectsByPredicate.end() && it->first == predicate); + ++it){ + results.push_back(it->second); + } - if(results.empty()){ // We do not have a hit, so we must construct the set by iterating over all objects and checking with the schema - for (ObjectSet::const_iterator it = m_objects.begin(); it != m_objects.end(); ++it){ - ObjectId object = *it; - check_error(object.isValid()); - if(m_schema->canBeAssigned(object->getType(), predicate)){ - results.push_back(object); - m_objectsByPredicate.insert(std::make_pair(predicate.getKey(), object)); - } + if(results.empty()){ // We do not have a hit, so we must construct the set by iterating over all objects and checking with the schema + for (ObjectSet::const_iterator it = m_objects.begin(); it != m_objects.end(); ++it){ + ObjectId object = *it; + check_error(object.isValid()); + if(m_schema->canBeAssigned(object->getType(), predicate)){ + results.push_back(object); + m_objectsByPredicate.insert(std::make_pair(predicate, object)); } } } +} - const ObjectId& PlanDatabase::getObject(const LabelStr& name) const{ - if (m_objectsByName.find(name.getKey()) == m_objectsByName.end()) + const ObjectId PlanDatabase::getObject(const std::string& name) const{ + if (m_objectsByName.find(name) == m_objectsByName.end()) return ObjectId::noId(); - return m_objectsByName.find(name.getKey())->second; + return m_objectsByName.find(name)->second; } const TokenSet& PlanDatabase::getTokens() const { @@ -617,21 +636,22 @@ namespace EUROPA{ } - const TokenSet& PlanDatabase::getActiveTokens(const LabelStr& predicate) const { - static const TokenSet sl_noTokens; - std::map::const_iterator it = m_activeTokensByPredicate.find(predicate); - if(it != m_activeTokensByPredicate.end()) - return it->second; - else - return sl_noTokens; - } +const TokenSet& PlanDatabase::getActiveTokens(const std::string& predicate) const { + static const TokenSet sl_noTokens; + std::map::const_iterator it = + m_activeTokensByPredicate.find(predicate); + if(it != m_activeTokensByPredicate.end()) + return it->second; + else + return sl_noTokens; +} bool PlanDatabase::isClosed() const { return (m_state == CLOSED); } - bool PlanDatabase::isClosed(const LabelStr& objectType) const { - check_error(m_schema->isObjectType(objectType), "Type '" + objectType.toString() + "' not defined in the model."); + bool PlanDatabase::isClosed(const std::string& objectType) const { + check_error(m_schema->isObjectType(objectType), "Type '" + objectType + "' not defined in the model."); return(m_state == CLOSED || (m_state == OPEN &&m_closedObjectTypes.find(objectType) != m_closedObjectTypes.end())); } @@ -652,42 +672,44 @@ namespace EUROPA{ check_error(connectedObjectVariable.isValid()); if(!connectedObjectVariable->isClosed()) connectedObjectVariable->close(); - delete (ObjectVariableListener*) it->second.second; + delete static_cast(it->second.second); m_objectVariablesByObjectType.erase(it++); } m_state = CLOSED; } - void PlanDatabase::close(const LabelStr& objectType){ - check_error(m_state == OPEN); - check_error(!isClosed(objectType)); +void PlanDatabase::close(const std::string& objectType) { + check_error(m_state == OPEN); + check_error(!isClosed(objectType)); - debugMsg("PlanDatabase:close","Closing "+objectType.toString()); + debugMsg("PlanDatabase:close","Closing "+objectType); - // Now we must close all the object variables associated with this type - ObjVarsByObjType_I it = m_objectVariablesByObjectType.find(objectType); - while (it != m_objectVariablesByObjectType.end() && it->first == objectType){ - ConstrainedVariableId connectedObjectVariable = it->second.first; - check_error(connectedObjectVariable.isValid()); - if(!connectedObjectVariable->isClosed()) { - debugMsg("PlanDatabase:close","Closing "+objectType.toString()+" closing "+connectedObjectVariable->toString()); - connectedObjectVariable->close(); - debugMsg("PlanDatabase:close","Closing "+objectType.toString()+" closed "+connectedObjectVariable->toString()); - } - delete (ObjectVariableListener*) it->second.second; - m_objectVariablesByObjectType.erase(it++); + // Now we must close all the object variables associated with this type + ObjVarsByObjType_I it = m_objectVariablesByObjectType.find(objectType); + while (it != m_objectVariablesByObjectType.end() && it->first == objectType){ + ConstrainedVariableId connectedObjectVariable = it->second.first; + check_error(connectedObjectVariable.isValid()); + if(!connectedObjectVariable->isClosed()) { + debugMsg("PlanDatabase:close", + "Closing " << objectType << " closing " << connectedObjectVariable->toString()); + connectedObjectVariable->close(); + debugMsg("PlanDatabase:close", + "Closing " << objectType << " closed " << connectedObjectVariable->toString()); } - m_closedObjectTypes.insert(objectType); - - debugMsg("PlanDatabase:close","Closed "+objectType.toString()); + delete static_cast(it->second.second); + m_objectVariablesByObjectType.erase(it++); } + m_closedObjectTypes.insert(objectType); + + debugMsg("PlanDatabase:close","Closed "+objectType); +} PlanDatabase::State PlanDatabase::getState() const { return m_state; } - void PlanDatabase::notifyActivated(const TokenId& token){ + void PlanDatabase::notifyActivated(const TokenId token){ // Need to insert this token in the activeToken index check_error(token.isValid()); check_error(token->isActive()); @@ -695,7 +717,7 @@ namespace EUROPA{ insertActiveToken(token); debugMsg("PlanDatabase:notifyActivated", - token->getPredicateName().toString() << "(" << token->getKey() << "}"); + token->getPredicateName() << "(" << token->getKey() << "}"); publish(notifyActivated(token)); } @@ -703,7 +725,7 @@ namespace EUROPA{ * @todo Can make thos more efficient by using the inheritance model as was donw on * insertion. */ - void PlanDatabase::notifyDeactivated(const TokenId& token){ + void PlanDatabase::notifyDeactivated(const TokenId token){ check_error(!Entity::isPurging()); check_error(token.isValid()); @@ -712,78 +734,78 @@ namespace EUROPA{ publish(notifyDeactivated(token)); debugMsg("PlanDatabase:notifyDeactivated", - token->getPredicateName().toString() << "(" << token->getKey() << "}"); + token->getPredicateName() << "(" << token->getKey() << "}"); } - void PlanDatabase::notifyMerged(const TokenId& token){ + void PlanDatabase::notifyMerged(const TokenId token){ publish(notifyMerged(token)); debugMsg("PlanDatabase:notifyMerged", - token->getPredicateName().toString() << "(" << token->getKey() << "}" << + token->getPredicateName() << "(" << token->getKey() << "}" << " merged with (" << token->getActiveToken()->getKey() << ")"); } - void PlanDatabase::notifySplit(const TokenId& token){ + void PlanDatabase::notifySplit(const TokenId token){ check_error(!Entity::isPurging()); publish(notifySplit(token)); debugMsg("PlanDatabase:notifySplit", - token->getPredicateName().toString() << "(" << token->getKey() << "}"); + token->getPredicateName() << "(" << token->getKey() << "}"); } - void PlanDatabase::notifyRejected(const TokenId& token){ + void PlanDatabase::notifyRejected(const TokenId token){ publish(notifyRejected(token)); debugMsg("PlanDatabase:notifyRejected", - token->getPredicateName().toString() << "(" << token->getKey() << "}"); + token->getPredicateName() << "(" << token->getKey() << "}"); } - void PlanDatabase::notifyReinstated(const TokenId& token){ + void PlanDatabase::notifyReinstated(const TokenId token){ check_error(!Entity::isPurging()); publish(notifyReinstated(token)); debugMsg("PlanDatabase:notifyReinstated", - token->getPredicateName().toString() << "(" << token->getKey() << "}"); + token->getPredicateName() << "(" << token->getKey() << "}"); } - void PlanDatabase::notifyCommitted(const TokenId& token){ + void PlanDatabase::notifyCommitted(const TokenId token){ check_error(!Entity::isPurging()); publish(notifyCommitted(token)); debugMsg("PlanDatabase:notifyCommitted", - token->getPredicateName().toString() << "(" << token->getKey() << "}"); + token->getPredicateName() << "(" << token->getKey() << "}"); } - void PlanDatabase::notifyTerminated(const TokenId& token){ + void PlanDatabase::notifyTerminated(const TokenId token){ check_error(!Entity::isPurging()); publish(notifyTerminated(token)); debugMsg("PlanDatabase:notifyTerminated", - token->getPredicateName().toString() << "(" << token->getKey() << "}"); + token->getPredicateName() << "(" << token->getKey() << "}"); } - void PlanDatabase::notifyConstrained(const ObjectId& object, const TokenId& predecessor, const TokenId& successor) { + void PlanDatabase::notifyConstrained(const ObjectId object, const TokenId predecessor, const TokenId successor) { publish(notifyConstrained(object, predecessor, successor)); debugMsg("PlanDatabase:notifyConstrained", "(" << predecessor->getKey() << ") On Object " << - object->getType().toString() << CLASS_DELIMITER << object->getName().toString() << " (" + object->getType() << CLASS_DELIMITER << object->getName() << " (" << object->getKey() << ") Constrained Before Token (" << successor->getKey() << ")"); } - void PlanDatabase::notifyFreed(const ObjectId& object, const TokenId& predecessor, const TokenId& successor) { + void PlanDatabase::notifyFreed(const ObjectId object, const TokenId predecessor, const TokenId successor) { check_error(!Entity::isPurging()); publish(notifyFreed(object, predecessor, successor)); debugMsg("PlanDatabase:notifyFreed", "(" << predecessor->getKey() << ") On Object " << - object->getType().toString() << CLASS_DELIMITER << object->getName().toString() << " (" + object->getType() << CLASS_DELIMITER << object->getName() << " (" << object->getKey() << ") Freed from Before Token (" << successor->getKey() << ")"); } - void PlanDatabase::notifyOrderingRequired(const ObjectId& object, const TokenId& token){ + void PlanDatabase::notifyOrderingRequired(const ObjectId object, const TokenId token){ debugMsg("PlanDatabase:notifyOrderingRequired", - object->getName().toString() << "(" << object->getKey() << ") from " << token->toString()); + object->getName() << "(" << object->getKey() << ") from " << token->toString()); checkError(token->isActive(), "Token must be active to induce an ordering:" << token->toString()); @@ -803,9 +825,9 @@ namespace EUROPA{ objects.insert(object); } - void PlanDatabase::notifyOrderingNoLongerRequired(const ObjectId& object, const TokenId& token){ + void PlanDatabase::notifyOrderingNoLongerRequired(const ObjectId object, const TokenId token){ debugMsg("PlanDatabase:notifyOrderingNoLongerRequired", - object->getName().toString() << "(" << object->getKey() << ") from " << token->toString()); + object->getName() << "(" << object->getKey() << ") from " << token->toString()); std::map >::iterator it = m_tokensToOrder.find(token->getKey()); checkError(it != m_tokensToOrder.end(), @@ -824,17 +846,17 @@ namespace EUROPA{ } - void PlanDatabase::makeObjectVariableFromType(const LabelStr& objectType, - const ConstrainedVariableId& objectVar, + void PlanDatabase::makeObjectVariableFromType(const std::string& objectType, + const ConstrainedVariableId objectVar, bool leaveOpen){ std::list objects; getObjectsByType(objectType, objects); makeObjectVariable(objectType, objects, objectVar, leaveOpen); } - void PlanDatabase::makeObjectVariable(const LabelStr& objectType, + void PlanDatabase::makeObjectVariable(const std::string& objectType, const std::list& objects, - const ConstrainedVariableId& objectVar, + const ConstrainedVariableId objectVar, bool leaveOpen){ check_error(objectVar.isValid()); check_error(!objectVar->isClosed()); @@ -844,8 +866,8 @@ namespace EUROPA{ check_error(object.isValid()); objectVar->insert(object->getKey()); debugMsg("PlanDatabase:makeObjectVariable", - "Inserting object " << object->getName().toString() << " of type " - << object->getType().toString() << " for base type " << objectType.toString()); + "Inserting object " << object->getName() << " of type " + << object->getType() << " for base type " << objectType); } handleObjectVariableCreation(objectType, objectVar, leaveOpen); @@ -854,22 +876,22 @@ namespace EUROPA{ /** * @brief Remove */ - void PlanDatabase::handleObjectVariableDeletion(const ConstrainedVariableId& objectVar){ - - // Now iterate over objectVariables stored and remove them - should be at least one reference - for(ObjVarsByObjType_I it = m_objectVariablesByObjectType.begin(); - it != m_objectVariablesByObjectType.end();){ - if(it->second.first == objectVar){ - delete (ObjectVariableListener*) it->second.second; - m_objectVariablesByObjectType.erase(it++); - } - else - ++it; +void PlanDatabase::handleObjectVariableDeletion(const ConstrainedVariableId objectVar){ + + // Now iterate over objectVariables stored and remove them - should be at least one reference + for(ObjVarsByObjType_I it = m_objectVariablesByObjectType.begin(); + it != m_objectVariablesByObjectType.end();){ + if(it->second.first == objectVar){ + delete static_cast(it->second.second); + m_objectVariablesByObjectType.erase(it++); } + else + ++it; } +} - void PlanDatabase::handleObjectVariableCreation(const LabelStr& objectType, - const ConstrainedVariableId& objectVar, + void PlanDatabase::handleObjectVariableCreation(const std::string& objectType, + const ConstrainedVariableId objectVar, bool leaveOpen){ if(!isClosed(objectType)){ ObjectVariableListener* ovl = new ObjectVariableListener(objectVar, m_id); @@ -883,98 +905,98 @@ namespace EUROPA{ return Entity::getEntity(key); } - unsigned int PlanDatabase::archive(eint tick){ - checkError(getConstraintEngine()->constraintConsistent(), - "Must be propagated to a consistent state before archiving."); +unsigned long PlanDatabase::archive(eint tick){ + checkError(getConstraintEngine()->constraintConsistent(), + "Must be propagated to a consistent state before archiving."); - const unsigned int initialCount = getTokens().size(); + const unsigned long initialCount = getTokens().size(); - // Build a collection of tokens ordered by earliest start time. This is done to make cleaning up - // of structures like a timeline more efficient. No measurements backing this up or evaluating the true cost - // of this algorithm - std::multimap tokensToRemove; - { - EntityIterator< TokenSet::const_iterator > tokenIterator(m_tokens.begin(), m_tokens.end()); - while(!tokenIterator.done()){ - TokenId token = tokenIterator.next(); + // Build a collection of tokens ordered by earliest start time. This is done to make cleaning up + // of structures like a timeline more efficient. No measurements backing this up or evaluating the true cost + // of this algorithm + std::multimap tokensToRemove; + { + EntityIterator< TokenSet::const_iterator > tokenIterator(m_tokens.begin(), m_tokens.end()); + while(!tokenIterator.done()){ + TokenId token = tokenIterator.next(); - // Do not store merged tokens for removal since we will terminate them when we terminate the - // supporting token. - if(token->isMerged()) - continue; + // Do not store merged tokens for removal since we will terminate them when we terminate the + // supporting token. + if(token->isMerged()) + continue; - eint latestEndTime = cast_int(token->end()->lastDomain().getUpperBound()); + eint latestEndTime = cast_int(token->end()->lastDomain().getUpperBound()); - if(latestEndTime <= tick && token->canBeTerminated(tick)){ - debugMsg("PlanDatabase:archive:remove", - token->toString() << " ending by " << latestEndTime << " for tick " << tick); - eint earliestStartTime = cast_int(token->start()->lastDomain().getLowerBound()); - tokensToRemove.insert(std::make_pair(earliestStartTime, token)); - } - else { - condDebugMsg(!token->isMerged(), "PlanDatabase:archive:skip", - token->toString() << " with end time " << token->end()->toString() << " for tick " << tick); - } + if(latestEndTime <= tick && token->canBeTerminated(tick)){ + debugMsg("PlanDatabase:archive:remove", + token->toString() << " ending by " << latestEndTime << " for tick " << tick); + eint earliestStartTime = cast_int(token->start()->lastDomain().getLowerBound()); + tokensToRemove.insert(std::make_pair(earliestStartTime, token)); + } + else { + condDebugMsg(!token->isMerged(), "PlanDatabase:archive:skip", + token->toString() << " with end time " << token->end()->toString() << " for tick " << tick); } } - - for(std::multimap::const_iterator it = tokensToRemove.begin(); it != tokensToRemove.end(); ++it){ - TokenId token = it->second; - token->terminate(); - token->discard(); - } - - return initialCount-getTokens().size(); } - void PlanDatabase::insertActiveToken(const TokenId& token){ - static const LabelStr sl_objectRoot("Object"); - static const LabelStr sl_timelineRoot("Timeline"); - LabelStr objectType = token->getObject()->baseDomain().getTypeName(); - LabelStr predicate = token->getPredicateName(); - LabelStr predicateSuffix = token->getUnqualifiedPredicateName(); + for(std::multimap::const_iterator it = tokensToRemove.begin(); it != tokensToRemove.end(); ++it){ + TokenId token = it->second; + token->terminate(); + token->discard(); + } - debugMsg("PlanDatabase:insertActiveToken", token->toString()); + return initialCount-getTokens().size(); +} - while(getSchema()->isPredicate(predicate)){ - std::map::iterator it = m_activeTokensByPredicate.find(predicate); - if(it == m_activeTokensByPredicate.end()){ - static const TokenSet emptySet; - std::pair entry(predicate, emptySet); - m_activeTokensByPredicate.insert(entry); - it = m_activeTokensByPredicate.find(predicate); - } +void PlanDatabase::insertActiveToken(const TokenId token){ + static const std::string sl_objectRoot("Object"); + static const std::string sl_timelineRoot("Timeline"); + std::string objectType = token->getObject()->baseDomain().getTypeName(); + std::string predicate = token->getPredicateName(); + std::string predicateSuffix = token->getUnqualifiedPredicateName(); + + debugMsg("PlanDatabase:insertActiveToken", token->toString()); + + while(getSchema()->isPredicate(predicate)){ + std::map::iterator it = m_activeTokensByPredicate.find(predicate); + if(it == m_activeTokensByPredicate.end()){ + static const TokenSet emptySet; + std::pair entry(predicate, emptySet); + m_activeTokensByPredicate.insert(entry); + it = m_activeTokensByPredicate.find(predicate); + } - TokenSet& activeTokens = it->second; - activeTokens.insert(token); - debugMsg("PlanDatabase:insertActiveToken", token->toString() << " added for " << predicate.toString()); + TokenSet& activeTokens = it->second; + activeTokens.insert(token); + debugMsg("PlanDatabase:insertActiveToken", token->toString() << " added for " << predicate); - // Break if we hit a built in class - if(objectType == sl_timelineRoot || objectType == sl_objectRoot) - break; + // Break if we hit a built in class + if(objectType == sl_timelineRoot || objectType == sl_objectRoot) + break; - objectType = getSchema()->getParent(objectType); + objectType = getSchema()->getParent(objectType); - std::string predStr = objectType.toString() + "." + predicateSuffix.c_str(); - predicate = predStr; - } + std::string predStr = objectType + "." + predicateSuffix.c_str(); + predicate = predStr; } +} - void PlanDatabase::removeActiveToken(const TokenId& token){ - static const LabelStr sl_objectRoot("Object"); - static const LabelStr sl_timelineRoot("Timeline"); - LabelStr objectType = token->getObject()->baseDomain().getTypeName(); - LabelStr predicate = token->getPredicateName(); - LabelStr predicateSuffix = token->getUnqualifiedPredicateName(); + void PlanDatabase::removeActiveToken(const TokenId token){ + static const std::string sl_objectRoot("Object"); + static const std::string sl_timelineRoot("Timeline"); + std::string objectType = token->getObject()->baseDomain().getTypeName(); + std::string predicate = token->getPredicateName(); + std::string predicateSuffix = token->getUnqualifiedPredicateName(); debugMsg("PlanDatabase:removeActiveToken", token->toString()); while(getSchema()->isPredicate(predicate)){ - std::map::iterator it = m_activeTokensByPredicate.find(predicate); + std::map::iterator it = m_activeTokensByPredicate.find(predicate); checkError(it != m_activeTokensByPredicate.end(), token->toString() << " must be present but isn't.") TokenSet& activeTokens = it->second; activeTokens.erase(token); - debugMsg("PlanDatabase:removeActiveToken", token->toString() << " removed for " << predicate.toString()); + debugMsg("PlanDatabase:removeActiveToken", token->toString() << " removed for " << predicate); // Break if we hit a built in class if(objectType == sl_timelineRoot || objectType == sl_objectRoot) @@ -982,84 +1004,81 @@ namespace EUROPA{ objectType = getSchema()->getParent(objectType); - std::string predStr = objectType.toString() + "." + predicateSuffix.c_str(); + std::string predStr = objectType + "." + predicateSuffix.c_str(); predicate = predStr; } } // PSPlanDatabase methods - PSList PlanDatabase::getAllObjects() const { - PSList retval; - const ObjectSet& objects = getObjects(); - for(ObjectSet::const_iterator it = objects.begin(); it != objects.end(); ++it) - retval.push_back((PSObject*) *it); - return retval; - } - - PSList PlanDatabase::getObjectsByType(const std::string& objectType) const - { - PSList retval; - - const ObjectSet& objects = getObjects(); - for(ObjectSet::const_iterator it = objects.begin(); it != objects.end(); ++it){ - ObjectId object = *it; - if(m_schema->isA(object->getType(), objectType.c_str())) - retval.push_back((PSObject *) object); - } - - return retval; - } +PSList PlanDatabase::getAllObjects() const { + PSList retval; + const ObjectSet& objects = getObjects(); + for(ObjectSet::const_iterator it = objects.begin(); it != objects.end(); ++it) + retval.push_back(id_cast(*it)); + return retval; +} - PSObject* PlanDatabase::getObjectByKey(PSEntityKey id) const - { - ObjectId object = Entity::getEntity(id); - check_runtime_error(object.isValid()); - return (PSObject *) object; - } +PSList PlanDatabase::getObjectsByType(const std::string& objectType) const { + PSList retval; - PSObject* PlanDatabase::getObjectByName(const std::string& name) const { - ObjectId object = getObject(LabelStr(name)); - check_runtime_error(object.isValid()); - return (PSObject *) object; + const ObjectSet& objects = getObjects(); + for(ObjectSet::const_iterator it = objects.begin(); it != objects.end(); ++it){ + ObjectId object = *it; + if(m_schema->isA(object->getType(), objectType.c_str())) + retval.push_back(id_cast(object)); } - PSList PlanDatabase::getAllTokens() const { - const TokenSet& tokens = getTokens(); - PSList retval; + return retval; +} - for(TokenSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it) { - TokenId id = *it; - retval.push_back((PSToken *) id); - } +PSObject* PlanDatabase::getObjectByKey(PSEntityKey id) const { + ObjectId object = Entity::getEntity(id); + check_runtime_error(object.isValid()); + return id_cast(object); +} - return retval; - } +PSObject* PlanDatabase::getObjectByName(const std::string& name) const { + ObjectId object = getObject(name); + check_runtime_error(object.isValid()); + return id_cast(object); +} - PSToken* PlanDatabase::getTokenByKey(PSEntityKey id) const - { - Id psId = Entity::getEntity(id); - check_runtime_error(psId.isValid()); - return (PSToken *) psId; +PSList PlanDatabase::getAllTokens() const { + const TokenSet& tokens = getTokens(); + PSList retval; + + for(TokenSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it) { + TokenId id = *it; + retval.push_back(id_cast(id)); } + + return retval; +} - PSList PlanDatabase::getAllGlobalVariables() const { +PSToken* PlanDatabase::getTokenByKey(PSEntityKey id) const { + Id psId = Entity::getEntity(id); + check_runtime_error(psId.isValid()); + return id_cast(psId); +} - const ConstrainedVariableSet& vars = getGlobalVariables(); - PSList retval; +PSList PlanDatabase::getAllGlobalVariables() const { - for(ConstrainedVariableSet::const_iterator it = vars.begin(); it != vars.end(); ++it) { - ConstrainedVariableId id = *it; - retval.push_back((PSVariable *) id); - } - return retval; + const ConstrainedVariableSet& vars = getGlobalVariables(); + PSList retval; + + for(ConstrainedVariableSet::const_iterator it = vars.begin(); it != vars.end(); ++it) { + ConstrainedVariableId id = *it; + retval.push_back(id_cast(id)); } + return retval; +} - ObjectId PlanDatabase::createObject(const LabelStr& objectType, - const LabelStr& objectName, + ObjectId PlanDatabase::createObject(const std::string& objectType, + const std::string& objectName, const std::vector& arguments) { - debugMsg("PlanDatabase:createObject", "objectType " << objectType.toString() << " objectName " << objectName.toString()); + debugMsg("PlanDatabase:createObject", "objectType " << objectType << " objectName " << objectName); ObjectFactoryId factory = getSchema()->getObjectFactory(objectType, arguments); ObjectId object = factory->createInstance(getId(), objectType, objectName, arguments); @@ -1068,25 +1087,25 @@ namespace EUROPA{ return object; } - std::string autoLabel(const char* prefix) - { - static int cnt = 0; - std::ostringstream os; - - os << prefix << "_" << cnt++; - return os.str(); - } +namespace { +std::string autoLabel(const char* prefix) { + static int cnt = 0; + std::ostringstream os; + + os << prefix << "_" << cnt++; + return os.str(); +} +} - TokenId PlanDatabase::createToken(const char* tokenType, - const char* tokenName, - bool rejectable, - bool isFact) - { - LabelStr ttype(tokenType); - std::string nameStr = (tokenName != NULL ? tokenName : autoLabel("globalToken")); - LabelStr tname(nameStr); +TokenId PlanDatabase::createToken(const std::string& tokenType, + const std::string& tokenName, + bool rejectable, + bool isFact) { + std::string ttype =tokenType; + std::string nameStr = (!tokenName.empty() ? tokenName : autoLabel("globalToken")); + std::string tname(nameStr); - debugMsg("PlanDatabase:createToken", ttype.toString() << " " << tname.toString()); + debugMsg("PlanDatabase:createToken", ttype << " " << tname); TokenTypeId factory = getSchema()->getTokenType(ttype); check_error(factory.isValid()); @@ -1106,14 +1125,14 @@ namespace EUROPA{ registerGlobalToken(token); - debugMsg("PlanDatabase:createToken","Created Token:" << tname.toString() << std::endl << token->toLongString()); + debugMsg("PlanDatabase:createToken","Created Token:" << tname << std::endl << token->toLongString()); return token; } - TokenId PlanDatabase::createSlaveToken(const TokenId& master, - const LabelStr& tokenType, - const LabelStr& relation) + TokenId PlanDatabase::createSlaveToken(const TokenId master, + const std::string& tokenType, + const std::string& relation) { check_error(master.isValid()); diff --git a/src/PLASMA/PlanDatabase/base/PlanDatabase.hh b/src/PLASMA/PlanDatabase/base/PlanDatabase.hh index 6d6276e62..4223fe0b2 100644 --- a/src/PLASMA/PlanDatabase/base/PlanDatabase.hh +++ b/src/PLASMA/PlanDatabase/base/PlanDatabase.hh @@ -1,5 +1,5 @@ -#ifndef _H_PlanDatabase -#define _H_PlanDatabase +#ifndef H_PlanDatabase +#define H_PlanDatabase /** * @file PlanDatabase.hh * @author Conor McGann @@ -14,7 +14,6 @@ #include "PSPlanDatabase.hh" #include "PlanDatabaseListener.hh" #include "Schema.hh" -#include "LabelStr.hh" #include "DbClient.hh" #include "Engine.hh" @@ -52,24 +51,24 @@ namespace EUROPA { PURGED }; - PlanDatabase(const ConstraintEngineId& constraintEngine, const SchemaId& schema); + PlanDatabase(const ConstraintEngineId constraintEngine, const SchemaId schema); ~PlanDatabase(); - const PlanDatabaseId& getId() const; + const PlanDatabaseId getId() const; - const ConstraintEngineId& getConstraintEngine() const; + const ConstraintEngineId getConstraintEngine() const; - const SchemaId& getSchema() const; + const SchemaId getSchema() const; - const TemporalAdvisorId& getTemporalAdvisor(); + const TemporalAdvisorId getTemporalAdvisor(); - void setTemporalAdvisor(const TemporalAdvisorId& temporalAdvisor); + void setTemporalAdvisor(const TemporalAdvisorId temporalAdvisor); /** * @brief Retrieve a client interface which provides an interception point for all transactions. */ - const DbClientId& getClient() const; + const DbClientId getClient() const; /** * @brief Retrieve an entity given its key value. @@ -94,18 +93,18 @@ namespace EUROPA { /** * @brief Returns the set of all active tokens by predicate. */ - const TokenSet& getActiveTokens(const LabelStr& predicate) const; + const TokenSet& getActiveTokens(const std::string& predicate) const; /** * @brief Register an allocated global variable. - * @param var. The variable to be registered. Must not have a parent. Furthermore, the name of the variable must be unique in this scope. + * @param var The variable to be registered. Must not have a parent. Furthermore, the name of the variable must be unique in this scope. */ - void registerGlobalVariable(const ConstrainedVariableId& var); + void registerGlobalVariable(const ConstrainedVariableId var); /** * @brief Un-register an allocated global variable. */ - void unregisterGlobalVariable(const ConstrainedVariableId& var); + void unregisterGlobalVariable(const ConstrainedVariableId var); /** * @brief Return all global variables registered with the plan database as such @@ -118,27 +117,27 @@ namespace EUROPA { * @brief Access a global variable by name. * @return The variable. It is an error if the variable is not present, or is corrupt in any way. */ - const ConstrainedVariableId& getGlobalVariable(const LabelStr& varName) const; + const ConstrainedVariableId getGlobalVariable(const std::string& varName) const; /** * @brief Test of a global exists for a given name * @return true of present, otherwise false. */ - bool isGlobalVariable(const LabelStr& varName) const; + bool isGlobalVariable(const std::string& varName) const; - void registerGlobalToken(const TokenId& t); - void unregisterGlobalToken(const TokenId& t); + void registerGlobalToken(const TokenId t); + void unregisterGlobalToken(const TokenId t); const TokenSet& getGlobalTokens() const; - const TokenId& getGlobalToken(const LabelStr& varName) const; - bool isGlobalToken(const LabelStr& varName) const; + const TokenId getGlobalToken(const std::string& varName) const; + bool isGlobalToken(const std::string& varName) const; /** * @brief Test if the given inactive token has any tokens with which it can merge. - * @param inactiveToken + * @param inactiveToken The token to check for merge candidates. * @return true if there is 1 or more tokens with which to merge, otherwse false. * @see getCompatibleTokens, countCompatibleTokens */ - bool hasCompatibleTokens(const TokenId& inactiveToken); + bool hasCompatibleTokens(const TokenId inactiveToken); /** * @brief Retrieves a collection of all Tokens that are compatible with the given token. @@ -147,7 +146,7 @@ namespace EUROPA { * @param results A (initially empty) collection to be populated with all compatible tokens. * All returned elements must be active(). */ - void getCompatibleTokens(const TokenId& inactiveToken, + void getCompatibleTokens(const TokenId inactiveToken, std::vector& results); /** @@ -159,11 +158,11 @@ namespace EUROPA { * @param limit Sets a limit to the quantity returned. Use to reduce cost of getting choices. * @param useExactTest If true, use a much more expensive but more rigorous comparison of timepoints. */ - void getCompatibleTokens(const TokenId& inactiveToken, + void getCompatibleTokens(const TokenId inactiveToken, std::vector& results, unsigned int limit, bool useExactTest); -// void getCompatibleTokens(const TokenId& inactiveToken, +// void getCompatibleTokens(const TokenId inactiveToken, // std::vector& results, // eint limit, // bool useExactTest); @@ -172,20 +171,20 @@ namespace EUROPA { * @brief Returns a count of compatible tokens up to the given limit * @see getCompatibleTokens */ - unsigned int countCompatibleTokens(const TokenId& inactiveToken, + unsigned long countCompatibleTokens(const TokenId inactiveToken, #ifdef _MSC_VER - unsigned int limit = UINT_MAX, //std::numeric_limits::max(), + unsigned int limit = UINT_MAX, //std::numeric_limits::max(), #else - unsigned int limit = std::numeric_limits::max(), + unsigned int limit = std::numeric_limits::max(), #endif //_MSC_VER - bool useExactTest = false); + bool useExactTest = false); /** * @brief Returns the last count obtained for the prior call to query the set of compatible tokens. This can be useful * as a 'probable' indicator of the count of compatible tokens in the next call. * @see countCompatibleTokens, getCompatibleTokens */ - unsigned int lastCompatibleTokenCount(const TokenId& inactiveToken) const; + unsigned int lastCompatibleTokenCount(const TokenId inactiveToken) const; /** * @brief Retrieves the map relating token keys and the set of objects that induce an ordering requirement on the token. @@ -200,7 +199,7 @@ namespace EUROPA { * @param limit An upper bound on the number of choices to return. * @see getTokensToOrder */ - void getOrderingChoices(const TokenId& tokenToOrder, + void getOrderingChoices(const TokenId tokenToOrder, std::vector< OrderingChoice >& results, #ifdef _MSC_VER unsigned int limit = UINT_MAX //std::numeric_limits::max(), @@ -212,11 +211,11 @@ namespace EUROPA { * @brief Returns a count or all ordering choices for a token up to the given limit * @see Object::getOrderingChoices */ - unsigned int countOrderingChoices(const TokenId& token, + unsigned long countOrderingChoices(const TokenId token, #ifdef _MSC_VER - unsigned int limit = UINT_MAX //std::numeric_limits::max(), + unsigned long limit = UINT_MAX //std::numeric_limits::max(), #else - unsigned int limit = std::numeric_limits::max() + unsigned long limit = std::numeric_limits::max() #endif //_MSC_VER ); /** @@ -224,12 +223,12 @@ namespace EUROPA { * @param token The token for which we want ordering choices. Cannot be rejected. * @return The last count value */ - unsigned int lastOrderingChoiceCount(const TokenId& token) const; + unsigned long lastOrderingChoiceCount(const TokenId token) const; /** * @brief True if there is at least one ordering choice */ - bool hasOrderingChoice(const TokenId& token); + bool hasOrderingChoice(const TokenId token); /** * @brief Retrieves a collection of object instances of the given type. Database must be closed. @@ -237,18 +236,18 @@ namespace EUROPA { * @param results A (initially empty) collection to be populated with all instances of that type. */ template - void getObjectsByType(const LabelStr& type, std::list& results); + void getObjectsByType(const std::string& type, std::list& results); /** * @brief Are there any object instances of the specified type? */ - bool hasObjectInstances(const LabelStr& objectType) const; + bool hasObjectInstances(const std::string& objectType) const; /** * @brief Lookup an object by name. It is an error if the object is not present. * @return The requested object */ - const ObjectId& getObject(const LabelStr& name) const; + const ObjectId getObject(const std::string& name) const; /** * @brief Specifies that no more objects are to be added to the database. @@ -261,7 +260,7 @@ namespace EUROPA { * Note that this will cause an error if Tokens have already been created for this type. This is * because we have the rule - once dynamic, always dynamic. */ - void close(const LabelStr& objectType); + void close(const std::string& objectType); /** * @brief True if and only if close() has been called. @@ -271,7 +270,7 @@ namespace EUROPA { /** * @brief True if close() has been called, or close(objectType) has been called */ - bool isClosed(const LabelStr& objectType) const; + bool isClosed(const std::string& objectType) const; /** * @brief True if close() has not been called. This is because the schema cannot be assumed to be fixed, and we therefore @@ -296,8 +295,8 @@ namespace EUROPA { * @param objectVar The variable to be populated and possibly synchronized. Must be open. * @param leaveOpen If true, the object var will remain open on completion. */ - void makeObjectVariableFromType(const LabelStr& objectType, - const ConstrainedVariableId& objectVar, + void makeObjectVariableFromType(const std::string& objectType, + const ConstrainedVariableId objectVar, bool leaveOpen = false); /** @@ -307,7 +306,7 @@ namespace EUROPA { * @note We can extend this to pass in a functor or some other object to allow it to handle archival details. * @see Object::archive */ - unsigned int archive(eint tick = PLUS_INFINITY); + unsigned long archive(eint tick = PLUS_INFINITY); // PSPlanDatabase methods @@ -321,18 +320,18 @@ namespace EUROPA { virtual PSList getAllGlobalVariables() const; - ObjectId createObject(const LabelStr& objectType, - const LabelStr& objectName, + ObjectId createObject(const std::string& objectType, + const std::string& objectName, const std::vector& arguments); - TokenId createToken(const char* tokenType, - const char* tokenName, + TokenId createToken(const std::string& tokenType, + const std::string& tokenName, bool rejectable=false, bool isFact=false); - TokenId createSlaveToken(const TokenId& master, - const LabelStr& tokenType, - const LabelStr& relation); + TokenId createSlaveToken(const TokenId master, + const std::string& tokenType, + const std::string& relation); bool hasTokenTypes() const; @@ -346,63 +345,63 @@ namespace EUROPA { friend class PlanDatabaseListener; friend class ObjectVariableListener; - void notifyAdded(const ObjectId& object); + void notifyAdded(const ObjectId object); - void notifyRemoved(const ObjectId& object); + void notifyRemoved(const ObjectId object); - void notifyAdded(const TokenId& token); + void notifyAdded(const TokenId token); - void notifyRemoved(const TokenId& token); + void notifyRemoved(const TokenId token); - void notifyAdded(const ObjectId& object, const TokenId& token); + void notifyAdded(const ObjectId object, const TokenId token); - void notifyRemoved(const ObjectId& object, const TokenId& token); + void notifyRemoved(const ObjectId object, const TokenId token); - void notifyActivated(const TokenId& token); + void notifyActivated(const TokenId token); - void notifyDeactivated(const TokenId& token); + void notifyDeactivated(const TokenId token); - void notifyMerged(const TokenId& token); + void notifyMerged(const TokenId token); - void notifySplit(const TokenId& token); + void notifySplit(const TokenId token); - void notifyRejected(const TokenId& token); + void notifyRejected(const TokenId token); - void notifyReinstated(const TokenId& token); + void notifyReinstated(const TokenId token); - void notifyCommitted(const TokenId& token); + void notifyCommitted(const TokenId token); - void notifyTerminated(const TokenId& token); + void notifyTerminated(const TokenId token); - void notifyConstrained(const ObjectId& object, const TokenId& predecessor, const TokenId& successor); + void notifyConstrained(const ObjectId object, const TokenId predecessor, const TokenId successor); - void notifyFreed(const ObjectId& object, const TokenId& predecessor, const TokenId& successor); + void notifyFreed(const ObjectId object, const TokenId predecessor, const TokenId successor); - void notifyAdded(const PlanDatabaseListenerId& listener); + void notifyAdded(const PlanDatabaseListenerId listener); - void notifyRemoved(const PlanDatabaseListenerId& listener); + void notifyRemoved(const PlanDatabaseListenerId listener); /** * @brief If an object induces an ordering constraint on a token, it notfifies the plan database. * @param object The object on which the token should be ordered. * @param token The token to order */ - void notifyOrderingRequired(const ObjectId& object, const TokenId& token); + void notifyOrderingRequired(const ObjectId object, const TokenId token); /** * @brief If an object's state has changed such that a previously required ordering is no longer required then it should * notify the plan database. */ - void notifyOrderingNoLongerRequired(const ObjectId& object, const TokenId& token); + void notifyOrderingNoLongerRequired(const ObjectId object, const TokenId token); - void makeObjectVariable(const LabelStr& objectType, const std::list& objects, - const ConstrainedVariableId& objectVar, + void makeObjectVariable(const std::string& objectType, const std::list& objects, + const ConstrainedVariableId objectVar, bool leaveOpen = false); - void handleObjectVariableDeletion(const ConstrainedVariableId& objectVar); + void handleObjectVariableDeletion(const ConstrainedVariableId objectVar); - void handleObjectVariableCreation(const LabelStr& objectType, - const ConstrainedVariableId& objectVar, + void handleObjectVariableCreation(const std::string& objectType, + const ConstrainedVariableId objectVar, bool leaveOpen = false); /* Useful internal accessors and indexes for accessing objects and tokens in the PlanDatabase. */ @@ -413,17 +412,17 @@ namespace EUROPA { * @param results A collection, initially empty, which is an output parameter for results. * @see Schema::isPredicateDefined, Schema::canBeAssigned */ - void getObjectsByPredicate(const LabelStr& predicate, std::list& results); + void getObjectsByPredicate(const std::string& predicate, std::list& results); /** * @brief Utility to index an active token. */ - void insertActiveToken(const TokenId& token); + void insertActiveToken(const TokenId token); /** * @brief Utility to remove an active token */ - void removeActiveToken(const TokenId& token); + void removeActiveToken(const TokenId token); PlanDatabaseId m_id; const ConstraintEngineId m_constraintEngine; @@ -440,40 +439,44 @@ namespace EUROPA { std::vector m_listeners; /* In the data structures below, the key is a LabelStr representation of a name */ - std::map m_objectsByName; /*!< Object names are unique. Holds all objects m_objectsByName.size() == m_objects.size(). */ - std::multimap m_objectsByPredicate; /*!< May be updated every time we add a Token, or remove an object. */ - std::multimap m_objectsByType; /*!< May be updated every time we add a Token, or remove an object. */ - std::set m_closedObjectTypes; /*!< The set of explicitly closed object types. + std::map m_objectsByName; /*!< Object names are unique. Holds all objects m_objectsByName.size() == m_objects.size(). */ + std::multimap m_objectsByPredicate; /*!< May be updated every time we add a Token, or remove an object. */ + std::multimap m_objectsByType; /*!< May be updated every time we add a Token, or remove an object. */ + std::set m_closedObjectTypes; /*!< The set of explicitly closed object types. If present here, it cannot be present in m_objectVariablesByType */ - std::map m_globalVarsByName; - std::map m_globalTokensByName; + std::map m_globalVarsByName; + std::map m_globalTokensByName; std::map > m_tokensToOrder; /*!< All tokens to order, with the object inducing the requirement stored in the set */ - std::map m_activeTokensByPredicate; /*!< All active tokens sorted by predicate */ + std::map m_activeTokensByPredicate; /*!< All active tokens sorted by predicate */ // All this to store variables (and their listeners) for Open Object Types - typedef std::multimap > ObjVarsByObjType; + typedef std::multimap > ObjVarsByObjType; typedef ObjVarsByObjType::iterator ObjVarsByObjType_I; typedef ObjVarsByObjType::const_iterator ObjVarsByObjType_CI; ObjVarsByObjType m_objectVariablesByObjectType; +private: + PlanDatabase(const PlanDatabase&); + PlanDatabase& operator=(const PlanDatabase&); }; - template - void PlanDatabase::getObjectsByType(const LabelStr& type, std::list& results) { - check_error(results.empty()); - checkError(m_schema->isObjectType(type), "Is not an object type in the plan database: " + type.toString()); - - for (std::multimap::const_iterator it = m_objectsByType.find(type.getKey()); - it != m_objectsByType.end() && it->first == type.getKey(); - ++it) { - debugMsg("PlanDatabase:getObjectsByType", "Adding object '" << it->second->getName().toString() << "' of type '" << - it->second->getType().toString() << "' for type '" << type.toString() << "'"); - debugMsg("PlanDatabase:getObjectsByType", "Typeid for object: " << typeid((*(it->second))).name()); - results.push_back(ID(it->second)); - } +template +void PlanDatabase::getObjectsByType(const std::string& type, std::list& results) { + check_error(results.empty()); + checkError(m_schema->isObjectType(type), + "Is not an object type in the plan database: " + type); + + for (std::multimap::const_iterator it = m_objectsByType.find(type); + it != m_objectsByType.end() && it->first == type; ++it) { + debugMsg("PlanDatabase:getObjectsByType", + "Adding object '" << it->second->getName() << "' of type '" << + it->second->getType() << "' for type '" << type << "'"); + debugMsg("PlanDatabase:getObjectsByType", "Typeid for object: " << typeid((*(it->second))).name()); + results.push_back(ID(it->second)); } } +} #endif diff --git a/src/PLASMA/PlanDatabase/base/PlanDatabaseListener.cc b/src/PLASMA/PlanDatabase/base/PlanDatabaseListener.cc index 947d44a27..346751bde 100644 --- a/src/PLASMA/PlanDatabase/base/PlanDatabaseListener.cc +++ b/src/PLASMA/PlanDatabase/base/PlanDatabaseListener.cc @@ -3,14 +3,14 @@ namespace EUROPA { - PlanDatabaseListener::PlanDatabaseListener(const PlanDatabaseId& planDatabase) - :m_id(this) { - setPlanDatabase(planDatabase); - } +PlanDatabaseListener::PlanDatabaseListener(const PlanDatabaseId planDatabase) + :m_id(this), m_planDatabase() { + setPlanDatabase(planDatabase); +} - PlanDatabaseListener::PlanDatabaseListener() - :m_id(this) { - } +PlanDatabaseListener::PlanDatabaseListener() + :m_id(this), m_planDatabase() { +} PlanDatabaseListener::~PlanDatabaseListener(){ check_error(m_id.isValid()); @@ -22,44 +22,44 @@ namespace EUROPA { m_id.remove(); } - void PlanDatabaseListener::setPlanDatabase(const PlanDatabaseId& planDatabase) { + void PlanDatabaseListener::setPlanDatabase(const PlanDatabaseId planDatabase) { m_planDatabase = planDatabase; check_error(m_planDatabase.isValid()); m_planDatabase->notifyAdded(m_id); } - void PlanDatabaseListener::notifyAdded(const ObjectId& object){} + void PlanDatabaseListener::notifyAdded(const ObjectId){} - void PlanDatabaseListener::notifyRemoved(const ObjectId& object){} + void PlanDatabaseListener::notifyRemoved(const ObjectId){} - void PlanDatabaseListener::notifyAdded(const TokenId& token){} + void PlanDatabaseListener::notifyAdded(const TokenId){} - void PlanDatabaseListener::notifyRemoved(const TokenId& token){} + void PlanDatabaseListener::notifyRemoved(const TokenId){} - void PlanDatabaseListener::notifyActivated(const TokenId& token){} + void PlanDatabaseListener::notifyActivated(const TokenId){} - void PlanDatabaseListener::notifyDeactivated(const TokenId& token){} + void PlanDatabaseListener::notifyDeactivated(const TokenId){} - void PlanDatabaseListener::notifyMerged(const TokenId& token){} + void PlanDatabaseListener::notifyMerged(const TokenId){} - void PlanDatabaseListener::notifySplit(const TokenId& token){} + void PlanDatabaseListener::notifySplit(const TokenId){} - void PlanDatabaseListener::notifyRejected(const TokenId& token){} + void PlanDatabaseListener::notifyRejected(const TokenId){} - void PlanDatabaseListener::notifyReinstated(const TokenId& token){} + void PlanDatabaseListener::notifyReinstated(const TokenId){} - void PlanDatabaseListener::notifyConstrained(const ObjectId& object, const TokenId& predecessor, const TokenId& successor){} + void PlanDatabaseListener::notifyConstrained(const ObjectId, const TokenId, const TokenId ){} - void PlanDatabaseListener::notifyFreed(const ObjectId& object, const TokenId& predecessor, const TokenId& successor){} + void PlanDatabaseListener::notifyFreed(const ObjectId, const TokenId, const TokenId){} - void PlanDatabaseListener::notifyAdded(const ObjectId& object, const TokenId& token){} + void PlanDatabaseListener::notifyAdded(const ObjectId, const TokenId){} - void PlanDatabaseListener::notifyRemoved(const ObjectId& object, const TokenId& token){} + void PlanDatabaseListener::notifyRemoved(const ObjectId, const TokenId){} - void PlanDatabaseListener::notifyCommitted(const TokenId& token){} + void PlanDatabaseListener::notifyCommitted(const TokenId){} - void PlanDatabaseListener::notifyTerminated(const TokenId& token){} + void PlanDatabaseListener::notifyTerminated(const TokenId){} - const PlanDatabaseListenerId& PlanDatabaseListener::getId() const{return m_id;} + const PlanDatabaseListenerId PlanDatabaseListener::getId() const{return m_id;} } diff --git a/src/PLASMA/PlanDatabase/base/PlanDatabaseListener.hh b/src/PLASMA/PlanDatabase/base/PlanDatabaseListener.hh index 3db45bae8..d43e05759 100644 --- a/src/PLASMA/PlanDatabase/base/PlanDatabaseListener.hh +++ b/src/PLASMA/PlanDatabase/base/PlanDatabaseListener.hh @@ -1,5 +1,5 @@ -#ifndef _H_PlanDatabaseListener -#define _H_PlanDatabaseListener +#ifndef H_PlanDatabaseListener +#define H_PlanDatabaseListener #include "PlanDatabaseDefs.hh" @@ -12,33 +12,33 @@ namespace EUROPA { /** * @brief Indicates a new Object has been added to the PlanDatabase. */ - virtual void notifyAdded(const ObjectId& object); + virtual void notifyAdded(const ObjectId object); /** * @brief Indicates an object has been removed from the PlanDatabase */ - virtual void notifyRemoved(const ObjectId& object); + virtual void notifyRemoved(const ObjectId object); /** * @brief Indicates that a new Token has been added to the PlanDatabase */ - virtual void notifyAdded(const TokenId& token); + virtual void notifyAdded(const TokenId token); /** * @brief Indicates that a token has been removed from the PlanDatabase. */ - virtual void notifyRemoved(const TokenId& token); + virtual void notifyRemoved(const TokenId token); /** * @brief Indicates a Token has been activated. * @see Token::activate */ - virtual void notifyActivated(const TokenId& token); - virtual void notifyDeactivated(const TokenId& token); - virtual void notifyMerged(const TokenId& token); - virtual void notifySplit(const TokenId& token); - virtual void notifyRejected(const TokenId& token); - virtual void notifyReinstated(const TokenId& token); + virtual void notifyActivated(const TokenId token); + virtual void notifyDeactivated(const TokenId token); + virtual void notifyMerged(const TokenId token); + virtual void notifySplit(const TokenId token); + virtual void notifyRejected(const TokenId token); + virtual void notifyReinstated(const TokenId token); /** * @brief Signals the event where a token has been temporally constrained to precede a given successor @@ -48,7 +48,7 @@ namespace EUROPA { * @param successor A token to precede. * @see Object::constrain, Object::free */ - virtual void notifyConstrained(const ObjectId& object, const TokenId& predecessor, const TokenId& successor); + virtual void notifyConstrained(const ObjectId object, const TokenId predecessor, const TokenId successor); /** * @brief Removes any constraints added through calls to Object::constrain(token, *). @@ -56,7 +56,7 @@ namespace EUROPA { * @param predecessor The token that had been succeded. * @param successor The token that had been preceded. */ - virtual void notifyFreed(const ObjectId& object, const TokenId& predecessor, const TokenId& successor); + virtual void notifyFreed(const ObjectId object, const TokenId predecessor, const TokenId successor); /** * @brief Signals the event where a Token has become a candidate for impacting an object. @@ -68,10 +68,10 @@ namespace EUROPA { * @li Propagation, or external restrictions on the object variable of the Token may cause assignment to be reversed. * @param object The object that may be impacted. * @param token The Token that may have an impact. The token must be active. The token's object variable must contain the object. - * @see notifyRemoved(const ObjectId& object, const TokenId& token) + * @see notifyRemoved(const ObjectId object, const TokenId token) * @see Object::getTokensToOrder() */ - virtual void notifyAdded(const ObjectId& object, const TokenId& token); + virtual void notifyAdded(const ObjectId object, const TokenId token); /** * @brief Signals the event where a Token which was previously a candidate for assignment to an object no longer can @@ -79,32 +79,32 @@ namespace EUROPA { * * @param object The object that can no longer be assigned the Token. * @param token The token that can no longer be assigned to the object. The Token must have been assignable previously. - * @see notifyAdded(const ObjectId& object, const TokenId& token) + * @see notifyAdded(const ObjectId object, const TokenId token) * @see Object::getTokensToOrder() */ - virtual void notifyRemoved(const ObjectId& object, const TokenId& token); + virtual void notifyRemoved(const ObjectId object, const TokenId token); /** * @brief Signals that a token has been committed. * @param token The token that has been committed. */ - virtual void notifyCommitted(const TokenId& token); + virtual void notifyCommitted(const TokenId token); /** * @brief Signals that a token has been terminated * @param token The token that has been terminated */ - virtual void notifyTerminated(const TokenId& token); + virtual void notifyTerminated(const TokenId token); - const PlanDatabaseListenerId& getId() const; + const PlanDatabaseListenerId getId() const; // for PSPlanDatabaseListener, where we don't have access to plan database // at construction time - virtual void setPlanDatabase(const PlanDatabaseId& planDatabase); + virtual void setPlanDatabase(const PlanDatabaseId planDatabase); protected: - PlanDatabaseListener(const PlanDatabaseId& planDatabase); + PlanDatabaseListener(const PlanDatabaseId planDatabase); PlanDatabaseListenerId m_id; PlanDatabaseId m_planDatabase; diff --git a/src/PLASMA/PlanDatabase/base/PlanDatabaseWriter.cc b/src/PLASMA/PlanDatabase/base/PlanDatabaseWriter.cc index 24f550473..a54b2de42 100644 --- a/src/PLASMA/PlanDatabase/base/PlanDatabaseWriter.cc +++ b/src/PLASMA/PlanDatabase/base/PlanDatabaseWriter.cc @@ -13,7 +13,7 @@ namespace EUROPA { // bool PlanDatabaseWriter::s_useStandardKeys = true; - std::string PlanDatabaseWriter::toString(const PlanDatabaseId& db, bool _useStandardKeys){ + std::string PlanDatabaseWriter::toString(const PlanDatabaseId db, bool _useStandardKeys){ useStandardKeys() = _useStandardKeys; checkError(useStandardKeys() == _useStandardKeys, "Failed to set standardKeys to method's input values"); std::stringstream sstr; @@ -29,8 +29,8 @@ namespace EUROPA { indent()++; for (ObjectSet::const_iterator oit = objs.begin(); oit != objs.end() ; ++oit) { ObjectId object = *oit; - os << indentation() << object->getType().toString() << ":" - << object->getName().toString() << "*************************" << std::endl; + os << indentation() << object->getType() << ":" + << object->getName() << "*************************" << std::endl; std::list toks; @@ -73,7 +73,7 @@ namespace EUROPA { indent()--; } - os << indentation() << "End " << object->getType().toString() << ":" << object->getName().toString() + os << indentation() << "End " << object->getType() << ":" << object->getName() << "*************************" << std::endl; } indent()--; @@ -172,18 +172,18 @@ namespace EUROPA { return ss.str(); } - std::string PlanDatabaseWriter::simpleTokenSummary(const TokenId& token) { + std::string PlanDatabaseWriter::simpleTokenSummary(const TokenId token) { std::stringstream ss; ss << token->toString() << timeDomain(token->start()->lastDomain()) << " --> " << timeDomain(token->end()->lastDomain()); return ss.str(); } - void PlanDatabaseWriter::writeToken(const TokenId& t, std::ostream& os) { + void PlanDatabaseWriter::writeToken(const TokenId t, std::ostream& os) { indent()++; check_error(t.isValid()); TempVarId st = t->start(); os << indentation() << "\t" << timeDomain(st->lastDomain()) << std::endl; - os << indentation() << "\t" << t->getPredicateName().toString() << "(" ; + os << indentation() << "\t" << t->getPredicateName() << "(" ; std::vector vars = t->parameters(); for (std::vector::const_iterator varit = vars.begin(); varit != vars.end(); ++varit) { ConstrainedVariableId v = (*varit); @@ -195,7 +195,7 @@ namespace EUROPA { else os.unsetf(std::ios::fixed); - os << v->getName().toString() << "=" << dom; + os << v->getName() << "=" << dom; os.unsetf(std::ios::fixed); } os << ")" <getName().toString() << "=" << var->lastDomain() << std::endl; + os << indentation() << var->getName() << "=" << var->lastDomain() << std::endl; indent()--; } - std::string PlanDatabaseWriter::getKey(const TokenId& token){ + std::string PlanDatabaseWriter::getKey(const TokenId token){ if(useStandardKeys()) return EUROPA::toString(token->getKey()); else diff --git a/src/PLASMA/PlanDatabase/base/PlanDatabaseWriter.hh b/src/PLASMA/PlanDatabase/base/PlanDatabaseWriter.hh index dbc531985..f232ad26d 100644 --- a/src/PLASMA/PlanDatabase/base/PlanDatabaseWriter.hh +++ b/src/PLASMA/PlanDatabase/base/PlanDatabaseWriter.hh @@ -1,5 +1,5 @@ -#ifndef _H_PlanDatabaseWriter -#define _H_PlanDatabaseWriter +#ifndef H_PlanDatabaseWriter +#define H_PlanDatabaseWriter #include "PlanDatabaseDefs.hh" #include @@ -10,14 +10,14 @@ namespace EUROPA { public: - static std::string toString(const PlanDatabaseId& db, bool _useStandardKeys = true); + static std::string toString(const PlanDatabaseId db, bool _useStandardKeys = true); static void write(PlanDatabaseId db, std::ostream& os); // [lb, ub] or {singleton} static std::string timeDomain(const Domain& dom); - static std::string simpleTokenSummary(const TokenId& token); + static std::string simpleTokenSummary(const TokenId token); private: @@ -25,11 +25,11 @@ namespace EUROPA { const std::string& name, const TokenSet& tokens); - static void writeToken(const TokenId& t, std::ostream& os); + static void writeToken(const TokenId t, std::ostream& os); - static void writeVariable(const ConstrainedVariableId& var, std::ostream& os); + static void writeVariable(const ConstrainedVariableId var, std::ostream& os); - static std::string getKey(const TokenId& token); + static std::string getKey(const TokenId token); static std::string indentation(); @@ -41,4 +41,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_PlanDatabaseWriter */ +#endif /* #ifndef H_PlanDatabaseWriter */ diff --git a/src/PLASMA/PlanDatabase/base/Schema.cc b/src/PLASMA/PlanDatabase/base/Schema.cc index 6ca6266c3..3516aee43 100644 --- a/src/PLASMA/PlanDatabase/base/Schema.cc +++ b/src/PLASMA/PlanDatabase/base/Schema.cc @@ -4,8 +4,9 @@ #include "Utils.hh" #include "Object.hh" #include "DataTypes.hh" +#include "CESchema.hh" - +#include #ifdef _MANAGED using namespace System; @@ -20,65 +21,62 @@ namespace EUROPA { - const char* Schema::getDelimiter(){ - static const char* sl_delimiter = "."; - return sl_delimiter; - } - - const LabelStr& Schema::rootObject(){ - static const LabelStr sl_rootObject("Object"); - return sl_rootObject; - } - - const std::set& Schema::getBuiltInVariableNames(){ - static std::set sl_instance; - static bool sl_initialized(false); - - if(!sl_initialized){ - sl_instance.insert(LabelStr("start")); - sl_instance.insert(LabelStr("end")); - sl_instance.insert(LabelStr("duration")); - sl_instance.insert(LabelStr("object")); - sl_instance.insert(LabelStr("state")); - sl_initialized = true; - } - - return sl_instance; - } - - const LabelStr Schema::makeQualifiedName(const LabelStr& objectType, - const LabelStr& unqualifiedPredicateName){ - std::string fullName = objectType.toString() + getDelimiter() + unqualifiedPredicateName.toString(); - return LabelStr(fullName.c_str()); - } - - Schema::Schema(const LabelStr& name, const CESchemaId& ces) - : m_id(this) - , m_name(name) - , m_ceSchema(ces) - , m_objectTypeMgr((new ObjectTypeMgr())->getId()) - , m_tokenTypeMgr((new TokenTypeMgr())->getId()) +const char Schema::getDelimiter(){ + static const char sl_delimiter = '.'; + return sl_delimiter; +} + +const std::string& Schema::rootObject() { + static const std::string sl_rootObject("Object"); + return sl_rootObject; +} + +const std::set& Schema::getBuiltInVariableNames(){ + static std::set sl_instance; + static bool sl_initialized(false); + + if(!sl_initialized){ + sl_instance.insert("start"); + sl_instance.insert("end"); + sl_instance.insert("duration"); + sl_instance.insert("object"); + sl_instance.insert("state"); + sl_initialized = true; + } + + return sl_instance; +} + +const std::string Schema::makeQualifiedName(const std::string& objectType, + const std::string& unqualifiedPredicateName){ + return objectType + getDelimiter() + unqualifiedPredicateName; +} + +Schema::Schema(const std::string& name, const CESchemaId ces) + : m_id(this), m_name(name), m_ceSchema(ces) + , m_objectTypeMgr((new ObjectTypeMgr())->getId()) + , m_tokenTypeMgr((new TokenTypeMgr())->getId()) + , m_methods(), enumValues(), enumValuesToEnums(), objectTypes() + , predicates(), primitives(), membershipRelation(), childOfRelation() + , objectPredicates(), typesWithNoPredicates(), allObjectTypes() + , m_predTrueCache(), m_predFalseCache(), m_hasParentCache() { reset(); - debugMsg("Schema:constructor", "created Schema:" << name.toString()); + debugMsg("Schema:constructor", "created Schema:" << name); } Schema::~Schema() { - delete (TokenTypeMgr*)m_tokenTypeMgr; - delete (ObjectTypeMgr*)m_objectTypeMgr; - - std::map::iterator mit = m_methods.begin(); - for(;mit != m_methods.end();++mit) - delete (Method*)mit->second; - m_methods.clear(); + delete static_cast(m_tokenTypeMgr); + delete static_cast(m_objectTypeMgr); - m_id.remove(); + cleanup(m_methods); + m_id.remove(); } - const SchemaId& Schema::getId() const {return m_id;} + const SchemaId Schema::getId() const {return m_id;} - const LabelStr& Schema::getName() const {return m_name;} + const std::string& Schema::getName() const {return m_name;} bool Schema::canCompare(const Domain& domx, const Domain& domy) const { @@ -87,7 +85,7 @@ namespace EUROPA { if(isObjectType(domx.getTypeName()) || isObjectType(domy.getTypeName())) return(isObjectType(domx.getTypeName()) && isObjectType(domy.getTypeName())); - return DomainComparator::canCompare(domx, domy); + return domx.getDataType()->canBeCompared(domy.getDataType()); } void Schema::reset(){ @@ -107,53 +105,57 @@ namespace EUROPA { addPrimitive("string"); } - bool Schema::isType(const LabelStr& type) const{ + bool Schema::isType(const std::string& type) const{ return(isPrimitive(type) || isObjectType(type) || isEnum(type) || isPredicate(type)); } - bool Schema::isPrimitive(const LabelStr& str) const { + bool Schema::isPrimitive(const std::string& str) const { return (primitives.find(str) != primitives.end()); } - bool Schema::isPredicate(const LabelStr& predicateName) const { +bool Schema::isPredicate(const std::string& predicateName) const { - if(m_predTrueCache.find(predicateName) != m_predTrueCache.end()) - return true; + if(m_predTrueCache.find(predicateName) != m_predTrueCache.end()) + return true; - if(m_predFalseCache.find(predicateName) != m_predFalseCache.end()) - return false; + if(m_predFalseCache.find(predicateName) != m_predFalseCache.end()) + return false; - bool result = false; + bool result = false; - if(predicates.find(predicateName) != predicates.end()) // If a direct hit, then true - result = true; - else if(predicateName.countElements(getDelimiter()) != 2) // If not the correct format, return false - result = false; - else { - // Call recursively if we have a parent - std::string predStr; - if(makeParentPredicateString(predicateName, predStr)) - result = isPredicate(predStr); - } + if(predicates.find(predicateName) != predicates.end()) // If a direct hit, then true + result = true; + else if(std::count(predicateName.begin(), predicateName.end(), getDelimiter()) != 1) // If not the correct format, return false + result = false; + else { + // Call recursively if we have a parent + std::string predStr; + if(makeParentPredicateString(predicateName, predStr)) + result = isPredicate(predStr); + } - if(result) - m_predTrueCache.insert(predicateName); - else - m_predFalseCache.insert(predicateName); + if(result) + m_predTrueCache.insert(predicateName); + else + m_predFalseCache.insert(predicateName); - return result; - } + return result; +} - bool Schema::isObjectType(const LabelStr& str) const { + bool Schema::isObjectType(const std::string& str) const { return objectTypes.find(str) != objectTypes.end(); } - bool Schema::isEnum(const LabelStr& str) const { + bool Schema::isEnum(const std::string& str) const { return (enumValues.find(str) != enumValues.end()); } - bool Schema::isEnumValue(const LabelStr& enumName, edouble value) const { - check_error(isEnum(enumName), enumName.toString() + " is not defined."); + bool Schema::isEnumValue(const std::string& enumName, edouble value) const { + check_error(isEnum(enumName), enumName + " is not defined."); + debugMsg("Schema:isEnumValue", + "Checking to see if " << value << + " is in enumeration " << enumName); + const std::set& members = enumValues.find(enumName)->second; return(members.find(value) != members.end()); } @@ -162,10 +164,10 @@ namespace EUROPA { return(enumValuesToEnums.find(value) != enumValuesToEnums.end()); } - bool Schema::canBeAssigned(const LabelStr& objectType, - const LabelStr& predicate) const { - check_error(isObjectType(objectType), objectType.toString() + " is not defined as an ObjectType"); - check_error(isPredicate(predicate), predicate.toString() + " is not defined as a Predicate"); + bool Schema::canBeAssigned(const std::string& objectType, + const std::string& predicate) const { + check_error(isObjectType(objectType), objectType + " is not defined as an ObjectType"); + check_error(isPredicate(predicate), predicate + " is not defined as a Predicate"); return isA(objectType, getObjectTypeForPredicate(predicate)); } @@ -174,9 +176,9 @@ namespace EUROPA { * comparable * @see canCompare */ - bool Schema::isA(const LabelStr& descendant, - const LabelStr& ancestor) const { - debugMsg("Schema:isA", "Checking if " << descendant.toString() << " is a " << ancestor.toString()); + bool Schema::isA(const std::string& descendant, + const std::string& ancestor) const { + debugMsg("Schema:isA", "Checking if " << descendant << " is a " << ancestor); // Special case if the 2 are the same, in which case we suspend any requirement that // they be predefined types - class, predicate, enum, primitive. @@ -184,9 +186,9 @@ namespace EUROPA { return true; checkError(isType(descendant), - descendant.toString() << " is not defined."); + descendant << " is not defined."); checkError(isType(ancestor), - "Ancestor of '" << descendant.toString() << "' is '" << ancestor.toString() << "' which is not defined."); + "Ancestor of '" << descendant << "' is '" << ancestor << "' which is not defined."); if(hasParent(descendant)) return isA(getParent(descendant), ancestor); @@ -198,122 +200,117 @@ namespace EUROPA { return false; } - bool Schema::canContain(const LabelStr& parentType, - const LabelStr& memberType, - const LabelStr& memberName) const { - check_error(isType(parentType), parentType.toString() + " is not defined."); +bool Schema::canContain(const std::string& parentType, + const std::string& memberType, + const std::string& memberName) const { + check_error(isType(parentType), parentType + " is not defined."); - // First see if we get a hit for the parentType - std::map::const_iterator membershipRelation_it = + // First see if we get a hit for the parentType + std::map::const_iterator membershipRelation_it = membershipRelation.find(parentType); - // If no hit, then try for the parent. There must be one since it is a valid - // type but no hit yet - if(membershipRelation_it == membershipRelation.end()) - return canContain(getParent(parentType), memberType, memberName); + // If no hit, then try for the parent. There must be one since it is a valid + // type but no hit yet + if(membershipRelation_it == membershipRelation.end()) + return canContain(getParent(parentType), memberType, memberName); - // Otherwise, we have a parentType with members defined, so search there - const NameValueVector& members = membershipRelation_it->second; - for(NameValueVector::const_iterator it = members.begin(); it != members.end();++it){ - const NameValuePair& pair = *it; - if(pair.second == memberName && isA(memberType, pair.first)) - return true; - } - - // Call recursively for inheritance relationships on parent and member types - if(hasParent(parentType) && canContain(getParent(parentType), memberType, memberName)) + // Otherwise, we have a parentType with members defined, so search there + const NameValueVector& members = membershipRelation_it->second; + for(NameValueVector::const_iterator it = members.begin(); it != members.end();++it){ + const NameValuePair& pair = *it; + if(pair.second == memberName && isA(memberType, pair.first)) return true; + } - // Allow for the possibility that it is declared as base type of the member type - if(isObjectType(memberType) && - hasParent(memberType) && - canContain(parentType,getParent(memberType), memberName)) - return true; + // Call recursively for inheritance relationships on parent and member types + if(hasParent(parentType) && canContain(getParent(parentType), memberType, memberName)) + return true; - return false; - } + // Allow for the possibility that it is declared as base type of the member type + if(isObjectType(memberType) && + hasParent(memberType) && + canContain(parentType,getParent(memberType), memberName)) + return true; + + return false; +} - const Schema::NameValueVector& Schema::getMembers(const LabelStr& objectType) const +const Schema::NameValueVector& Schema::getMembers(const std::string& objectType) const { - std::map::const_iterator it = membershipRelation.find(objectType); + std::map::const_iterator it = membershipRelation.find(objectType); - check_error(it != membershipRelation.end(), "Unable to find members for object type:" + objectType.toString() ); + check_error(it != membershipRelation.end(), + "Unable to find members for object type:" + objectType); return it->second; } // For now just return the member names, not their types: // TODO: Is it better to use an iterator in this loop? - PSList Schema::getMembers(const std::string& objectType) const - { - PSList retval; - const NameValueVector& members = getMembers(LabelStr(objectType)); - for(std::vector< std::pair >::const_iterator it = members.begin(); - it != members.end(); ++it) - { - retval.push_back((*it).second.toString()); - } - return retval; +PSList Schema::getObjectMembers(const std::string& objectType) const { + PSList retval; + const NameValueVector& members = getMembers(objectType); + for(std::vector< std::pair >::const_iterator it = members.begin(); + it != members.end(); ++it) { + retval.push_back((*it).second); } + return retval; +} - bool Schema::hasMember(const std::string& parentType, const std::string& memberName) const - { - return hasMember(LabelStr(parentType), LabelStr(memberName)); - } - bool Schema::hasMember(const LabelStr& parentType, const LabelStr& memberName) const{ - check_error(isType(parentType), parentType.toString() + " is undefined."); +bool Schema::hasMember(const std::string& parentType, const std::string& memberName) const { + check_error(isType(parentType), parentType + " is undefined."); - // First see if we get a hit for the parentType - std::map::const_iterator membershipRelation_it = + // First see if we get a hit for the parentType + std::map::const_iterator membershipRelation_it = membershipRelation.find(parentType); - // If no hit, then try for the parent. There must be one since it is a valid - // type but no hit yet - if(membershipRelation_it == membershipRelation.end()) - return hasMember(getParent(parentType), memberName); + // If no hit, then try for the parent. There must be one since it is a valid + // type but no hit yet + if(membershipRelation_it == membershipRelation.end()) + return hasMember(getParent(parentType), memberName); - const NameValueVector& members = membershipRelation_it->second; - for(NameValueVector::const_iterator it = members.begin(); it != members.end(); ++it){ - const LabelStr& name = it->second; - if(name == memberName) // Is the name equal to param - return true; - } + const NameValueVector& members = membershipRelation_it->second; + for(NameValueVector::const_iterator it = members.begin(); it != members.end(); ++it){ + const std::string& name = it->second; + if(name == memberName) // Is the name equal to param + return true; + } - // Recursive call if appropriate - if(hasParent(parentType)) - return hasMember(getParent(parentType), memberName); + // Recursive call if appropriate + if(hasParent(parentType)) + return hasMember(getParent(parentType), memberName); - // Otherwise, last act, see if it is built in - return isPredicate(parentType) && getBuiltInVariableNames().find(memberName) != getBuiltInVariableNames().end(); - } + // Otherwise, last act, see if it is built in + return isPredicate(parentType) && getBuiltInVariableNames().find(memberName) != getBuiltInVariableNames().end(); +} - const LabelStr Schema::getObjectTypeForPredicate(const LabelStr& predicate) const { + const std::string Schema::getObjectTypeForPredicate(const std::string& predicate) const { check_error(isPredicate(predicate), - "Predicate "+predicate.toString() + + "Predicate "+predicate + " is not defined, but we expect all predicates to be defined. See 'isPredicate'"); - return predicate.getElement(0, getDelimiter()); + return predicate.substr(0, predicate.find(getDelimiter())); } - const std::vector& Schema::getAllObjectTypes(const LabelStr& objectType) { - std::map >::iterator it = allObjectTypes.find(objectType); - if(it != allObjectTypes.end()) - return it->second; +const std::vector& Schema::getAllObjectTypes(const std::string& objectType) { + std::map >::iterator it = allObjectTypes.find(objectType); + if(it != allObjectTypes.end()) + return it->second; - std::vector results; - results.clear(); - results.push_back(objectType); - LabelStr lbl = objectType; - while(hasParent(lbl)){ - lbl = getParent(lbl); - results.push_back(lbl); - } + std::vector results; + results.clear(); + results.push_back(objectType); + std::string lbl = objectType; + while(hasParent(lbl)){ + lbl = getParent(lbl); + results.push_back(lbl); + } - allObjectTypes.insert(std::pair >(objectType, results)); + allObjectTypes.insert(std::make_pair(objectType, results)); - return getAllObjectTypes(objectType); - } + return getAllObjectTypes(objectType); +} - bool Schema::hasParent(const LabelStr& type) const { + bool Schema::hasParent(const std::string& type) const { if(m_hasParentCache.find(type) != m_hasParentCache.end()) return true; @@ -327,7 +324,7 @@ namespace EUROPA { else { std::string predStr; if(makeParentPredicateString(type, predStr)) - result = predicates.find(LabelStr(predStr)) != predicates.end() || hasParent(predStr); + result = predicates.find(predStr) != predicates.end() || hasParent(predStr); } // If we get a true result, store it in the cache @@ -337,8 +334,8 @@ namespace EUROPA { return result; } - const LabelStr Schema::getParent(const LabelStr& type) const { - check_error(hasParent(type), type.toString() + " does not have a parent."); + const std::string Schema::getParent(const std::string& type) const { + check_error(hasParent(type), type + " does not have a parent."); // If it is an objectType. return child relation if(isObjectType(type)) @@ -347,49 +344,49 @@ namespace EUROPA { // Otherwise it must be a predicate, so build the new fully qualified name std::string predStr; makeParentPredicateString(type, predStr); - check_error(predStr != std::string(), "Attempted to get a parent predicate for " + type.toString() + " failed."); + check_error(predStr != std::string(), "Attempted to get a parent predicate for " + type + " failed."); return predStr; } - const LabelStrSet& Schema::getAllObjectTypes() const { - return objectTypes; - } +const std::set& Schema::getAllObjectTypes() const { + return objectTypes; +} - const std::set& Schema::getEnumValues(const LabelStr& enumName) const { - check_error(isEnum(enumName), enumName.toString() + " is not a defined enumeration."); + const std::set& Schema::getEnumValues(const std::string& enumName) const { + check_error(isEnum(enumName), enumName + " is not a defined enumeration."); return enumValues.find(enumName)->second; } - void Schema::getPredicates(const LabelStr& objectType, std::set& results) const { - check_error(isType(objectType), objectType.toString() + " is undefined"); - for(LabelStrSet::const_iterator pred = predicates.begin(); pred != predicates.end(); ++pred) { - LabelStr predLbl(*pred); - LabelStr object((predLbl).getElement(0, getDelimiter())); - LabelStr predicate((predLbl).getElement(1, getDelimiter())); + void Schema::getPredicates(const std::string& objectType, std::set& results) const { + check_error(isType(objectType), objectType + " is undefined"); + for(std::set::const_iterator pred = predicates.begin(); pred != predicates.end(); ++pred) { + std::string predLbl(*pred); + std::string object(predLbl.substr(0, predLbl.find(getDelimiter()))); + std::string predicate(predLbl.substr(predLbl.find(getDelimiter()) + 1)); if ((object == objectType) || isA(objectType, object)) results.insert(predicate); } } - void Schema::getPredicates(std::set& results) const { - for(LabelStrSet::const_iterator it = predicates.begin(); it != predicates.end(); ++it) + void Schema::getPredicates(std::set& results) const { + for(std::set::const_iterator it = predicates.begin(); it != predicates.end(); ++it) results.insert(*it); } - bool Schema::hasPredicates(const LabelStr& objectType) { - check_error(isType(objectType), objectType.toString() + " is undefined"); + bool Schema::hasPredicates(const std::string& objectType) { + check_error(isType(objectType), objectType + " is undefined"); // Try for a quick hit if(typesWithNoPredicates.find(objectType) != typesWithNoPredicates.end()) return false; // Otherwise, it is not conclusive, so we try in detail - for(LabelStrSet::const_iterator pred = predicates.begin(); pred != predicates.end(); ++pred) { - LabelStr predLbl(*pred); - LabelStr object((predLbl).getElement(0, getDelimiter())); + for(std::set::const_iterator pred = predicates.begin(); pred != predicates.end(); ++pred) { + std::string predLbl(*pred); + std::string object(predLbl.substr(0, predLbl.find(getDelimiter()))); if ((object == objectType) || isA(objectType, object)) return true; } @@ -399,12 +396,12 @@ namespace EUROPA { return false; } - const LabelStr Schema::getMemberType(const LabelStr& parentType, const LabelStr& memberName) const { + const std::string Schema::getMemberType(const std::string& parentType, const std::string& memberName) const { check_error(hasMember(parentType, memberName), - memberName.toString() + " is not a member of " + parentType.toString()); + memberName + " is not a member of " + parentType); // First see if we get a hit for the parentType - std::map::const_iterator membershipRelation_it = + std::map::const_iterator membershipRelation_it = membershipRelation.find(parentType); // At this point we know if we do not have a hit, then try a parent @@ -414,7 +411,7 @@ namespace EUROPA { // Alternately, we have to have a hit const NameValueVector& members = membershipRelation_it->second; for(NameValueVector::const_iterator it = members.begin(); it != members.end(); ++it){ - const LabelStr& name = it->second; + const std::string& name = it->second; if(name == memberName) // Is the name equal to param return it->first; } @@ -423,12 +420,12 @@ namespace EUROPA { return getMemberType(getParent(parentType), memberName); } - unsigned int Schema::getIndexFromName(const LabelStr& parentType, const LabelStr& memberName) const { + unsigned int Schema::getIndexFromName(const std::string& parentType, const std::string& memberName) const { check_error(hasMember(parentType, memberName), - memberName.toString() + " is not a member of " + parentType.toString()); + memberName + " is not a member of " + parentType); // First see if we get a hit for the parentType - std::map::const_iterator membershipRelation_it = + std::map::const_iterator membershipRelation_it = membershipRelation.find(parentType); // At this point we know if we do not have a hit, then try a parent @@ -439,7 +436,7 @@ namespace EUROPA { const NameValueVector& members = membershipRelation_it->second; unsigned int index = 0; for(NameValueVector::const_iterator it = members.begin(); it != members.end(); ++it){ - const LabelStr& name = it->second; + const std::string& name = it->second; if(name == memberName) // Is the name equal to param return index; else @@ -450,16 +447,18 @@ namespace EUROPA { return getIndexFromName(getParent(parentType), memberName); } - const LabelStr Schema::getNameFromIndex(const LabelStr& parentType, unsigned int index) const { + const std::string Schema::getNameFromIndex(const std::string& parentType, unsigned int index) const { // First see if we get a hit for the parentType - std::map::const_iterator membershipRelation_it = + std::map::const_iterator membershipRelation_it = membershipRelation.find(parentType); // At this point we know if we do not have a hit, then try a parent if(membershipRelation_it == membershipRelation.end() && hasParent(parentType)) return getNameFromIndex(getParent(parentType), index); - // Alternately, we have to have a hit + checkError(membershipRelation_it != membershipRelation.end(), + "Invalid membership relation: " << parentType); + // Alternately, we have to have a hit const NameValueVector& members = membershipRelation_it->second; unsigned int counter = 0; for(NameValueVector::const_iterator it = members.begin(); it != members.end(); ++it){ @@ -471,7 +470,7 @@ namespace EUROPA { // If we get to here, we should pursue the parent type (and it will have to have one). checkError(hasParent(parentType), - parentType.toString() << " has no member with index " << index); + parentType << " has no member with index " << index); return getNameFromIndex(getParent(parentType), index); } @@ -480,31 +479,31 @@ namespace EUROPA { * @todo This may not be valid since a member name could in theory be duplicated * across enumerations. Look into this when we address enum scoping in a language */ - const LabelStr Schema::getEnumFromMember(const LabelStr& member) const { - for(LabelStr_ValueSet_Map::const_iterator it = enumValues.begin(); + const std::string Schema::getEnumFromMember(const LabelStr& member) const { + for(std::map::const_iterator it = enumValues.begin(); it != enumValues.end(); ++it) for(ValueSet::const_iterator memIt = it->second.begin(); memIt != it->second.end(); ++memIt) if((*memIt) == member) return it->first; check_error(ALWAYS_FAILS, member.toString() + " is not a member of any enumeration."); - return LabelStr("error"); + return "error"; } - unsigned int Schema::getParameterCount(const LabelStr& predicate) const { - check_error(isPredicate(predicate), predicate.toString() + " is not defined as a Predicate"); + unsigned long Schema::getParameterCount(const std::string& predicate) const { + check_error(isPredicate(predicate), predicate + " is not defined as a Predicate"); // First see if we get a hit for the parentType - std::map::const_iterator membershipRelation_it = + std::map::const_iterator membershipRelation_it = membershipRelation.find(predicate); - check_error(membershipRelation_it != membershipRelation.end(), predicate.toString() + " not found in the membership relation"); + check_error(membershipRelation_it != membershipRelation.end(), predicate + " not found in the membership relation"); const NameValueVector& members = membershipRelation_it->second; return(members.size()); } - const LabelStr Schema::getParameterType(const LabelStr& predicate, unsigned int paramIndex) const { - check_error(isPredicate(predicate), predicate.toString() + " is not defined as a Predicate"); + const std::string Schema::getParameterType(const std::string& predicate, unsigned int paramIndex) const { + check_error(isPredicate(predicate), predicate + " is not defined as a Predicate"); #ifdef _MANAGED std::string tmp; System::String ^ tmpStr = paramIndex + " is not a valid index"; @@ -514,7 +513,7 @@ namespace EUROPA { checkError(paramIndex < getParameterCount(predicate), paramIndex << " is not a valid index"); #endif // First see if we get a hit for the parentType - std::map::const_iterator membershipRelation_it = + std::map::const_iterator membershipRelation_it = membershipRelation.find(predicate); check_error(membershipRelation_it != membershipRelation.end()); @@ -523,94 +522,94 @@ namespace EUROPA { return(members[paramIndex].first); } - void Schema::addPrimitive(const LabelStr& primitiveName){ - check_error(!isPrimitive(primitiveName), primitiveName.toString() + " is already defined."); - debugMsg("Schema:addPrimitive", "[" << m_name.toString() << "] " << "Adding primitive type " << primitiveName.toString()); + void Schema::addPrimitive(const std::string& primitiveName){ + check_error(!isPrimitive(primitiveName), primitiveName + " is already defined."); + debugMsg("Schema:addPrimitive", "[" << m_name << "] " << "Adding primitive type " << primitiveName); primitives.insert(primitiveName); } - void Schema::declareObjectType(const LabelStr& objectType) { + void Schema::declareObjectType(const std::string& objectType) { if (!this->isObjectType(objectType)) { - debugMsg("Schema:declareObjectType", "[" << m_name.toString() << "] " << "Declaring object type " << objectType.toString()); + debugMsg("Schema:declareObjectType", "[" << m_name << "] " << "Declaring object type " << objectType); objectTypes.insert(objectType); getCESchema()->registerDataType((new ObjectDT(objectType.c_str()))->getId()); } else { - debugMsg("Schema:declareObjectType", "[" << m_name.toString() << "] " << "Object type already declared, ignoring re-declaration for" << objectType.toString()); + debugMsg("Schema:declareObjectType", "[" << m_name << "] " << "Object type already declared, ignoring re-declaration for" << objectType); } } - void Schema::addObjectType(const LabelStr& objectType) { + void Schema::addObjectType(const std::string& objectType) { // Enforce assumption of a singly rooted class hierarchy addObjectType(objectType, rootObject()); } - void Schema::addObjectType(const LabelStr& objectType, const LabelStr& parent) { + void Schema::addObjectType(const std::string& objectType, const std::string& parent) { - check_error(objectType.countElements(getDelimiter()) == 1, - "ObjectType must not be delimited:" + objectType.toString()); + check_error(std::count(objectType.begin(), objectType.end(), getDelimiter()) == 0, + "ObjectType must not be delimited:" + objectType); if (objectType != rootObject()) { - checkError(isObjectType(parent), objectType.toString() + " has undefined parent class : " + parent.toString()); - checkError(childOfRelation.find(objectType) == childOfRelation.end(),objectType.toString() << " is already defined."); - childOfRelation.insert(std::pair(objectType, parent)); + checkError(isObjectType(parent), objectType + " has undefined parent class : " + parent); + checkError(childOfRelation.find(objectType) == childOfRelation.end(),objectType << " is already defined."); + childOfRelation.insert(std::pair(objectType, parent)); } objectTypes.insert(objectType); - membershipRelation.insert(std::pair(objectType, NameValueVector())); + membershipRelation.insert(std::pair(objectType, NameValueVector())); // Add type for constrained variables to be able to hold references to objects of the new type if (!getCESchema()->isDataType(objectType.c_str())) getCESchema()->registerDataType((new ObjectDT(objectType.c_str()))->getId()); debugMsg("Schema:addObjectType", - "[" << m_name.toString() << "] " << "Added object type " << objectType.toString() << " that extends " << - parent.toString()); + "[" << m_name << "] " << "Added object type " << objectType << " that extends " << + parent); } - void Schema::addPredicate(const LabelStr& predicate) { - check_error(predicate.countElements(getDelimiter()) == 2, - "Expect predicate names to be structured as .. Not found in "+ - predicate.toString()); +void Schema::addPredicate(const std::string& predicate) { + check_error(std::count(predicate.begin(), predicate.end(), getDelimiter()) == 1, + "Expect predicate names to be structured as .. Not found in "+ + predicate); - check_error(isObjectType(predicate.getElement(0, getDelimiter())), - "Object Type not defined for " + predicate.toString() + "."); + check_error(isObjectType(predicate.substr(0, predicate.find(getDelimiter()))), + "Object Type not defined for " + predicate + "."); - check_error(predicates.find(predicate) == predicates.end(), predicate.toString() + " already defined."); + check_error(predicates.find(predicate) == predicates.end(), predicate + " already defined."); - debugMsg("Schema:addPredicate", - "[" << m_name.toString() << "] " << "Added predicate " << predicate.toString()); - predicates.insert(predicate); - membershipRelation.insert(std::pair(predicate, NameValueVector())); - } + debugMsg("Schema:addPredicate", + "[" << m_name << "] " << "Added predicate " << predicate); + predicates.insert(predicate); + membershipRelation.insert(std::pair(predicate, NameValueVector())); +} /** * @todo memberType is not checked yet. It can be a class, enum, or primitive */ - unsigned int Schema::addMember(const LabelStr& parentType, - const LabelStr& memberType, - const LabelStr& memberName) { - check_error(isType(parentType), parentType.toString() + " is undefined."); + unsigned long Schema::addMember(const std::string& parentType, + const std::string& memberType, + const std::string& memberName) { + check_error(isType(parentType), parentType + " is undefined."); check_error(!canContain(parentType, memberType, memberName), - parentType.toString() + " already contains " + memberName.toString()); + parentType + " already contains " + memberName); debugMsg("Schema:addMember", - "[" << m_name.toString() << "] " << "Added to " << parentType.toString() << ": " << memberType.toString() << " " << - memberName.toString()); + "[" << m_name << "] " << "Added to " << parentType << ": " << memberType << " " << + memberName); // We can now assume the entry is present, so just add where appropriate NameValueVector& members = membershipRelation.find(parentType)->second; members.push_back(NameValuePair(memberType, memberName)); return (members.size()-1); } - void Schema::addEnum(const LabelStr& enumName) { - check_error(!isEnum(enumName), enumName.toString() + " is already defined as an enumeration."); - check_error(!isObjectType(enumName), enumName.toString() + " is already defined as an object type."); - debugMsg("Schema:addEnum", "[" << m_name.toString() << "] " << "Added enumeration " << enumName.toString()); - enumValues.insert(std::pair(enumName, ValueSet())); + void Schema::addEnum(const std::string& enumName) { + check_error(!isEnum(enumName), enumName + " is already defined as an enumeration."); + check_error(!isObjectType(enumName), enumName + " is already defined as an object type."); + debugMsg("Schema:addEnum", "[" << m_name << "] " << "Added enumeration " << enumName); + enumValues.insert(std::pair(enumName, ValueSet())); } - void Schema::registerEnum(const char* enumName, const EnumeratedDomain& domain) + void Schema::registerEnum(const std::string& enumName, const EnumeratedDomain& domain) { debugMsg("Schema:enumdef","Defining enum:" << enumName); @@ -631,225 +630,220 @@ namespace EUROPA { " with base domain " << domain.toString()); } - void Schema::addValue(const LabelStr& enumName, edouble enumValue) { - check_error(isEnum(enumName), enumName.toString() + " is undefined."); - check_error(enumValuesToEnums.find(enumValue) == enumValuesToEnums.end(), - LabelStr(enumValue).toString() + " is already an enum value for " + (enumValuesToEnums[enumValue]).toString()); - - debugMsg("Schema:addValue", "[" << m_name.toString() << "] " << "Added " << - (LabelStr::isString(enumValue) ? LabelStr(enumValue).toString() : toString(enumValue)) << " to " << - enumName.toString()); - ValueSet& members = enumValues.find(enumName)->second; - members.insert(enumValue); - enumValuesToEnums[enumValue] = enumName; - } - - const LabelStr& Schema::getEnumForValue(edouble value) const - { - check_error(enumValuesToEnums.find(value) != enumValuesToEnums.end()); - return enumValuesToEnums.find(value)->second; - } - - void Schema::write(ostream& os) const{ - os << "SCHEMA RULES:\n"; - for(LabelStr_LabelStrSet_Map::const_iterator it = objectPredicates.begin(); - it != objectPredicates.end(); ++it){ - LabelStr objectName = it->first; - os << objectName.toString() << ":{"; - for (LabelStrSet::const_iterator pos = it->second.begin(); pos != it->second.end(); ++pos){ - LabelStr predicate = *pos; - os << predicate.toString() << " "; - } - os << "}\n"; +void Schema::addValue(const std::string& enumName, edouble enumValue) { + check_error(isEnum(enumName), enumName + " is undefined."); + check_error(enumValuesToEnums.find(enumValue) == enumValuesToEnums.end(), + LabelStr(enumValue).toString() + " is already an enum value for " + enumValuesToEnums[enumValue]); + + debugMsg("Schema:addValue", "[" << m_name << "] " << "Added " << + (LabelStr::isString(enumValue) ? LabelStr(enumValue).toString() : toString(enumValue)) << " to " << + enumName); + ValueSet& members = enumValues.find(enumName)->second; + members.insert(enumValue); + enumValuesToEnums[enumValue] = enumName; +} + +const std::string& Schema::getEnumForValue(edouble value) const { + check_error(enumValuesToEnums.find(value) != enumValuesToEnums.end()); + return enumValuesToEnums.find(value)->second; +} + +void Schema::write(ostream& os) const { + os << "SCHEMA RULES:\n"; + for(std::map >::const_iterator it = objectPredicates.begin(); + it != objectPredicates.end(); ++it){ + std::string objectName = it->first; + os << objectName << ":{"; + for (std::set::const_iterator pos = it->second.begin(); pos != it->second.end(); ++pos){ + os << *pos << " "; } + os << "}\n"; } +} - bool Schema::makeParentPredicateString(const LabelStr& predicate, std::string& predStr) const{ - check_error(predicate.countElements(getDelimiter()) == 2, - "Invalid format for predicate " + predicate.toString()); - - LabelStr prefix = predicate.getElement(0, getDelimiter()); +bool Schema::makeParentPredicateString(const std::string& predicate, std::string& predStr) const{ + check_error(std::count(predicate.begin(), predicate.end(), getDelimiter()) == 1, + "Invalid format for predicate " + predicate); - // If not a defined class, or has no parent class, do no more and return false - if(!isObjectType(prefix) || !hasParent(prefix)) - return false; + std::string prefix = predicate.substr(0, predicate.find(getDelimiter())); - // Otherwise we are ready to compose with the parent - LabelStr suffix = predicate.getElement(1, getDelimiter()); - predStr = getParent(prefix).toString() + getDelimiter() + suffix.toString(); - return true; - } + // If not a defined class, or has no parent class, do no more and return false + if(!isObjectType(prefix) || !hasParent(prefix)) + return false; - void Schema::getEnumerations(std::list& results) const { - for(LabelStr_ValueSet_Map::const_iterator it = enumValues.begin(); - it != enumValues.end(); ++it) - results.push_back(it->first); + // Otherwise we are ready to compose with the parent + std::string suffix = predicate.substr(predicate.find(getDelimiter()) + 1); + predStr = getParent(prefix) + getDelimiter() + suffix; + return true; +} + +void Schema::getEnumerations(std::list& results) const { + for(std::map::const_iterator it = enumValues.begin(); + it != enumValues.end(); ++it) + results.push_back(it->first); +} + +namespace { +const Id createDefaultObjectFactory( + const ObjectTypeId objType, + bool canCreateObjects) { + std::vector constructorArgNames; + std::vector constructorArgTypes; + std::vector constructorBody; + ExprConstructorSuperCall* superCallExpr = NULL; + + // If it can't create objects, generate default super call + if (!canCreateObjects) + superCallExpr = new ExprConstructorSuperCall(objType->getParent()->getName(),std::vector()); + + return (new InterpretedObjectFactory( + objType, + objType->getName(), + constructorArgNames, + constructorArgTypes, + superCallExpr, + constructorBody, + canCreateObjects) + )->getId(); +} +} + +void Schema::registerObjectType(const ObjectTypeId objType) { + const std::string& className = objType->getName(); + + if (objType->getName() == Schema::rootObject()) + addObjectType(className); + else + addObjectType(className,objType->getParent()->getName().c_str()); + + if (objType->getObjectFactories().size() == 0) { + bool canCreateObjects = objType->isNative(); + objType->addObjectFactory(createDefaultObjectFactory(objType,canCreateObjects)); + debugMsg("Schema:registerObjectType","Generated default factory for object type:" << objType->getName().c_str()); + } + + m_objectTypeMgr->registerObjectType(objType); + + // Add type for constrained variables to be able to hold references to objects of the new type + if (!getCESchema()->isDataType(className)) + getCESchema()->registerDataType((new ObjectDT(className))->getId()); + + // TODO: all these need to go eventually (except for the registerTokenType call) + { + std::map::const_iterator it = objType->getMembers().begin(); + for(;it != objType->getMembers().end(); ++it) + addMember(className, it->second->getName() /*type*/, it->first/*name*/); } - const Id& createDefaultObjectFactory( - const ObjectTypeId& objType, - bool canCreateObjects) - { - std::vector constructorArgNames; - std::vector constructorArgTypes; - std::vector constructorBody; - ExprConstructorSuperCall* superCallExpr = NULL; - - // If it can't create objects, generate default super call - if (!canCreateObjects) - superCallExpr = new ExprConstructorSuperCall(objType->getParent()->getName(),std::vector()); - - return (new InterpretedObjectFactory( - objType, - objType->getName(), - constructorArgNames, - constructorArgTypes, - superCallExpr, - constructorBody, - canCreateObjects) - )->getId(); - } - - void Schema::registerObjectType(const ObjectTypeId& objType) { - const char* className = objType->getName().c_str(); - - if (objType->getName() == Schema::rootObject()) - addObjectType(className); - else - addObjectType(className,objType->getParent()->getName().c_str()); - - if (objType->getObjectFactories().size() == 0) { - bool canCreateObjects = objType->isNative(); - objType->addObjectFactory(createDefaultObjectFactory(objType,canCreateObjects)); - debugMsg("Schema:registerObjectType","Generated default factory for object type:" << objType->getName().c_str()); - } - - m_objectTypeMgr->registerObjectType(objType); - - // Add type for constrained variables to be able to hold references to objects of the new type - if (!getCESchema()->isDataType(className)) - getCESchema()->registerDataType((new ObjectDT(className))->getId()); + std::map::const_iterator it = objType->getTokenTypes().begin(); + for(;it != objType->getTokenTypes().end(); ++it) { + const TokenTypeId tokenType = it->second; + std::string predName = tokenType->getSignature(); - // TODO: all these need to go eventually (except for the registerTokenType call) - { - std::map::const_iterator it = objType->getMembers().begin(); - for(;it != objType->getMembers().end(); ++it) - addMember(className, it->second->getName().toString() /*type*/, it->first/*name*/); - } - - { - std::map::const_iterator it = objType->getTokenTypes().begin(); - for(;it != objType->getTokenTypes().end(); ++it) { - const TokenTypeId& tokenType = it->second; - LabelStr predName = tokenType->getSignature(); + addPredicate(predName.c_str()); + std::map::const_iterator paramIt = tokenType->getArgs().begin(); + for(;paramIt != tokenType->getArgs().end();++paramIt) + addMember(predName.c_str(), paramIt->second->getName() /*type*/, paramIt->first/*name*/); - addPredicate(predName.c_str()); - std::map::const_iterator paramIt = tokenType->getArgs().begin(); - for(;paramIt != tokenType->getArgs().end();++paramIt) - addMember(predName.c_str(), paramIt->second->getName() /*type*/, paramIt->first/*name*/); - - registerTokenType(it->second); - } - } - - debugMsg("Schema:registerObjectType","Registered object type:" << std::endl << objType->toString()); + registerTokenType(it->second); + } } - const ObjectTypeId& Schema::getObjectType(const LabelStr& objType) - { - return m_objectTypeMgr->getObjectType(objType); - } + debugMsg("Schema:registerObjectType","Registered object type:" << std::endl << objType->toString()); +} - ObjectFactoryId Schema::getObjectFactory(const LabelStr& objectType, const std::vector& arguments, const bool doCheckError) - { - return m_objectTypeMgr->getFactory(getId(),objectType,arguments,doCheckError); - } +const ObjectTypeId Schema::getObjectType(const std::string& objType) { + return m_objectTypeMgr->getObjectType(objType); +} - void Schema::registerTokenType(const TokenTypeId& f) +ObjectFactoryId Schema::getObjectFactory(const std::string& objectType, + const std::vector& arguments, + const bool doCheckError) { + return m_objectTypeMgr->getFactory(getId(),objectType,arguments,doCheckError); +} + + void Schema::registerTokenType(const TokenTypeId f) { m_tokenTypeMgr->registerType(f); } - TokenTypeId Schema::getTokenType(const LabelStr& type) - { - return m_tokenTypeMgr->getType(getId(),type); - } +TokenTypeId Schema::getTokenType(const std::string& type) { + return m_tokenTypeMgr->getType(getId(),type); +} - TokenTypeId Schema::getParentTokenType(const LabelStr& tokenType, const LabelStr& parentObjType) - { - LabelStr objType = parentObjType; - std::string tokenName = tokenType.getElement(1, getDelimiter()).toString(); - - for(;;) { - std::string parentName = objType.toString()+getDelimiter()+tokenName; - if (isPredicate(parentName)) - return getTokenType(parentName); - if (hasParent(objType)) - objType = getParent(objType); - else - break; - } +TokenTypeId Schema::getParentTokenType(const std::string& tokenType, + const std::string& parentObjType) { + std::string objType = parentObjType; + std::string tokenName = tokenType.substr(tokenType.find(getDelimiter()) + 1); - return TokenTypeId::noId(); + for(;;) { + std::string parentName = objType+getDelimiter()+tokenName; + if (isPredicate(parentName)) + return getTokenType(parentName); + if (hasParent(objType)) + objType = getParent(objType); + else + break; } + return TokenTypeId::noId(); +} + bool Schema::hasTokenTypes() const { return m_tokenTypeMgr->hasType(); } - void Schema::registerMethod(const MethodId& m) - { - // TODO: allow method overloading - check_runtime_error(m_methods.find(m->getName()) == m_methods.end(), std::string("Method ")+m->getName().toString()+" already exists"); - m_methods[m->getName()] = m; - } +void Schema::registerMethod(const MethodId m) { + // TODO: allow method overloading + check_runtime_error(m_methods.find(m->getName()) == m_methods.end(), + std::string("Method ")+m->getName()+" already exists"); + m_methods[m->getName()] = m; +} - MethodId Schema::getMethod(const LabelStr& methodName, const DataTypeId& targetType, const std::vector& argTypes) - { - // TODO: use target type and arg types to resolve - std::map::iterator it = m_methods.find(methodName); - return (it != m_methods.end() ? it->second : MethodId::noId()); - } +MethodId Schema::getMethod(const std::string& methodName, const DataTypeId, + const std::vector&) { + // TODO: use target type and arg types to resolve + std::map::iterator it = m_methods.find(methodName); + return (it != m_methods.end() ? it->second : MethodId::noId()); +} - std::vector Schema::getTypeSupporters( TokenTypeId type ) - { - edouble key = type->getSignature().getKey(); - std::vector retval; +std::vector Schema::getTypeSupporters( TokenTypeId type ) { + std::string key = type->getSignature(); + std::vector retval; - PSList actionTypes = getPSTokenTypesByAttr( PSTokenType::ACTION ); + PSList actionTypes = getPSTokenTypesByAttr( PSTokenType::ACTION ); - for( int i = 0; i < actionTypes.size(); i++){ + for( int i = 0; i < actionTypes.size(); i++){ - TokenType* tt = (TokenType*)actionTypes.get( i ); - PSList effects = tt->getSubgoalsByAttr( PSTokenType::EFFECT); + TokenType* tt = boost::polymorphic_cast(actionTypes.get( i )); + PSList effects = tt->getSubgoalsByAttr( PSTokenType::EFFECT); - for ( int i = 0; i < effects.size(); i++ ) { - TokenType* tt_effect = (TokenType*) effects.get(i); - if( tt_effect->getSignature().getKey() == key) - retval.push_back( tt->getId() ); - } + for (long j = 0; j < effects.size(); j++ ) { + TokenType* tt_effect = dynamic_cast(effects.get(j)); + if( tt_effect->getSignature() == key) + retval.push_back( tt->getId() ); } + } - return retval; + return retval; - } +} // PSSchema methods: - PSList Schema::getAllPredicates() const - { - PSList retval; - std::set predicates; - getPredicates(predicates); - for(std::set::const_iterator it = predicates.begin(); it != predicates.end(); ++it) - { - retval.push_back((*it).toString()); - } - return retval; - } +PSList Schema::getAllPredicates() const { + PSList retval; + std::set predicates_; + getPredicates(predicates_); + for(std::set::const_iterator it = predicates_.begin(); it != predicates_.end(); + ++it) { + retval.push_back((*it)); + } + return retval; +} PSList Schema::getAllPSObjectTypes() const { PSList retval; diff --git a/src/PLASMA/PlanDatabase/base/Schema.hh b/src/PLASMA/PlanDatabase/base/Schema.hh index aad1873d5..798afb62b 100644 --- a/src/PLASMA/PlanDatabase/base/Schema.hh +++ b/src/PLASMA/PlanDatabase/base/Schema.hh @@ -5,12 +5,11 @@ * @author Conor McGann, Andrew Bachmann */ -#ifndef _H_Schema -#define _H_Schema +#ifndef H_Schema +#define H_Schema #include "PlanDatabaseDefs.hh" #include "PSPlanDatabase.hh" -#include "LabelStr.hh" #include "Domain.hh" #include "ObjectType.hh" #include "TokenTypeMgr.hh" @@ -19,8 +18,7 @@ #include namespace EUROPA { - - typedef std::set LabelStrSet; +class LabelStr; /** * @class Schema @@ -36,38 +34,34 @@ namespace EUROPA { class Schema: public DomainComparator, public PSSchema { public: - typedef std::pair NameValuePair; + typedef std::pair NameValuePair; typedef std::vector NameValueVector; typedef std::set ValueSet; - typedef std::map LabelStr_LabelStr_Map; - typedef std::map LabelStr_LabelStrSet_Map; - typedef std::map LabelStr_ValueSet_Map; - typedef std::map LabelStr_LabelStrLabelStrMap_Map; - Schema(const LabelStr& name, const CESchemaId& cesch); + Schema(const std::string& name, const CESchemaId cesch); ~Schema(); /** * @brief Retrieve the delimiter for separating elements in schema element names. */ - static const char* getDelimiter(); + static const char getDelimiter(); /** * @brief Creates a fully qualifiedName for a predicate * @see getDelimiter() */ - static const LabelStr makeQualifiedName(const LabelStr& objectType, - const LabelStr& unqualifiedPredicateName); + static const std::string makeQualifiedName(const std::string& objectType, + const std::string& unqualifiedPredicateName); /** * @brief Accessor for the root object */ - static const LabelStr& rootObject(); + static const std::string& rootObject(); - const SchemaId& getId() const; + const SchemaId getId() const; - const LabelStr& getName() const; + const std::string& getName() const; /** * @brief Implements the DomainComparator interface function @@ -84,48 +78,48 @@ namespace EUROPA { /** * @brief Tests if the given name is a defined objectType or predciate */ - bool isType(const LabelStr& type) const; + bool isType(const std::string& type) const; /** * @brief Tests if the given name is a recognized primitove type */ - bool isPrimitive(const LabelStr& str) const; + bool isPrimitive(const std::string& str) const; /** * @brief Test if the given string is an enumerated type */ - bool isEnum(const LabelStr& str) const; + bool isEnum(const std::string& str) const; /** - * @brief Test if the given value is a member of the given enum + * @brief Test if the given value is a member of the given enum. Calling this + * function with a name that isn't an enum is an error. * @param enumName The name of the enumeration * @param value The value to be tested. - * @error !isEnum(enum) */ - bool isEnumValue(const LabelStr& enumName, edouble value) const; + bool isEnumValue(const std::string& enumName, const edouble value) const; /** * @brief Test if the given value is a member of any enum * @param value The value to be tested. */ - bool isEnumValue(edouble value) const; + bool isEnumValue(const edouble value) const; /** * @brief Determine of a given predicate is part of the schema */ - bool isPredicate(const LabelStr& type) const; + bool isPredicate(const std::string& type) const; /** * @brief Test if the given string is a class name */ - bool isObjectType(const LabelStr& type) const; + bool isObjectType(const std::string& type) const; /** * @brief Determine if a given predicate is compatible with a given object type. */ - bool canBeAssigned(const LabelStr& objectType, - const LabelStr& predicate) const; + bool canBeAssigned(const std::string& objectType, + const std::string& predicate) const; /** * @brief Determine if a given composition of objects is allowed. @@ -133,9 +127,9 @@ namespace EUROPA { * @param memberType the type of the composed object * @param memberName the member name for the composed field. */ - bool canContain(const LabelStr& parentType, - const LabelStr& memberType, - const LabelStr& memberName) const; + bool canContain(const std::string& parentType, + const std::string& memberType, + const std::string& memberName) const; /** * @@ -144,22 +138,22 @@ namespace EUROPA { * - the first element is the member's type * - the second elemnt is the member's name */ - const NameValueVector& getMembers(const LabelStr& objectType) const; + const NameValueVector& getMembers(const std::string& objectType) const; /** * @brief Determines if the given member is contained in the parent * @param parentType the type of the composing object or predicate * @param memberName the member name for the composed field. */ - bool hasMember(const LabelStr& parentType, const LabelStr& memberName) const; + bool hasMember(const std::string& parentType, const std::string& memberName) const; /** * @brief Gets the type of a parents member. * @param parentType The parentType. * @param parameterName The parameter name. */ - const LabelStr getMemberType(const LabelStr& parentType, - const LabelStr& parameterName) const; + const std::string getMemberType(const std::string& parentType, + const std::string& parameterName) const; /** * @brief Determine if one type is a sub type of another @@ -167,7 +161,7 @@ namespace EUROPA { * @param ancestor The candidate ancestor type. Must be a defined objectType. * @see isObjectType */ - bool isA(const LabelStr& descendant, const LabelStr& ancestor) const; + bool isA(const std::string& descendant, const std::string& ancestor) const; /** * @brief Tests if the given type has a parent. @@ -175,20 +169,20 @@ namespace EUROPA { * @return true if it does, otherwise false. * @see getParent, isA */ - bool hasParent(const LabelStr& objectType) const; + bool hasParent(const std::string& objectType) const; /** * @brief Obtains the parent of a given type, if there is one. Will error out if it has no parent. * @param objectType the input type for which to obtain the parent * @see hasParent, isA */ - const LabelStr getParent(const LabelStr& objectType) const; + const std::string getParent(const std::string& objectType) const; /** * @brief Obtains all the Object Types in the Schema. - * @return a const ref to a set of LabelStr (each of which is the name of an ObjectType) + * @return a const ref to a set of std::string (each of which is the name of an ObjectType) */ - const LabelStrSet& getAllObjectTypes() const; + const std::set& getAllObjectTypes() const; /** * @brief Obtains the set of all ObjectTypes that can be matched with the given object type. @@ -196,42 +190,41 @@ namespace EUROPA { * @return results All matchable classes in the schema. Includes objectType and all super classes. * @see hasParent, getParent */ - const std::vector& getAllObjectTypes(const LabelStr& objectType); + const std::vector& getAllObjectTypes(const std::string& objectType); /** - * @brief Obtains the set of values for an enumeration. + * @brief Obtains the set of values for an enumeration. Calling this function with a + * name not of an enumeration is an error. * @param enumName enumeration type name. * @return a const ref to the set of values for enumName. - * @error !isEnum(enumName). */ - const std::set& getEnumValues(const LabelStr& enumName) const; + const std::set& getEnumValues(const std::string& enumName) const; /** * @brief Obtains the enum name for an enum value * @param value enum value to be looked up */ - const LabelStr& getEnumForValue(edouble value) const; + const std::string& getEnumForValue(edouble value) const; /** - * @brief Obtain the set of predicates for a given object type. + * @brief Obtain the set of predicates for a given object type. Errors if objectType + * doesn't name an object type. * @param objectType The ObjectType to use - * @return a const ref to a set of LabelStr (each of which is the name of a Predicate) * @see addObjectType, isType - * @error !isType(objecttype) */ - void getPredicates(const LabelStr& objectType, std::set& results) const; + void getPredicates(const std::string& objectType, std::set& results) const; /** * @brief Obtain the entire set of predicates. * @param results The set into which the predicates are put. */ - void getPredicates(std::set& results) const; + void getPredicates(std::set& results) const; /** * @brief Test if an object type has any predicates */ - bool hasPredicates(const LabelStr& objectType); + bool hasPredicates(const std::string& objectType); /** * @brief Helper method to compose a parent string @@ -239,80 +232,78 @@ namespace EUROPA { * @param predStr The result. Must be initially empty * @return true if it has a parent, othwerise false */ - bool makeParentPredicateString(const LabelStr& predicate, std::string& predStr) const; + bool makeParentPredicateString(const std::string& predicate, std::string& predStr) const; /** - * @brief Obtain the object type for the given predicate. + * @brief Obtain the object type for the given predicate. Errors if predicate doesn't + * name an existing predicate. * @param predicate The predicate to use * @see addPredicate, isPredicateDefined - * @error !isPredicateDefined(predicate) */ - const LabelStr getObjectTypeForPredicate(const LabelStr& predicate) const; + const std::string getObjectTypeForPredicate(const std::string& predicate) const; /** * @brief Gets the index of a named member in a types member list. * @param type the type to search * @param memberName the name of the member */ - unsigned int getIndexFromName(const LabelStr& type, const LabelStr& memberName) const; + unsigned int getIndexFromName(const std::string& type, const std::string& memberName) const; /** * @brief Gets the name of a member from a types member list. * @param type the type to search * @param index the index of the member */ - const LabelStr getNameFromIndex(const LabelStr& type, unsigned int index) const; + const std::string getNameFromIndex(const std::string& type, unsigned int index) const; /** * @brief Gets the type of the enumeration to which the given member belongs * @param member the member */ - const LabelStr getEnumFromMember(const LabelStr& member) const; + const std::string getEnumFromMember(const LabelStr& member) const; /** - * @brief Gets the number of parameters in a predicate + * @brief Gets the number of parameters in a predicate. Error: !isPredicateDefined(predicate) * @param predicate the name of the predicate - * @error !isPredicateDefined(predicate) */ - unsigned int getParameterCount(const LabelStr& predicate) const; + unsigned long getParameterCount(const std::string& predicate) const; /** - * @brief Gets the type of parameter at a particular index location in a predicate + * @brief Gets the type of parameter at a particular index location in a predicate. + * Errors: !isPredicateDefined(predicate) * @param predicate the name of the predicate * @param paramIndex the index of the parameter - * @error !isPredicateDefined(predicate) */ - const LabelStr getParameterType(const LabelStr& predicate, unsigned int paramIndex) const; + const std::string getParameterType(const std::string& predicate, unsigned int paramIndex) const; /** * @brief Introduce a primitive type name to be used */ - void addPrimitive(const LabelStr& primitiveName); + void addPrimitive(const std::string& primitiveName); /** * @brief Declare an object type. The type can be referenced from now on. * I'ts the responsibility of the client to make sure that addObjectType will be called for this type eventually * */ - void declareObjectType(const LabelStr& objectType); + void declareObjectType(const std::string& objectType); /** * @brief Add an object type. It must not be present already. */ - void addObjectType(const LabelStr& objectType); + void addObjectType(const std::string& objectType); /** * @brief Add an object type as a derived type from the parent. */ - void addObjectType(const LabelStr& objectType, - const LabelStr& parent); + void addObjectType(const std::string& objectType, + const std::string& parent); /** - * @brief Adds a predicate. + * @brief Adds a predicate. Errors: !isObjectType(prefix), isPredicateDefined(suffix) * @param predicate The fully qualified name of the predicate. Must be of the form . - * @error !isObjectType(prefix), isPredicateDefined(suffix) */ - void addPredicate(const LabelStr& predicate); + void addPredicate(const std::string& predicate); /** * @brief Indicates a composition of members @@ -321,91 +312,90 @@ namespace EUROPA { * @param memberName The name of the composed member * @return The indexed position of the parameter in the predicate list of parameters. */ - unsigned int addMember(const LabelStr& parentObjectType, - const LabelStr& memberType, - const LabelStr& memberName); + unsigned long addMember(const std::string& parentObjectType, + const std::string& memberType, + const std::string& memberName); /** * @brief Introduces a user defined enumeration type. * @param enumName The name of the enumeration. */ - void addEnum(const LabelStr& enumName); + void addEnum(const std::string& enumName); /** * @brief Add a member to a custom defined enumeration * @param enumName The name of the enumeration * @param enumValue The member to be added */ - void addValue(const LabelStr& enumName, edouble enumValue); + void addValue(const std::string& enumName, edouble enumValue); - void registerEnum(const char* enumName, const EnumeratedDomain& domain); + void registerEnum(const std::string& enumName, const EnumeratedDomain& domain); /** * @brief Obtain a list of names of enumerations * @param results a list of enumeration names */ - void getEnumerations(std::list& results) const; + void getEnumerations(std::list& results) const; /** * @brief Output contents to the given stream */ void write (ostream& os) const; - const CESchemaId& getCESchema() const { return m_ceSchema; } + const CESchemaId getCESchema() const { return m_ceSchema; } // TODO: ObjectType is replacing ObjectFactory - void registerObjectType(const ObjectTypeId& objType); - const ObjectTypeId& getObjectType(const LabelStr& objType); - ObjectFactoryId getObjectFactory(const LabelStr& objectType, const std::vector& arguments, const bool doCheckError = true); + void registerObjectType(const ObjectTypeId objType); + const ObjectTypeId getObjectType(const std::string& objType); + ObjectFactoryId getObjectFactory(const std::string& objectType, const std::vector& arguments, const bool doCheckError = true); - void registerTokenType(const TokenTypeId& tokenType); - TokenTypeId getTokenType(const LabelStr& tokenType); - TokenTypeId getParentTokenType( const LabelStr& tokenType, const LabelStr& parentObjType); + void registerTokenType(const TokenTypeId tokenType); + TokenTypeId getTokenType(const std::string& tokenType); + TokenTypeId getParentTokenType( const std::string& tokenType, const std::string& parentObjType); bool hasTokenTypes() const; - void registerMethod(const MethodId& m); - MethodId getMethod(const LabelStr& methodName, const DataTypeId& targetType, const std::vector& argTypes); + void registerMethod(const MethodId m); + MethodId getMethod(const std::string& methodName, const DataTypeId targetType, const std::vector& argTypes); std::vector getTypeSupporters( TokenTypeId type ); //PSSchema methods: PSList getAllPredicates() const; - PSList getMembers(const std::string& objectType) const; - bool hasMember(const std::string& parentType, const std::string& memberName) const; + PSList getObjectMembers(const std::string& objectType) const; PSList getAllPSObjectTypes() const; PSList getPSTokenTypesByAttr( int attrMask ) const; protected: SchemaId m_id; - const LabelStr m_name; - const CESchemaId& m_ceSchema; + const std::string m_name; + const CESchemaId m_ceSchema; const ObjectTypeMgrId m_objectTypeMgr; const TokenTypeMgrId m_tokenTypeMgr; - std::map m_methods; // TODO: define methodMgr instead of keeping a map here + std::map m_methods; // TODO: define methodMgr instead of keeping a map here // TODO: Drop these. Enums have been deprecated - LabelStr_ValueSet_Map enumValues; - std::map enumValuesToEnums; + std::map > enumValues; + std::map enumValuesToEnums; // TODO: get rid of all data members from this point on. There are object-oriented abstractions in place now // that hold the same information - LabelStrSet objectTypes; - LabelStrSet predicates; - LabelStrSet primitives; + std::set objectTypes; + std::set predicates; + std::set primitives; - std::map membershipRelation; /*! All type compositions */ - std::map childOfRelation; /*! Required to answer the getParent query */ - LabelStr_LabelStrSet_Map objectPredicates; /*! All predicates by object type */ - LabelStrSet typesWithNoPredicates; /*! Cache for lookup efficiently */ - std::map > allObjectTypes; /*! Cache to retrieve allObjectTypes by sub-class */ + std::map membershipRelation; /*! All type compositions */ + std::map childOfRelation; /*! Required to answer the getParent query */ + std::map > objectPredicates; /*! All predicates by object type */ + std::set typesWithNoPredicates; /*! Cache for lookup efficiently */ + std::map > allObjectTypes; /*! Cache to retrieve allObjectTypes by sub-class */ - mutable std::set m_predTrueCache, m_predFalseCache; /**< Caches from isPredicate, now useful and not static . */ - mutable std::set m_hasParentCache; /**< Cache from hasParent, now useful and not static */ + mutable std::set m_predTrueCache, m_predFalseCache; /**< Caches from isPredicate, now useful and not static . */ + mutable std::set m_hasParentCache; /**< Cache from hasParent, now useful and not static */ Schema(const Schema&); /**< NO IMPL */ - static const std::set& getBuiltInVariableNames(); + static const std::set& getBuiltInVariableNames(); }; diff --git a/src/PLASMA/PlanDatabase/base/StackMemento.cc b/src/PLASMA/PlanDatabase/base/StackMemento.cc index 69f308812..88733c67b 100644 --- a/src/PLASMA/PlanDatabase/base/StackMemento.cc +++ b/src/PLASMA/PlanDatabase/base/StackMemento.cc @@ -9,8 +9,9 @@ namespace EUROPA{ - StackMemento::StackMemento(const TokenId& activeTokenToStack, const TokenId& activeToken) - :m_activeTokenToStack(activeTokenToStack), m_activeToken(activeToken){ + StackMemento::StackMemento(const TokenId activeTokenToStack, const TokenId activeToken) + :m_activeTokenToStack(activeTokenToStack), m_activeToken(activeToken), + m_stackConstraints() { // Iterate over all variables and impose equivalence constraints // between the corresponding variables @@ -27,7 +28,7 @@ namespace EUROPA{ newScope.push_back(stackVariables[i]); newScope.push_back(activeVariables[i]); ConstraintId newConstraint = m_activeToken->getPlanDatabase()->getConstraintEngine()->createConstraint( - LabelStr("eq"), + "eq", newScope); check_error(newConstraint.isValid()); m_stackConstraints.push_back(newConstraint); @@ -39,16 +40,10 @@ namespace EUROPA{ void StackMemento::undo(bool){ check_error(!m_stackConstraints.empty()); // Delete all new constraints. - for(std::list::const_iterator it = m_stackConstraints.begin(); it!= m_stackConstraints.end(); ++it) { - ConstraintId constraint = *it; - check_error(constraint.isValid()); - delete (Constraint*) constraint; - } - - m_stackConstraints.clear(); + cleanup(m_stackConstraints); } - void StackMemento::handleAdditionOfInactiveConstraint(const ConstraintId& constraint){ } + void StackMemento::handleAdditionOfInactiveConstraint(const ConstraintId){ } - void StackMemento::handleRemovalOfInactiveConstraint(const ConstraintId& constraint){ } + void StackMemento::handleRemovalOfInactiveConstraint(const ConstraintId){ } } diff --git a/src/PLASMA/PlanDatabase/base/StackMemento.hh b/src/PLASMA/PlanDatabase/base/StackMemento.hh index c7d5e9bef..b338753ba 100644 --- a/src/PLASMA/PlanDatabase/base/StackMemento.hh +++ b/src/PLASMA/PlanDatabase/base/StackMemento.hh @@ -1,10 +1,9 @@ -#ifndef _H_StackMemento -#define _H_StackMemento +#ifndef H_StackMemento +#define H_StackMemento #include "PlanDatabaseDefs.hh" #include "Token.hh" //#include "TokenVariable.hh" -#include "LabelStr.hh" #include "Constraint.hh" #include "ConstrainedVariable.hh" #include @@ -16,11 +15,11 @@ namespace EUROPA { virtual ~StackMemento(); private: friend class UnifyMemento; - StackMemento(const TokenId& activeTokenToStack, const TokenId& activeToken); + StackMemento(const TokenId activeTokenToStack, const TokenId activeToken); void undo(bool activeTokenDeleted); - void handleAdditionOfInactiveConstraint(const ConstraintId& constraint); - void handleRemovalOfInactiveConstraint(const ConstraintId& constraint); + void handleAdditionOfInactiveConstraint(const ConstraintId constraint); + void handleRemovalOfInactiveConstraint(const ConstraintId constraint); const TokenId m_activeTokenToStack; const TokenId m_activeToken; std::list m_stackConstraints; diff --git a/src/PLASMA/PlanDatabase/base/TemporalAdvisor.hh b/src/PLASMA/PlanDatabase/base/TemporalAdvisor.hh index 7fbe6ab79..c329753c1 100644 --- a/src/PLASMA/PlanDatabase/base/TemporalAdvisor.hh +++ b/src/PLASMA/PlanDatabase/base/TemporalAdvisor.hh @@ -1,8 +1,8 @@ -#ifndef _H_TemporalAdvisor -#define _H_TemporalAdvisor +#ifndef H_TemporalAdvisor +#define H_TemporalAdvisor #include "PlanDatabaseDefs.hh" - +#include "PlanDatabaseVarDefs.hh" namespace EUROPA{ /** @@ -22,9 +22,9 @@ namespace EUROPA{ * @param second Candidate to be successor * @return true if temporal distance first.end to second.start can be >= 0 */ - virtual bool canPrecede(const TokenId& first, const TokenId& second) = 0; + virtual bool canPrecede(const TokenId first, const TokenId second) = 0; - virtual bool canPrecede(const TimeVarId& first, const TimeVarId& second) = 0; + virtual bool canPrecede(const TimeVarId first, const TimeVarId second) = 0; /** * @brief test if the given token can fit between the predecessor and successor. @@ -34,8 +34,8 @@ namespace EUROPA{ * @return True if sumultaneously the temporal distance between predecessor.end and successor.start >= minimum token.duration and * canPrecede(predecessor, token) and canPrecede(token, successor) */ - virtual bool canFitBetween(const TokenId& token, const TokenId& predecessor, - const TokenId& successor) = 0; + virtual bool canFitBetween(const TokenId token, const TokenId predecessor, + const TokenId successor) = 0; /** * @brief test of the given tokens can have a zero temporal distance between their respective timepoints. Particularly @@ -44,7 +44,7 @@ namespace EUROPA{ * @param second A token to consider * @return true if distance beteen start times includes 0 and distance between end times includes 0. */ - virtual bool canBeConcurrent(const TokenId& first, const TokenId& second) = 0; + virtual bool canBeConcurrent(const TokenId first, const TokenId second) = 0; /** @@ -54,8 +54,8 @@ namespace EUROPA{ * @param exact if true, it will enforce most rigourous test and give tightest bounds. If false, it can use * previously calcuated results but may be quite wrong. */ - virtual const IntervalIntDomain getTemporalDistanceDomain(const TimeVarId& first, - const TimeVarId& second, + virtual const IntervalIntDomain getTemporalDistanceDomain(const TimeVarId first, + const TimeVarId second, const bool exact) = 0; /** @@ -64,7 +64,7 @@ namespace EUROPA{ * @param seconds The other time points * @param domains The returned calculated domains. */ - virtual void getTemporalDistanceDomains(const ConstrainedVariableId& first, + virtual void getTemporalDistanceDomains(const ConstrainedVariableId first, const std::vector& seconds, std::vector& domains) = 0; @@ -78,7 +78,7 @@ namespace EUROPA{ * @param ubs The returned upper-bound signs as numbers with correct signs but arbitrary values. */ //it's posible that these numbers don't need to be eints - virtual void getTemporalDistanceSigns(const ConstrainedVariableId& first, + virtual void getTemporalDistanceSigns(const ConstrainedVariableId first, const std::vector& seconds, std::vector& lbs, diff --git a/src/PLASMA/PlanDatabase/base/Token.cc b/src/PLASMA/PlanDatabase/base/Token.cc index 5e5cdd5ca..2f26eecfd 100644 --- a/src/PLASMA/PlanDatabase/base/Token.cc +++ b/src/PLASMA/PlanDatabase/base/Token.cc @@ -12,13 +12,13 @@ #include "ConstraintType.hh" #include "Utils.hh" #include "Debug.hh" +#include "CESchema.hh" #include /** * @author Conor McGann */ -#define MERGING 1 namespace EUROPA{ @@ -33,32 +33,32 @@ namespace EUROPA{ StateDomain::StateDomain(const Domain& org) : EnumeratedDomain(org) { - check_error(org.getTypeName().toString() == SymbolDT::NAME(), - "Attempted to construct a StateDomain with invalid type " + org.getTypeName().toString()); + check_error(org.getTypeName() == SymbolDT::NAME(), + "Attempted to construct a StateDomain with invalid type " + org.getTypeName()); } - void StateDomain::operator>>(ostream&os) const { - // Now commence output - Domain::operator>>(os); - os << "{"; +void StateDomain::operator>>(ostream&os) const { + // Now commence output + Domain::operator>>(os); + os << "{"; - // First construct a lexicographic ordering for the set of values. - std::set orderedSet; + // First construct a lexicographic ordering for the set of values. + std::set orderedSet; - for (std::set::const_iterator it = m_values.begin(); it != m_values.end(); ++it) { - LabelStr value = *it; - orderedSet.insert(value.toString()); - } - - std::string comma = ""; - for (std::set::const_iterator it = orderedSet.begin(); it != orderedSet.end(); ++it) { - os << comma << *it; - comma = ","; - } + for (std::set::const_iterator it = m_values.begin(); it != m_values.end(); ++it) { + LabelStr value = *it; + orderedSet.insert(value.toString()); + } - os << "}"; + std::string comma = ""; + for (std::set::const_iterator it = orderedSet.begin(); it != orderedSet.end(); ++it) { + os << comma << *it; + comma = ","; } + os << "}"; +} + /** * Allocate Constants for possible state variable values */ @@ -68,47 +68,88 @@ namespace EUROPA{ const LabelStr Token::MERGED("MERGED"); const LabelStr Token::REJECTED("REJECTED"); - const LabelStr& Token::noObject(){ - static const LabelStr sl_noObject("NO_OBJECT_ASSIGNED"); - return sl_noObject; - } +const std::string& Token::noObject(){ + static const std::string sl_noObject("NO_OBJECT_ASSIGNED"); + return sl_noObject; +} - Token::Token(const PlanDatabaseId& planDatabase, - const LabelStr& tokenTypeName, + Token::Token(const PlanDatabaseId planDatabase, + const std::string& tokenTypeName, bool rejectable, - bool isFact, + bool _isFact, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed) :Entity(), m_id(this), m_name(tokenTypeName), + m_master(), m_relation("none"), + m_baseObjectType(), m_predicateName(tokenTypeName), - m_planDatabase(planDatabase) { - commonInit(tokenTypeName, rejectable, isFact, durationBaseDomain, objectName, closed); - } - - // Slave tokens cannot be rejectable. - Token::Token(const TokenId& master, - const LabelStr& relation, - const LabelStr& tokenTypeName, - const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, - bool closed) - :Entity(), - m_id(this), - m_name(tokenTypeName), - m_master(master), - m_relation(relation), - m_predicateName(tokenTypeName), - m_planDatabase((*master).m_planDatabase) { + m_state(), + m_object(), + m_duration(), + m_isFact(false), + m_attributes(0), + m_parameters(), + m_allVariables(), + m_slaves(), + m_standardConstraints(), + m_pseudoVariables(), + m_planDatabase(planDatabase), + m_mergedTokens(), + m_activeToken(), + m_unifyMemento(), + m_committed(false), + m_deleted(false), + m_terminated(false), + m_localVariables(), + m_unqualifiedPredicateName() +{ + commonInit(tokenTypeName, rejectable, _isFact, durationBaseDomain, objectName, closed); + } + +// Slave tokens cannot be rejectable. +Token::Token(const TokenId _master, + const std::string& relation, + const std::string& tokenTypeName, + const IntervalIntDomain& durationBaseDomain, + const std::string& objectName, + bool closed) + :Entity(), + m_id(this), + m_name(tokenTypeName), + m_master(_master), + m_relation(relation), + m_baseObjectType(), + m_predicateName(tokenTypeName), + m_state(), + m_object(), + m_duration(), + m_isFact(false), + m_attributes(0), + m_parameters(), + m_allVariables(), + m_slaves(), + m_standardConstraints(), + m_pseudoVariables(), + m_planDatabase((*_master).m_planDatabase), + m_mergedTokens(), + m_activeToken(), + m_unifyMemento(), + m_committed(false), + m_deleted(false), + m_terminated(false), + m_localVariables(), + m_unqualifiedPredicateName() +{ - // Master must be active to add children - check_error(m_master->isActive()); - m_master->add(m_id); - commonInit(tokenTypeName, false, false, durationBaseDomain, objectName, closed); - } + // Master must be active to add children + check_error(m_master->isActive()); + m_master->add(m_id); + commonInit(tokenTypeName, false, false, durationBaseDomain, objectName, closed); +} Token::~Token(){ discard(false); @@ -161,36 +202,33 @@ namespace EUROPA{ Entity::handleDiscard(); } - const TokenId& Token::getId() const { + const TokenId Token::getId() const { check_error(m_id.isValid()); return m_id; } - const TokenId& Token::master() const { + const TokenId Token::master() const { check_error(m_master.isNoId() || m_master.isValid()); return m_master; } - const LabelStr& Token::getRelation() const { - check_error(m_master.isNoId() || m_master.isValid()); - return m_relation; // returns "NONE" if m_master isNoId() - } +const std::string& Token::getRelation() const { + check_error(m_master.isNoId() || m_master.isValid()); + return m_relation; // returns "NONE" if m_master isNoId() +} /** * This works because we have key based comparators which allow us to rely on positions */ - const TokenId& Token::getSlave(int slavePosition) const{ - int i = 0; - for(TokenSet::const_iterator it = m_slaves.begin(); it != m_slaves.end(); ++it){ - if(i == slavePosition) - return *it; - else - i++; - } +const TokenId Token::getSlave(unsigned int slavePosition) const{ + if(slavePosition >= m_slaves.size()) return TokenId::noId(); - } + TokenSet::const_iterator it = m_slaves.begin(); + std::advance(it, slavePosition); + return *it; +} - int Token::getSlavePosition(const TokenId& slave) const{ + int Token::getSlavePosition(const TokenId slave) const{ int i = 0; for(TokenSet::const_iterator it = m_slaves.begin(); it != m_slaves.end(); ++it){ TokenId token = *it; @@ -202,29 +240,29 @@ namespace EUROPA{ return -1; } - const LabelStr& Token::getBaseObjectType() const {return m_baseObjectType;} +const std::string& Token::getBaseObjectType() const {return m_baseObjectType;} - const LabelStr& Token::getName() const { return m_name; } +const std::string& Token::getName() const { return m_name; } - void Token::setName(const LabelStr& name) { m_name = name; } +void Token::setName(const std::string& name) { m_name = name; } - const LabelStr& Token::getPredicateName() const {return m_predicateName;} +const std::string& Token::getPredicateName() const {return m_predicateName;} - const LabelStr& Token::getUnqualifiedPredicateName() const {return m_unqualifiedPredicateName;} +const std::string& Token::getUnqualifiedPredicateName() const {return m_unqualifiedPredicateName;} - const PlanDatabaseId& Token::getPlanDatabase() const { + const PlanDatabaseId Token::getPlanDatabase() const { check_error(m_planDatabase.isValid()); return m_planDatabase; } - const StateVarId& Token::getState() const{ + const StateVarId Token::getState() const{ checkError(m_state.isValid(), m_state); return m_state; } - const ObjectVarId& Token::getObject() const{ + const ObjectVarId Token::getObject() const{ checkError(m_object.isValid(), m_object); return m_object; } - const TempVarId& Token::duration() const{ + const TempVarId Token::duration() const{ checkError(m_duration.isValid(), m_duration); return m_duration; } @@ -232,9 +270,10 @@ namespace EUROPA{ const std::vector& Token::getVariables() const {return m_allVariables;} const TokenSet& Token::slaves() const {return m_slaves;} const TokenSet& Token::getMergedTokens() const {return m_mergedTokens;} - const TokenId& Token::getActiveToken() const {return m_activeToken;} + const TokenId Token::getActiveToken() const {return m_activeToken;} - const ConstrainedVariableId Token::getVariable(const LabelStr& name, bool checkGlobalContext) const{ +const ConstrainedVariableId Token::getVariable(const std::string& name, + bool checkGlobalContext) const{ const std::vector& vars = getVariables(); for(std::vector::const_iterator it = vars.begin(); it != vars.end(); ++it){ @@ -250,7 +289,7 @@ namespace EUROPA{ return ConstrainedVariableId::noId(); } - void Token::add(const TokenId& slave){ + void Token::add(const TokenId slave){ check_error(!isIncomplete()); check_error(m_slaves.find(slave) == m_slaves.end()); check_error(slave->getPlanDatabase() == m_planDatabase); @@ -258,7 +297,7 @@ namespace EUROPA{ m_slaves.insert(slave); } - void Token::remove(const TokenId& slave){ + void Token::remove(const TokenId slave){ check_error(!Entity::isPurging()); check_error(!isIncomplete()); @@ -314,30 +353,34 @@ namespace EUROPA{ check_error(ALWAYS_FAILS); } - void Token::doMerge(const TokenId& activeToken){ - check_error(isValid()); - check_error(isInactive()); - check_error(activeToken.isValid()); - check_error(activeToken->isActive()); - checkError(m_state->lastDomain().isMember(MERGED), "Not permitted to merge." << toString()); - check_error(getPlanDatabase()->getSchema()->isA(activeToken->getPredicateName(), m_predicateName), - "Cannot merge tokens with different predicates: " + - m_predicateName.toString() + ", " + activeToken->getPredicateName().toString()); - - m_state->setSpecified(MERGED); - m_unifyMemento = UnifyMementoId(new UnifyMemento(m_id, activeToken)); - m_activeToken = activeToken; - m_activeToken->addMergedToken(m_id); - - /** Send a message to all objects that it has been rejected **/ - const std::set& objects = getObject()->getBaseDomain().getValues(); - for(std::set::const_iterator it = objects.begin(); it!= objects.end(); ++it){ - ObjectId object = Entity::getTypedEntity(*it); - object->notifyMerged(m_id); - } - - m_planDatabase->notifyMerged(m_id); - } +void Token::doMerge(const TokenId activeToken){ + check_error(isValid()); + check_error(isInactive()); + check_error(activeToken.isValid()); + check_error(activeToken->isActive()); + checkError(m_state->lastDomain().isMember(MERGED), + "Not permitted to merge." << toString()); + check_error(getPlanDatabase()->getSchema()->isA(activeToken->getPredicateName(), m_predicateName), + "Cannot merge tokens with different predicates: " + + m_predicateName + ", " + activeToken->getPredicateName()); + checkError((isFact() && activeToken->isFact()) || true, + "Cannot merge fact " << toString() << " onto non-fact " << + activeToken->toString()); + + m_state->setSpecified(MERGED); + m_unifyMemento = UnifyMementoId(new UnifyMemento(m_id, activeToken)); + m_activeToken = activeToken; + m_activeToken->addMergedToken(m_id); + + /** Send a message to all objects that it has been rejected **/ + const std::set& objects = getObject()->getBaseDomain().getValues(); + for(std::set::const_iterator it = objects.begin(); it!= objects.end(); ++it){ + ObjectId object = Entity::getTypedEntity(*it); + object->notifyMerged(m_id); + } + + m_planDatabase->notifyMerged(m_id); +} void Token::split(){ check_error(isValid()); @@ -434,12 +477,12 @@ namespace EUROPA{ m_planDatabase->notifyDeactivated(m_id); } - void Token::addStandardConstraint(const ConstraintId& constraint) + void Token::addStandardConstraint(const ConstraintId constraint) { m_standardConstraints.insert(constraint); } - bool Token::isStandardConstraint(const ConstraintId& constraint) const{ + bool Token::isStandardConstraint(const ConstraintId constraint) const{ return(m_standardConstraints.find(constraint) != m_standardConstraints.end()); } @@ -505,17 +548,17 @@ namespace EUROPA{ /** * @todo - add typechecking here */ - void Token::commonInit(const LabelStr& predicateName, +void Token::commonInit(const std::string& predicateName, bool rejectable, - bool isFact, + bool _isFact, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed){ // The plan database must be valid check_error(m_planDatabase.isValid()); - if(predicateName.countElements(".") == 2) - m_unqualifiedPredicateName = predicateName.getElement(1, "."); + if(std::count(predicateName.begin(), predicateName.end(), '.') == 1) + m_unqualifiedPredicateName = predicateName.substr(predicateName.find('.') + 1); else m_unqualifiedPredicateName = predicateName; @@ -524,12 +567,12 @@ namespace EUROPA{ m_terminated = false; m_isFact = false; - if (isFact) + if (_isFact) makeFact(); debugMsg("Token:commonInit", - "Initializing token (" << getKey() << ") for predicate " << predicateName.toString() - << " on object " << objectName.toString()); + "Initializing token (" << getKey() << ") for predicate " << predicateName + << " on object " << objectName); // Allocate the state variable with initial base domain. StateDomain stateBaseDomain; @@ -542,27 +585,27 @@ namespace EUROPA{ stateBaseDomain, false, // TODO: fixme false, - LabelStr("state")))->getId(); + "state"))->getId(); m_allVariables.push_back(m_state); // If present the schema must be valid and the predicate must be OK. check_error(m_planDatabase->getSchema().isNoId() || m_planDatabase->getSchema()->isPredicate(predicateName), - "Invalid predicate: " + predicateName.toString()); + "Invalid predicate: " + predicateName); // Allocate an object variable with an empty domain m_baseObjectType = m_planDatabase->getSchema()->getObjectTypeForPredicate(m_predicateName); - const DataTypeId& dt = m_planDatabase->getSchema()->getCESchema()->getDataType(m_baseObjectType.c_str()); + const DataTypeId dt = m_planDatabase->getSchema()->getCESchema()->getDataType(m_baseObjectType.c_str()); m_object = (new TokenVariable(m_id, m_allVariables.size(), m_planDatabase->getConstraintEngine(), ObjectDomain(dt), false, // TODO: fixme true, - LabelStr("object")))->getId(); + "object"))->getId(); checkError(m_planDatabase->hasObjectInstances(m_baseObjectType), - "Allocated a token with no object instance available of type " << m_baseObjectType.toString()); + "Allocated a token with no object instance available of type " << m_baseObjectType); // Call the plan database to fill it in, and maintain synchronization for dynamic objects m_planDatabase->makeObjectVariableFromType(m_baseObjectType, m_object); @@ -585,7 +628,7 @@ namespace EUROPA{ durationBaseDomain, false, // TODO: fixme true, - LabelStr("duration")))->getId(); + "duration"))->getId(); m_allVariables.push_back(m_duration); @@ -613,7 +656,7 @@ namespace EUROPA{ check_error(isValid()); } - void Token::handleAdditionOfInactiveConstraint(const ConstraintId& constraint){ + void Token::handleAdditionOfInactiveConstraint(const ConstraintId constraint){ check_error(constraint.isValid()); check_error(isMerged()); @@ -621,7 +664,7 @@ namespace EUROPA{ m_unifyMemento->handleAdditionOfInactiveConstraint(constraint); } - void Token::handleRemovalOfInactiveConstraint(const ConstraintId& constraint){ + void Token::handleRemovalOfInactiveConstraint(const ConstraintId constraint){ check_error(constraint.isValid()); check_error(isMerged()); @@ -724,110 +767,113 @@ namespace EUROPA{ * @brief Tests if a token can be terminated. * @see terminate */ - bool Token::canBeTerminated(eint tick) const{ - if(isTerminated()) +bool Token::canBeTerminated(eint) const{ + if(isTerminated()) + return false; + + // Rejected tokens can be immediately terminated without any consideration of their variables or their constraints + if(isRejected()) + return true; + + // Now if it has any merged tokens, it cannot be terminated. The merged tokens must be removed first + if(!m_mergedTokens.empty()){ + debugMsg("Token:canBeTerminated", + "Cannot terminate " << toString() << + " because of remaining supported token " << + (*m_mergedTokens.begin())->toString()); + return false; + } + + // Use this count for iteration later + const unsigned long varCount = m_allVariables.size(); + + // If merged, it is redundant if the variables in its scope are supersets of the corresponding active token variable base domain + if(isMerged()){ + TokenId activeToken = getActiveToken(); + + // No basis for termination if active token is not committed. + if(!activeToken->isCommitted()){ + debugMsg("Token:canBeTerminated", "Cannot terminate " << toString() << " which is a slave of " << m_master->toString()); return false; + } - // Rejected tokens can be immediately terminated without any consideration of their variables or their constraints - if(isRejected()) + // Definitiely can terminate if the active token is terminated + if(activeToken->isTerminated()) return true; - // Now if it has any merged tokens, it cannot be terminated. The merged tokens must be removed first - if(!m_mergedTokens.empty()){ - debugMsg("Token:canBeTerminated", "Cannot terminate " << toString() << " because of remaining supported token " << ((TokenId) * (m_mergedTokens.begin()))->toString() ); - return false; + // Finally, we have to analyze the variables to see if the merged token is imposing restrictions on the active token + // that would be lost if it were removed. The anaylsis will check that the base domain of the active token is a subset of the + // derived domain of the merged token. + const std::vector& activeVariables = activeToken->getVariables(); + // All variables except state variable + for(unsigned int i = 1; i < varCount; i++){ + const Domain& activeBaseDomain = activeVariables[i]->baseDomain(); + const Domain& inactiveDerivedDomain = m_allVariables[i]->lastDomain(); + if(!activeBaseDomain.isSubsetOf(inactiveDerivedDomain)){ + debugMsg("Token:canBeTerminated", + "Cannot terminate " << this->toString() << activeBaseDomain.toString() << " can be further restricted by " << inactiveDerivedDomain.toString() << std::endl << + "Active Variable: " << activeVariables[i]->toString() << " Inactive Variable: " << m_allVariables[i]->toString()); + + return false; + } } - // Use this count for iteration later - const unsigned int varCount = m_allVariables.size(); + return true; + } - // If merged, it is redundant if the variables in its scope are supersets of the corresponding active token variable base domain - if(isMerged()){ - TokenId activeToken = getActiveToken(); + // + // Declare a set to pull together all variables in the scope of a token into a single easy to check collection. + // Could manage this incrementally on the token also for greater efficiency + std::set allVars; - // No basis for termination if active token is not committed. - if(!activeToken->isCommitted()){ - debugMsg("Token:canBeTerminated", "Cannot terminate " << toString() << " which is a slave of " << m_master->toString()); - return false; - } + // Construct the set of constraints on variables of this token. Use a constraint set to avoid memory dependent order. + ConstraintSet constraints; + for(unsigned int i = 0; i < varCount; i++){ + ConstrainedVariableId var = m_allVariables[i]; + var->constraints(constraints); + allVars.insert(var->getKey()); + } - // Definitiely can terminate if the active token is terminated - if(activeToken->isTerminated()) - return true; - - // Finally, we have to analyze the variables to see if the merged token is imposing restrictions on the active token - // that would be lost if it were removed. The anaylsis will check that the base domain of the active token is a subset of the - // derived domain of the merged token. - const std::vector& activeVariables = activeToken->getVariables(); - // All variables except state variable - for(unsigned int i = 1; i < varCount; i++){ - const Domain& activeBaseDomain = activeVariables[i]->baseDomain(); - const Domain& inactiveDerivedDomain = m_allVariables[i]->lastDomain(); - if(!activeBaseDomain.isSubsetOf(inactiveDerivedDomain)){ - debugMsg("Token:canBeTerminated", - "Cannot terminate " << this->toString() << activeBaseDomain.toString() << " can be further restricted by " << inactiveDerivedDomain.toString() << std::endl << - "Active Variable: " << activeVariables[i]->toString() << " Inactive Variable: " << m_allVariables[i]->toString()); - - return false; - } - } + for(ConstrainedVariableSet::const_iterator it = m_localVariables.begin(); it != m_localVariables.end(); ++it){ + ConstrainedVariableId var = *it; + var->constraints(constraints); + allVars.insert(var->getKey()); + } - return true; - } + for(ConstraintSet::const_iterator it = constraints.begin(); it != constraints.end(); ++it){ + ConstraintId constraint = *it; + checkError(constraint.isValid(), constraint); - // - // Declare a set to pull together all variables in the scope of a token into a single easy to check collection. - // Could manage this incrementally on the token also for greater efficiency - std::set allVars; + // No problem if the constraint has been deactivated already + if(!constraint->isActive() || constraint->isRedundant()) + continue; - // Construct the set of constraints on variables of this token. Use a constraint set to avoid memory dependent order. - ConstraintSet constraints; - for(unsigned int i = 0; i < varCount; i++){ - ConstrainedVariableId var = m_allVariables[i]; - var->constraints(constraints); - allVars.insert(var->getKey()); - } + // If it is active, then we should ensure it has at least one external variable + const std::vector& scope = constraint->getScope(); + for(unsigned int i=0;iconstraints(constraints); - allVars.insert(var->getKey()); - } + // If the variable has no parent, its scope is not defined temporally. This is typically only arising + // in initialization. + if (var->parent().isNoId()) + continue; - for(ConstraintSet::const_iterator it = constraints.begin(); it != constraints.end(); ++it){ - ConstraintId constraint = *it; - checkError(constraint.isValid(), constraint); - - // No problem if the constraint has been deactivated already - if(!constraint->isActive() || constraint->isRedundant()) - continue; - - // If it is active, then we should ensure it has at least one external variable - const std::vector& scope = constraint->getScope(); - for(unsigned int i=0;iparent().isNoId()) - continue; - - // If it is a culprit with an unbound domain, and an external variable, - // then it is an external constraint that must be retained and so we cannot terminate - if(allVars.find(var->getKey()) == allVars.end() && !var->baseDomain().isSingleton()){ - debugMsg("Token:canBeTerminated", - "Cannot terminate " << toString() << ". " - << var->toString() << " has an active external constraint " - << constraint->toString() << "."); - - return false; - } + // If it is a culprit with an unbound domain, and an external variable, + // then it is an external constraint that must be retained and so we cannot terminate + if(allVars.find(var->getKey()) == allVars.end() && !var->baseDomain().isSingleton()){ + debugMsg("Token:canBeTerminated", + "Cannot terminate " << toString() << ". " + << var->toString() << " has an active external constraint " + << constraint->toString() << "."); + + return false; } } - - return true; } + return true; +} + void Token::terminate(){ // Set this flag immediately so that other tokens can evaluate its state when we are dealing with cascaded effects m_terminated = true; @@ -883,7 +929,7 @@ namespace EUROPA{ return true; } - bool Token::canBeCompared(const EntityId& entity) const{ + bool Token::canBeCompared(const EntityId entity) const{ return TokenId::convertable(entity); } @@ -892,19 +938,19 @@ namespace EUROPA{ m_planDatabase->notifyActivated(m_id); } - void Token::addMergedToken(const TokenId& token){ + void Token::addMergedToken(const TokenId token){ checkError(isActive(), "Must be ative to merge onto it."); m_mergedTokens.insert(token); incRefCount(); } - bool Token::removeMergedToken(const TokenId& token){ + bool Token::removeMergedToken(const TokenId token){ checkError(isActive(), "Must be ative to merge onto it."); m_mergedTokens.erase(token); return decRefCount(); } - bool Token::removeMaster(const TokenId& token){ + bool Token::removeMaster(const TokenId token){ checkError(m_master.isValid(), "Master is not present or not valid."); checkError(m_master == token, "Trying to remove " << token->toString() << " instead of " << m_master->toString()); m_master = TokenId::noId(); @@ -926,8 +972,8 @@ namespace EUROPA{ return willBeDiscarded; } - bool Token::isStateVariable(const ConstrainedVariableId& var){ - static const LabelStr sl_stateStr("state"); + bool Token::isStateVariable(const ConstrainedVariableId var){ + static const std::string sl_stateStr("state"); bool result = (var->getName() == sl_stateStr); @@ -937,11 +983,11 @@ namespace EUROPA{ return result; } - void Token::addLocalVariable(const ConstrainedVariableId& var){ + void Token::addLocalVariable(const ConstrainedVariableId var){ m_localVariables.insert(var); } - void Token::removeLocalVariable(const ConstrainedVariableId& var){ + void Token::removeLocalVariable(const ConstrainedVariableId var){ m_localVariables.erase(var); } @@ -950,14 +996,14 @@ namespace EUROPA{ } - LabelStr Token::makePseudoVarName(){ - static int sl_varKey(0); - static std::string sl_prefix("PSEUDO_VARIABLE_"); - std::stringstream ss; - ss << sl_prefix; - ss << sl_varKey++; - return ss.str(); - } +std::string Token::makePseudoVarName(){ + static int sl_varKey(0); + static std::string sl_prefix("PSEUDO_VARIABLE_"); + std::stringstream ss; + ss << sl_prefix; + ss << sl_varKey++; + return ss.str(); +} // PS Methods: const std::string& Token::getEntityType() const @@ -968,11 +1014,11 @@ const std::string& Token::getEntityType() const std::string Token::getTokenType() const { - return getUnqualifiedPredicateName().toString(); + return getUnqualifiedPredicateName(); } std::string Token::getFullTokenType() const { - return getPredicateName().toString(); + return getPredicateName(); } PSObject* Token::getOwner() const { @@ -981,16 +1027,16 @@ PSObject* Token::getOwner() const { ObjectVarId objVar = getObject(); ObjectId id = Entity::getTypedEntity(objVar->lastDomain().getSingletonValue()); - return (PSObject *) id; + return id_cast(id); // return new PSObject(ObjectId(objVar->lastDomain().getSingletonValue())); } PSToken* Token::getMaster() const { - TokenId m = master(); - if (m.isNoId()) - return NULL; - - return (PSToken *) m; + TokenId m = master(); + if (m.isNoId()) + return NULL; + + return id_cast(m); } PSList Token::getSlaves() const { @@ -1000,14 +1046,14 @@ PSList Token::getSlaves() const { for(TokenSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it) { TokenId id = *it; //PSToken* tok = new PSToken(*it); - retval.push_back((PSToken *) id); + retval.push_back(id_cast(id)); } return retval; } PSToken* Token::getActive() const { - return (PSToken*)((Token*)getActiveToken()); + return id_cast(getActiveToken()); } PSList Token::getMerged() const @@ -1023,47 +1069,36 @@ PSList Token::getMerged() const } -PSTokenState Token::getTokenState() const -{ - if (isActive()) - return EUROPA::ACTIVE; +PSTokenState Token::getTokenState() const { + if (isActive()) + return EUROPA::ACTIVE; - if (isInactive()) - return EUROPA::INACTIVE; + if (isInactive()) + return EUROPA::INACTIVE; - if (isMerged()) - return EUROPA::MERGED; + if (isMerged()) + return EUROPA::MERGED; - if (isRejected()) - return EUROPA::REJECTED; + if (isRejected()) + return EUROPA::REJECTED; - check_error(ALWAYS_FAIL,"Unknown token state"); - return EUROPA::INACTIVE; + check_runtime_error(ALWAYS_FAIL,"Unknown token state"); } -PSVariable* Token::getStart() const -{ - return (PSVariable *) start(); -} +PSVariable* Token::getStart() const {return id_cast(start());} -PSVariable* Token::getEnd() const -{ - return (PSVariable *) end(); -} +PSVariable* Token::getEnd() const {return id_cast(end());} -PSVariable* Token::getDuration() const -{ - return (PSVariable *) duration(); -} +PSVariable* Token::getDuration() const {return id_cast(duration());} -PSList Token::getParameters() const -{ + +PSList Token::getParameters() const { PSList retval; const std::vector& vars = getVariables(); for(std::vector::const_iterator it = vars.begin(); it != vars.end();++it) { - ConstrainedVariableId id = *it; - PSVariable* psVar = (PSVariable *) id; - retval.push_back(psVar); + ConstrainedVariableId id = *it; + PSVariable* psVar = id_cast(id); + retval.push_back(psVar); } return retval; } @@ -1073,23 +1108,21 @@ PSList Token::getPredicateParameters() const { const std::vector& vars = parameters(); for(std::vector::const_iterator it = vars.begin(); it != vars.end();++it) { ConstrainedVariableId id = *it; - PSVariable* psVar = (PSVariable *) id; + PSVariable* psVar = id_cast(id); retval.push_back(psVar); } return retval; } -PSVariable* Token::getParameter(const std::string& name) const -{ - LabelStr realName(name); +PSVariable* Token::getParameter(const std::string& name) const { PSVariable* retval = NULL; const std::vector& vars = getVariables(); for(std::vector::const_iterator it = vars.begin(); it != vars.end(); - ++it) { - ConstrainedVariableId id = *it; - if((*it)->getName() == realName) { - retval = (PSVariable *) id; - break; + ++it) { + ConstrainedVariableId id = *it; + if((*it)->getName() == name) { + retval = id_cast(id); + break; } } return retval; @@ -1102,38 +1135,38 @@ void Token::merge(PSToken* activeToken) doMerge(tok); } -PSList Token::getCompatibleTokens(unsigned int limit, bool useExactTest) -{ - std::vector tokens; - getPlanDatabase()->getCompatibleTokens(this,tokens,limit,useExactTest); - PSList retval; - - for(unsigned int i=0;i Token::getCompatibleTokens(unsigned int limit, bool useExactTest) { + std::vector tokens; + getPlanDatabase()->getCompatibleTokens(this,tokens,limit,useExactTest); + PSList retval; + + for(unsigned int i=0;i(id)); + } + + return retval; } -std::string attrsToString(int attrs) -{ - std::ostringstream os; +namespace { +std::string attrsToString(int attrs) { + std::ostringstream os; - os << "{"; + os << "{"; - if (attrs & PSTokenType::ACTION) - os << " ACTION"; - if (attrs & PSTokenType::PREDICATE) - os << " PREDICATE"; - if (attrs & PSTokenType::CONDITION) - os << " CONDITION"; - if (attrs & PSTokenType::EFFECT) - os << " EFFECT"; + if (attrs & PSTokenType::ACTION) + os << " ACTION"; + if (attrs & PSTokenType::PREDICATE) + os << " PREDICATE"; + if (attrs & PSTokenType::CONDITION) + os << " CONDITION"; + if (attrs & PSTokenType::EFFECT) + os << " EFFECT"; - os << " }"; + os << " }"; - return os.str(); + return os.str(); +} } std::string Token::toLongString() const diff --git a/src/PLASMA/PlanDatabase/base/Token.hh b/src/PLASMA/PlanDatabase/base/Token.hh index 9b97cb881..5853a44c2 100644 --- a/src/PLASMA/PlanDatabase/base/Token.hh +++ b/src/PLASMA/PlanDatabase/base/Token.hh @@ -1,5 +1,5 @@ -#ifndef _H_Token -#define _H_Token +#ifndef H_Token +#define H_Token /** * @author Conor McGann @@ -7,8 +7,6 @@ #include "PlanDatabaseDefs.hh" #include "UnifyMemento.hh" -#include "StackMemento.hh" -#include "MergeMemento.hh" #include "Schema.hh" #include "Entity.hh" #include "LabelStr.hh" @@ -58,48 +56,48 @@ namespace EUROPA { /** * @brief Get the internal Id. */ - const TokenId& getId() const; + const TokenId getId() const; /** * @brief Get the name */ - const LabelStr& getName() const; + const std::string& getName() const; /** * @brief Set the name */ - void setName(const LabelStr& name); + void setName(const std::string& name); /** * @brief Accessor for the master token for this token. * @return TokenId::noId() if this is a Master Token, otherwise returns the Token from * which this token was sub-goaled. */ - const TokenId& master() const; + const TokenId master() const; /** * @brief Accessor for the relation to the master token. * @return one of the supported allen relations (see documentation) */ - const LabelStr& getRelation() const; + const std::string& getRelation() const; /** * @brief Obtain a slave token using a positional offset from this token * @return TokenId::noId() if no token is found at that location */ - const TokenId& getSlave(int slavePosition) const; + const TokenId getSlave(unsigned int slavePosition) const; /** * @brief Obtain the position of the given slave token in its ordered set of slaves. * @param slave The slave token to be found. It must be present. * @return Will return -1 if not found, otherwise will give the 0 based position. */ - int getSlavePosition(const TokenId& slave) const; + int getSlavePosition(const TokenId slave) const; /** * @brief All tokens are part of exactly one PlanDatabase */ - const PlanDatabaseId& getPlanDatabase() const; + const PlanDatabaseId getPlanDatabase() const; /** * @brief Access to the base type of the predicate. @@ -107,7 +105,7 @@ namespace EUROPA { * Note that since we have an inheritance mechanism, the token may actually be associated with an instance of a derived * class. */ - const LabelStr& getBaseObjectType() const; + const std::string& getBaseObjectType() const; /** * @brief Access the predicate name for the token. @@ -115,12 +113,12 @@ namespace EUROPA { * This information is used for type checking with respect to the schema and is essential to the semantics of the token. * @see Schema::isPredicateDefined, Schema::canBeAssigned, Schema::canContain */ - const LabelStr& getPredicateName() const; + const std::string& getPredicateName() const; /** * @brief Access to the unqualified predicate name (if it has delimiters they are stripped). */ - const LabelStr& getUnqualifiedPredicateName() const; + const std::string& getUnqualifiedPredicateName() const; /** * @brief Obtain the variable used to store reachable states. The full domain is INCOMPLETE, ACTIVE, MERGED and REJECTED. @@ -128,30 +126,30 @@ namespace EUROPA { * Operations controlling the lifecyle of the token control this variable. It cannot be specified directly. * @see close, activate, merge, reject, cancel. */ - const StateVarId& getState() const; + const StateVarId getState() const; /** * @brief In a fully grounded plan, a Token is assigned to a single object. The domain of this variable indicates * the possible assigments remaining. */ - const ObjectVarId& getObject() const; + const ObjectVarId getObject() const; /** * @brief The start variable is a pure virtual function since we derived classes with no duration * may have an optimized implementation that shares start and end variable as the same variable. */ - virtual const TempVarId& start() const = 0; + virtual const TempVarId start() const = 0; /** * @brief The end variable is a pure virtual function since we derived classes with no duration * may have an optimized implementation that shares start and end variable as the same variable. */ - virtual const TempVarId& end() const = 0; + virtual const TempVarId end() const = 0; /** * @brief All Tokens will have a temporal duration. */ - const TempVarId& duration() const; + const TempVarId duration() const; /** * @brief Access all Parameter variables for the token. May be empty. @@ -166,7 +164,7 @@ namespace EUROPA { /** * @brief Access all variables (state, object, start, end, duration, parameters). */ - const ConstrainedVariableId getVariable(const LabelStr& name, bool checkGlobalContext=true) const; + const ConstrainedVariableId getVariable(const std::string& name, bool checkGlobalContext=true) const; /** * @brief Access all tokens generated as sub-goals of this token. @@ -181,17 +179,17 @@ namespace EUROPA { /** * @brief Access the active token supporting this token, if this is a merged token. */ - const TokenId& getActiveToken() const; + const TokenId getActiveToken() const; /** * @brief add a built in constraint for the token */ - void addStandardConstraint(const ConstraintId& constraint); + void addStandardConstraint(const ConstraintId constraint); /** * @brief Test if a given constraint is a built in constraint for the token */ - bool isStandardConstraint(const ConstraintId& constraint) const; + bool isStandardConstraint(const ConstraintId constraint) const; /** * @brief Internally generated constraints that are standard across Token instances of the same type. @@ -298,7 +296,7 @@ namespace EUROPA { * @pre isInactive * @post isMerged */ - void doMerge(const TokenId& activeToken); + void doMerge(const TokenId activeToken); /** * @brief Activate a token, thereby inserting it into the plan. @@ -331,12 +329,12 @@ namespace EUROPA { /** * @brief Invoked when a constraint is added to a merged token */ - void handleAdditionOfInactiveConstraint(const ConstraintId& constraint); + void handleAdditionOfInactiveConstraint(const ConstraintId constraint); /** * @brief Invoked when a constaint is removed from a merged token */ - void handleRemovalOfInactiveConstraint(const ConstraintId& constraint); + void handleRemovalOfInactiveConstraint(const ConstraintId constraint); /** * @brief Test of the token is assigned to an object. @@ -361,37 +359,37 @@ namespace EUROPA { /** * @brief Test if the variable is a token state variable */ - static bool isStateVariable(const ConstrainedVariableId& var); + static bool isStateVariable(const ConstrainedVariableId var); - void addLocalVariable(const ConstrainedVariableId& var); - void removeLocalVariable(const ConstrainedVariableId& var); + void addLocalVariable(const ConstrainedVariableId var); + void removeLocalVariable(const ConstrainedVariableId var); const ConstrainedVariableSet& getLocalVariables(); - static const LabelStr& noObject(); + static const std::string& noObject(); /** * @brief Utility for allocating pseudo variable names such that there are no duplicates. Duplicates can be dangerous * since associative maps look up variables by name and can lead to mix-ups. */ - static LabelStr makePseudoVarName(); + static std::string makePseudoVarName(); /** * @brief Add a parameter as a member to the object. This is used when building the instance * and cannot be called once the specific token instance has been closed. + * Errors: If a parameter of the given type with the given name cannot be added * @param baseDomain The base domain to use to populate the variable * @param name The member name - * @error If a parameter of the given type with the given name cannot be added * @see Scheme::hasMember, Schema::canContain, Token::close() */ template - ConstrainedVariableId addParameter(const DomainType& baseDomain, const LabelStr& name){ + ConstrainedVariableId addParameter(const DomainType& baseDomain, const std::string& name){ check_error(isIncomplete(), - "Cannot add parameter " + name.toString() + + "Cannot add parameter " + name + " after completing token construction."); check_error(m_planDatabase->getSchema()->canContain(m_predicateName, baseDomain.getTypeName(), name), - "Predicate '" + m_predicateName.toString() + - "' cannot contain parameter '" + name.toString() + "'"); + "Predicate '" + m_predicateName + + "' cannot contain parameter '" + name + "'"); ConstrainedVariableId id = (new TokenVariable(m_id, m_allVariables.size(), @@ -408,14 +406,14 @@ namespace EUROPA { /** * @brief Tests if the given entity can be compared to this token */ - bool canBeCompared(const EntityId& entity) const; + bool canBeCompared(const EntityId entity) const; /** * @brief Indicates the master token is being removed. Token may self-destruct. * @param token The token just unmerged * @return true if the token self-destructed */ - bool removeMaster(const TokenId& token); + bool removeMaster(const TokenId token); virtual std::string toLongString() const; @@ -451,22 +449,22 @@ namespace EUROPA { /** * @brief Constructor for master token creation. */ - Token(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + Token(const PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed); /** * @brief Constructor for slave token creation. */ - Token(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, + Token(const TokenId master, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed); /** @@ -476,8 +474,8 @@ namespace EUROPA { void deactivate(); void reinstate(); - void add(const TokenId& slave); - void remove(const TokenId& slave); + void add(const TokenId slave); + void remove(const TokenId slave); /** * Used to allow derived classes to restrict state on creation. @@ -488,21 +486,21 @@ namespace EUROPA { * @brief Will insert token in set of merged tokens. * @param token The merged token */ - void addMergedToken(const TokenId& token); + void addMergedToken(const TokenId token); /** * @brief Will remove the token from the set of merged tokens. Token may self-destruct. * @param token The token just unmerged * @return true if the token self-destructed */ - bool removeMergedToken(const TokenId& token); + bool removeMergedToken(const TokenId token); TokenId m_id; - LabelStr m_name; + std::string m_name; TokenId m_master; - LabelStr m_relation; - LabelStr m_baseObjectType; - LabelStr m_predicateName; + std::string m_relation; + std::string m_baseObjectType; + std::string m_predicateName; StateVarId m_state; /*!< state variable for token.*/ ObjectVarId m_object; /*!< object variable for token. The set of objects it may be assigned to. */ TempVarId m_duration; /*!< The duration of the token. [0 +inf]. */ @@ -533,11 +531,11 @@ namespace EUROPA { * @brief Shared initialization code across master and slave constructors * @see Token::Token */ - void commonInit(const LabelStr& predicateName, + void commonInit(const std::string& predicateName, bool rejectable, bool isFact, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed); /** @@ -550,13 +548,12 @@ namespace EUROPA { TokenId m_activeToken; UnifyMementoId m_unifyMemento; bool m_committed; - unsigned int m_refCount; /*!< The number of sources requiring existence of the token */ bool m_deleted; bool m_terminated; ConstrainedVariableSet m_localVariables; /*!< Variables created external to the token but related to it. They are not part of the predicate definition but may be derived from the model elsewhere such as via local rule variables.*/ - LabelStr m_unqualifiedPredicateName; + std::string m_unqualifiedPredicateName; }; class StateDomain : public EnumeratedDomain { diff --git a/src/PLASMA/PlanDatabase/base/TokenType.cc b/src/PLASMA/PlanDatabase/base/TokenType.cc index 9d9f4e5cd..84417fa54 100644 --- a/src/PLASMA/PlanDatabase/base/TokenType.cc +++ b/src/PLASMA/PlanDatabase/base/TokenType.cc @@ -3,15 +3,20 @@ #include "Token.hh" #include "Utils.hh" +#include + namespace EUROPA { - TokenType::TokenType(const ObjectTypeId& ot, const LabelStr& signature) +TokenType::TokenType(const ObjectTypeId ot, const std::string& signature) : m_id(this) , m_objType(ot) , m_signature(signature) + , m_predicateName() , m_attributes(0) + , m_args() + , m_subgoalsByAttr() { - m_predicateName = signature.getElement(1,"."); + m_predicateName = signature.substr(signature.find('.') + 1); } TokenType::~TokenType() @@ -19,53 +24,52 @@ namespace EUROPA { m_id.remove(); } - const TokenTypeId& TokenType::getId() const {return m_id;} + const TokenTypeId TokenType::getId() const {return m_id;} // TODO: should probably cache this?, maybe in the constructor? - const TokenTypeId& TokenType::getParentType() const { return m_objType->getParentType(getId()); } + const TokenTypeId TokenType::getParentType() const { return m_objType->getParentType(getId()); } - const ObjectTypeId& TokenType::getObjectType() const { return m_objType; } + const ObjectTypeId TokenType::getObjectType() const { return m_objType; } - const LabelStr& TokenType::getPredicateName() const { return m_predicateName; } + const std::string& TokenType::getPredicateName() const { return m_predicateName; } - const LabelStr& TokenType::getSignature() const {return m_signature;} + const std::string& TokenType::getSignature() const {return m_signature;} - const std::map& TokenType::getArgs() const { return m_args; } +const std::map& TokenType::getArgs() const { return m_args; } // TODO: this should live in one place only static RestrictedDT StateDT("TokenStates",SymbolDT::instance(),StateDomain()); - const DataTypeId& TokenType::getArgType(const char* argName) const - { - std::map::const_iterator it = m_args.find(argName); +const DataTypeId TokenType::getArgType(const std::string& argName) const { + std::map::const_iterator it = m_args.find(argName); - if (it != m_args.end()) - return it->second; + if (it != m_args.end()) + return it->second; - std::string name(argName); + std::string name(argName); - if (name == "state") - return StateDT.getId(); + if (name == "state") + return StateDT.getId(); - if (name == "object") - return m_objType->getVarType(); + if (name == "object") + return m_objType->getVarType(); - if (name=="start" || name=="end" || name=="duration") - return IntDT::instance(); + if (name=="start" || name=="end" || name=="duration") + return IntDT::instance(); - TokenTypeId parent = getParentType(); - if (parent.isId()) - return parent->getArgType(argName); + TokenTypeId parent = getParentType(); + if (parent.isId()) + return parent->getArgType(argName); - return DataTypeId::noId(); - } + return DataTypeId::noId(); +} - void TokenType::addArg(const DataTypeId& type, const LabelStr& name) + void TokenType::addArg(const DataTypeId type, const std::string& name) { checkRuntimeError(m_args.find(name) == m_args.end(), - m_objType->getName().toString() << "." << m_predicateName.toString() - << " already has a parameter called " << name.toString()); + m_objType->getName() << "." << m_predicateName + << " already has a parameter called " << name); m_args[name] = type; } @@ -89,66 +93,64 @@ namespace EUROPA { return (m_attributes & attrMask) == attrMask; } - std::string TokenType::toString() const - { - std::stringstream oss; - //oss << getId() << " - "; - oss << "\t" <::const_iterator it = m_args.begin(); it != m_args.end(); ++it) { - oss<< it->first.toString(); - oss<< " "; - } - oss<<")"; - - return oss.str(); +std::string TokenType::toString() const { + std::stringstream oss; + //oss << getId() << " - "; + oss << "\t" <::const_iterator it = m_args.begin(); it != m_args.end(); ++it) { + oss<< it->first; + oss<< " "; } + oss<<")"; - std::string TokenType::toLongString() const - { - std::stringstream oss; - //oss << getId() << " - "; - oss << "\t" <::const_iterator it = m_args.begin(); it != m_args.end(); ++it) { - oss<< it->first.toString(); - oss<< " "; + return oss.str(); +} + +std::string TokenType::toLongString() const { + std::stringstream oss; + //oss << getId() << " - "; + oss << "\t" <::const_iterator it = m_args.begin(); it != m_args.end(); ++it) { + oss<< it->first; + oss<< " "; + } + oss<<")"; + + /** + * TODO: condition on variable v and no effect changes v, then condition + * needs to be taken as an side-effect + */ + if(hasAttributes(PSTokenType::ACTION)){ + oss << ":" << std::endl; + + oss << "\t\t" << "Conditions:" << std::endl; + PSList conditions = getSubgoalsByAttr( PSTokenType::CONDITION); + + for ( int i = 0; i < conditions.size(); i++ ){ + TokenType* tt = boost::polymorphic_cast(conditions.get(i)); + oss << "\t\t\t"; + oss<< tt->toLongString(); } - oss<<")"; - - /** - * TODO: condition on variable v and no effect changes v, then condition - * needs to be taken as an side-effect - */ - if(hasAttributes(PSTokenType::ACTION)){ - oss << ":" << std::endl; - - oss << "\t\t" << "Conditions:" << std::endl; - PSList conditions = getSubgoalsByAttr( PSTokenType::CONDITION); - - for ( int i = 0; i < conditions.size(); i++ ){ - TokenType* tt = (TokenType*) conditions.get(i); - oss << "\t\t\t"; - oss<< tt->toLongString(); - } - oss << "\t\t" << "Effects:" << std::endl; - PSList effects = getSubgoalsByAttr( PSTokenType::EFFECT); + oss << "\t\t" << "Effects:" << std::endl; + PSList effects = getSubgoalsByAttr( PSTokenType::EFFECT); - for ( int i = 0; i < effects.size(); i++ ){ - TokenType* tt = (TokenType*) effects.get(i); - oss << "\t\t\t"; - oss<< tt->toLongString(); - } + for ( int i = 0; i < effects.size(); i++ ){ + TokenType* tt = boost::polymorphic_cast(effects.get(i)); + oss << "\t\t\t"; + oss<< tt->toLongString(); } - else - oss << std::endl; - - return oss.str(); } + else + oss << std::endl; + + return oss.str(); +} void TokenType::addSubgoalByAttr( TokenTypeId type, int attr ){ for( int attrMask = 1; attrMask <= attr; attrMask = attrMask << 1 ){ if( ( attr & attrMask ) == attrMask ){ - m_subgoalsByAttr[ attrMask ].push_back( (PSTokenType*) type ); + m_subgoalsByAttr[ attrMask ].push_back(id_cast(type)); } } } @@ -160,20 +162,20 @@ namespace EUROPA { return ( cit == m_subgoalsByAttr.end() ) ? retEmpty : cit->second ; } - PSList TokenType::getParameterNames() const { - PSList retval; - for (std::map::const_iterator it = m_args.begin(); it != m_args.end(); ++it) { - retval.push_back(it->first.toString()); - } - return retval; +PSList TokenType::getParameterNames() const { + PSList retval; + for (std::map::const_iterator it = m_args.begin(); it != m_args.end(); ++it) { + retval.push_back(it->first); } + return retval; +} - PSDataType* TokenType::getParameterType(int index) const { - check_error((unsigned int) index < m_args.size(), "Index out of bounds"); - std::map::const_iterator it = m_args.begin(); - while (index-- > 0) ++it; - return it->second; - } +PSDataType* TokenType::getParameterType(int index) const { + check_error(static_cast(index) < m_args.size(), "Index out of bounds"); + std::map::const_iterator it = m_args.begin(); + while (index-- > 0) ++it; + return it->second; +} PSDataType* TokenType::getParameterType(const std::string& name) const { return getArgType(name.c_str()); diff --git a/src/PLASMA/PlanDatabase/base/TokenType.hh b/src/PLASMA/PlanDatabase/base/TokenType.hh index 1f2b0ed99..6a14eb141 100644 --- a/src/PLASMA/PlanDatabase/base/TokenType.hh +++ b/src/PLASMA/PlanDatabase/base/TokenType.hh @@ -1,9 +1,8 @@ -#ifndef _H_TokenType -#define _H_TokenType +#ifndef H_TokenType +#define H_TokenType #include "PlanDatabaseDefs.hh" -#include "LabelStr.hh" -//#include "TokenTypeMgr.hh" +#include "PSList.hh" #include #include @@ -14,6 +13,7 @@ * @see DbClient */ namespace EUROPA { +class PSDataType; /** Version of TokenType for communication with other languages */ class PSTokenType { @@ -46,75 +46,76 @@ namespace EUROPA { /** * @brief Each concrete class must provide an implementation for this. */ - class TokenType: public PSTokenType { - public: - TokenType(const ObjectTypeId& ot,const LabelStr& signature); +class TokenType: public PSTokenType { + public: + TokenType(const ObjectTypeId ot,const std::string& signature); - virtual ~TokenType(); + virtual ~TokenType(); - void addArg(const DataTypeId& type, const LabelStr& name); + void addArg(const DataTypeId type, const std::string& name); - const LabelStr& getPredicateName() const; - std::string toString() const; - std::string toLongString() const; + const std::string& getPredicateName() const; + std::string toString() const; + std::string toLongString() const; - // From PSTokenType - const std::string& getName() const { return getPredicateName().toString(); } - const std::map& getArgs() const; - const DataTypeId& getArgType(const char* argName) const; + // From PSTokenType + const std::string& getName() const { return getPredicateName(); } + const std::map& getArgs() const; + const DataTypeId getArgType(const std::string& argName) const; - const TokenTypeId& getId() const; + const TokenTypeId getId() const; - const TokenTypeId& getParentType() const; + const TokenTypeId getParentType() const; - const ObjectTypeId& getObjectType() const; + const ObjectTypeId getObjectType() const; - /** - * @brief Return the type for which this type is registered. - */ - const LabelStr& getSignature() const; + /** + * @brief Return the type for which this type is registered. + */ + const std::string& getSignature() const; - /** - * @brief Create a root token instance - * @see DbClient::createInstance(const LabelStr& type, const LabelStr& name) - */ - virtual TokenId createInstance(const PlanDatabaseId& planDb, - const LabelStr& name, - bool rejectable = false, - bool isFact = false) const = 0; + /** + * @brief Create a root token instance + * @see DbClient::createInstance(const std::string& type, const std::string& name) + */ + virtual TokenId createInstance(const PlanDatabaseId planDb, + const std::string& name, + bool rejectable = false, + bool isFact = false) const = 0; - /** - * @brief Create a slave token - */ - virtual TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const = 0; + /** + * @brief Create a slave token + */ + virtual TokenId createInstance(const TokenId master, const std::string& name, + const std::string& relation) const = 0; - // From PSTokenType - virtual PSList getParameterNames() const; - virtual PSDataType* getParameterType(int index) const; - virtual PSDataType* getParameterType(const std::string& name) const; + // From PSTokenType + virtual PSList getParameterNames() const; + virtual PSDataType* getParameterType(int index) const; + virtual PSDataType* getParameterType(const std::string& name) const; - // See PSTokenType::TokenAttribute - virtual int getAttributes() const; - virtual void setAttributes(int attrs); - virtual void addAttributes(int attrMask); - virtual bool hasAttributes( int attrMask ) const; + // See PSTokenType::TokenAttribute + virtual int getAttributes() const; + virtual void setAttributes(int attrs); + virtual void addAttributes(int attrMask); + virtual bool hasAttributes( int attrMask ) const; - virtual PSList getSubgoalsByAttr( int attrMask ) const; + virtual PSList getSubgoalsByAttr( int attrMask ) const; - protected: + protected: - void addSubgoalByAttr( TokenTypeId type, int attr ); + void addSubgoalByAttr( TokenTypeId type, int attr ); - TokenTypeId m_id; - ObjectTypeId m_objType; - LabelStr m_signature; - LabelStr m_predicateName; - int m_attributes; - std::map m_args; + TokenTypeId m_id; + ObjectTypeId m_objType; + std::string m_signature; + std::string m_predicateName; + int m_attributes; + std::map m_args; - std::map< int, PSList > m_subgoalsByAttr; + std::map< int, PSList > m_subgoalsByAttr; - }; +}; } #endif // H_TokenType diff --git a/src/PLASMA/PlanDatabase/base/TokenTypeMgr.cc b/src/PLASMA/PlanDatabase/base/TokenTypeMgr.cc index e1b3e0069..d13979927 100644 --- a/src/PLASMA/PlanDatabase/base/TokenTypeMgr.cc +++ b/src/PLASMA/PlanDatabase/base/TokenTypeMgr.cc @@ -12,9 +12,7 @@ namespace EUROPA */ TokenTypeMgr::TokenTypeMgr() -: m_id(this) -{ -} + : m_id(this), m_typesByPredicate(), m_types() {} TokenTypeMgr::~TokenTypeMgr() { @@ -22,49 +20,49 @@ TokenTypeMgr::~TokenTypeMgr() m_id.remove(); } -const TokenTypeMgrId& TokenTypeMgr::getId() const {return m_id;} +const TokenTypeMgrId TokenTypeMgr::getId() const {return m_id;} -void TokenTypeMgr::registerType(const TokenTypeId& type) { - check_error(type.isValid()); +void TokenTypeMgr::registerType(const TokenTypeId type) { + check_error(type.isValid()); - // Ensure it is not present already - check_error(m_types.find(type) == m_types.end()) ; + // Ensure it is not present already + check_error(m_types.find(type) == m_types.end()) ; - m_types.insert(type); - m_typesByPredicate.insert(std::make_pair(type->getSignature().getKey(), type)); + m_types.insert(type); + m_typesByPredicate.insert(std::make_pair(type->getSignature(), type)); } /** * First try a hit for the predicate name as provided. If that does not work, extract the object, * and try each parent object until we get a hit. */ -TokenTypeId TokenTypeMgr::getType(const SchemaId& schema, const LabelStr& predicateName){ - check_error(schema->isPredicate(predicateName), predicateName.toString() + " is undefined."); +TokenTypeId TokenTypeMgr::getType(const SchemaId schema, const std::string& predicateName) { + check_error(schema->isPredicate(predicateName), predicateName + " is undefined."); - // Confirm it is present - const std::map::const_iterator pos = m_typesByPredicate.find(predicateName.getKey()); + // Confirm it is present + const std::map::const_iterator pos = m_typesByPredicate.find(predicateName); - if (pos != m_typesByPredicate.end()) // We have found what we are looking for - return(pos->second); + if (pos != m_typesByPredicate.end()) // We have found what we are looking for + return(pos->second); - // If we are here, we have not found it, so build up a list of parents, and try each one. We have to use the schema - // for this. + // If we are here, we have not found it, so build up a list of parents, and try each one. We have to use the schema + // for this. - // Call recursively if we have a parent - if (schema->hasParent(predicateName)) { - TokenTypeId type = getType(schema, schema->getParent(predicateName)); + // Call recursively if we have a parent + if (schema->hasParent(predicateName)) { + TokenTypeId type = getType(schema, schema->getParent(predicateName)); - check_error(type.isValid(), "No type found for " + predicateName.toString()); + check_error(type.isValid(), "No type found for " + predicateName); - // Log the mapping in this case, from the original predicate, to make it faster the next time around - m_typesByPredicate.insert(std::make_pair(predicateName, type)); - return(type); - } + // Log the mapping in this case, from the original predicate, to make it faster the next time around + m_typesByPredicate.insert(std::make_pair(predicateName, type)); + return(type); + } - // If we get here, it is an error - check_error(ALWAYS_FAILS, "Failed in TokenTypeMgr::getType for " + predicateName.toString()); + // If we get here, it is an error + check_error(ALWAYS_FAILS, "Failed in TokenTypeMgr::getType for " + predicateName); - return TokenTypeId::noId(); + return TokenTypeId::noId(); } bool TokenTypeMgr::hasType() diff --git a/src/PLASMA/PlanDatabase/base/TokenTypeMgr.hh b/src/PLASMA/PlanDatabase/base/TokenTypeMgr.hh index 23c9d3042..1876f57aa 100644 --- a/src/PLASMA/PlanDatabase/base/TokenTypeMgr.hh +++ b/src/PLASMA/PlanDatabase/base/TokenTypeMgr.hh @@ -3,7 +3,6 @@ #define EUROPA_TOKENTYPE_MGR_H #include "PlanDatabaseDefs.hh" -#include "LabelStr.hh" #include "TokenType.hh" #include "Utils.hh" @@ -14,13 +13,13 @@ namespace EUROPA { * on binding to concrete token types for easy distinct class. * @see TokenType */ - class TokenTypeMgr { - public: +class TokenTypeMgr { + public: TokenTypeMgr(); ~TokenTypeMgr(); - const TokenTypeMgrId& getId() const; + const TokenTypeMgrId getId() const; void purgeAll(); @@ -32,18 +31,18 @@ namespace EUROPA { /** * @brief Add a factory to provide instantiation of particular concrete types based on a label. */ - void registerType(const TokenTypeId& type ); + void registerType(const TokenTypeId type ); /** * @brief Obtain the factory based on the predicate name */ - TokenTypeId getType(const SchemaId& schema, const LabelStr& predicateName); + TokenTypeId getType(const SchemaId schema, const std::string& predicateName); - protected: - TokenTypeMgrId m_id; - std::map m_typesByPredicate; - std::set m_types; - }; + protected: + TokenTypeMgrId m_id; + std::map m_typesByPredicate; + std::set m_types; +}; } //namespace EUROPA diff --git a/src/PLASMA/PlanDatabase/base/TokenVariable.hh b/src/PLASMA/PlanDatabase/base/TokenVariable.hh index 082a18a05..477bcc525 100644 --- a/src/PLASMA/PlanDatabase/base/TokenVariable.hh +++ b/src/PLASMA/PlanDatabase/base/TokenVariable.hh @@ -1,11 +1,9 @@ -#ifndef _H_TokenVariable -#define _H_TokenVariable +#ifndef H_TokenVariable +#define H_TokenVariable #include "Token.hh" #include "PlanDatabaseDefs.hh" #include "Variable.hh" -//#include "Token.hh" - /** * @file Provides implementation and interface for TokenVariables. @@ -25,13 +23,13 @@ namespace EUROPA{ template class TokenVariable : public Variable { public: - TokenVariable(const TokenId& parent, - int index, - const ConstraintEngineId& constraintEngine, + TokenVariable(const TokenId parent, + unsigned long index, + const ConstraintEngineId constraintEngine, const Domain& baseDomain, const bool internal = false, bool canBeSpecified = true, - const LabelStr& name = ConstrainedVariable::NO_NAME()); + const std::string& name = ConstrainedVariable::NO_NAME()); virtual ~TokenVariable(); @@ -55,11 +53,14 @@ namespace EUROPA{ void handleReset(); - bool isCompatible(const ConstrainedVariableId& var) const; + bool isCompatible(const ConstrainedVariableId var) const; - const TokenId& getParentToken() const; + const TokenId getParentToken() const; private: +private: + TokenVariable(const TokenVariable&); + TokenVariable& operator=(const TokenVariable&); // Internal methods for specification that circumvent test for canBeSpeciifed() friend class Token; void setSpecified(edouble singletonValue); @@ -67,9 +68,9 @@ namespace EUROPA{ bool computeBaseDomain(); - void handleConstraintAdded(const ConstraintId& constraint); + void handleConstraintAdded(const ConstraintId constraint); - void handleConstraintRemoved(const ConstraintId& constraint); + void handleConstraintRemoved(const ConstraintId constraint); DomainType* m_integratedBaseDomain; /**< The integrated base domain over this and all supported tokens. */ bool m_isLocallySpecified; @@ -78,26 +79,25 @@ namespace EUROPA{ }; template - const TokenId& TokenVariable::getParentToken() const { return m_parentToken; } - - template - TokenVariable::TokenVariable(const TokenId& parent, - int index, - const ConstraintEngineId& constraintEngine, - const Domain& baseDomain, - const bool internal, - bool canBeSpecified, - const LabelStr& name) - : Variable(constraintEngine, baseDomain, internal, canBeSpecified, name, parent, index), - m_integratedBaseDomain(static_cast(baseDomain.copy())), m_isLocallySpecified(false), m_localSpecifiedValue(0), - m_parentToken(parent){ - check_error(m_parentToken.isValid()); - check_error(this->getIndex() >= 0); - if (this->isSpecified()) { - m_isLocallySpecified = true; - m_localSpecifiedValue = baseDomain.getSingletonValue(); - } + const TokenId TokenVariable::getParentToken() const { return m_parentToken; } + +template +TokenVariable::TokenVariable(const TokenId _parent, + unsigned long index, + const ConstraintEngineId constraintEngine, + const Domain& _baseDomain, + const bool internal, + bool _canBeSpecified, + const std::string& name) + : Variable(constraintEngine, _baseDomain, internal, _canBeSpecified, name, _parent, index), + m_integratedBaseDomain(static_cast(_baseDomain.copy())), m_isLocallySpecified(false), m_localSpecifiedValue(0), + m_parentToken(_parent){ + check_error(m_parentToken.isValid()); + if (this->isSpecified()) { + m_isLocallySpecified = true; + m_localSpecifiedValue = _baseDomain.getSingletonValue(); } +} template TokenVariable::~TokenVariable() @@ -253,7 +253,7 @@ namespace EUROPA{ } template - void TokenVariable::handleConstraintAdded(const ConstraintId& constraint){ + void TokenVariable::handleConstraintAdded(const ConstraintId constraint){ // Not valid to add a constraint if token is rejected //check_error(!this->m_parentToken->isRejected()); @@ -265,7 +265,7 @@ namespace EUROPA{ } template - void TokenVariable::handleConstraintRemoved(const ConstraintId& constraint){ + void TokenVariable::handleConstraintRemoved(const ConstraintId constraint){ // If the Token has been merged, then have to handle the migrated constraint also. For // Example, suppose a constraint was posted on the token. if(this->m_parentToken->isMerged() && !constraint->isActive()) @@ -273,7 +273,7 @@ namespace EUROPA{ } template - bool TokenVariable::isCompatible(const ConstrainedVariableId& var) const { + bool TokenVariable::isCompatible(const ConstrainedVariableId var) const { Id > id(var); if(id.isNoId() || this->m_index != id->getIndex() || TokenVariable::getBaseDomain() != id->getBaseDomain()) diff --git a/src/PLASMA/PlanDatabase/base/UnifyMemento.cc b/src/PLASMA/PlanDatabase/base/UnifyMemento.cc index 9411e2bc2..5809f141e 100644 --- a/src/PLASMA/PlanDatabase/base/UnifyMemento.cc +++ b/src/PLASMA/PlanDatabase/base/UnifyMemento.cc @@ -11,9 +11,11 @@ namespace EUROPA { m_sm.release(); } - UnifyMemento::UnifyMemento() {} +UnifyMemento::UnifyMemento() : m_method(mergeMethod), m_mm(), m_sm() {} - UnifyMemento::UnifyMemento(const TokenId& inactiveToken, const TokenId& activeToken) { +UnifyMemento::UnifyMemento(const TokenId inactiveToken, + const TokenId activeToken) : m_method(mergeMethod), m_mm(), + m_sm() { static const char* TRUE_VALUE = "1"; const char *envStr = getenv("EUROPA_USE_STACK_METHOD"); @@ -43,7 +45,7 @@ namespace EUROPA { m_mm->undo(activeTokenDeleted); } - void UnifyMemento::handleAdditionOfInactiveConstraint(const ConstraintId& constraint) { + void UnifyMemento::handleAdditionOfInactiveConstraint(const ConstraintId constraint) { check_error(m_mm.isNoId() || m_sm.isNoId()); check_error(!m_mm.isNoId() || !m_sm.isNoId()); if (m_mm.isNoId()) @@ -52,7 +54,7 @@ namespace EUROPA { m_mm->handleAdditionOfInactiveConstraint(constraint); } - void UnifyMemento::handleRemovalOfInactiveConstraint(const ConstraintId& constraint) { + void UnifyMemento::handleRemovalOfInactiveConstraint(const ConstraintId constraint) { check_error(m_mm.isNoId() || m_sm.isNoId()); check_error(!m_mm.isNoId() || !m_sm.isNoId()); if (m_mm.isNoId()) diff --git a/src/PLASMA/PlanDatabase/base/UnifyMemento.hh b/src/PLASMA/PlanDatabase/base/UnifyMemento.hh index 7d0d2a0a9..d725b7bb9 100644 --- a/src/PLASMA/PlanDatabase/base/UnifyMemento.hh +++ b/src/PLASMA/PlanDatabase/base/UnifyMemento.hh @@ -1,40 +1,39 @@ -#ifndef _H_UnifyMemento -#define _H_UnifyMemento +#ifndef H_UnifyMemento +#define H_UnifyMemento #include "PlanDatabaseDefs.hh" //#include "TokenVariable.hh" #include "MergeMemento.hh" #include "StackMemento.hh" -#include "LabelStr.hh" #include "Constraint.hh" #include "ConstrainedVariable.hh" namespace EUROPA { - class UnifyMemento { - public: - virtual ~UnifyMemento(); - protected: - friend class Token; +class UnifyMemento { + public: + virtual ~UnifyMemento(); + protected: + friend class Token; - enum UnifyMethod { - mergeMethod = 0, - stackMethod - }; + enum UnifyMethod { + mergeMethod = 0, + stackMethod + }; - UnifyMemento(); - UnifyMemento(const TokenId& inactiveToken, const TokenId& activeToken); + UnifyMemento(); + UnifyMemento(const TokenId inactiveToken, const TokenId activeToken); - void undo(bool activeTokenDeleted); + void undo(bool activeTokenDeleted); - void handleAdditionOfInactiveConstraint(const ConstraintId& constraint); - void handleRemovalOfInactiveConstraint(const ConstraintId& constraint); + void handleAdditionOfInactiveConstraint(const ConstraintId constraint); + void handleRemovalOfInactiveConstraint(const ConstraintId constraint); - private: - UnifyMethod m_method; - MergeMementoId m_mm; - StackMementoId m_sm; - }; + private: + UnifyMethod m_method; + MergeMementoId m_mm; + StackMementoId m_sm; +}; } #endif diff --git a/src/PLASMA/PlanDatabase/component/Db.hh b/src/PLASMA/PlanDatabase/component/Db.hh index 037695299..b8249ca07 100644 --- a/src/PLASMA/PlanDatabase/component/Db.hh +++ b/src/PLASMA/PlanDatabase/component/Db.hh @@ -1,5 +1,5 @@ -#ifndef _H_Db -#define _H_Db +#ifndef H_Db +#define H_Db #include "PlanDatabaseDefs.hh" #include "Timeline.hh" diff --git a/src/PLASMA/PlanDatabase/component/DbClientTransactionLog.cc b/src/PLASMA/PlanDatabase/component/DbClientTransactionLog.cc index 30bc8dbf1..ab7998e4f 100644 --- a/src/PLASMA/PlanDatabase/component/DbClientTransactionLog.cc +++ b/src/PLASMA/PlanDatabase/component/DbClientTransactionLog.cc @@ -8,13 +8,13 @@ #include "DbClientTransactionLog.hh" namespace EUROPA { - DbClientTransactionLog::DbClientTransactionLog(const DbClientId& client, bool chronologicalBacktracking) + DbClientTransactionLog::DbClientTransactionLog(const DbClientId client, bool chronologicalBacktracking) : DbClientListener(client) + , m_bufferedTransactions() + , m_chronologicalBacktracking(chronologicalBacktracking) + , m_tokensCreated(0) , m_client(client) - { - m_chronologicalBacktracking = chronologicalBacktracking; - m_tokensCreated = 0; - } + {} DbClientTransactionLog::~DbClientTransactionLog(){ cleanup(m_bufferedTransactions); @@ -22,13 +22,13 @@ namespace EUROPA { const std::list& DbClientTransactionLog::getBufferedTransactions() const {return m_bufferedTransactions;} - const bool DbClientTransactionLog::isBool(const std::string& typeName) { + bool DbClientTransactionLog::isBool(const std::string& typeName) { return (strcmp(typeName.c_str(),"bool") == 0 || strcmp(typeName.c_str(), "BOOL" ) == 0 || strcmp(typeName.c_str(),BoolDT::NAME().c_str()) == 0); } - const bool DbClientTransactionLog::isInt(const std::string& typeName) { + bool DbClientTransactionLog::isInt(const std::string& typeName) { return (strcmp(typeName.c_str(),"int") == 0 || strcmp(typeName.c_str(),BoolDT::NAME().c_str()) == 0); } @@ -45,63 +45,60 @@ namespace EUROPA { popTransaction(); } - void DbClientTransactionLog::notifyVariableCreated(const ConstrainedVariableId& variable) { - if(!variable->isInternal()) { - TiXmlElement * element = allocateXmlElement("var"); - const Domain& baseDomain = variable->baseDomain(); - std::string type = baseDomain.getTypeName().toString(); - if (m_client->getSchema()->isObjectType(type)) { - ObjectId object = Entity::getTypedEntity(baseDomain.getLowerBound()); - check_error(object.isValid()); - type = object->getType().toString(); - } - element->SetAttribute( "type", type ); - if (LabelStr::isString(variable->getName())) { - element->SetAttribute( "name", variable->getName().toString() ); - } - debugMsg("notifyVariableCreated"," variable name = " << variable->getName().c_str() << " typeName = " << type << " type = " << baseDomain.getTypeName().c_str()); +void DbClientTransactionLog::notifyVariableCreated(const ConstrainedVariableId variable) { + if(!variable->isInternal()) { + TiXmlElement * element = allocateXmlElement("var"); + const Domain& baseDomain = variable->baseDomain(); + std::string type = baseDomain.getTypeName(); + if (m_client->getSchema()->isObjectType(type)) { + ObjectId object = Entity::getTypedEntity(baseDomain.getLowerBound()); + check_error(object.isValid()); + type = object->getType(); + } + element->SetAttribute( "type", type ); + element->SetAttribute( "name", variable->getName() ); + debugMsg("notifyVariableCreated"," variable name = " << variable->getName().c_str() << " typeName = " << type << " type = " << baseDomain.getTypeName().c_str()); - element->SetAttribute("index", m_client->getIndexByVariable(variable)); + element->SetAttribute("index", static_cast(m_client->getIndexByVariable(variable))); - if (!baseDomain.isEmpty()) { - TiXmlElement * value = abstractDomainAsXml(&baseDomain); - element->LinkEndChild(value); - } - pushTransaction(element); + if (!baseDomain.isEmpty()) { + TiXmlElement * value = abstractDomainAsXml(&baseDomain); + element->LinkEndChild(value); } + pushTransaction(element); } +} - void DbClientTransactionLog::notifyVariableDeleted(const ConstrainedVariableId& variable) { - if(!variable->isInternal()) { - TiXmlElement* element = allocateXmlElement("deletevar"); - element->SetAttribute("index", m_client->getIndexByVariable(variable)); - element->SetAttribute("name", variable->getName().toString() ); - element->SetAttribute("type", variable->baseDomain().getTypeName().toString() ); - pushTransaction(element); - } +void DbClientTransactionLog::notifyVariableDeleted(const ConstrainedVariableId variable) { + if(!variable->isInternal()) { + TiXmlElement* element = allocateXmlElement("deletevar"); + element->SetAttribute("index", static_cast(m_client->getIndexByVariable(variable))); + element->SetAttribute("name", variable->getName() ); + element->SetAttribute("type", variable->baseDomain().getTypeName() ); + pushTransaction(element); } +} - void DbClientTransactionLog::notifyObjectCreated(const ObjectId& object){ + void DbClientTransactionLog::notifyObjectCreated(const ObjectId object){ const std::vector noArguments; notifyObjectCreated(object, noArguments); } - void DbClientTransactionLog::notifyObjectCreated(const ObjectId& object, const std::vector& arguments){ - TiXmlElement * element = allocateXmlElement("new"); - if (LabelStr::isString(object->getName())) { - element->SetAttribute("name", object->getName().toString()); - } - element->SetAttribute("type", object->getType().toString()); - std::vector::const_iterator iter; - for (iter = arguments.begin() ; iter != arguments.end() ; iter++) { - element->LinkEndChild(abstractDomainAsXml(*iter)); - } - pushTransaction(element); +void DbClientTransactionLog::notifyObjectCreated(const ObjectId object, + const std::vector& arguments){ + TiXmlElement * element = allocateXmlElement("new"); + element->SetAttribute("name", object->getName()); + element->SetAttribute("type", object->getType()); + std::vector::const_iterator iter; + for (iter = arguments.begin() ; iter != arguments.end() ; iter++) { + element->LinkEndChild(abstractDomainAsXml(*iter)); } + pushTransaction(element); +} - void DbClientTransactionLog::notifyObjectDeleted(const ObjectId& object) { + void DbClientTransactionLog::notifyObjectDeleted(const ObjectId object) { TiXmlElement* element = allocateXmlElement("deleteobject"); - element->SetAttribute("name", object->getName().toString()); + element->SetAttribute("name", object->getName()); pushTransaction(element); } @@ -111,39 +108,38 @@ namespace EUROPA { pushTransaction(element); } - void DbClientTransactionLog::notifyClosed(const LabelStr& objectType){ + void DbClientTransactionLog::notifyClosed(const std::string& objectType){ TiXmlElement * element = allocateXmlElement("invoke"); element->SetAttribute("name", "close"); - element->SetAttribute("identifier", objectType.toString()); + element->SetAttribute("identifier", objectType); pushTransaction(element); } - void DbClientTransactionLog::notifyTokenCreated(const TokenId& token){ + void DbClientTransactionLog::notifyTokenCreated(const TokenId token){ TiXmlElement * element = (token->isFact() ? allocateXmlElement("fact") : allocateXmlElement("goal")); TiXmlElement * instance = allocateXmlElement("predicateinstance"); instance->SetAttribute("name", m_tokensCreated++); - check_error(LabelStr::isString(token->getPredicateName())); - instance->SetAttribute("type", token->getPredicateName().toString()); + instance->SetAttribute("type", token->getPredicateName()); instance->SetAttribute("path", m_client->getPathAsString(token)); element->LinkEndChild(instance); pushTransaction(element); } - void DbClientTransactionLog::notifyTokenDeleted(const TokenId& token, + void DbClientTransactionLog::notifyTokenDeleted(const TokenId token, const std::string& name) { TiXmlElement* element = allocateXmlElement("deletetoken"); - element->SetAttribute("type", token->getPredicateName().toString()); + element->SetAttribute("type", token->getPredicateName()); element->SetAttribute("path", m_client->getPathAsString(token)); if(!name.empty()) element->SetAttribute("name", name); pushTransaction(element); } - void DbClientTransactionLog::notifyConstrained(const ObjectId& object, const TokenId& predecessor, const TokenId& successor){ + void DbClientTransactionLog::notifyConstrained(const ObjectId object, const TokenId predecessor, const TokenId successor){ TiXmlElement * element = allocateXmlElement("constrain"); TiXmlElement * object_el = allocateXmlElement("object"); - object_el->SetAttribute("name", object->getName().toString()); + object_el->SetAttribute("name", object->getName()); element->LinkEndChild(object_el); element->LinkEndChild(tokenAsXml(predecessor)); element->LinkEndChild(tokenAsXml(successor)); @@ -151,7 +147,7 @@ namespace EUROPA { } - void DbClientTransactionLog::notifyFreed(const ObjectId& object, const TokenId& predecessor, const TokenId& successor){ + void DbClientTransactionLog::notifyFreed(const ObjectId object, const TokenId predecessor, const TokenId successor){ if(m_chronologicalBacktracking) { check_error(strcmp(m_bufferedTransactions.back()->Value(), "constrain") == 0, "Chronological backtracking assumption violated"); @@ -160,39 +156,39 @@ namespace EUROPA { } TiXmlElement * element = allocateXmlElement("free"); TiXmlElement * object_el = allocateXmlElement("object"); - object_el->SetAttribute("name", object->getName().toString()); + object_el->SetAttribute("name", object->getName()); element->LinkEndChild(object_el); element->LinkEndChild(tokenAsXml(predecessor)); element->LinkEndChild(tokenAsXml(successor)); pushTransaction(element); } - void DbClientTransactionLog::notifyActivated(const TokenId& token){ + void DbClientTransactionLog::notifyActivated(const TokenId token){ TiXmlElement * element = allocateXmlElement("activate"); element->LinkEndChild(tokenAsXml(token)); pushTransaction(element); } - void DbClientTransactionLog::notifyMerged(const TokenId& token, const TokenId& activeToken){ + void DbClientTransactionLog::notifyMerged(const TokenId token, const TokenId activeToken){ TiXmlElement * element = allocateXmlElement("merge"); element->LinkEndChild(tokenAsXml(token)); element->LinkEndChild(tokenAsXml(activeToken)); pushTransaction(element); } - void DbClientTransactionLog::notifyMerged(const TokenId& token){ + void DbClientTransactionLog::notifyMerged(const TokenId token){ TiXmlElement * element = allocateXmlElement("merge"); element->LinkEndChild(tokenAsXml(token)); pushTransaction(element); } - void DbClientTransactionLog::notifyRejected(const TokenId& token){ + void DbClientTransactionLog::notifyRejected(const TokenId token){ TiXmlElement * element = allocateXmlElement("reject"); element->LinkEndChild(tokenAsXml(token)); pushTransaction(element); } - void DbClientTransactionLog::notifyCancelled(const TokenId& token){ + void DbClientTransactionLog::notifyCancelled(const TokenId token){ if (m_chronologicalBacktracking) { check_error((strcmp(m_bufferedTransactions.back()->Value(), "activate") == 0) || (strcmp(m_bufferedTransactions.back()->Value(), "reject") == 0) || @@ -206,33 +202,33 @@ namespace EUROPA { pushTransaction(element); } - void DbClientTransactionLog::notifyConstraintCreated(const ConstraintId& constraint){ - TiXmlElement * element = allocateXmlElement("invoke"); - element->SetAttribute("name", constraint->getName().toString()); - element->SetAttribute("index", m_client->getIndexByConstraint(constraint)); - const std::vector& variables = constraint->getScope(); - std::vector::const_iterator iter; - for (iter = variables.begin() ; iter != variables.end() ; iter++) { - const ConstrainedVariableId variable = *iter; - element->LinkEndChild(variableAsXml(variable)); +void DbClientTransactionLog::notifyConstraintCreated(const ConstraintId constraint){ + TiXmlElement * element = allocateXmlElement("invoke"); + element->SetAttribute("name", constraint->getName()); + element->SetAttribute("index", static_cast(m_client->getIndexByConstraint(constraint))); + const std::vector& variables = constraint->getScope(); + std::vector::const_iterator iter; + for (iter = variables.begin() ; iter != variables.end() ; iter++) { + const ConstrainedVariableId variable = *iter; + element->LinkEndChild(variableAsXml(variable)); } - pushTransaction(element); - } + pushTransaction(element); +} - void DbClientTransactionLog::notifyConstraintDeleted(const ConstraintId& constraint) { - TiXmlElement* element = allocateXmlElement("deleteconstraint"); - element->SetAttribute("name", constraint->getName().toString()); - element->SetAttribute("index", m_client->getIndexByConstraint(constraint)); - const std::vector& variables = constraint->getScope(); - std::vector::const_iterator iter; - for (iter = variables.begin() ; iter != variables.end() ; iter++) { - const ConstrainedVariableId variable = *iter; - element->LinkEndChild(variableAsXml(variable)); - } - pushTransaction(element); - } +void DbClientTransactionLog::notifyConstraintDeleted(const ConstraintId constraint) { + TiXmlElement* element = allocateXmlElement("deleteconstraint"); + element->SetAttribute("name", constraint->getName()); + element->SetAttribute("index", static_cast(m_client->getIndexByConstraint(constraint))); + const std::vector& variables = constraint->getScope(); + std::vector::const_iterator iter; + for (iter = variables.begin() ; iter != variables.end() ; iter++) { + const ConstrainedVariableId variable = *iter; + element->LinkEndChild(variableAsXml(variable)); + } + pushTransaction(element); +} - void DbClientTransactionLog::notifyVariableSpecified(const ConstrainedVariableId& variable){ + void DbClientTransactionLog::notifyVariableSpecified(const ConstrainedVariableId variable){ if(!variable->isInternal()) { checkError(variable->lastDomain().isSingleton(), variable->toString() << " is not a singleton."); TiXmlElement * element = allocateXmlElement("specify"); @@ -242,7 +238,7 @@ namespace EUROPA { } } - void DbClientTransactionLog::notifyVariableRestricted(const ConstrainedVariableId& variable){ + void DbClientTransactionLog::notifyVariableRestricted(const ConstrainedVariableId variable){ if(!variable->isInternal()) { TiXmlElement * element = allocateXmlElement("restrict"); element->LinkEndChild(variableAsXml(variable)); @@ -251,7 +247,7 @@ namespace EUROPA { } } - void DbClientTransactionLog::notifyVariableReset(const ConstrainedVariableId& variable){ + void DbClientTransactionLog::notifyVariableReset(const ConstrainedVariableId variable){ if(!variable->isInternal()) { if (m_chronologicalBacktracking) { check_error(strcmp(m_bufferedTransactions.back()->Value(), "specify") == 0, @@ -276,33 +272,32 @@ namespace EUROPA { std::string DbClientTransactionLog::domainValueAsString(const Domain * domain, edouble value) { - if (isBool(domain->getTypeName().toString())) { + if (isBool(domain->getTypeName())) { return (value == 1 ? "true" : "false"); } else if (domain->isNumeric()) { // CMG: Do not use snprintf. Not supported on DEC std::stringstream ss; - if (isInt(domain->getTypeName().toString())) { + if (isInt(domain->getTypeName())) { ss << cast_int(value); } else { ss << value; } return ss.str(); } else if (LabelStr::isString(domain->getUpperBound())) { - const LabelStr& label = value; - return label.toString(); + return LabelStr(value).toString(); } else { ObjectId object = Entity::getTypedEntity(value); check_error(object.isValid()); - return object->getName().toString(); + return object->getName(); } } TiXmlElement * DbClientTransactionLog::domainValueAsXml(const Domain * domain, edouble value) { - LabelStr typeName = domain->getTypeName(); + std::string typeName = domain->getTypeName(); if (m_client->getSchema()->isObjectType(typeName)) { TiXmlElement * element = allocateXmlElement("object"); element->SetAttribute("value", domainValueAsString(domain, value)); @@ -311,7 +306,7 @@ namespace EUROPA { debugMsg("domainValueAsXml"," domain type = " << domain->getTypeName().c_str() << " domain name = " << typeName.c_str()); - if (isBool(domain->getTypeName().toString())) { + if (isBool(domain->getTypeName())) { TiXmlElement * element = allocateXmlElement("value"); element->SetAttribute("type", "bool"); element->SetAttribute("name", domainValueAsString(domain, value)); @@ -320,13 +315,13 @@ namespace EUROPA { else { if (domain->isNumeric()) { TiXmlElement * element = allocateXmlElement("value"); - element->SetAttribute("type", typeName.toString()); + element->SetAttribute("type", typeName); element->SetAttribute("name", domainValueAsString(domain, value)); return(element); } else { TiXmlElement * element = allocateXmlElement("symbol"); - element->SetAttribute("type", typeName.toString()); + element->SetAttribute("type", typeName); element->SetAttribute("value", domainValueAsString(domain, value)); return(element); } @@ -342,7 +337,7 @@ namespace EUROPA { return domainValueAsXml(domain, domain->getSingletonValue()); } else if (domain->isEnumerated()) { TiXmlElement * element = allocateXmlElement("set"); - element->SetAttribute("type", domain->getTypeName().toString()); + element->SetAttribute("type", domain->getTypeName()); std::list values; domain->getValues(values); std::list::const_iterator iter; @@ -352,7 +347,7 @@ namespace EUROPA { return element; } else if (domain->isInterval()) { TiXmlElement * element = allocateXmlElement("interval"); - std::string typeName = domain->getTypeName().toString(); + std::string typeName = domain->getTypeName(); element->SetAttribute("type",typeName); element->SetAttribute("min", domainValueAsString(domain, domain->getLowerBound())); element->SetAttribute("max", domainValueAsString(domain, domain->getUpperBound())); @@ -363,43 +358,46 @@ namespace EUROPA { } TiXmlElement * - DbClientTransactionLog::tokenAsXml(const TokenId& token) const + DbClientTransactionLog::tokenAsXml(const TokenId token) const { TiXmlElement * token_el = allocateXmlElement("token"); token_el->SetAttribute("path", m_client->getPathAsString(token)); return token_el; } - TiXmlElement * - DbClientTransactionLog::variableAsXml(const ConstrainedVariableId& variable) const - { - TiXmlElement * var_el = allocateXmlElement("variable"); - const EntityId& parent = variable->parent(); - if (parent != EntityId::noId()) { - if (TokenId::convertable(parent)) { - TokenId token = parent; - check_error(token.isValid()); - var_el->SetAttribute("token", m_client->getPathAsString(token)); - } else if (ObjectId::convertable(parent)) { - ObjectId object = parent; - check_error(object.isValid()); - var_el->SetAttribute("object", object->getName().toString()); - } else { - var_el->SetAttribute("index", m_client->getIndexByVariable(variable)); - return var_el; - } - } else { - var_el->SetAttribute("index", m_client->getIndexByVariable(variable)); - return var_el; +TiXmlElement * +DbClientTransactionLog::variableAsXml(const ConstrainedVariableId variable) const { + TiXmlElement * var_el = allocateXmlElement("variable"); + const EntityId parent = variable->parent(); + if (parent != EntityId::noId()) { + if (TokenId::convertable(parent)) { + TokenId token = parent; + check_error(token.isValid()); + var_el->SetAttribute("token", m_client->getPathAsString(token)); + } + else if (ObjectId::convertable(parent)) { + ObjectId object = parent; + check_error(object.isValid()); + var_el->SetAttribute("object", object->getName()); } - if (variable->getIndex() != ConstrainedVariable::NO_INDEX) { - var_el->SetAttribute("index", variable->getIndex()); - } else { - var_el->SetAttribute("index", m_client->getIndexByVariable(variable)); + else { + var_el->SetAttribute("index", static_cast(m_client->getIndexByVariable(variable))); return var_el; } + } + else { + var_el->SetAttribute("index", static_cast(m_client->getIndexByVariable(variable))); return var_el; } + if (variable->getIndex() != ConstrainedVariable::NO_INDEX) { + var_el->SetAttribute("index", static_cast(variable->getIndex())); + } + else { + var_el->SetAttribute("index", static_cast(m_client->getIndexByVariable(variable))); + return var_el; + } + return var_el; +} TiXmlElement * DbClientTransactionLog::allocateXmlElement(const std::string& name) const { TiXmlElement * element = new TiXmlElement(name); diff --git a/src/PLASMA/PlanDatabase/component/DbClientTransactionLog.hh b/src/PLASMA/PlanDatabase/component/DbClientTransactionLog.hh index 10f948943..7e3255446 100644 --- a/src/PLASMA/PlanDatabase/component/DbClientTransactionLog.hh +++ b/src/PLASMA/PlanDatabase/component/DbClientTransactionLog.hh @@ -1,5 +1,5 @@ -#ifndef _H_DbClientTransactionLog -#define _H_DbClientTransactionLog +#ifndef H_DbClientTransactionLog +#define H_DbClientTransactionLog #include "DbClientListener.hh" #include @@ -20,31 +20,31 @@ namespace EUROPA { class DbClientTransactionLog: public DbClientListener { public: - DbClientTransactionLog(const DbClientId& client, bool chronologicalBacktracking = true); + DbClientTransactionLog(const DbClientId client, bool chronologicalBacktracking = true); ~DbClientTransactionLog(); /* Declare DbClient event handlers we will over-ride */ - void notifyObjectCreated(const ObjectId& object); - void notifyObjectCreated(const ObjectId& object, const std::vector& arguments); - void notifyObjectDeleted(const ObjectId& object); + void notifyObjectCreated(const ObjectId object); + void notifyObjectCreated(const ObjectId object, const std::vector& arguments); + void notifyObjectDeleted(const ObjectId object); void notifyClosed(); - void notifyClosed(const LabelStr& objectType); - void notifyTokenCreated(const TokenId& token); - void notifyTokenDeleted(const TokenId& token, const std::string& name); - void notifyConstrained(const ObjectId& object, const TokenId& predecessor, const TokenId& successor); - void notifyFreed(const ObjectId& object, const TokenId& predecessor, const TokenId& successor); - void notifyActivated(const TokenId& token); - void notifyMerged(const TokenId& token, const TokenId& activeToken); - void notifyMerged(const TokenId& token); - void notifyRejected(const TokenId& token); - void notifyCancelled(const TokenId& token); - void notifyConstraintCreated(const ConstraintId& constraint); - void notifyConstraintDeleted(const ConstraintId& constraint); - void notifyVariableCreated(const ConstrainedVariableId& variable); - void notifyVariableDeleted(const ConstrainedVariableId& variable); - void notifyVariableSpecified(const ConstrainedVariableId& variable); - void notifyVariableRestricted(const ConstrainedVariableId& variable); - void notifyVariableReset(const ConstrainedVariableId& variable); + void notifyClosed(const std::string& objectType); + void notifyTokenCreated(const TokenId token); + void notifyTokenDeleted(const TokenId token, const std::string& name); + void notifyConstrained(const ObjectId object, const TokenId predecessor, const TokenId successor); + void notifyFreed(const ObjectId object, const TokenId predecessor, const TokenId successor); + void notifyActivated(const TokenId token); + void notifyMerged(const TokenId token, const TokenId activeToken); + void notifyMerged(const TokenId token); + void notifyRejected(const TokenId token); + void notifyCancelled(const TokenId token); + void notifyConstraintCreated(const ConstraintId constraint); + void notifyConstraintDeleted(const ConstraintId constraint); + void notifyVariableCreated(const ConstrainedVariableId variable); + void notifyVariableDeleted(const ConstrainedVariableId variable); + void notifyVariableSpecified(const ConstrainedVariableId variable); + void notifyVariableRestricted(const ConstrainedVariableId variable); + void notifyVariableReset(const ConstrainedVariableId variable); void insertBreakpoint(); void removeBreakpoint(); @@ -61,13 +61,13 @@ namespace EUROPA { void pushTransaction(TiXmlElement *); void popTransaction(); - const bool isBool(const std::string& typeName); - const bool isInt(const std::string& typeName); + bool isBool(const std::string& typeName); + bool isInt(const std::string& typeName); std::list m_bufferedTransactions; bool m_chronologicalBacktracking; int m_tokensCreated; - const DbClientId& m_client; + const DbClientId m_client; //! string output functions @@ -91,12 +91,12 @@ namespace EUROPA { /** * @brief create an xml element to represent a token */ - TiXmlElement * tokenAsXml(const TokenId& token) const; + TiXmlElement * tokenAsXml(const TokenId token) const; /** * @brief create an xml element to represent a variable */ - TiXmlElement * variableAsXml(const ConstrainedVariableId& variable) const; + TiXmlElement * variableAsXml(const ConstrainedVariableId variable) const; }; } #endif diff --git a/src/PLASMA/PlanDatabase/component/DbClientTransactionPlayer.cc b/src/PLASMA/PlanDatabase/component/DbClientTransactionPlayer.cc index e6877c2d9..2b49a1f52 100644 --- a/src/PLASMA/PlanDatabase/component/DbClientTransactionPlayer.cc +++ b/src/PLASMA/PlanDatabase/component/DbClientTransactionPlayer.cc @@ -12,11 +12,15 @@ #include "DbClientTransactionPlayer.hh" #include "DbClientTransactionLog.hh" #include "Utils.hh" +#include "CESchema.hh" #include #include #include +#include +#include + namespace EUROPA { const std::set& DbClientTransactionPlayer::MODEL_TRANSACTIONS() { @@ -67,10 +71,10 @@ namespace EUROPA { return sl_retval; } - static const std::vector + static const std::vector pathAsVector(const std::string & path) { size_t path_back, path_front, path_end; - std::vector result; + std::vector result; path_back = 0; path_end = path.size(); while (true) { @@ -79,33 +83,32 @@ namespace EUROPA { break; } std::string numstr = path.substr(path_back, path_front-path_back); - result.push_back(atoi(numstr.c_str())); + result.push_back(static_cast(atoi(numstr.c_str()))); path_back = path_front + 1; } std::string numstr = path.substr(path_back, path_end-path_back); - result.push_back(atoi(numstr.c_str())); + result.push_back(static_cast(atoi(numstr.c_str()))); return result; } DbClientTransactionPlayer::DbClientTransactionPlayer(const DbClientId & client) - : m_client(client), m_objectCount(0), m_varCount(0) { + : m_client(client), m_objectCount(0), m_varCount(0), m_filters(), m_tokens(), + m_variables(), m_relations(){ } DbClientTransactionPlayer::~DbClientTransactionPlayer() { } - const SchemaId& DbClientTransactionPlayer::getSchema() const - { - return m_client->getSchema(); - } +SchemaId DbClientTransactionPlayer::getSchema() const { + return m_client->getSchema(); +} - const CESchemaId& DbClientTransactionPlayer::getCESchema() const - { - return m_client->getCESchema(); - } +CESchemaId DbClientTransactionPlayer::getCESchema() const { + return m_client->getCESchema(); +} - void DbClientTransactionPlayer::setFilter(const std::set& filters) { + void DbClientTransactionPlayer::setFilter(const std::set&) { } @@ -127,7 +130,7 @@ namespace EUROPA { check_error(txCounter > 0, "Failed to find any transactions in stream."); } - void DbClientTransactionPlayer::play(const DbClientTransactionLogId& txLog) { + void DbClientTransactionPlayer::play(const DbClientTransactionLogId txLog) { const std::list& transactions = txLog->getBufferedTransactions(); for (std::list::const_iterator it = transactions.begin(); it != transactions.end(); @@ -160,7 +163,7 @@ namespace EUROPA { cleanup(transactions); } - void DbClientTransactionPlayer::rewind(const DbClientTransactionLogId& txLog, + void DbClientTransactionPlayer::rewind(const DbClientTransactionLogId txLog, bool breakpoint) { const std::list& transactions = txLog->getBufferedTransactions(); while(!transactions.empty()) { @@ -446,37 +449,36 @@ namespace EUROPA { checkError(ALWAYS_FAIL, "No creation transaction to complement " << element); } - const char* DbClientTransactionPlayer::getObjectAndType( - const SchemaId& schema, - const DbClientId& client, - const char* predicate, - ObjectId& object) - { - if (!schema->isPredicate(predicate)) { - LabelStr typeStr(predicate); - int cnt = typeStr.countElements(Schema::getDelimiter()); - LabelStr prefix = typeStr.getElement(0, Schema::getDelimiter()); - object = client->getObject(prefix.c_str()); - check_error(object.isValid(), "Failed to find an object named " + prefix.toString()); - LabelStr objType = object->getType(); - LabelStr suffix = typeStr.getElement(1, Schema::getDelimiter()); - - for (int i=2; igetMemberType(objType,suffix); - suffix = typeStr.getElement(i, Schema::getDelimiter()); - } - - std::string objName(predicate); - objName = objName.substr(0,objName.length()-suffix.toString().length()-1); - object = client->getObject(objName.c_str()); - check_error(object.isValid(), "Failed to find an object named " + objName); - LabelStr newType(objType.toString() + Schema::getDelimiter() + suffix.toString()); - return newType.c_str(); - } - else { - return predicate; - } +std::string DbClientTransactionPlayer::getObjectAndType(const SchemaId schema, + const DbClientId client, + const std::string& predicate, + ObjectId& object) { + if (!schema->isPredicate(predicate)) { + std::string typeStr(predicate); + std::vector components; + boost::split(components, typeStr, boost::is_any_of(".")); + + object = client->getObject(components.front().c_str()); + check_error(object.isValid(), "Failed to find an object named " + components.front()); + + std::string objType = object->getType(); + std::string suffix = *(components.begin() + 1); + for(std::vector::const_iterator it = components.begin() + 2; + it != components.end(); ++it) { + objType = schema->getMemberType(objType,suffix); + suffix = *it; + } + std::string objName(predicate); + objName = objName.substr(0,objName.length()-suffix.length()-1); + object = client->getObject(objName.c_str()); + check_error(object.isValid(), "Failed to find an object named " + objName); + std::string newType(objType + Schema::getDelimiter() + suffix); + return newType.c_str(); + } + else { + return predicate; } +} TokenId DbClientTransactionPlayer::createToken( const char* name, @@ -488,9 +490,9 @@ namespace EUROPA { // object and specify it. We will also have to generate the appropriate type designation // by extracting the class from the object ObjectId object; - const char* predicateType = getObjectAndType(getSchema(),m_client,type,object); + std::string predicateType = getObjectAndType(getSchema(),m_client,type,object); - TokenId token = m_client->createToken(predicateType,name,rejectable,isFact); + TokenId token = m_client->createToken(predicateType.c_str(),name,rejectable,isFact); if (!object.isNoId()) { // We restrict the base domain permanently since the name is specifically mentioned on creation @@ -524,30 +526,28 @@ namespace EUROPA { ); } - void DbClientTransactionPlayer::playTokenCreated(const TiXmlElement & element) { - const char * relation = element.Attribute("relation"); - if (relation != NULL) { - playTemporalRelationCreated(element); - return; - } - // simple token creation - TiXmlElement * child = element.FirstChildElement(); - check_error(child != NULL); - const char * type = child->Attribute("type"); - check_error(type != NULL); - - const char * mandatory = element.Attribute("mandatory"); - bool rejectable = true; - if(mandatory != NULL && (strcmp(mandatory, "true") == 0)) - rejectable = false; - - TokenId token = createToken( - child->Attribute("name"), - type, - rejectable, // rejectable - false // isFact - ); +void DbClientTransactionPlayer::playTokenCreated(const TiXmlElement & element) { + const char * relation = element.Attribute("relation"); + if (relation != NULL) { + playTemporalRelationCreated(element); + return; } + // simple token creation + TiXmlElement * child = element.FirstChildElement(); + check_error(child != NULL); + const char * type = child->Attribute("type"); + check_error(type != NULL); + + const char * mandatory = element.Attribute("mandatory"); + bool rejectable = true; + if(mandatory != NULL && (strcmp(mandatory, "true") == 0)) + rejectable = false; + + createToken(child->Attribute("name"), type, + rejectable, // rejectable + false // isFact + ); +} //bizarre... playTokenCreated will, separately, create a token and create a temporal relation //these should be separated! @@ -580,13 +580,13 @@ namespace EUROPA { std::vector tokens; tokenize(pathStr, tokens, "."); - std::vector path; + std::vector path; for(std::vector::iterator it = tokens.begin(); it != tokens.end(); ++it) { std::stringstream str; str << *it; - int element; - str >> element; - path.push_back(element); + unsigned int pathElement = 0; + str >> pathElement; + path.push_back(pathElement); } tok = m_client->getTokenByPath(path); } @@ -715,15 +715,15 @@ namespace EUROPA { } DbClientTransactionPlayer::TemporalRelations::iterator - DbClientTransactionPlayer::getTemporalConstraint(const ConstrainedVariableId& fvar, - const ConstrainedVariableId& svar, + DbClientTransactionPlayer::getTemporalConstraint(const ConstrainedVariableId fvar, + const ConstrainedVariableId svar, const std::string& name) { std::pair range = m_relations.equal_range(std::make_pair(fvar, svar)); checkError(range.first != m_relations.end(), "No saved temporal constraints between " << fvar->toString() << " and " << svar->toString()); - LabelStr relName(name); + std::string relName(name); for(TemporalRelations::iterator it = range.first; it != range.second; ++it) { if(it->second->getName() == relName) return it; @@ -739,8 +739,8 @@ namespace EUROPA { m_client->deleteConstraint(constr); } - void DbClientTransactionPlayer::removeTemporalConstraint(const ConstrainedVariableId& fvar, - const ConstrainedVariableId& svar, + void DbClientTransactionPlayer::removeTemporalConstraint(const ConstrainedVariableId fvar, + const ConstrainedVariableId svar, const std::string& name) { deleteTemporalConstraint(getTemporalConstraint(fvar, svar, name)); } @@ -1123,9 +1123,9 @@ namespace EUROPA { template void DbClientTransactionPlayer::playVariableUnreset(const TiXmlElement& element, Iterator start, Iterator end) { - TiXmlElement * var_el = element.FirstChildElement(); - check_error(var_el != NULL); - ConstrainedVariableId var = xmlAsVariable(*var_el); + TiXmlElement * root_el = element.FirstChildElement(); + check_error(root_el != NULL); + ConstrainedVariableId var = xmlAsVariable(*root_el); for(Iterator it = start; it != end; ++it) { if(strcmp((*it)->Value(), "specify") == 0 || @@ -1182,7 +1182,7 @@ namespace EUROPA { std::stringstream str; str << index; - int key; + unsigned int key = 0; str >> key; ConstraintId constr = m_client->getConstraintByIndex(key); m_client->deleteConstraint(constr); @@ -1301,31 +1301,32 @@ namespace EUROPA { DbClientTransactionPlayer::parseVariable(const char * varString) { check_error(varString != NULL); - std::string variable = varString; + std::string variableName = varString; size_t ident_back, ident_front, variable_end; ident_back = 0; - variable_end = variable.size(); - ident_front = variable.find('.', ident_back); + variable_end = variableName.size(); + ident_front = variableName.find('.', ident_back); if ((ident_front == std::string::npos) || (ident_front > variable_end)) { // simple identifier (might be a symbol) - if (m_variables.find(variable) != m_variables.end()) { - return m_variables[variable]; - } else { + if (m_variables.find(variableName) != m_variables.end()) { + return m_variables[variableName]; + } + else { // presumably a symbol return ConstrainedVariableId::noId(); } } // compound identifier - std::string ident = variable.substr(ident_back, ident_front - ident_back); + std::string ident = variableName.substr(ident_back, ident_front - ident_back); TokenId token = m_tokens[ident]; if (token != token.noId()) { - std::string name = variable.substr(ident_front + 1); - LabelStr nameAsLabelStr(name.c_str()); + std::string name = variableName.substr(ident_front + 1); + std::string nameAsLabelStr(name.c_str()); const std::vector & variables = token->getVariables(); std::vector::const_iterator iter = variables.begin(); while (iter != variables.end()) { ConstrainedVariableId variable = *iter++; - const LabelStr& varName = variable->getName(); + const std::string& varName = variable->getName(); if (nameAsLabelStr == varName) { return variable; } @@ -1336,7 +1337,7 @@ namespace EUROPA { checkError(var.isValid(), "Invalid id for " << ident); ObjectId object = Entity::getTypedEntity(var->lastDomain().getSingletonValue()); checkError(object.isValid(), "Invalid object for " << ident); - var = object->getVariable(LabelStr(varString)); + var = object->getVariable(varString); checkError(var.isValid(), varString << " not found on " << object->toString()); return var; } @@ -1366,8 +1367,8 @@ namespace EUROPA { return(new ObjectDomain(getCESchema()->getDataType(type), Entity::getTypedEntity(xmlAsValue(element, name)))); } if (strcmp(tag, "id") == 0) { - const char * name = element.Attribute("name"); - ConstrainedVariableId var = parseVariable(name); + const char * varName = element.Attribute("name"); + ConstrainedVariableId var = parseVariable(varName); check_error(var.isValid()); return(var->baseDomain().copy()); } @@ -1379,12 +1380,12 @@ namespace EUROPA { // New XML style for simple types. const char * type = element.Attribute("type"); check_error(type != NULL, "missing type for domain in transaction XML"); - const char * name = element.Attribute("name"); - check_error(name != NULL, "missing name for domain in transaction XML"); + const char * domainName = element.Attribute("name"); + check_error(domainName != NULL, "missing name for domain in transaction XML"); Domain * domain = getCESchema()->baseDomain(type).copy(); check_error(domain != 0, "unknown type, lack of memory, or other problem with domain in transaction XML"); - edouble value = m_client->createValue(type, name); + edouble value = m_client->createValue(type, domainName); if(domain->isOpen() && !domain->isMember(value)) domain->insert(value); domain->set(value); @@ -1438,114 +1439,114 @@ namespace EUROPA { return domain; } - EnumeratedDomain * - DbClientTransactionPlayer::xmlAsEnumeratedDomain(const TiXmlElement & element, - const char* otherTypeName) { - enum { ANY, BOOL, INT, FLOAT, STRING, SYMBOL, OBJECT } type = ANY; - std::string typeName; - // determine most specific type - for (TiXmlElement * child_el = element.FirstChildElement() ; - child_el != NULL ; child_el = child_el->NextSiblingElement()) { - std::string thisType; - if (strcmp(child_el->Value(), "value") == 0) - // New style XML for simple types: the type is within and tag is always 'value' - thisType = child_el->Attribute("type"); - else - // Non-simple type or old style XML for a simple type: type is the tag and/or within (e.g., specific type is within if symbol even old style) - thisType = child_el->Value(); - - debugMsg("DbClientTransactionPlayer:xmlAsEnumeratedDomain", " thisType= " << thisType); - - check_error(thisType != "", "no type for domain in XML"); - if (strcmp(thisType.c_str(), "bool") == 0 || - strcmp(thisType.c_str(), "BOOL") == 0 || - strcmp(thisType.c_str(), BoolDT::NAME().c_str()) == 0) { - if (type == ANY) { - type = BOOL; - typeName = "bool"; - } - if (type == BOOL) - continue; +EnumeratedDomain * +DbClientTransactionPlayer::xmlAsEnumeratedDomain(const TiXmlElement & element, + const char* otherTypeName) { + enum { ANY, BOOL, INT, FLOAT, STRING, SYMBOL, OBJECT } type = ANY; + std::string typeName; + // determine most specific type + for (TiXmlElement * child_el = element.FirstChildElement() ; + child_el != NULL ; child_el = child_el->NextSiblingElement()) { + std::string thisType; + if (strcmp(child_el->Value(), "value") == 0) + // New style XML for simple types: the type is within and tag is always 'value' + thisType = child_el->Attribute("type"); + else + // Non-simple type or old style XML for a simple type: type is the tag and/or within (e.g., specific type is within if symbol even old style) + thisType = child_el->Value(); + + debugMsg("DbClientTransactionPlayer:xmlAsEnumeratedDomain", " thisType= " << thisType); + + check_error(thisType != "", "no type for domain in XML"); + if (strcmp(thisType.c_str(), "bool") == 0 || + strcmp(thisType.c_str(), "BOOL") == 0 || + strcmp(thisType.c_str(), BoolDT::NAME().c_str()) == 0) { + if (type == ANY) { + type = BOOL; + typeName = "bool"; } - if (strcmp(thisType.c_str(), "int") == 0 || - strcmp(thisType.c_str(), "INT") == 0 || - strcmp(thisType.c_str(), IntDT::NAME().c_str()) == 0) { - if (type == ANY) { - type = INT; - typeName = "int"; - } - if ((type == FLOAT) || (type == INT)) - continue; + if (type == BOOL) + continue; + } + if (strcmp(thisType.c_str(), "int") == 0 || + strcmp(thisType.c_str(), "INT") == 0 || + strcmp(thisType.c_str(), IntDT::NAME().c_str()) == 0) { + if (type == ANY) { + type = INT; + typeName = "int"; } - if (strcmp(thisType.c_str(), "float") == 0 || - strcmp(thisType.c_str(), "FLOAT") == 0 || - strcmp(thisType.c_str(), FloatDT::NAME().c_str()) == 0) { - if ((type == ANY) || (type == INT)) { - type = FLOAT; - typeName = "float"; - } - if (type == FLOAT) - continue; + if ((type == FLOAT) || (type == INT)) + continue; + } + if (strcmp(thisType.c_str(), "float") == 0 || + strcmp(thisType.c_str(), "FLOAT") == 0 || + strcmp(thisType.c_str(), FloatDT::NAME().c_str()) == 0) { + if ((type == ANY) || (type == INT)) { + type = FLOAT; + typeName = "float"; } - if (strcmp(thisType.c_str(), "string") == 0 || - strcmp(thisType.c_str(), "STRING") == 0 || - strcmp(thisType.c_str(), StringDT::NAME().c_str()) == 0) { - if (type == ANY) { - type = STRING; - typeName = "string"; - } - if (type == STRING) - continue; + if (type == FLOAT) + continue; + } + if (strcmp(thisType.c_str(), "string") == 0 || + strcmp(thisType.c_str(), "STRING") == 0 || + strcmp(thisType.c_str(), StringDT::NAME().c_str()) == 0) { + if (type == ANY) { + type = STRING; + typeName = "string"; } - if (strcmp(thisType.c_str(), "symbol") == 0) { - if (type == ANY) { - type = SYMBOL; - typeName = child_el->Attribute("type"); - } - if (type == SYMBOL) { - check_error(strcmp(typeName.c_str(), child_el->Attribute("type")) == 0, - "symbols from different types in the same enumerated set"); - debugMsg("DbClientTransactionPlayer:xmlAsEnumeratedDomain:symbol", " thisType= " << thisType << " typeName = " <Attribute("type"); } -// if (strcmp(thisType.c_str(), "object") == 0) { -// if (type == ANY) { -// type = OBJECT; -// } -// if (type == OBJECT) -// //!!This needs a similar type check to SYMBOL, just above (but more complex due to inheritance?) -// continue; -// } - check_error(ALWAYS_FAILS, "unknown or inappropriately mixed type(s) for value(s) in an enumerated set"); - } - check_error(type != ANY); - // gather the values - std::list values; - for (TiXmlElement * child_el = element.FirstChildElement() ; - child_el != NULL ; child_el = child_el->NextSiblingElement()) { - const char * value_st = child_el->Attribute("value"); - if (value_st == NULL) // Check for the new style XML for simple types - value_st = child_el->Attribute("name"); - check_error(value_st != NULL); - switch (type) { - case BOOL: case INT: case FLOAT: case STRING: case SYMBOL: - values.push_back(m_client->createValue(typeName.c_str(), value_st)); - break; - case OBJECT: - values.push_back(m_client->getObject(value_st)->getKey()); - break; - default: - check_error(ALWAYS_FAILS); + if (type == SYMBOL) { + check_error(strcmp(typeName.c_str(), child_el->Attribute("type")) == 0, + "symbols from different types in the same enumerated set"); + debugMsg("DbClientTransactionPlayer:xmlAsEnumeratedDomain:symbol", " thisType= " << thisType << " typeName = " < values; + for (TiXmlElement * child_el = element.FirstChildElement() ; + child_el != NULL ; child_el = child_el->NextSiblingElement()) { + const char * value_st = child_el->Attribute("value"); + if (value_st == NULL) // Check for the new style XML for simple types + value_st = child_el->Attribute("name"); + check_error(value_st != NULL); + switch (type) { + case BOOL: case INT: case FLOAT: case STRING: case SYMBOL: + values.push_back(m_client->createValue(typeName.c_str(), value_st)); + break; + case OBJECT: + values.push_back(m_client->getObject(value_st)->getKey()); + break; + case ANY: + check_error(ALWAYS_FAILS); } + } - // return the domain - if (otherTypeName != NULL) - typeName = otherTypeName; + // return the domain + if (otherTypeName != NULL) + typeName = otherTypeName; - switch (type) { + switch (type) { case BOOL: case INT: case FLOAT: return(new EnumeratedDomain(getCESchema()->getDataType(typeName.c_str()),values)); case STRING: @@ -1554,11 +1555,12 @@ namespace EUROPA { return(new SymbolDomain(values,getCESchema()->getDataType(typeName.c_str()))); case OBJECT: return(new EnumeratedDomain(getCESchema()->getDataType(typeName.c_str()),values)); - default: + case ANY: check_error(ALWAYS_FAILS); return(0); - } } + check_error(ALWAYS_FAILS); +} edouble DbClientTransactionPlayer::xmlAsValue(const TiXmlElement & value, const char * name) { const char * tag = value.Value(); @@ -1583,10 +1585,10 @@ namespace EUROPA { // Now deallocate domains created for arguments for (std::vector::const_iterator it = arguments.begin(); it != arguments.end(); ++it) { - Domain* tmp = (Domain*)(*it); + Domain* tmp = const_cast(*it); delete tmp; } - return (edouble)object->getKey(); + return static_cast(object->getKey()); } if (strcmp(tag, "value") == 0) { // New style XML for simple types. @@ -1633,20 +1635,20 @@ namespace EUROPA { if (token_path != NULL) { TokenId token = m_client->getTokenByPath(pathAsVector(token_path)); check_error(token.isValid()); - check_error((unsigned)index < token->getVariables().size()); - return token->getVariables()[index]; + check_error(static_cast(index) < token->getVariables().size()); + return token->getVariables()[static_cast(index)]; } const char * object_name = variable.Attribute("object"); if (object_name != NULL) { ObjectId object = m_client->getObject(object_name); check_error(object.isValid()); - check_error((unsigned)index < object->getVariables().size()); - return object->getVariables()[index]; + check_error(static_cast(index) < object->getVariables().size()); + return object->getVariables()[static_cast(index)]; } // rule variables - return m_client->getVariableByIndex(index); + return m_client->getVariableByIndex(static_cast(index)); } ConstrainedVariableId var = xmlAsCreateVariable(NULL, NULL, &variable); diff --git a/src/PLASMA/PlanDatabase/component/DbClientTransactionPlayer.hh b/src/PLASMA/PlanDatabase/component/DbClientTransactionPlayer.hh index c09d3eb6f..7cb5a3170 100644 --- a/src/PLASMA/PlanDatabase/component/DbClientTransactionPlayer.hh +++ b/src/PLASMA/PlanDatabase/component/DbClientTransactionPlayer.hh @@ -1,5 +1,5 @@ -#ifndef _H_DbClientTransactionPlayer -#define _H_DbClientTransactionPlayer +#ifndef H_DbClientTransactionPlayer +#define H_DbClientTransactionPlayer #include "PlanDatabaseDefs.hh" #include @@ -33,7 +33,7 @@ namespace EUROPA { * @brief Play all transactions from a given TransactionLog * @param txLog the source log which has all transactions in memory */ - void play(const DbClientTransactionLogId& txLog); + void play(const DbClientTransactionLogId txLog); /** * @brief Play the inverses of transactions from an input stream. @@ -48,14 +48,17 @@ namespace EUROPA { * @param txLog The source log which has all transactions in memory. * @param breakpoint If true, stop at the first "breakpoint" transaction */ - void rewind(const DbClientTransactionLogId& txLog, bool breakpoint = false); + void rewind(const DbClientTransactionLogId txLog, bool breakpoint = false); void setFilter(const std::set& filters); static const std::set& MODEL_TRANSACTIONS(); static const std::set& STATE_TRANSACTIONS(); static const std::set& NO_TRANSACTIONS(); - static const char* getObjectAndType(const SchemaId& schema, const DbClientId& client, const char* predicate,ObjectId& object); + static std::string getObjectAndType(const SchemaId schema, + const DbClientId client, + const std::string& predicate, + ObjectId& object); protected: typedef std::multimap, ConstraintId> TemporalRelations; @@ -115,18 +118,18 @@ namespace EUROPA { void playUninvokeTransaction(const TiXmlElement& element, Iterator start, Iterator end); void playTemporalRelationCreated(const TiXmlElement& element); void playTemporalRelationDeleted(const TiXmlElement& element); - TemporalRelations::iterator getTemporalConstraint(const ConstrainedVariableId& fvar, - const ConstrainedVariableId& svar, + TemporalRelations::iterator getTemporalConstraint(const ConstrainedVariableId fvar, + const ConstrainedVariableId svar, const std::string& name); void deleteTemporalConstraint(TemporalRelations::iterator it); - void removeTemporalConstraint(const ConstrainedVariableId& fvar, - const ConstrainedVariableId& svar, + void removeTemporalConstraint(const ConstrainedVariableId fvar, + const ConstrainedVariableId svar, const std::string& name); void getElementsFromConstrain(const TiXmlElement& elem, ObjectId& obj, TokenId& pred, TokenId& succ); - const CESchemaId& getCESchema() const; - const SchemaId& getSchema() const; + CESchemaId getCESchema() const; + SchemaId getSchema() const; DbClientId m_client; int m_objectCount; @@ -207,4 +210,4 @@ namespace EUROPA { }; } -#endif // _H_DbClientTransactionPlayer +#endif // H_DbClientTransactionPlayer diff --git a/src/PLASMA/PlanDatabase/component/EventToken.cc b/src/PLASMA/PlanDatabase/component/EventToken.cc index b7e09c054..25a3d1e0b 100644 --- a/src/PLASMA/PlanDatabase/component/EventToken.cc +++ b/src/PLASMA/PlanDatabase/component/EventToken.cc @@ -6,38 +6,38 @@ namespace EUROPA{ - EventToken::EventToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, - bool closed) +EventToken::EventToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + const IntervalIntDomain& timeBaseDomain, + const std::string& objectName, + bool closed) :Token(planDatabase, predicateName, rejectable, - isFact, + _isFact, IntervalIntDomain(0, 0), objectName, - closed){ - commonInit(timeBaseDomain); - } + closed), m_time() { + commonInit(timeBaseDomain); +} - EventToken::EventToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, + EventToken::EventToken(const TokenId _master, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed) - :Token(master, relation, predicateName, + :Token(_master, relation, predicateName, IntervalIntDomain(0, 0), objectName, - closed){ + closed), m_time() { commonInit(timeBaseDomain); } - const TempVarId& EventToken::start() const{return m_time;} - const TempVarId& EventToken::end() const{return m_time;} - const TempVarId& EventToken::getTime() const{return m_time;} + const TempVarId EventToken::start() const{return m_time;} + const TempVarId EventToken::end() const{return m_time;} + const TempVarId EventToken::getTime() const{return m_time;} void EventToken::commonInit(const IntervalIntDomain& timeBaseDomain){ m_time = (new TokenVariable(m_id, @@ -46,7 +46,7 @@ namespace EUROPA{ timeBaseDomain, false, // TODO: fixme true, - LabelStr("time")))->getId(); + "time"))->getId(); m_allVariables.push_back(m_time); } } diff --git a/src/PLASMA/PlanDatabase/component/EventToken.hh b/src/PLASMA/PlanDatabase/component/EventToken.hh index 7ea6c242b..bba337924 100644 --- a/src/PLASMA/PlanDatabase/component/EventToken.hh +++ b/src/PLASMA/PlanDatabase/component/EventToken.hh @@ -1,5 +1,5 @@ -#ifndef _H_EventToken -#define _H_EventToken +#ifndef H_EventToken +#define H_EventToken #include "PlanDatabaseDefs.hh" #include "IntervalToken.hh" @@ -12,24 +12,24 @@ namespace EUROPA { */ class EventToken: public Token { public: - EventToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + EventToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, const IntervalIntDomain& timeBaseDomain = IntervalIntDomain(), - const LabelStr& objectName = Token::noObject(), + const std::string& objectName = Token::noObject(), bool closed = true); - EventToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, + EventToken(const TokenId master, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& timeBaseDomain = IntervalIntDomain(), - const LabelStr& objectName = Token::noObject(), + const std::string& objectName = Token::noObject(), bool closed = true); - const TempVarId& start() const; - const TempVarId& end() const; - const TempVarId& getTime() const; + const TempVarId start() const; + const TempVarId end() const; + const TempVarId getTime() const; private: void commonInit(const IntervalIntDomain& timeBaseDomain); TempVarId m_time; diff --git a/src/PLASMA/PlanDatabase/component/IntervalToken.cc b/src/PLASMA/PlanDatabase/component/IntervalToken.cc index ab7f8acff..4318dd26d 100644 --- a/src/PLASMA/PlanDatabase/component/IntervalToken.cc +++ b/src/PLASMA/PlanDatabase/component/IntervalToken.cc @@ -6,47 +6,47 @@ namespace EUROPA{ - IntervalToken::IntervalToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, - bool closed) - :Token(planDatabase, - predicateName, - rejectable, - isFact, - durationBaseDomain, - objectName, - false){ - commonInit(startBaseDomain, endBaseDomain, closed); - } +IntervalToken::IntervalToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const std::string& objectName, + bool closed) +:Token(planDatabase, + predicateName, + rejectable, + _isFact, + durationBaseDomain, + objectName, + false), m_start(), m_end(){ + commonInit(startBaseDomain, endBaseDomain, closed); +} - IntervalToken::IntervalToken(const TokenId& m_master, - const LabelStr& m_relation, - const LabelStr& predicateName, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, - bool closed) - :Token(m_master, - m_relation, +IntervalToken::IntervalToken(const TokenId _master, + const std::string& _relation, + const std::string& predicateName, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const std::string& objectName, + bool closed) + :Token(_master, + _relation, predicateName, durationBaseDomain, objectName, - false){ - commonInit(startBaseDomain, endBaseDomain, closed); - } + false), m_start(), m_end() { + commonInit(startBaseDomain, endBaseDomain, closed); +} - const TempVarId& IntervalToken::start() const{ + const TempVarId IntervalToken::start() const{ checkError(m_start.isValid(), m_start); return m_start;} - const TempVarId& IntervalToken::end() const{ + const TempVarId IntervalToken::end() const{ checkError(m_end.isValid(), m_end); return m_end; } @@ -65,7 +65,7 @@ namespace EUROPA{ startBaseDomain, false, // TODO: fixme true, - LabelStr("start")))->getId(); + "start"))->getId(); m_allVariables.push_back(m_start); m_end = (new TokenVariable(m_id, @@ -74,7 +74,7 @@ namespace EUROPA{ endBaseDomain, false, // TODO: fixme true, - LabelStr("end")))->getId(); + "end"))->getId(); m_allVariables.push_back(m_end); std::vector temp; @@ -83,7 +83,7 @@ namespace EUROPA{ temp.push_back(m_end); ConstraintId temporalRelation = - m_planDatabase->getConstraintEngine()->createConstraint(LabelStr("temporalDistance"),temp); + m_planDatabase->getConstraintEngine()->createConstraint("temporalDistance",temp); m_standardConstraints.insert(temporalRelation); diff --git a/src/PLASMA/PlanDatabase/component/IntervalToken.hh b/src/PLASMA/PlanDatabase/component/IntervalToken.hh index 1d163910b..4f21e79fb 100644 --- a/src/PLASMA/PlanDatabase/component/IntervalToken.hh +++ b/src/PLASMA/PlanDatabase/component/IntervalToken.hh @@ -1,5 +1,5 @@ -#ifndef _H_IntervalToken -#define _H_IntervalToken +#ifndef H_IntervalToken +#define H_IntervalToken #include "PlanDatabaseDefs.hh" #include "Token.hh" @@ -12,27 +12,27 @@ namespace EUROPA { class IntervalToken: public Token { public: - IntervalToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + IntervalToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, const IntervalIntDomain& startBaseDomain = IntervalIntDomain(), const IntervalIntDomain& endBaseDomain = IntervalIntDomain(), const IntervalIntDomain& durationBaseDomain = IntervalIntDomain(1, PLUS_INFINITY), - const LabelStr& objectName = Token::noObject(), + const std::string& objectName = Token::noObject(), bool closed = true); - IntervalToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, + IntervalToken(const TokenId master, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain = IntervalIntDomain(), const IntervalIntDomain& endBaseDomain = IntervalIntDomain(), const IntervalIntDomain& durationBaseDomain = IntervalIntDomain(1, PLUS_INFINITY), - const LabelStr& objectName = Token::noObject(), + const std::string& objectName = Token::noObject(), bool closed = true); - const TempVarId& start() const; - const TempVarId& end() const; + const TempVarId start() const; + const TempVarId end() const; private: void commonInit(const IntervalIntDomain& startBaseDomain, diff --git a/src/PLASMA/PlanDatabase/component/Methods.cc b/src/PLASMA/PlanDatabase/component/Methods.cc index 155a027f3..e1d47bd9d 100644 --- a/src/PLASMA/PlanDatabase/component/Methods.cc +++ b/src/PLASMA/PlanDatabase/component/Methods.cc @@ -15,30 +15,31 @@ namespace EUROPA { // TODO: keep using pdbClient? -const DbClientId& getCtxPDB(EvalContext& context) -{ - // TODO: Add this behavior to EvalContext instead? - DbClient* dbClient = (DbClient*)context.getElement("DbClient"); - if (dbClient != NULL) - return dbClient->getId(); +namespace { +const DbClientId getCtxPDB(EvalContext& context) { + // TODO: Add this behavior to EvalContext instead? + DbClient* dbClient = reinterpret_cast(context.getElement("DbClient")); + if (dbClient != NULL) + return dbClient->getId(); - PlanDatabase* pdb = (PlanDatabase*)context.getElement("PlanDatabase"); - check_error(pdb != NULL,"Could not find Plan Database in eval context"); - return pdb->getClient(); + PlanDatabase* pdb = reinterpret_cast(context.getElement("PlanDatabase")); + check_error(pdb != NULL,"Could not find Plan Database in eval context"); + return pdb->getClient(); } -TokenId varToToken(const ConstrainedVariableId& v) +TokenId varToToken(const ConstrainedVariableId v) { StateVarId stateVar = v; return stateVar->getParentToken(); } -ObjectId varToObject(const ConstrainedVariableId& v) +ObjectId varToObject(const ConstrainedVariableId v) { return Entity::getTypedEntity(v->derivedDomain().getSingletonValue()); } +} -DataRef PDBClose::eval(EvalContext& context, const std::vector& args) const +DataRef PDBClose::eval(EvalContext& context, const std::vector&) const { getCtxPDB(context)->close(); return DataRef::null; @@ -50,7 +51,7 @@ const std::vector& PDBClose::getSignature() return signature; } -const DataTypeId& PDBClose::getReturnType() +const DataTypeId PDBClose::getReturnType() { return VoidDT::instance(); } @@ -68,12 +69,12 @@ const std::vector& VariableMethod::getSignature() return signature; } -const DataTypeId& VariableMethod::getReturnType() +const DataTypeId VariableMethod::getReturnType() { return VoidDT::instance(); } -DataRef SpecifyVariable::eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const +DataRef SpecifyVariable::eval(EvalContext& context, ConstrainedVariableId var, const std::vector& args) const { const Domain& ad = args[1]->lastDomain(); if (ad.isSingleton()) @@ -84,13 +85,13 @@ DataRef SpecifyVariable::eval(EvalContext& context, ConstrainedVariableId& var, return DataRef::null; } -DataRef ResetVariable::eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const +DataRef ResetVariable::eval(EvalContext& context, ConstrainedVariableId var, const std::vector&) const { getCtxPDB(context)->reset(var); return DataRef::null; } -DataRef CloseVariable::eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const +DataRef CloseVariable::eval(EvalContext& context, ConstrainedVariableId var, const std::vector&) const { getCtxPDB(context)->close(var); return DataRef::null; @@ -109,12 +110,12 @@ const std::vector& ObjectMethod::getSignature() return signature; } -const DataTypeId& ObjectMethod::getReturnType() +const DataTypeId ObjectMethod::getReturnType() { return VoidDT::instance(); } -DataRef ConstrainToken::eval(EvalContext& context, ObjectId& obj, const std::vector& args) const +DataRef ConstrainToken::eval(EvalContext& context, ObjectId obj, const std::vector& args) const { TokenId pred = varToToken(args[1]); TokenId succ = (args.size()==3 ? varToToken(args[2]) : pred); @@ -123,7 +124,7 @@ DataRef ConstrainToken::eval(EvalContext& context, ObjectId& obj, const std::vec return DataRef::null; } -DataRef FreeToken::eval(EvalContext& context, ObjectId& obj, const std::vector& args) const +DataRef FreeToken::eval(EvalContext& context, ObjectId obj, const std::vector& args) const { TokenId pred = varToToken(args[1]); TokenId succ = (args.size()==3 ? varToToken(args[2]) : pred); @@ -145,12 +146,12 @@ const std::vector& TokenMethod::getSignature() return signature; } -const DataTypeId& TokenMethod::getReturnType() +const DataTypeId TokenMethod::getReturnType() { return VoidDT::instance(); } -DataRef ActivateToken::eval(EvalContext& context, TokenId& tok, const std::vector& args) const +DataRef ActivateToken::eval(EvalContext& context, TokenId tok, const std::vector&) const { if(!tok->isActive()) //Temporary. Pull out when we scrub test input files. DbClientTransactionPlayer is doing the same getCtxPDB(context)->activate(tok); @@ -158,20 +159,20 @@ DataRef ActivateToken::eval(EvalContext& context, TokenId& tok, const std::vecto return DataRef::null; } -DataRef MergeToken::eval(EvalContext& context, TokenId& tok, const std::vector& args) const +DataRef MergeToken::eval(EvalContext& context, TokenId tok, const std::vector& args) const { TokenId activeToken = varToToken(args[1]); getCtxPDB(context)->merge(tok,activeToken); return DataRef::null; } -DataRef RejectToken::eval(EvalContext& context, TokenId& tok, const std::vector& args) const +DataRef RejectToken::eval(EvalContext& context, TokenId tok, const std::vector&) const { getCtxPDB(context)->reject(tok); return DataRef::null; } -DataRef CancelToken::eval(EvalContext& context, TokenId& tok, const std::vector& args) const +DataRef CancelToken::eval(EvalContext& context, TokenId tok, const std::vector&) const { getCtxPDB(context)->cancel(tok); return DataRef::null; @@ -191,7 +192,7 @@ const std::vector& CloseClass::getSignature() return signature; } -const DataTypeId& CloseClass::getReturnType() +const DataTypeId CloseClass::getReturnType() { return VoidDT::instance(); } diff --git a/src/PLASMA/PlanDatabase/component/Methods.hh b/src/PLASMA/PlanDatabase/component/Methods.hh index 77d5ece03..ccea94c4d 100644 --- a/src/PLASMA/PlanDatabase/component/Methods.hh +++ b/src/PLASMA/PlanDatabase/component/Methods.hh @@ -24,7 +24,7 @@ public: virtual DataRef eval(EvalContext& context, const std::vector& args) const; virtual const std::vector& getSignature(); - virtual const DataTypeId& getReturnType(); + virtual const DataTypeId getReturnType(); }; class VariableMethod : public Method @@ -36,10 +36,10 @@ public: virtual DataRef eval(EvalContext& context, const std::vector& args) const; virtual const std::vector& getSignature(); - virtual const DataTypeId& getReturnType(); + virtual const DataTypeId getReturnType(); protected: - virtual DataRef eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const = 0; + virtual DataRef eval(EvalContext& context, ConstrainedVariableId var, const std::vector& args) const = 0; }; class SpecifyVariable : public VariableMethod @@ -49,7 +49,7 @@ public: virtual ~SpecifyVariable() {} protected: - virtual DataRef eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, ConstrainedVariableId var, const std::vector& args) const; }; class ResetVariable : public VariableMethod @@ -59,7 +59,7 @@ public: virtual ~ResetVariable() {} protected: - virtual DataRef eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, ConstrainedVariableId var, const std::vector& args) const; }; class CloseVariable : public VariableMethod @@ -69,7 +69,7 @@ public: virtual ~CloseVariable() {} protected: - virtual DataRef eval(EvalContext& context, ConstrainedVariableId& var, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, ConstrainedVariableId var, const std::vector& args) const; }; @@ -82,10 +82,10 @@ public: virtual DataRef eval(EvalContext& context, const std::vector& args) const; virtual const std::vector& getSignature(); - virtual const DataTypeId& getReturnType(); + virtual const DataTypeId getReturnType(); protected: - virtual DataRef eval(EvalContext& context, ObjectId& obj, const std::vector& args) const = 0; + virtual DataRef eval(EvalContext& context, ObjectId obj, const std::vector& args) const = 0; }; class ConstrainToken : public ObjectMethod @@ -95,7 +95,7 @@ public: virtual ~ConstrainToken() {} protected: - virtual DataRef eval(EvalContext& context, ObjectId& obj, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, ObjectId obj, const std::vector& args) const; }; class FreeToken : public ObjectMethod @@ -105,7 +105,7 @@ public: virtual ~FreeToken() {} protected: - virtual DataRef eval(EvalContext& context, ObjectId& obj, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, ObjectId obj, const std::vector& args) const; }; @@ -118,10 +118,10 @@ public: virtual DataRef eval(EvalContext& context, const std::vector& args) const; virtual const std::vector& getSignature(); - virtual const DataTypeId& getReturnType(); + virtual const DataTypeId getReturnType(); protected: - virtual DataRef eval(EvalContext& context, TokenId& tok, const std::vector& args) const = 0; + virtual DataRef eval(EvalContext& context, TokenId tok, const std::vector& args) const = 0; }; class ActivateToken : public TokenMethod @@ -131,7 +131,7 @@ public: virtual ~ActivateToken() {} protected: - virtual DataRef eval(EvalContext& context, TokenId& tok, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, TokenId tok, const std::vector& args) const; }; class MergeToken : public TokenMethod @@ -141,7 +141,7 @@ public: virtual ~MergeToken() {} protected: - virtual DataRef eval(EvalContext& context, TokenId& tok, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, TokenId tok, const std::vector& args) const; }; class RejectToken : public TokenMethod @@ -151,7 +151,7 @@ public: virtual ~RejectToken() {} protected: - virtual DataRef eval(EvalContext& context, TokenId& tok, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, TokenId tok, const std::vector& args) const; }; class CancelToken : public TokenMethod @@ -161,7 +161,7 @@ public: virtual ~CancelToken() {} protected: - virtual DataRef eval(EvalContext& context, TokenId& tok, const std::vector& args) const; + virtual DataRef eval(EvalContext& context, TokenId tok, const std::vector& args) const; }; class CloseClass : public Method @@ -173,7 +173,7 @@ public: virtual DataRef eval(EvalContext& context, const std::vector& args) const; virtual const std::vector& getSignature(); - virtual const DataTypeId& getReturnType(); + virtual const DataTypeId getReturnType(); }; } diff --git a/src/PLASMA/PlanDatabase/component/Timeline.cc b/src/PLASMA/PlanDatabase/component/Timeline.cc index 784a96b34..221680baf 100644 --- a/src/PLASMA/PlanDatabase/component/Timeline.cc +++ b/src/PLASMA/PlanDatabase/component/Timeline.cc @@ -25,11 +25,15 @@ namespace EUROPA { /** TIMELINE IMPLEMENTATION **/ - Timeline::Timeline(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open) - : Object(planDatabase, type, name, true) {commonInit(open);} +Timeline::Timeline(const PlanDatabaseId planDatabase, const std::string& type, + const std::string& name, bool open) + : Object(planDatabase, type, name, true), m_tokenSequence(), m_tokenIndex() +{commonInit(open);} - Timeline::Timeline(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open) - : Object(parent, type, localName, true) {commonInit(open);} + Timeline::Timeline(const ObjectId parent, const std::string& type, + const std::string& localName, bool open) + : Object(parent, type, localName, true), m_tokenSequence(), m_tokenIndex() +{commonInit(open);} Timeline::~Timeline(){ discard(false); @@ -40,13 +44,13 @@ namespace EUROPA { close(); } - bool Timeline::hasToken(const TokenId& token) const{ + bool Timeline::hasToken(const TokenId token) const{ return m_tokenIndex.find(token->getKey()) != m_tokenIndex.end(); } - void Timeline::getOrderingChoices(const TokenId& token, + void Timeline::getOrderingChoices(const TokenId token, std::vector< std::pair >& results, - unsigned int limit){ + unsigned long limit){ check_error(results.empty()); check_error(token.isValid()); check_error(limit > 0, "Cannot set limit to less than 1."); @@ -64,7 +68,7 @@ namespace EUROPA { // we trap that as an error. We could just return indicating no choices but that might lead caller to conclude // there is simply an inconsistency rather than force them to write code to ensure this does not happen. check_error(m_tokenIndex.find(token->getKey()) == m_tokenIndex.end(), - "Attempted to query for choices to constrain token " + token->getPredicateName().toString() + + "Attempted to query for choices to constrain token " + token->getPredicateName() + " which has already been constrained."); // If the sequence is empty, add the case where both elements of the pair are the given token. @@ -198,7 +202,7 @@ namespace EUROPA { * @todo Consider deactivating redundant constraints. If we do this, we would also have to * activate them when freeing. */ - void Timeline::constrain(const TokenId& predecessor, const TokenId& successor) { + void Timeline::constrain(const TokenId predecessor, const TokenId successor) { checkError(getPrecedenceConstraint(predecessor, successor).isNoId(), "At least one of predecessor and successor should not be sequenced yet." << predecessor->toString() << " before " << successor->toString()); @@ -273,12 +277,12 @@ namespace EUROPA { } } - void Timeline::add(const TokenId& token){ + void Timeline::add(const TokenId token){ Object::add(token); notifyOrderingRequired(token); } - void Timeline::remove(const TokenId& token) { + void Timeline::remove(const TokenId token) { check_error(token.isValid()); check_error(isValid(CLEANING_UP)); @@ -329,7 +333,7 @@ namespace EUROPA { * what tokens to remove from the sequence, and what constraints should correctly * be removed. */ - void Timeline::free(const TokenId& predecessor, const TokenId& successor) { + void Timeline::free(const TokenId predecessor, const TokenId successor) { check_error(m_tokenIndex.find(predecessor->getKey()) != m_tokenIndex.end() && m_tokenIndex.find(successor->getKey()) != m_tokenIndex.end(), "Predecessor and successor must both be sequenced if they are to be freed"); @@ -408,13 +412,13 @@ namespace EUROPA { // Also ensure x.end <= (x+1).start. if (!cleaningUp && getPlanDatabase()->getConstraintEngine()->constraintConsistent()) { check_error(predecessor.isNoId() || isConstrainedToPrecede(predecessor, token)); - eint earliest_start = (eint) token->start()->lastDomain().getLowerBound(); - eint latest_start = (eint) token->start()->lastDomain().getUpperBound(); + eint earliest_start = static_cast(token->start()->lastDomain().getLowerBound()); + eint latest_start = static_cast(token->start()->lastDomain().getUpperBound()); check_error(earliest_start == MINUS_INFINITY || earliest_start == PLUS_INFINITY || earliest_start > prior_earliest_start); check_error(prior_earliest_end <= earliest_start); check_error(prior_latest_end <= latest_start); - prior_earliest_end = (eint) token->end()->lastDomain().getLowerBound(); - prior_latest_end = (eint) token->end()->lastDomain().getLowerBound(); + prior_earliest_end = static_cast(token->end()->lastDomain().getLowerBound()); + prior_latest_end = static_cast(token->end()->lastDomain().getLowerBound()); prior_earliest_start = earliest_start; } predecessor = token; @@ -424,15 +428,15 @@ namespace EUROPA { return(true); } - bool Timeline::atStart(const TokenId& token) const { + bool Timeline::atStart(const TokenId token) const { return(!m_tokenSequence.empty() && token == m_tokenSequence.front()); } - bool Timeline::atEnd(const TokenId& token) const { + bool Timeline::atEnd(const TokenId token) const { return(!m_tokenSequence.empty() && token == m_tokenSequence.back()); } - TokenId Timeline::removeSuccessor(const TokenId& token) { + TokenId Timeline::removeSuccessor(const TokenId token) { freeImplicitConstraints(token); std::list::iterator pos = m_tokenIndex.find(token->getKey())->second; removeFromIndex(token); @@ -451,7 +455,7 @@ namespace EUROPA { return *pos; } - TokenId Timeline::removePredecessor(const TokenId& token) { + TokenId Timeline::removePredecessor(const TokenId token) { freeImplicitConstraints(token); std::list::iterator pos = m_tokenIndex.find(token->getKey())->second; removeFromIndex(token); @@ -470,7 +474,7 @@ namespace EUROPA { return(*pos); } - bool Timeline::adjacent(const TokenId& x, const TokenId& y) const { + bool Timeline::adjacent(const TokenId x, const TokenId y) const { if (x.isNoId() || y.isNoId()) return(false); std::list::const_iterator pos = m_tokenIndex.find(x->getKey())->second; @@ -478,7 +482,7 @@ namespace EUROPA { return(pos != m_tokenSequence.end() && y == *pos); } - void Timeline::unlink(const TokenId& token) { + void Timeline::unlink(const TokenId token) { freeImplicitConstraints(token); std::list::iterator pos = m_tokenIndex.find(token->getKey())->second; removeFromIndex(token); @@ -498,27 +502,27 @@ namespace EUROPA { return; } - void Timeline::insertToIndex(const TokenId& token, const std::list::iterator& position){ + void Timeline::insertToIndex(const TokenId token, const std::list::iterator& position){ // Remove the cache entry for this token as it is now inserted m_tokenIndex.insert(std::make_pair(token->getKey(), position)); } - void Timeline::removeFromIndex(const TokenId& token){ + void Timeline::removeFromIndex(const TokenId token){ m_tokenIndex.erase(token->getKey()); notifyOrderingRequired(token); } - bool Timeline::orderingRequired(const TokenId& token){ + bool Timeline::orderingRequired(const TokenId token){ return (!token->isDeleted() && m_tokenIndex.find(token->getKey()) == m_tokenIndex.end()); } - void Timeline::notifyMerged(const TokenId& token){} - void Timeline::notifyRejected(const TokenId& token) {} - void Timeline::notifyDeleted(const TokenId& token){ + void Timeline::notifyMerged(const TokenId ){} + void Timeline::notifyRejected(const TokenId) {} + void Timeline::notifyDeleted(const TokenId token){ remove(token); } - TimelineObjectFactory::TimelineObjectFactory(const ObjectTypeId& objType) + TimelineObjectFactory::TimelineObjectFactory(const ObjectTypeId objType) : NativeObjectFactory(objType,objType->getName()) { } @@ -528,13 +532,13 @@ namespace EUROPA { } ObjectId TimelineObjectFactory::makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, - const std::vector& arguments) const + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, + const std::vector&) const { ObjectId instance = (new Timeline(planDb, objectType, objectName,true))->getId(); - debugMsg("Interpreter:NativeObjectFactory","Created Native " << m_className.toString() << ":" << objectName.toString() << " type:" << objectType.toString()); + debugMsg("Interpreter:NativeObjectFactory","Created Native " << m_className << ":" << objectName << " type:" << objectType); return instance; } diff --git a/src/PLASMA/PlanDatabase/component/Timeline.hh b/src/PLASMA/PlanDatabase/component/Timeline.hh index 5be805c21..84c39dec1 100644 --- a/src/PLASMA/PlanDatabase/component/Timeline.hh +++ b/src/PLASMA/PlanDatabase/component/Timeline.hh @@ -1,5 +1,5 @@ -#ifndef _H_Timeline -#define _H_Timeline +#ifndef H_Timeline +#define H_Timeline /** * @file Timeline.hh @@ -26,15 +26,15 @@ namespace EUROPA { enum Policy {EARLIEST = 0, LATEST}; - Timeline(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open = false); + Timeline(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open = false); - Timeline(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open = false); + Timeline(const ObjectId parent, const std::string& type, const std::string& localName, bool open = false); virtual ~Timeline(); - void getOrderingChoices(const TokenId& token, + void getOrderingChoices(const TokenId token, std::vector< std::pair >& results, - unsigned int limit = std::numeric_limits::max()); + unsigned long limit = std::numeric_limits::max()); void getTokensToOrder(std::vector& results); @@ -45,19 +45,19 @@ namespace EUROPA { * explicit ordering. * @see constrain */ - bool hasToken(const TokenId& token) const; + bool hasToken(const TokenId token) const; const std::list& getTokenSequence() const; - void constrain(const TokenId& predecessor, const TokenId& successor); + void constrain(const TokenId predecessor, const TokenId successor); - void free(const TokenId& predecessor, const TokenId& successor); + void free(const TokenId predecessor, const TokenId successor); protected: /** Implement notifications to synch cached data **/ - void notifyMerged(const TokenId& token); - void notifyRejected(const TokenId& token); - void notifyDeleted(const TokenId& token); + void notifyMerged(const TokenId token); + void notifyRejected(const TokenId token); + void notifyDeleted(const TokenId token); private: /** @@ -66,30 +66,30 @@ namespace EUROPA { void commonInit(bool open); /** Over-ride base class implementations to add extra handling **/ - void add(const TokenId& token); - void remove(const TokenId& token); + void add(const TokenId token); + void remove(const TokenId token); - void insertToIndex(const TokenId& token, const std::list::iterator& position); - void removeFromIndex(const TokenId& token); - bool orderingRequired(const TokenId& token); + void insertToIndex(const TokenId token, const std::list::iterator& position); + void removeFromIndex(const TokenId token); + bool orderingRequired(const TokenId token); bool isValid(bool cleaningUp = false) const; /** * @brief True iff this token is the first in the sequence */ - bool atStart(const TokenId& token) const; + bool atStart(const TokenId token) const; /** * @brief True iff this token is the last in the sequence */ - bool atEnd(const TokenId& token) const; + bool atEnd(const TokenId token) const; /** Helper methods for the 'free' algorithm */ - void unlink(const TokenId& token); - TokenId removeSuccessor(const TokenId& token); - TokenId removePredecessor(const TokenId& token); - bool adjacent(const TokenId& x, const TokenId& y) const; + void unlink(const TokenId token); + TokenId removeSuccessor(const TokenId token); + TokenId removePredecessor(const TokenId token); + bool adjacent(const TokenId x, const TokenId y) const; /** @@ -110,14 +110,14 @@ namespace EUROPA { class TimelineObjectFactory : public NativeObjectFactory { public: - TimelineObjectFactory(const ObjectTypeId& objType); + TimelineObjectFactory(const ObjectTypeId objType); virtual ~TimelineObjectFactory(); protected: virtual ObjectId makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const; }; } diff --git a/src/PLASMA/PlanDatabase/test/db-test-module.cc b/src/PLASMA/PlanDatabase/test/db-test-module.cc index 1dbb7dbdb..f9fb14b5f 100644 --- a/src/PLASMA/PlanDatabase/test/db-test-module.cc +++ b/src/PLASMA/PlanDatabase/test/db-test-module.cc @@ -1,5 +1,6 @@ #include "db-test-module.hh" +#include "TestUtils.hh" #include "Utils.hh" #include "PlanDatabase.hh" #include "Schema.hh" @@ -20,19 +21,26 @@ #include "Debug.hh" #include "PlanDatabaseWriter.hh" +#include "CESchema.hh" #include "Constraints.hh" #include "Engine.hh" #include "ModuleConstraintEngine.hh" #include "ModulePlanDatabase.hh" +#include "unused.hh" + #include #include #include #include +#include -const char* DEFAULT_OBJECT_TYPE = "TestObject"; -const char* DEFAULT_PREDICATE = "TestObject.DEFAULT_PREDICATE"; +using namespace EUROPA; +namespace { +const std::string DEFAULT_OBJECT_TYPE = "TestObject"; +const std::string DEFAULT_PREDICATE = "TestObject.DEFAULT_PREDICATE"; +} #define GET_DEFAULT_OBJECT_TYPE(ce) ce->getCESchema()->getDataType(DEFAULT_OBJECT_TYPE) #define GET_DATA_TYPE(pdb,dt) pdb->getSchema()->getCESchema()->getDataType(dt) @@ -42,23 +50,24 @@ const char* DEFAULT_PREDICATE = "TestObject.DEFAULT_PREDICATE"; class DBFoo : public Timeline { public: - DBFoo(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name); - DBFoo(const ObjectId& parent, const LabelStr& type, const LabelStr& name); + DBFoo(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name); + DBFoo(const ObjectId parent, const std::string& type, const std::string& name); void handleDefaults(bool autoClose = true); // default variable initialization // test/simple-predicate.nddl:4 DBFoo + void constructor(const std::vector&) {constructor();} void constructor(); - void constructor(eint arg0, LabelStr& arg1); + void constructor(eint arg0, const LabelStr& arg1); ConstrainedVariableId m_0; ConstrainedVariableId m_1; }; - DBFoo::DBFoo(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name) - : Timeline(planDatabase, type, name, true) { - } +DBFoo::DBFoo(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name) + : Timeline(planDatabase, type, name, true), m_0(), m_1() { +} - DBFoo::DBFoo(const ObjectId& parent, const LabelStr& type, const LabelStr& name) - : Timeline(parent, type, name, true) {} +DBFoo::DBFoo(const ObjectId parent, const std::string& type, const std::string& name) + : Timeline(parent, type, name, true), m_0(), m_1() {} // default initialization of member variables void DBFoo::handleDefaults(bool autoClose) { @@ -74,19 +83,19 @@ const char* DEFAULT_PREDICATE = "TestObject.DEFAULT_PREDICATE"; m_1 = addVariable(LabelSet(LabelStr("Hello World")), "LabelSetVar"); } - void DBFoo::constructor(eint arg0, LabelStr& arg1) { + void DBFoo::constructor(eint arg0, const LabelStr&) { m_0 = addVariable(IntervalIntDomain(arg0), "IntervalIntVar"); m_1 = addVariable(LabelSet(LabelStr("Hello World")), "LabelSetVar"); } class StandardDBFooFactory: public ObjectFactory { public: - StandardDBFooFactory(): ObjectFactory(LabelStr(DEFAULT_OBJECT_TYPE)){} + StandardDBFooFactory(): ObjectFactory(DEFAULT_OBJECT_TYPE){} private: - ObjectId createInstance(const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + ObjectId createInstance(const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { CPPUNIT_ASSERT(arguments.empty()); DBFooId foo = (new DBFoo(planDb, objectType, objectName))->getId(); @@ -98,21 +107,21 @@ const char* DEFAULT_PREDICATE = "TestObject.DEFAULT_PREDICATE"; class SpecialDBFooFactory: public ObjectFactory{ public: - SpecialDBFooFactory(): ObjectFactory(LabelStr(DEFAULT_OBJECT_TYPE).toString() + + SpecialDBFooFactory(): ObjectFactory(DEFAULT_OBJECT_TYPE + ":" + IntDT::NAME() + ":" + StringDT::NAME()) {} private: - ObjectId createInstance(const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + ObjectId createInstance(const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { DBFooId foo = (new DBFoo(planDb, objectType, objectName))->getId(); // Type check the arguments CPPUNIT_ASSERT(arguments.size() == 2); - CPPUNIT_ASSERT(arguments[0]->getTypeName().toString() == IntDT::NAME()); - CPPUNIT_ASSERT(arguments[1]->getTypeName().toString() == StringDT::NAME()); + CPPUNIT_ASSERT(arguments[0]->getTypeName() == IntDT::NAME()); + CPPUNIT_ASSERT(arguments[1]->getTypeName() == StringDT::NAME()); eint arg0(arguments[0]->getSingletonValue()); LabelStr arg1(arguments[1]->getSingletonValue()); @@ -122,30 +131,32 @@ const char* DEFAULT_PREDICATE = "TestObject.DEFAULT_PREDICATE"; } }; - class IntervalTokenType: public TokenType { - public: - IntervalTokenType(const ObjectTypeId& ot) - : TokenType(ot,LabelStr(DEFAULT_PREDICATE)) { - addArg(FloatDT::instance(), "IntervalParam"); - addArg(IntDT::instance(), "IntervalIntParam"); - addArg(BoolDT::instance(), "BoolParam"); - addArg(StringDT::instance(), "LabelSetParam"); - addArg(FloatDT::instance(), "EnumeratedParam"); - } - private: - TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable = false, bool isFact = false) const { - TokenId token = (new IntervalToken(planDb, name, rejectable, isFact))->getId(); - return(token); - } - TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const{ - TokenId token = (new IntervalToken(master, relation, name))->getId(); - return(token); - } - }; +class IntervalTokenType: public TokenType { + public: + IntervalTokenType(const ObjectTypeId ot) + : TokenType(ot,DEFAULT_PREDICATE) { + addArg(FloatDT::instance(), "IntervalParam"); + addArg(IntDT::instance(), "IntervalIntParam"); + addArg(BoolDT::instance(), "BoolParam"); + addArg(StringDT::instance(), "LabelSetParam"); + addArg(FloatDT::instance(), "EnumeratedParam"); + } + private: + TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, bool rejectable = false, bool isFact = false) const { + TokenId token = (new IntervalToken(planDb, name, rejectable, isFact))->getId(); + return(token); + } + TokenId createInstance(const TokenId master, const std::string& name, const std::string& relation) const{ + TokenId token = (new IntervalToken(master, relation, name))->getId(); + return(token); + } +}; -void initDbTestSchema(const SchemaId& schema) { +namespace { +void initDbTestSchema(const SchemaId schema) { // Set up object types and compositions for testing - builds a recursive structure - ObjectType* objType = new ObjectType(DEFAULT_OBJECT_TYPE,schema->getObjectType(Schema::rootObject())); + ObjectType* objType = new ObjectType(DEFAULT_OBJECT_TYPE.c_str(), + schema->getObjectType(Schema::rootObject())); objType->addMember(objType->getVarType(), "id0"); objType->addMember(objType->getVarType(), "id1"); @@ -193,6 +204,7 @@ void initDbTestSchema(const SchemaId& schema) { schema->registerEnum("Locations",locationsBaseDomain); } +} class PDBTestEngine : public EngineBase { @@ -200,9 +212,9 @@ class PDBTestEngine : public EngineBase PDBTestEngine(); virtual ~PDBTestEngine(); - const ConstraintEngineId& getConstraintEngine() const; - const SchemaId& getSchema() const; - const PlanDatabaseId& getPlanDatabase() const; + const ConstraintEngineId getConstraintEngine() const; + const SchemaId getSchema() const; + const PlanDatabaseId getPlanDatabase() const; protected: void createModules(); @@ -212,11 +224,11 @@ PDBTestEngine::PDBTestEngine() { createModules(); doStart(); - const SchemaId& schema = ((Schema*)getComponent("Schema"))->getId(); + const SchemaId schema = boost::polymorphic_cast(getComponent("Schema"))->getId(); initDbTestSchema(schema); // Tokens require temporal distance constraints - CESchema* ces = (CESchema*)getComponent("CESchema"); + CESchema* ces = boost::polymorphic_cast(getComponent("CESchema")); REGISTER_SYSTEM_CONSTRAINT(ces,EqualConstraint, "concurrent", "Default"); REGISTER_SYSTEM_CONSTRAINT(ces,LessThanEqualConstraint, "precedes", "Default"); REGISTER_SYSTEM_CONSTRAINT(ces,AddEqualConstraint, "temporaldistance", "Default"); @@ -228,19 +240,19 @@ PDBTestEngine::~PDBTestEngine() doShutdown(); } -const ConstraintEngineId& PDBTestEngine::getConstraintEngine() const +const ConstraintEngineId PDBTestEngine::getConstraintEngine() const { - return ((ConstraintEngine*)getComponent("ConstraintEngine"))->getId(); + return boost::polymorphic_cast(getComponent("ConstraintEngine"))->getId(); } -const SchemaId& PDBTestEngine::getSchema() const +const SchemaId PDBTestEngine::getSchema() const { - return ((Schema*)getComponent("Schema"))->getId(); + return boost::polymorphic_cast(getComponent("Schema"))->getId(); } -const PlanDatabaseId& PDBTestEngine::getPlanDatabase() const +const PlanDatabaseId PDBTestEngine::getPlanDatabase() const { - return ((PlanDatabase*)getComponent("PlanDatabase"))->getId(); + return boost::polymorphic_cast(getComponent("PlanDatabase"))->getId(); } void PDBTestEngine::createModules() @@ -250,9 +262,11 @@ void PDBTestEngine::createModules() addModule((new ModulePlanDatabase())->getId()); } +namespace { ConstraintEngineId ce; SchemaId schema; PlanDatabaseId db; +} #define DEFAULT_SETUP(ce, db, autoClose) \ PDBTestEngine testEngine; \ @@ -266,17 +280,14 @@ PlanDatabaseId db; #define DEFAULT_TEARDOWN() \ } \ -#define DEFAULT_TEARDOWN_MULTI(ce, db) \ - }\ - /** * @brief Declaration and definition for test constraint to force a failure when the domain becomes a singleton */ class ForceFailureConstraint : public Constraint { public: - ForceFailureConstraint(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + ForceFailureConstraint(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables){} @@ -289,14 +300,14 @@ PlanDatabaseId db; class DummyTokenType : public TokenType{ public: - DummyTokenType(const ObjectTypeId& ot,const LabelStr& predicateName) : TokenType(ot, predicateName){} + DummyTokenType(const ObjectTypeId ot,const std::string& predicateName) : TokenType(ot, predicateName){} virtual ~DummyTokenType(){} - virtual TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable, bool isFact) const{ + virtual TokenId createInstance(const PlanDatabaseId, const std::string&, bool, bool) const{ TokenId token; return token; } - virtual TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const{ + virtual TokenId createInstance(const TokenId, const std::string&, const std::string&) const{ TokenId token; return token; } @@ -338,31 +349,31 @@ class SchemaTest { static bool testEnumerations(){ DEFAULT_SETUP(ce, db, true); schema->reset(); - schema->addEnum(LabelStr("FooEnum")); - schema->addValue(LabelStr("FooEnum"), LabelStr("FOO")); - schema->addValue(LabelStr("FooEnum"), LabelStr("BAR")); - schema->addValue(LabelStr("FooEnum"), LabelStr("BAZ")); - schema->addEnum(LabelStr("BarEnum")); - schema->addValue(LabelStr("BarEnum"), 0); - schema->addValue(LabelStr("BarEnum"), 5); - schema->addValue(LabelStr("BarEnum"), 10); - - CPPUNIT_ASSERT(schema->isEnum(LabelStr("FooEnum"))); - CPPUNIT_ASSERT(schema->isEnum(LabelStr("BarEnum"))); - CPPUNIT_ASSERT(!schema->isEnum(LabelStr("BazEnum"))); - CPPUNIT_ASSERT(schema->isEnumValue(LabelStr("FooEnum"), LabelStr("FOO"))); - CPPUNIT_ASSERT(schema->isEnumValue(LabelStr("FooEnum"), LabelStr("BAZ"))); - CPPUNIT_ASSERT(schema->isEnumValue(LabelStr("BarEnum"), 5)); - CPPUNIT_ASSERT(!schema->isEnumValue(LabelStr("BarEnum"), 6)); - - std::list allenums; + schema->addEnum("FooEnum"); + schema->addValue("FooEnum", LabelStr("FOO")); + schema->addValue("FooEnum", LabelStr("BAR")); + schema->addValue("FooEnum", LabelStr("BAZ")); + schema->addEnum("BarEnum"); + schema->addValue("BarEnum", 0); + schema->addValue("BarEnum", 5); + schema->addValue("BarEnum", 10); + + CPPUNIT_ASSERT(schema->isEnum("FooEnum")); + CPPUNIT_ASSERT(schema->isEnum("BarEnum")); + CPPUNIT_ASSERT(!schema->isEnum("BazEnum")); + CPPUNIT_ASSERT(schema->isEnumValue("FooEnum", LabelStr("FOO"))); + CPPUNIT_ASSERT(schema->isEnumValue("FooEnum", LabelStr("BAZ"))); + CPPUNIT_ASSERT(schema->isEnumValue("BarEnum", 5)); + CPPUNIT_ASSERT(!schema->isEnumValue("BarEnum", 6)); + + std::list allenums; schema->getEnumerations(allenums); CPPUNIT_ASSERT(allenums.size() == 2); - CPPUNIT_ASSERT(allenums.back() == LabelStr("BarEnum")); - CPPUNIT_ASSERT(allenums.front() == LabelStr("FooEnum")); + CPPUNIT_ASSERT(std::find(allenums.begin(), allenums.end(), "BarEnum") != allenums.end()); + CPPUNIT_ASSERT(std::find(allenums.begin(), allenums.end(), "FooEnum") != allenums.end()); // test getEnumValues. - LabelStr enumDomainName = "TestEnum"; + std::string enumDomainName = "TestEnum"; std::set testEnumDomain; testEnumDomain.insert( 1 ); testEnumDomain.insert( 2 ); @@ -384,43 +395,43 @@ class SchemaTest { static bool testObjectTypeRelationships() { - DEFAULT_SETUP(ce, db, true); + DEFAULT_SETUP(ce, db, true); - unsigned int initOTcnt = schema->getAllObjectTypes().size(); + unsigned long initOTcnt = schema->getAllObjectTypes().size(); - schema->addObjectType(LabelStr("Foo")); - schema->addObjectType(LabelStr("Baz")); + schema->addObjectType("Foo"); + schema->addObjectType("Baz"); schema->addPredicate("Baz.pred"); - CPPUNIT_ASSERT(schema->isObjectType(LabelStr("Foo"))); - CPPUNIT_ASSERT(schema->isA(LabelStr("Foo"), LabelStr("Foo"))); - CPPUNIT_ASSERT(!schema->isObjectType(LabelStr("Bar"))); - CPPUNIT_ASSERT(!schema->isA(LabelStr("Foo"), LabelStr("Baz"))); + CPPUNIT_ASSERT(schema->isObjectType("Foo")); + CPPUNIT_ASSERT(schema->isA("Foo", "Foo")); + CPPUNIT_ASSERT(!schema->isObjectType("Bar")); + CPPUNIT_ASSERT(!schema->isA("Foo", "Baz")); // Inheritance - schema->addObjectType(LabelStr("Bar"), LabelStr("Foo")); - CPPUNIT_ASSERT(schema->isObjectType(LabelStr("Bar"))); - CPPUNIT_ASSERT(schema->isA(LabelStr("Bar"), LabelStr("Foo"))); - CPPUNIT_ASSERT(!schema->isA(LabelStr("Foo"), LabelStr("Bar"))); - CPPUNIT_ASSERT(schema->getAllObjectTypes(LabelStr("Bar")).size() == 3); + schema->addObjectType("Bar", "Foo"); + CPPUNIT_ASSERT(schema->isObjectType("Bar")); + CPPUNIT_ASSERT(schema->isA("Bar", "Foo")); + CPPUNIT_ASSERT(!schema->isA("Foo", "Bar")); + CPPUNIT_ASSERT(schema->getAllObjectTypes("Bar").size() == 3); // Composition - schema->addMember(LabelStr("Foo"), LabelStr("float"), LabelStr("arg0")); - schema->addMember(LabelStr("Foo"), LabelStr("Foo"), LabelStr("arg1")); - schema->addMember(LabelStr("Foo"), LabelStr("Bar"), LabelStr("arg2")); + schema->addMember("Foo", "float", "arg0"); + schema->addMember("Foo", "Foo", "arg1"); + schema->addMember("Foo", "Bar", "arg2"); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Foo"), LabelStr("float"), LabelStr("arg0"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Foo"), LabelStr("Foo"), LabelStr("arg1"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Foo"), LabelStr("Bar"), LabelStr("arg2"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Foo"), LabelStr("Bar"), LabelStr("arg1"))); // isA(Bar,Foo) + CPPUNIT_ASSERT(schema->canContain("Foo", "float", "arg0")); + CPPUNIT_ASSERT(schema->canContain("Foo", "Foo", "arg1")); + CPPUNIT_ASSERT(schema->canContain("Foo", "Bar", "arg2")); + CPPUNIT_ASSERT(schema->canContain("Foo", "Bar", "arg1")); // isA(Bar,Foo) - CPPUNIT_ASSERT(!schema->canContain(LabelStr("Foo"), LabelStr("Foo"), LabelStr("arg2"))); - CPPUNIT_ASSERT(!schema->canContain(LabelStr("Foo"), LabelStr("Foo"), LabelStr("arg3"))); - CPPUNIT_ASSERT(!schema->canContain(LabelStr("Foo"), LabelStr("float"), LabelStr("arg1"))); + CPPUNIT_ASSERT(!schema->canContain("Foo", "Foo", "arg2")); + CPPUNIT_ASSERT(!schema->canContain("Foo", "Foo", "arg3")); + CPPUNIT_ASSERT(!schema->canContain("Foo", "float", "arg1")); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Bar"), LabelStr("float"), LabelStr("arg0"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Bar"), LabelStr("Foo"), LabelStr("arg1"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Bar"), LabelStr("Bar"), LabelStr("arg1"))); + CPPUNIT_ASSERT(schema->canContain("Bar", "float", "arg0")); + CPPUNIT_ASSERT(schema->canContain("Bar", "Foo", "arg1")); + CPPUNIT_ASSERT(schema->canContain("Bar", "Bar", "arg1")); CPPUNIT_ASSERT(schema->getAllObjectTypes().size() == (initOTcnt+3)); @@ -436,68 +447,68 @@ class SchemaTest { static bool testObjectPredicateRelationships() { DEFAULT_SETUP(ce, db, true); - schema->addObjectType(LabelStr("Reservoir")); - schema->addObjectType(LabelStr("NddlReservoir"), LabelStr("Reservoir")); - schema->addPredicate(LabelStr("Reservoir.consume")); - schema->addPredicate(LabelStr("Reservoir.produce")); - CPPUNIT_ASSERT(schema->isPredicate(LabelStr("Reservoir.produce"))); - CPPUNIT_ASSERT(schema->isPredicate(LabelStr("Reservoir.consume"))); - - schema->addMember(LabelStr("Reservoir.produce"), LabelStr("float"), LabelStr("quantity")); - schema->addMember(LabelStr("Reservoir.consume"), LabelStr("float"), LabelStr("quantity")); - - schema->addObjectType(LabelStr("Battery"), LabelStr("Reservoir")); - CPPUNIT_ASSERT(schema->hasParent(LabelStr("Battery.produce"))); - CPPUNIT_ASSERT(schema->hasParent(LabelStr("Battery.consume"))); - CPPUNIT_ASSERT(schema->getParent(LabelStr("Battery.consume")) == LabelStr("Reservoir.consume")); - CPPUNIT_ASSERT(schema->getParent(LabelStr("Battery.produce")) == LabelStr("Reservoir.produce")); - - schema->addObjectType(LabelStr("World")); - schema->addPredicate(LabelStr("World.initialState")); - CPPUNIT_ASSERT(schema->isPredicate(LabelStr("Battery.produce"))); - CPPUNIT_ASSERT(schema->isPredicate(LabelStr("Battery.consume"))); - - CPPUNIT_ASSERT(schema->isPredicate(LabelStr("World.initialState"))); - CPPUNIT_ASSERT(!schema->isPredicate(LabelStr("World.NOPREDICATE"))); - CPPUNIT_ASSERT(schema->isObjectType(LabelStr("Reservoir"))); - CPPUNIT_ASSERT(schema->isObjectType(LabelStr("World"))); - CPPUNIT_ASSERT(schema->isObjectType(LabelStr("Battery"))); - CPPUNIT_ASSERT(!schema->isObjectType(LabelStr("NOTYPE"))); - - CPPUNIT_ASSERT(schema->canContain(LabelStr("Reservoir.consume"), LabelStr("float"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Reservoir.produce"), LabelStr("float"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Battery.consume"), LabelStr("float"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("Battery.produce"), LabelStr("float"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("NddlReservoir.consume"), LabelStr("float"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->canContain(LabelStr("NddlReservoir.produce"), LabelStr("float"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->hasMember(LabelStr("Reservoir.consume"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->hasMember(LabelStr("Reservoir.produce"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->hasMember(LabelStr("NddlReservoir.consume"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->hasMember(LabelStr("NddlReservoir.produce"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->hasMember(LabelStr("Battery.consume"), LabelStr("quantity"))); - CPPUNIT_ASSERT(schema->hasMember(LabelStr("Battery.produce"), LabelStr("quantity"))); - - CPPUNIT_ASSERT(schema->canBeAssigned(LabelStr("World"), LabelStr("World.initialState"))); - - CPPUNIT_ASSERT(schema->canBeAssigned(LabelStr("Reservoir"), LabelStr("Reservoir.consume"))); - CPPUNIT_ASSERT(schema->canBeAssigned(LabelStr("Reservoir"), LabelStr("Reservoir.produce"))); - CPPUNIT_ASSERT(schema->canBeAssigned(LabelStr("Battery"), LabelStr("Reservoir.consume"))); - CPPUNIT_ASSERT(schema->canBeAssigned(LabelStr("Battery"), LabelStr("Reservoir.produce"))); - CPPUNIT_ASSERT(!schema->canBeAssigned(LabelStr("World"), LabelStr("Reservoir.consume"))); - CPPUNIT_ASSERT(!schema->canBeAssigned(LabelStr("World"), LabelStr("Reservoir.produce"))); - CPPUNIT_ASSERT(!schema->canBeAssigned(LabelStr("Reservoir"), LabelStr("Battery.consume"))); - CPPUNIT_ASSERT(!schema->canBeAssigned(LabelStr("Reservoir"), LabelStr("Battery.produce"))); - - CPPUNIT_ASSERT(!schema->isA(LabelStr("Reservoir"), LabelStr("Battery"))); - CPPUNIT_ASSERT(schema->isA(LabelStr("Battery"), LabelStr("Reservoir"))); - CPPUNIT_ASSERT(schema->isA(LabelStr("Battery"), LabelStr("Battery"))); - CPPUNIT_ASSERT(schema->hasParent(LabelStr("Battery"))); - CPPUNIT_ASSERT(schema->getParent(LabelStr("Battery")) == LabelStr("Reservoir")); - CPPUNIT_ASSERT(schema->getObjectTypeForPredicate(LabelStr("World.initialState")) == LabelStr("World")); - CPPUNIT_ASSERT(schema->getObjectTypeForPredicate(LabelStr("Battery.consume")) == LabelStr("Battery")); - CPPUNIT_ASSERT(schema->getObjectTypeForPredicate(LabelStr("Battery.produce")) == LabelStr("Battery")); - CPPUNIT_ASSERT(schema->getObjectTypeForPredicate(LabelStr("Battery.consume")) != LabelStr("Reservoir")); - CPPUNIT_ASSERT(schema->getObjectTypeForPredicate(LabelStr("Battery.produce")) != LabelStr("Reservoir")); + schema->addObjectType("Reservoir"); + schema->addObjectType("NddlReservoir", "Reservoir"); + schema->addPredicate("Reservoir.consume"); + schema->addPredicate("Reservoir.produce"); + CPPUNIT_ASSERT(schema->isPredicate("Reservoir.produce")); + CPPUNIT_ASSERT(schema->isPredicate("Reservoir.consume")); + + schema->addMember("Reservoir.produce", "float", "quantity"); + schema->addMember("Reservoir.consume", "float", "quantity"); + + schema->addObjectType("Battery", "Reservoir"); + CPPUNIT_ASSERT(schema->hasParent("Battery.produce")); + CPPUNIT_ASSERT(schema->hasParent("Battery.consume")); + CPPUNIT_ASSERT(schema->getParent("Battery.consume") == "Reservoir.consume"); + CPPUNIT_ASSERT(schema->getParent("Battery.produce") == "Reservoir.produce"); + + schema->addObjectType("World"); + schema->addPredicate("World.initialState"); + CPPUNIT_ASSERT(schema->isPredicate("Battery.produce")); + CPPUNIT_ASSERT(schema->isPredicate("Battery.consume")); + + CPPUNIT_ASSERT(schema->isPredicate("World.initialState")); + CPPUNIT_ASSERT(!schema->isPredicate("World.NOPREDICATE")); + CPPUNIT_ASSERT(schema->isObjectType("Reservoir")); + CPPUNIT_ASSERT(schema->isObjectType("World")); + CPPUNIT_ASSERT(schema->isObjectType("Battery")); + CPPUNIT_ASSERT(!schema->isObjectType("NOTYPE")); + + CPPUNIT_ASSERT(schema->canContain("Reservoir.consume", "float", "quantity")); + CPPUNIT_ASSERT(schema->canContain("Reservoir.produce", "float", "quantity")); + CPPUNIT_ASSERT(schema->canContain("Battery.consume", "float", "quantity")); + CPPUNIT_ASSERT(schema->canContain("Battery.produce", "float", "quantity")); + CPPUNIT_ASSERT(schema->canContain("NddlReservoir.consume", "float", "quantity")); + CPPUNIT_ASSERT(schema->canContain("NddlReservoir.produce", "float", "quantity")); + CPPUNIT_ASSERT(schema->hasMember("Reservoir.consume", "quantity")); + CPPUNIT_ASSERT(schema->hasMember("Reservoir.produce", "quantity")); + CPPUNIT_ASSERT(schema->hasMember("NddlReservoir.consume", "quantity")); + CPPUNIT_ASSERT(schema->hasMember("NddlReservoir.produce", "quantity")); + CPPUNIT_ASSERT(schema->hasMember("Battery.consume", "quantity")); + CPPUNIT_ASSERT(schema->hasMember("Battery.produce", "quantity")); + + CPPUNIT_ASSERT(schema->canBeAssigned("World", "World.initialState")); + + CPPUNIT_ASSERT(schema->canBeAssigned("Reservoir", "Reservoir.consume")); + CPPUNIT_ASSERT(schema->canBeAssigned("Reservoir", "Reservoir.produce")); + CPPUNIT_ASSERT(schema->canBeAssigned("Battery", "Reservoir.consume")); + CPPUNIT_ASSERT(schema->canBeAssigned("Battery", "Reservoir.produce")); + CPPUNIT_ASSERT(!schema->canBeAssigned("World", "Reservoir.consume")); + CPPUNIT_ASSERT(!schema->canBeAssigned("World", "Reservoir.produce")); + CPPUNIT_ASSERT(!schema->canBeAssigned("Reservoir", "Battery.consume")); + CPPUNIT_ASSERT(!schema->canBeAssigned("Reservoir", "Battery.produce")); + + CPPUNIT_ASSERT(!schema->isA("Reservoir", "Battery")); + CPPUNIT_ASSERT(schema->isA("Battery", "Reservoir")); + CPPUNIT_ASSERT(schema->isA("Battery", "Battery")); + CPPUNIT_ASSERT(schema->hasParent("Battery")); + CPPUNIT_ASSERT(schema->getParent("Battery") == "Reservoir"); + CPPUNIT_ASSERT(schema->getObjectTypeForPredicate("World.initialState") == "World"); + CPPUNIT_ASSERT(schema->getObjectTypeForPredicate("Battery.consume") == "Battery"); + CPPUNIT_ASSERT(schema->getObjectTypeForPredicate("Battery.produce") == "Battery"); + CPPUNIT_ASSERT(schema->getObjectTypeForPredicate("Battery.consume") != "Reservoir"); + CPPUNIT_ASSERT(schema->getObjectTypeForPredicate("Battery.produce") != "Reservoir"); schema->addObjectType("Base"); schema->addObjectType("Derived"); @@ -505,16 +516,16 @@ class SchemaTest { schema->addMember("Derived.Predicate", "Battery", "battery"); - CPPUNIT_ASSERT(schema->getParameterCount(LabelStr("Reservoir.produce")) == 1); - CPPUNIT_ASSERT(schema->getParameterCount(LabelStr("Reservoir.consume")) == 1); - CPPUNIT_ASSERT(schema->getParameterType(LabelStr("Reservoir.consume"), 0) == LabelStr("float")); - CPPUNIT_ASSERT(schema->getParameterType(LabelStr("Reservoir.produce"), 0) == LabelStr("float")); + CPPUNIT_ASSERT(schema->getParameterCount("Reservoir.produce") == 1); + CPPUNIT_ASSERT(schema->getParameterCount("Reservoir.consume") == 1); + CPPUNIT_ASSERT(schema->getParameterType("Reservoir.consume", 0) == "float"); + CPPUNIT_ASSERT(schema->getParameterType("Reservoir.produce", 0) == "float"); - std::set predicates; - schema->getPredicates(LabelStr("Battery"), predicates); + std::set predicates; + schema->getPredicates("Battery", predicates); CPPUNIT_ASSERT(predicates.size() == 2); predicates.clear(); - schema->getPredicates(LabelStr("Reservoir"), predicates); + schema->getPredicates("Reservoir", predicates); CPPUNIT_ASSERT(predicates.size() == 2); schema->addObjectType("One"); @@ -524,7 +535,7 @@ class SchemaTest { schema->addPredicate("One.Predicate4"); predicates.clear(); - schema->getPredicates(LabelStr("One"), predicates); + schema->getPredicates("One", predicates); CPPUNIT_ASSERT(predicates.size() == 4); DEFAULT_TEARDOWN(); @@ -534,43 +545,43 @@ class SchemaTest { static bool testPredicateParameterAccessors() { DEFAULT_SETUP(ce, db, true); - schema->addObjectType(LabelStr("Reservoir")); - schema->addObjectType(LabelStr("NddlReservoir"), LabelStr("Reservoir")); - schema->addPredicate(LabelStr("Reservoir.consume")); - schema->addPredicate(LabelStr("Reservoir.produce")); - schema->addObjectType(LabelStr("Battery"), LabelStr("Reservoir")); - schema->addMember(LabelStr("Reservoir.consume"), LabelStr("float"), LabelStr("quantity")); - schema->addMember(LabelStr("Reservoir.produce"), LabelStr("float"), LabelStr("quantity")); - schema->addMember(LabelStr("Reservoir.consume"), LabelStr("float"), LabelStr("quality")); - schema->addMember(LabelStr("Reservoir.produce"), LabelStr("float"), LabelStr("quality")); - CPPUNIT_ASSERT(schema->getIndexFromName(LabelStr("Reservoir.consume"), LabelStr("quality")) == 1); - CPPUNIT_ASSERT(schema->getIndexFromName(LabelStr("Reservoir.produce"), LabelStr("quality")) == 1); - CPPUNIT_ASSERT(schema->getNameFromIndex(LabelStr("Reservoir.consume"), 0).getKey() == LabelStr("quantity").getKey()); - CPPUNIT_ASSERT(schema->getNameFromIndex(LabelStr("Reservoir.produce"), 0).getKey() == LabelStr("quantity").getKey()); - - schema->addObjectType(LabelStr("Foo")); - schema->addPredicate(LabelStr("Foo.Argle")); + schema->addObjectType("Reservoir"); + schema->addObjectType("NddlReservoir", "Reservoir"); + schema->addPredicate("Reservoir.consume"); + schema->addPredicate("Reservoir.produce"); + schema->addObjectType("Battery", "Reservoir"); + schema->addMember("Reservoir.consume", "float", "quantity"); + schema->addMember("Reservoir.produce", "float", "quantity"); + schema->addMember("Reservoir.consume", "float", "quality"); + schema->addMember("Reservoir.produce", "float", "quality"); + CPPUNIT_ASSERT(schema->getIndexFromName("Reservoir.consume", "quality") == 1); + CPPUNIT_ASSERT(schema->getIndexFromName("Reservoir.produce", "quality") == 1); + CPPUNIT_ASSERT(schema->getNameFromIndex("Reservoir.consume", 0) == "quantity"); + CPPUNIT_ASSERT(schema->getNameFromIndex("Reservoir.produce", 0) == "quantity"); + + schema->addObjectType("Foo"); + schema->addPredicate("Foo.Argle"); schema->addPrimitive("Bargle"); - schema->addMember(LabelStr("Foo.Argle"), LabelStr("Bargle"), LabelStr("bargle")); + schema->addMember("Foo.Argle", "Bargle", "bargle"); schema->addPrimitive("Targle"); - schema->addMember(LabelStr("Foo.Argle"), LabelStr("Targle"), LabelStr("targle")); + schema->addMember("Foo.Argle", "Targle", "targle"); - CPPUNIT_ASSERT(schema->getMemberType(LabelStr("Foo.Argle"), LabelStr("bargle")) == LabelStr("Bargle")); - CPPUNIT_ASSERT(schema->getMemberType(LabelStr("Foo.Argle"), LabelStr("targle")) == LabelStr("Targle")); + CPPUNIT_ASSERT(schema->getMemberType("Foo.Argle", "bargle") == "Bargle"); + CPPUNIT_ASSERT(schema->getMemberType("Foo.Argle", "targle") == "Targle"); // Extend attributes on a derived class. Must declare predicate with derived type qualifier - schema->addObjectType(LabelStr("Bar"), LabelStr("Foo")); - schema->addPredicate(LabelStr("Bar.Argle")); - CPPUNIT_ASSERT(schema->hasParent(LabelStr("Bar.Argle"))); - schema->addMember(LabelStr("Bar.Argle"), LabelStr("float"), LabelStr("huey")); - CPPUNIT_ASSERT(schema->getMemberType(LabelStr("Bar.Argle"), LabelStr("huey")) == LabelStr("float")); + schema->addObjectType("Bar", "Foo"); + schema->addPredicate("Bar.Argle"); + CPPUNIT_ASSERT(schema->hasParent("Bar.Argle")); + schema->addMember("Bar.Argle", "float", "huey"); + CPPUNIT_ASSERT(schema->getMemberType("Bar.Argle", "huey") == "float"); - schema->addObjectType(LabelStr("Baz"), LabelStr("Bar")); - CPPUNIT_ASSERT(schema->getMemberType(LabelStr("Baz.Argle"), LabelStr("targle")) == LabelStr("Targle")); + schema->addObjectType("Baz", "Bar"); + CPPUNIT_ASSERT(schema->getMemberType("Baz.Argle", "targle") == "Targle"); - CPPUNIT_ASSERT(schema->getParameterCount(LabelStr("Foo.Argle")) == 2); - CPPUNIT_ASSERT(schema->getParameterType(LabelStr("Foo.Argle"), 0) == LabelStr("Bargle")); - CPPUNIT_ASSERT(schema->getParameterType(LabelStr("Foo.Argle"), 1) == LabelStr("Targle")); + CPPUNIT_ASSERT(schema->getParameterCount("Foo.Argle") == 2); + CPPUNIT_ASSERT(schema->getParameterType("Foo.Argle", 0) == "Bargle"); + CPPUNIT_ASSERT(schema->getParameterType("Foo.Argle", 1) == "Targle"); schema->reset(); DEFAULT_TEARDOWN(); @@ -661,7 +672,7 @@ class ObjectTest { CPPUNIT_ASSERT(db->getObjects().size() == 4); CPPUNIT_ASSERT(o1.getComponents().size() == 1); CPPUNIT_ASSERT(o3.getParent() == o2.getId()); - delete (Object*) id0; + delete static_cast(id0); CPPUNIT_ASSERT(db->getObjects().size() == 3); CPPUNIT_ASSERT(o1.getComponents().empty()); @@ -669,7 +680,7 @@ class ObjectTest { new Object(id1, LabelStr(DEFAULT_OBJECT_TYPE), "id2"); ObjectId id3((new Object(id1, LabelStr(DEFAULT_OBJECT_TYPE), "id3"))->getId()); CPPUNIT_ASSERT(db->getObjects().size() == 6); - CPPUNIT_ASSERT(id3->getName().toString() == "id1.id3"); + CPPUNIT_ASSERT(id3->getName() == "id1.id3"); // Test ancestor call ObjectId id4((new Object(id3, LabelStr(DEFAULT_OBJECT_TYPE), "id4"))->getId()); @@ -679,7 +690,7 @@ class ObjectTest { CPPUNIT_ASSERT(ancestors.back() == id1); // Force cascaded delete - delete (Object*) id1; + delete static_cast(id1); CPPUNIT_ASSERT(db->getObjects().size() == 3); // Now allocate dynamically and allow the plan database to clean it up when it deallocates @@ -744,22 +755,22 @@ class ObjectTest { // Add a unary constraint Variable superset(db->getConstraintEngine(), IntervalIntDomain(10, 20));; - ConstraintId subsetConstraint = db->getConstraintEngine()->createConstraint("SubsetOf", + ConstraintId subsetConstraint = db->getConstraintEngine()->createConstraint("subsetOf", makeScope(o1.getVariables()[0], superset.getId())); // Now add a constraint equating the variables and test propagation std::vector constrainedVars; constrainedVars.push_back(o1.getVariables()[0]); constrainedVars.push_back(o2.getVariables()[0]); - ConstraintId constraint = db->getConstraintEngine()->createConstraint("Equal", + ConstraintId constraint = db->getConstraintEngine()->createConstraint("eq", constrainedVars); CPPUNIT_ASSERT(db->getConstraintEngine()->propagate()); CPPUNIT_ASSERT(o1.getVariables()[0]->lastDomain() == o1.getVariables()[0]->lastDomain()); // Delete one of the constraints to force automatic clean-up path and explciit clean-up - delete (Constraint*) constraint; - delete (Constraint*) subsetConstraint; + delete static_cast(constraint); + delete static_cast(subsetConstraint); DEFAULT_TEARDOWN(); @@ -1010,7 +1021,7 @@ class ObjectTest { CPPUNIT_ASSERT(v0->lastDomain().isSingleton() && v0->lastDomain().getSingletonValue() == o1.getKey()); // Now delete the variable. This should remove the listener - delete (ConstrainedVariable*) v0; + delete static_cast(v0); DEFAULT_TEARDOWN(); return true; @@ -1052,8 +1063,8 @@ class ObjectTest { v1->lastDomain().isMember(o2.getKey())); // Now delete the variables. - delete (ConstrainedVariable*) v0; - delete (ConstrainedVariable*) v1; + delete static_cast(v0); + delete static_cast(v1); DEFAULT_TEARDOWN(); return true; @@ -1190,9 +1201,9 @@ class TokenTest { private: static bool testBasicTokenAllocation() { - DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); - db->close(); + DEFAULT_SETUP(ce, db, false); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + db->close(); // Event Token EventToken eventToken(db, LabelStr(DEFAULT_PREDICATE), true, false, IntervalIntDomain(0, 1000), Token::noObject(), false); CPPUNIT_ASSERT(eventToken.start()->getDerivedDomain() == eventToken.end()->getDerivedDomain()); @@ -1237,7 +1248,7 @@ class TokenTest { IntervalIntDomain(2, 10), Token::noObject(), true))->getId(); - delete (Token*) token; // It is inComplete + delete static_cast(token); // It is inComplete DEFAULT_TEARDOWN(); return true; } @@ -1261,7 +1272,7 @@ class TokenTest { static bool testStateModel(){ DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); IntervalToken t0(db, LabelStr(DEFAULT_PREDICATE), @@ -1316,9 +1327,9 @@ class TokenTest { } static bool testMasterSlaveRelationship(){ - DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); - db->close(); + DEFAULT_SETUP(ce, db, false); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + db->close(); IntervalToken t0(db, LabelStr(DEFAULT_PREDICATE), false, @@ -1371,13 +1382,13 @@ class TokenTest { // Delete slave only - master must be committed to allow this t0.commit(); - delete (Token*) t2; + delete static_cast(t2); CPPUNIT_ASSERT(t0.slaves().size() == 3); // Should verify correct count of tokens remain. --wedgingt 2004 Feb 27 // Delete master & slaves - delete (Token*) t1; + delete static_cast(t1); // Should verify correct count of tokens remain. --wedgingt 2004 Feb 27 DEFAULT_TEARDOWN(); // Remainder should be cleaned up automatically. @@ -1389,10 +1400,10 @@ class TokenTest { * without causing prpagation. */ static bool testTermination(){ - DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); - db->close(); - + DEFAULT_SETUP(ce, db, false); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + db->close(); + { IntervalToken t0(db, LabelStr(DEFAULT_PREDICATE), @@ -1474,7 +1485,7 @@ class TokenTest { CPPUNIT_ASSERT(ce->constraintConsistent()); CPPUNIT_ASSERT(t1->master().isNoId()); t1->terminate(); - delete (Token*) t1; + delete static_cast(t1); CPPUNIT_ASSERT(ce->constraintConsistent()); DEFAULT_TEARDOWN(); @@ -1484,7 +1495,7 @@ class TokenTest { // Added for GNATS 3077 static bool testMergingWithEmptyDomains() { DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); // Create 2 mergeable tokens. @@ -1533,7 +1544,7 @@ class TokenTest { static bool testBasicMerging(){ DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); // Create 2 mergeable tokens - predicates, types and base domaiuns match IntervalToken t0(db, @@ -1611,7 +1622,7 @@ class TokenTest { t1.doMerge(t0.getId()); // Confirm deletion of the constraint is handled correctly - delete (Constraint*) equalityConstraint; + delete static_cast(equalityConstraint); CPPUNIT_ASSERT(t0.end()->getDerivedDomain() != t2.end()->getDerivedDomain()); @@ -1619,11 +1630,11 @@ class TokenTest { t1.cancel(); Variable superset(db->getConstraintEngine(), IntervalIntDomain(5, 6)); - ConstraintId subsetOfConstraint = db->getConstraintEngine()->createConstraint("SubsetOf", + ConstraintId subsetOfConstraint = db->getConstraintEngine()->createConstraint("subsetOf", makeScope(t1.duration(), superset.getId())); t1.doMerge(t0.getId()); CPPUNIT_ASSERT(t0.duration()->getDerivedDomain().getUpperBound() == 6); - delete (Constraint*) subsetOfConstraint; + delete static_cast(subsetOfConstraint); DEFAULT_TEARDOWN(); // Deletion will now occur and test proper cleanup. @@ -1701,7 +1712,7 @@ class TokenTest { */ static bool testConstraintAdditionAfterMerging(){ DEFAULT_SETUP(ce, db, false); - ObjectId timeline1 = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "timeline1"))->getId(); + unused(ObjectId timeline1) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "timeline1"))->getId(); new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "timeline2"); db->close(); @@ -1816,7 +1827,7 @@ class TokenTest { token3.close(); // create a test constraint between t2 and t3 - ce->createConstraint(LabelStr("precedes"),makeScope(token2.end(),token3.start())); + ce->createConstraint("precedes",makeScope(token2.end(),token3.start())); CPPUNIT_ASSERT(ce->propagate()); @@ -1905,24 +1916,24 @@ class TokenTest { typedef Id IntervalTokenId; - static const int NUMTOKS=3; - static const int UNIFIED=1; - static const int NUMPARAMS=1; + static const unsigned int NUMTOKS=3; + static const unsigned int UNIFIED=2; + static const unsigned int NUMPARAMS=1; //Create tokens with the same domains. We will impose a constraint on //each token variable. Tokens will have 5 parameter variables. std::vector< std::vector > tokens; // Add parameters to schema - for(int i=0;i< UNIFIED; i++) { + for(unsigned int i=0;i< UNIFIED; i++) { std::stringstream str; str << "P" << i; schema->addMember(LabelStr(DEFAULT_PREDICATE), IntDT::NAME(), LabelStr(str.str()).c_str()); } - for (int i=0; i < NUMTOKS; i++) { + for (unsigned int i=0; i < NUMTOKS; i++) { std::vector tmp; - for (int j=0; j < UNIFIED; j++) { + for (unsigned int j=0; j < UNIFIED; j++) { IntervalTokenId t = (new IntervalToken(db, LabelStr(DEFAULT_PREDICATE), true, @@ -1931,7 +1942,7 @@ class TokenTest { IntervalIntDomain(0, 220), IntervalIntDomain(1, 110), Token::noObject(), false))->getId(); - for (int k=0; k < NUMPARAMS; k++) { + for (unsigned int k=0; k < NUMPARAMS; k++) { std::stringstream str; str << "P" << k; t->addParameter(IntervalIntDomain(500+j,1000), LabelStr(str.str()).c_str()); @@ -1957,7 +1968,7 @@ class TokenTest { TokenId predecessor = tokens[0][0]; predecessor->activate(); - for (int i=1; i < NUMTOKS; i++) { + for (unsigned int i=1; i < NUMTOKS; i++) { tokens[i][0]->activate(); timeline->constrain(tokens[i-1][0], tokens[i][0]); } @@ -1975,8 +1986,8 @@ class TokenTest { CPPUNIT_ASSERT(pdom2.getLowerBound() == 500); CPPUNIT_ASSERT(pdom2.getUpperBound() == 1000); - for (int i=0; i < NUMTOKS; i++) - for (int j=1; j < UNIFIED; j++) { + for (unsigned int i=0; i < NUMTOKS; i++) + for (unsigned int j=1; j < UNIFIED; j++) { tokens[i][j]->doMerge(tokens[i][0]); ce->propagate(); } @@ -1994,8 +2005,8 @@ class TokenTest { CPPUNIT_ASSERT(pdom3.getLowerBound() == 500+UNIFIED-1); CPPUNIT_ASSERT(pdom3.getUpperBound() == 1000); - for (int i=0; i < NUMTOKS; i++) - for (int j=1; j < UNIFIED; j++) { + for (unsigned int i=0; i < NUMTOKS; i++) + for (unsigned int j=1; j < UNIFIED; j++) { tokens[i][j]->cancel(); ce->propagate(); } @@ -2019,7 +2030,7 @@ class TokenTest { static bool testTokenCompatibility(){ DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); // Create 2 mergeable tokens - predicates, types and base domaiuns match @@ -2109,7 +2120,7 @@ class TokenTest { std::string str; for(std::vector::const_iterator it = tokens.begin(); it != tokens.end(); ++it){ TokenId token = *it; - str = str + token->getName().toString() + ":"; + str = str + token->getName() + ":"; } return str; } @@ -2139,7 +2150,7 @@ class TokenTest { // Populate an instance of each predicate type IntervalToken t0(db, - LabelStr("A.a"), + "A.a", true, false, IntervalIntDomain(0, 10), @@ -2150,7 +2161,7 @@ class TokenTest { t0.activate(); IntervalToken t1(db, - LabelStr("A.b"), + "A.b", true, false, IntervalIntDomain(0, 10), @@ -2161,7 +2172,7 @@ class TokenTest { t1.activate(); IntervalToken t2(db, - LabelStr("B.a"), + "B.a", true, false, IntervalIntDomain(0, 10), @@ -2172,7 +2183,7 @@ class TokenTest { t2.activate(); IntervalToken t3(db, - LabelStr("C.a"), + "C.a", true, false, IntervalIntDomain(0, 10), @@ -2183,7 +2194,7 @@ class TokenTest { t3.activate(); IntervalToken t4(db, - LabelStr("C.b"), + "C.b", true, false, IntervalIntDomain(0, 10), @@ -2194,7 +2205,7 @@ class TokenTest { t4.activate(); IntervalToken t5(db, - LabelStr("C.c"), + "C.c", true, false, IntervalIntDomain(0, 10), @@ -2205,7 +2216,7 @@ class TokenTest { t5.activate(); IntervalToken t6(db, - LabelStr("D.a"), + "D.a", true, false, IntervalIntDomain(0, 10), @@ -2216,7 +2227,7 @@ class TokenTest { t6.activate(); IntervalToken t7(db, - LabelStr("D.b"), + "D.b", true, false, IntervalIntDomain(0, 10), @@ -2230,7 +2241,7 @@ class TokenTest { { std::vector results; IntervalToken t(db, - LabelStr("A.a"), + "A.a", true, false, IntervalIntDomain(0, 10), @@ -2245,14 +2256,14 @@ class TokenTest { LabelStr encodedNames = encodePredicateNames(results); CPPUNIT_ASSERT_MESSAGE("Expected = A.a:B.a:C.a:D.a:, Actual = " + encodedNames.toString(), - encodedNames == LabelStr("A.a:B.a:C.a:D.a:")); + encodedNames == "A.a:B.a:C.a:D.a:"); } // A.a => A.a, B.a, C.a., D.a. This is the case for GNATS 2837 { std::vector results; IntervalToken t(db, - LabelStr("D.b"), + "D.b", true, false, IntervalIntDomain(0, 10), @@ -2267,7 +2278,7 @@ class TokenTest { LabelStr encodedNames = encodePredicateNames(results); CPPUNIT_ASSERT_MESSAGE("Expected = D.b':, Actual = " + encodedNames.toString(), - encodedNames == LabelStr("D.b:")); + encodedNames == "D.b:"); } DEFAULT_TEARDOWN(); @@ -2276,14 +2287,14 @@ class TokenTest { static bool testTokenType(){ DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); - TokenId master = db->createToken(DEFAULT_PREDICATE, NULL, true); + TokenId master = db->createToken(DEFAULT_PREDICATE, "", true); master->activate(); - TokenId slave = db->createSlaveToken(master, LabelStr(DEFAULT_PREDICATE), LabelStr("any")); + TokenId slave = db->createSlaveToken(master, LabelStr(DEFAULT_PREDICATE), "any"); CPPUNIT_ASSERT(slave->master() == master); - TokenId rejectable = db->createToken(DEFAULT_PREDICATE, NULL, false); + TokenId rejectable = db->createToken(DEFAULT_PREDICATE, "", false); rejectable->activate(); //!!Should try rejecting master and verify inconsistency //!!Should try rejecting rejectable and verify consistency @@ -2297,7 +2308,7 @@ class TokenTest { */ static bool testCorrectSplit_Gnats2450(){ DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); IntervalToken tokenA(db, @@ -2358,10 +2369,10 @@ class TokenTest { static bool testOpenMerge() { DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); - schema->addMember(LabelStr(DEFAULT_PREDICATE),"int",LabelStr("FOO")); + schema->addMember(LabelStr(DEFAULT_PREDICATE),"int","FOO"); EnumeratedDomain zero(IntDT::instance()); zero.insert(0); zero.close(); @@ -2378,7 +2389,7 @@ class TokenTest { IntervalIntDomain(1, 1000), Token::noObject(), false); - t0.addParameter(zero, LabelStr("FOO")); + t0.addParameter(zero, "FOO"); t0.close(); IntervalToken t1(db, @@ -2390,8 +2401,8 @@ class TokenTest { IntervalIntDomain(1, 1000), Token::noObject(), false); - t1.addParameter(zero, LabelStr("FOO")); - t1.getVariable(LabelStr("FOO"))->open(); + t1.addParameter(zero, "FOO"); + t1.getVariable("FOO")->open(); t1.close(); IntervalToken t2(db, @@ -2403,8 +2414,8 @@ class TokenTest { IntervalIntDomain(1, 1000), Token::noObject(), false); - t2.addParameter(zero, LabelStr("FOO")); - t2.getVariable(LabelStr("FOO"))->open(); + t2.addParameter(zero, "FOO"); + t2.getVariable("FOO")->open(); t2.close(); IntervalToken t3(db, @@ -2416,8 +2427,8 @@ class TokenTest { IntervalIntDomain(1, 1000), Token::noObject(), false); - t3.addParameter(one, LabelStr("FOO")); - t3.getVariable(LabelStr("FOO"))->open(); + t3.addParameter(one, "FOO"); + t3.getVariable("FOO")->open(); t3.close(); IntervalToken t4(db, @@ -2429,8 +2440,8 @@ class TokenTest { IntervalIntDomain(1, 1000), Token::noObject(), false); - t4.addParameter(one, LabelStr("FOO")); - t4.getVariable(LabelStr("FOO"))->open(); + t4.addParameter(one, "FOO"); + t4.getVariable("FOO")->open(); t4.close(); CPPUNIT_ASSERT(t0.getObject()->isClosed()); @@ -2470,7 +2481,7 @@ class TokenTest { static bool testGNATS_3086() { DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); LabelSet lbl; @@ -2524,7 +2535,7 @@ class TokenTest { static bool testCompatCacheReset() { DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); //create a regular token IntervalToken t0(db, @@ -2569,7 +2580,7 @@ class TokenTest { //shouldn't be able to merge with anything CPPUNIT_ASSERT(db->countCompatibleTokens(t2.getId(), std::numeric_limits::max(), true) == 0); - delete (Constraint *) eq; //remove the constraint + delete static_cast(eq); //remove the constraint ce->propagate(); @@ -2668,11 +2679,11 @@ class TokenTest { // Now delete the master and expect the uncommitted slave to be discarded but the committed slave to // be retained. - delete (Token*) master; + delete static_cast(master); CPPUNIT_ASSERT(slaveA->isDiscarded()); CPPUNIT_ASSERT(slaveB->isCommitted()); - delete (Token*) slaveB; + delete static_cast(slaveB); DEFAULT_TEARDOWN(); return true; } @@ -2738,16 +2749,16 @@ class TokenTest { orphan->doMerge(slaveC); // Now delete the master - should force slaves A and B to be deleted - delete (Token*) master; + delete static_cast(master); CPPUNIT_ASSERT(slaveA->isDiscarded()); CPPUNIT_ASSERT(slaveB->isDiscarded()); CPPUNIT_ASSERT(slaveC->isCommitted()); CPPUNIT_ASSERT(orphan->isMerged()); - delete (Token*) slaveC; + delete static_cast(slaveC); CPPUNIT_ASSERT(orphan->isInactive()); - delete (Token*) orphan; + delete static_cast(orphan); DEFAULT_TEARDOWN(); return true; } @@ -2778,7 +2789,7 @@ class TokenTest { CPPUNIT_ASSERT(db->getActiveTokens(LabelStr(DEFAULT_PREDICATE)).size() == 1); // Delete the token and ensure that we no longer have active tokens - delete (Token*) a; + delete static_cast(a); CPPUNIT_ASSERT(db->getActiveTokens(LabelStr(DEFAULT_PREDICATE)).empty()); DEFAULT_TEARDOWN(); @@ -2930,7 +2941,7 @@ class TimelineTest { CPPUNIT_ASSERT(tokens.size() == 4); CPPUNIT_ASSERT(timeline.getTokenSequence().size() == 0); CPPUNIT_ASSERT(timeline.hasTokensToOrder()); - unsigned int num_constraints = ce->getConstraints().size(); + unsigned long num_constraints = ce->getConstraints().size(); /** * BASE CASE - end insertion and retraction @@ -3134,11 +3145,11 @@ class TimelineTest { Id timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); - const int COUNT = 5; - const int DURATION = 10; + const unsigned int COUNT = 5; + const unsigned int DURATION = 10; - for (int i=0;iactivate(); } - CPPUNIT_ASSERT(timeline->tokens().size() == (unsigned int) COUNT); + CPPUNIT_ASSERT(timeline->tokens().size() == COUNT); ce->propagate(); // Should not alter the count. Relationship updated eagerly - CPPUNIT_ASSERT(timeline->tokens().size() == (unsigned int) COUNT); + CPPUNIT_ASSERT(timeline->tokens().size() == COUNT); - int i = 0; + unsigned int i = 0; std::vector tokensToOrder; timeline->getTokensToOrder(tokensToOrder); while(!tokensToOrder.empty()){ - CPPUNIT_ASSERT(timeline->getTokenSequence().size() == (unsigned int) i); - CPPUNIT_ASSERT(tokensToOrder.size() == (unsigned int) (COUNT - i)); + CPPUNIT_ASSERT(timeline->getTokenSequence().size() == i); + CPPUNIT_ASSERT(tokensToOrder.size() == (COUNT - i)); std::vector< std::pair > choices; TokenId toConstrain = tokensToOrder.front(); timeline->getOrderingChoices(toConstrain, choices); @@ -3530,7 +3541,7 @@ class TimelineTest { CPPUNIT_ASSERT(ce->propagate()); // Now delete t4 to leave a hole which will require repair - delete (Token*) t4; + delete static_cast(t4); CPPUNIT_ASSERT(ce->propagate()); DEFAULT_TEARDOWN(); return true; @@ -3570,7 +3581,7 @@ class TimelineTest { ce->propagate(); // Now nuke the master and make sure we safely delete both. - delete (Token*) master; + delete static_cast(master); CPPUNIT_ASSERT(db->getTokens().empty()); } @@ -3601,7 +3612,7 @@ class TimelineTest { ce->propagate(); // Now nuke the master and make sure we safely delete both. - delete (Token*) master; + delete static_cast(master); CPPUNIT_ASSERT(db->getTokens().empty()); } @@ -3800,7 +3811,7 @@ class TimelineTest { const unsigned int TOKENS_PER_TICK(1); for(unsigned int i=startTick;igetTokens().size() == (endTick - i) * TOKENS_PER_TICK); - unsigned int deletionCount = db->archive(i+1); + unsigned long deletionCount = db->archive(i+1); CPPUNIT_ASSERT_MESSAGE(toString(deletionCount), deletionCount == TOKENS_PER_TICK); CPPUNIT_ASSERT(ce->constraintConsistent()); } @@ -3870,8 +3881,8 @@ class DbClientTest { LabelSet arg1(LabelStr("Label")); arguments.push_back(&arg0); arguments.push_back(&arg1); - LabelStr factoryName = ObjectTypeMgr::makeFactoryName(LabelStr("Foo"), arguments); - CPPUNIT_ASSERT(factoryName == LabelStr("Foo:int:string")); + LabelStr factoryName = ObjectTypeMgr::makeFactoryName("Foo", arguments); + CPPUNIT_ASSERT(factoryName == "Foo:int:string"); return true; } @@ -3909,7 +3920,7 @@ class DbClientTest { static bool testPathBasedRetrieval(){ DEFAULT_SETUP(ce, db, false); - ObjectId timeline = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); + unused(ObjectId timeline) = (new Timeline(db, LabelStr(DEFAULT_OBJECT_TYPE), "o2"))->getId(); db->close(); db->getClient()->enableTransactionLogging(); @@ -3958,7 +3969,7 @@ class DbClientTest { t0_1_1->activate(); // Test paths - std::vector path; + std::vector path; path.push_back(0); // Start with the index of the token key in the path @@ -4080,8 +4091,8 @@ class DbTransPlayerTest { CPPUNIT_ASSERT(s_dbPlayer != 0); ObjectTypeId testClass2_OT = (new ObjectType("TestClass2",db->getSchema()->getObjectType(Schema::rootObject())))->getId(); - testClass2_OT->addObjectFactory((new TestClass2Factory(LabelStr("TestClass2")))->getId()); - testClass2_OT->addObjectFactory((new TestClass2Factory(LabelStr("TestClass2:string:int:float:Locations")))->getId()); + testClass2_OT->addObjectFactory((new TestClass2Factory("TestClass2"))->getId()); + testClass2_OT->addObjectFactory((new TestClass2Factory("TestClass2:string:int:float:Locations"))->getId()); /* Token factory for predicate Sample */ testClass2_OT->addTokenType((new TestClass2::Sample::Factory(testClass2_OT->getId()))->getId()); @@ -4165,17 +4176,17 @@ class DbTransPlayerTest { class TestClass2 : public Timeline { public: - TestClass2(const PlanDatabaseId& planDatabase, const LabelStr& name) - : Timeline(planDatabase, "TestClass2", name, true) { + TestClass2(const PlanDatabaseId planDatabase, const LabelStr& name) + : Timeline(planDatabase, "TestClass2", name, true), m_int1(), m_float2(), m_where() { } - TestClass2(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name) - : Timeline(planDatabase, type, name, true) { + TestClass2(const PlanDatabaseId planDatabase, const LabelStr& type, const LabelStr& name) + : Timeline(planDatabase, type, name, true), m_int1(), m_float2(), m_where() { } - TestClass2(const ObjectId& parent, const LabelStr& name) - : Timeline(parent, "TestClass2", name, true) { + TestClass2(const ObjectId parent, const LabelStr& name) + : Timeline(parent, "TestClass2", name, true), m_int1(), m_float2(), m_where() { } - TestClass2(const ObjectId& parent, const LabelStr& type, const LabelStr& name) - : Timeline(parent, type, name, true) { + TestClass2(const ObjectId parent, const LabelStr& type, const LabelStr& name) + : Timeline(parent, type, name, true), m_int1(), m_float2(), m_where() { } void handleDefaults(bool autoClose = false) { if (m_int1.isNoId()) @@ -4187,6 +4198,7 @@ class DbTransPlayerTest { if (autoClose || LocationsBaseDomain().isClosed()) close(); } + void constructor(const std::vector&) {constructor();} void constructor() { handleDefaults(); } @@ -4201,14 +4213,16 @@ class DbTransPlayerTest { // Borrowed from System/test/backtr.{nddl,cc,hh,xml} class Sample : public IntervalToken { public: - Sample(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable = false, bool isFact = false) - : IntervalToken(planDb, name, rejectable, isFact, IntervalIntDomain(), IntervalIntDomain(), - IntervalIntDomain(1, PLUS_INFINITY), Token::noObject(), false) { + Sample(const PlanDatabaseId planDb, const LabelStr& name, bool rejectable = false, bool _isFact = false) + : IntervalToken(planDb, name, rejectable, _isFact, IntervalIntDomain(), IntervalIntDomain(), + IntervalIntDomain(1, PLUS_INFINITY), Token::noObject(), false), + m_x(), m_y(), m_closest(){ handleDefaults(); } - Sample(const TokenId& parent, const LabelStr& name, const LabelStr& relation) + Sample(const TokenId parent, const LabelStr& name, const LabelStr& relation) : IntervalToken(parent, relation, name, IntervalIntDomain(), IntervalIntDomain(), - IntervalIntDomain(1, PLUS_INFINITY), Token::noObject(), false) { + IntervalIntDomain(1, PLUS_INFINITY), Token::noObject(), false), + m_x(), m_y(), m_closest(){ handleDefaults(); } void handleDefaults() { @@ -4222,15 +4236,15 @@ class DbTransPlayerTest { } class Factory : public TokenType { public: - Factory(const ObjectTypeId& ot) + Factory(const ObjectTypeId ot) : TokenType(ot,LabelStr("TestClass2.Sample")) { } private: - TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable = false, bool isFact = false) const { + TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, bool rejectable = false, bool isFact = false) const { TokenId token = (new Sample(planDb, name, rejectable, isFact))->getId(); return(token); } - TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const { + TokenId createInstance(const TokenId master, const std::string& name, const std::string& relation) const { TokenId token = (new Sample(master, name, relation))->getId(); return(token); } @@ -4249,18 +4263,18 @@ class DbTransPlayerTest { : ObjectFactory(name) { } private: - ObjectId createInstance(const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + ObjectId createInstance(const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { CPPUNIT_ASSERT(arguments.size() == 0 || arguments.size() == 4); if (arguments.size() == 4) { //!!I'm not sure why this first one is passed in; it appears to be the object's type info. //!!--wedgingt@email.arc.nasa.gov 2004 Nov 1 - CPPUNIT_ASSERT(arguments[0]->getTypeName() == LabelStr(StringDT::NAME())); - CPPUNIT_ASSERT(arguments[1]->getTypeName() == LabelStr(IntDT::NAME())); - CPPUNIT_ASSERT(arguments[2]->getTypeName() == LabelStr(FloatDT::NAME())); - CPPUNIT_ASSERT(arguments[3]->getTypeName() == LabelStr("Locations")); + CPPUNIT_ASSERT(arguments[0]->getTypeName() == StringDT::NAME()); + CPPUNIT_ASSERT(arguments[1]->getTypeName() == IntDT::NAME()); + CPPUNIT_ASSERT(arguments[2]->getTypeName() == FloatDT::NAME()); + CPPUNIT_ASSERT(arguments[3]->getTypeName() == "Locations"); } TestClass2Id instance = (new TestClass2(planDb, objectType, objectName))->getId(); instance->handleDefaults(); @@ -4271,7 +4285,7 @@ class DbTransPlayerTest { else vars[i - 1]->restrictBaseDomain(*(arguments[i])); } - debugMsg("TestClass2:createInstance", "TestClass2 objectId " << instance->getId() << ' ' << instance->getName().toString() + debugMsg("TestClass2:createInstance", "TestClass2 objectId " << instance->getId() << ' ' << instance->getName() << " has varIds " << vars[0] << ' ' << vars[1] << ' ' << vars[2] << '\n'); return(instance); } @@ -4320,21 +4334,21 @@ class DbTransPlayerTest { ConstrainedVariableSet::iterator varIter = allVars.begin(); ConstrainedVariableId g_int2, g_float2, g_location2; for ( ; varIter != allVars.end(); varIter++) { - if ((*varIter)->getName() == LabelStr("g_int")) { + if ((*varIter)->getName() == LabelStr("g_int").toString()) { if (sg_int.isNoId()) sg_int = *varIter; else g_int2 = *varIter; } else { - if ((*varIter)->getName() == LabelStr("g_float")) { + if ((*varIter)->getName() == LabelStr("g_float").toString()) { if (sg_float.isNoId()) sg_float = *varIter; else g_float2 = *varIter; } else { - if ((*varIter)->getName() == LabelStr("g_location")) { + if ((*varIter)->getName() == LabelStr("g_location").toString()) { if (sg_location.isNoId()) sg_location = *varIter; else @@ -4363,7 +4377,7 @@ class DbTransPlayerTest { CPPUNIT_ASSERT(!s_db->getClient()->isGlobalVariable("g_int")); ConstrainedVariableSet allVars = s_ce->getVariables(); for(ConstrainedVariableSet::iterator it = allVars.begin(); it != allVars.end(); ++it) { - CPPUNIT_ASSERT((*it)->getName() != LabelStr("g_int")); + CPPUNIT_ASSERT((*it)->getName() != LabelStr("g_int").toString()); } //have to re-create the variable because future tests depend on it TEST_PLAYING_XML(buildXMLNameTypeStr("var", "g_int", @@ -4374,7 +4388,7 @@ class DbTransPlayerTest { allVars = s_ce->getVariables(); for(ConstrainedVariableSet::iterator it = allVars.begin(); it != allVars.end() && !found; ++it) { - if((found = ((*it)->getName() == LabelStr("g_int")))) { + if((found = ((*it)->getName() == LabelStr("g_int").toString()))) { sg_int = (*it); } } @@ -4387,7 +4401,7 @@ class DbTransPlayerTest { ConstrainedVariableSet allVars = s_ce->getVariables(); for(ConstrainedVariableSet::iterator it = allVars.begin(); it != allVars.end() && !found; ++it) - found = ((*it)->getName() == LabelStr("g_int")); + found = ((*it)->getName() == LabelStr("g_int").toString()); CPPUNIT_ASSERT(found); std::stringstream transactions; @@ -4398,7 +4412,7 @@ class DbTransPlayerTest { CPPUNIT_ASSERT(!s_db->getClient()->isGlobalVariable("g_int")); allVars = s_ce->getVariables(); for(ConstrainedVariableSet::iterator it = allVars.begin(); it != allVars.end(); ++it) { - CPPUNIT_ASSERT((*it)->getName() != LabelStr("g_int")); + CPPUNIT_ASSERT((*it)->getName() != LabelStr("g_int").toString()); } std::stringstream otherTransactions; @@ -4414,7 +4428,7 @@ class DbTransPlayerTest { allVars = s_ce->getVariables(); for(ConstrainedVariableSet::iterator it = allVars.begin(); it != allVars.end() && !found; ++it) { - if((found = ((*it)->getName() == LabelStr("g_int")))) { + if((found = ((*it)->getName() == LabelStr("g_int").toString()))) { sg_int = (*it); } } @@ -4460,11 +4474,11 @@ class DbTransPlayerTest { cleanDomains(domains); ObjectId obj2a = s_db->getObject("testObj2a"); CPPUNIT_ASSERT(!obj2a.isNoId() && obj2a.isValid()); - CPPUNIT_ASSERT(obj2a->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2a->getName() == LabelStr("testObj2a")); + CPPUNIT_ASSERT(obj2a->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2a->getName() == "testObj2a"); std::vector obj2vars = obj2a->getVariables(); CPPUNIT_ASSERT(obj2vars.size() == 3); - for (int i = 0; i < 3; i++) { + for (unsigned int i = 0; i < 3; i++) { ConstrainedVariableId var = obj2vars[i]; CPPUNIT_ASSERT(!var.isNoId() && var.isValid()); CPPUNIT_ASSERT(var->isValid()); @@ -4481,9 +4495,9 @@ class DbTransPlayerTest { CPPUNIT_ASSERT(var->lastDomain() == IntervalDomain(1.414)); break; case 2: { - Locations* ld1 = new Locations(LocationsBaseDomain()); - ld1->set(LabelStr("Hill")); - CPPUNIT_ASSERT(var->lastDomain() == *ld1); + Locations* ld2 = new Locations(LocationsBaseDomain()); + ld2->set(LabelStr("Hill")); + CPPUNIT_ASSERT(var->lastDomain() == *ld2); break; } default: @@ -4503,11 +4517,11 @@ class DbTransPlayerTest { cleanDomains(domains); ObjectId obj2b = s_db->getObject("testObj2b"); CPPUNIT_ASSERT(!obj2b.isNoId() && obj2b.isValid()); - CPPUNIT_ASSERT(obj2b->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2b->getName() == LabelStr("testObj2b")); + CPPUNIT_ASSERT(obj2b->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2b->getName() == "testObj2b"); obj2vars = obj2b->getVariables(); CPPUNIT_ASSERT(obj2vars.size() == 3); - for (int i = 0; i < 3; i++) { + for (unsigned int i = 0; i < 3; i++) { ConstrainedVariableId var = obj2vars[i]; CPPUNIT_ASSERT(!var.isNoId() && var.isValid()); CPPUNIT_ASSERT(var->isValid()); @@ -4535,7 +4549,7 @@ class DbTransPlayerTest { //!!std::cout << "\n PlanDB objects are:"; //!!std::set >::const_iterator it = objects.begin(); //!!for ( ; it != objects.end(); it++) - //!! std::cout << "\n id " << *it << " name " << (*it)->getName().toString(); + //!! std::cout << "\n id " << *it << " name " << (*it)->getName(); //!!std::cout << std::endl; //!!Mix of singleton and non-singleton member vars in testObj2c? //!!Find each in PlanDB just after each is built @@ -4544,8 +4558,8 @@ class DbTransPlayerTest { static void testDeleteObject() { ObjectId obj2a = s_db->getObject("testObj2a"); CPPUNIT_ASSERT(!obj2a.isNoId() && obj2a.isValid()); - CPPUNIT_ASSERT(obj2a->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2a->getName() == LabelStr("testObj2a")); + CPPUNIT_ASSERT(obj2a->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2a->getName() == "testObj2a"); std::vector domains; domains.push_back(new IntervalIntDomain(1)); @@ -4565,16 +4579,16 @@ class DbTransPlayerTest { TEST_PLAYING_XML(transaction); obj2a = s_db->getObject("testObj2a"); CPPUNIT_ASSERT(!obj2a.isNoId() && obj2a.isValid()); - CPPUNIT_ASSERT(obj2a->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2a->getName() == LabelStr("testObj2a")); + CPPUNIT_ASSERT(obj2a->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2a->getName() == "testObj2a"); } static void testUndeleteObject() { ObjectId obj2a = s_db->getObject("testObj2a"); CPPUNIT_ASSERT(!obj2a.isNoId() && obj2a.isValid()); - CPPUNIT_ASSERT(obj2a->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2a->getName() == LabelStr("testObj2a")); + CPPUNIT_ASSERT(obj2a->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2a->getName() == "testObj2a"); std::vector domains; domains.push_back(new IntervalIntDomain(1)); @@ -4603,8 +4617,8 @@ class DbTransPlayerTest { obj2a = s_db->getObject("testObj2a"); CPPUNIT_ASSERT(!obj2a.isNoId() && obj2a.isValid()); - CPPUNIT_ASSERT(obj2a->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2a->getName() == LabelStr("testObj2a")); + CPPUNIT_ASSERT(obj2a->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2a->getName() == "testObj2a"); } @@ -4633,8 +4647,8 @@ class DbTransPlayerTest { ObjectId obj2b = s_db->getObject("testObj2b"); CPPUNIT_ASSERT(!obj2b.isNoId() && obj2b.isValid()); - CPPUNIT_ASSERT(obj2b->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2b->getName() == LabelStr("testObj2b")); + CPPUNIT_ASSERT(obj2b->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2b->getName() == "testObj2b"); std::vector obj2vars = obj2b->getVariables(); CPPUNIT_ASSERT(obj2vars.size() == 3); TEST_PLAYING_XML(buildXMLResetVariableStr(obj2vars[0])); @@ -4670,8 +4684,8 @@ class DbTransPlayerTest { // First section: constraints between variables ObjectId obj2b = s_db->getObject("testObj2b"); CPPUNIT_ASSERT(!obj2b.isNoId() && obj2b.isValid()); - CPPUNIT_ASSERT(obj2b->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2b->getName() == LabelStr("testObj2b")); + CPPUNIT_ASSERT(obj2b->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2b->getName() == "testObj2b"); std::vector obj2vars = obj2b->getVariables(); CPPUNIT_ASSERT(obj2vars.size() == 3); @@ -4679,13 +4693,13 @@ class DbTransPlayerTest { std::list vars; vars.push_back(sg_int); vars.push_back(obj2vars[0]); - std::string transaction = buildXMLInvokeConstrainVarsStr("Equal", vars); + std::string transaction = buildXMLInvokeConstrainVarsStr("eq", vars); TEST_PLAYING_XML(transaction); std::set constraints; sg_int->constraints(constraints); CPPUNIT_ASSERT(constraints.size() == 1); ConstraintId constr = *(constraints.begin()); - CPPUNIT_ASSERT(constr->getName() == LabelStr("Equal")); + CPPUNIT_ASSERT(constr->getName() == LabelStr("eq").toString()); CPPUNIT_ASSERT(constr->getScope().size() == 2); CPPUNIT_ASSERT(constr->isVariableOf(sg_int)); CPPUNIT_ASSERT(constr->isVariableOf(obj2vars[0])); @@ -4699,14 +4713,14 @@ class DbTransPlayerTest { vars.clear(); vars.push_back(sg_int); vars.push_back(sg_float); - TEST_PLAYING_XML(buildXMLInvokeConstrainVarsStr("LessThanEqual", vars)); + TEST_PLAYING_XML(buildXMLInvokeConstrainVarsStr("leq", vars)); constraints.clear(); sg_int->constraints(constraints); CPPUNIT_ASSERT(constraints.size() == 2); CPPUNIT_ASSERT(constraints.find(constr) != constraints.end()); constraints.erase(constraints.find(constr)); constr = *(constraints.begin()); - CPPUNIT_ASSERT(constr->getName() == LabelStr("LessThanEqual")); + CPPUNIT_ASSERT(constr->getName() == LabelStr("leq").toString()); CPPUNIT_ASSERT(constr->getScope().size() == 2); CPPUNIT_ASSERT(constr->isVariableOf(sg_int)); CPPUNIT_ASSERT(constr->isVariableOf(sg_float)); @@ -4719,12 +4733,12 @@ class DbTransPlayerTest { vars.clear(); vars.push_back(sg_location); vars.push_back(obj2vars[2]); - TEST_PLAYING_XML(buildXMLInvokeConstrainVarsStr("NotEqual", vars)); + TEST_PLAYING_XML(buildXMLInvokeConstrainVarsStr("neq", vars)); constraints.clear(); sg_location->constraints(constraints); CPPUNIT_ASSERT(constraints.size() == 1); constr = *(constraints.begin()); - CPPUNIT_ASSERT(constr->getName() == LabelStr("NotEqual")); + CPPUNIT_ASSERT(constr->getName() == LabelStr("neq").toString()); CPPUNIT_ASSERT(constr->getScope().size() == 2); CPPUNIT_ASSERT(constr->isVariableOf(sg_location)); CPPUNIT_ASSERT(constr->isVariableOf(obj2vars[2])); @@ -4817,11 +4831,11 @@ class DbTransPlayerTest { * than 'if (!cond) return(false);', making which condition failed * obvious. */ - static bool checkToken(const TokenId& token, const LabelStr& name, const LabelStr& predName, - const TokenId& master, const StateDomain& stateDom) { + static bool checkToken(const TokenId token, const std::string& name, const std::string& predName, + const TokenId, const StateDomain& stateDom) { if (token.isNoId() || !token.isValid()) return(false); - if ((name.toString() != "_auto_") && (token->getName() != name)) + if ((name != "_auto_") && (token->getName() != name)) return(false); if (token->getPredicateName() != predName) return(false); @@ -4837,7 +4851,7 @@ class DbTransPlayerTest { TokenSet tokens = s_db->getTokens(); CPPUNIT_ASSERT(tokens.size() == 1); TokenId token = *(tokens.begin()); - CPPUNIT_ASSERT(checkToken(token, LabelStr("sample1"), LabelStr("TestClass2.Sample"), + CPPUNIT_ASSERT(checkToken(token, "sample1", "TestClass2.Sample", TokenId::noId(), getMandatoryStateDom())); /* Create a rejectable token. */ @@ -4850,9 +4864,9 @@ class DbTransPlayerTest { tokens.erase(tokens.begin()); token2 = *(tokens.begin()); } - CPPUNIT_ASSERT(checkToken(token2, LabelStr("sample2"), - LabelStr("TestClass2.Sample"), - TokenId::noId(), getRejectableStateDom())); + CPPUNIT_ASSERT(checkToken(token2, "sample2", + "TestClass2.Sample", + TokenId::noId(), getRejectableStateDom())); //!!other predicates? } @@ -4871,7 +4885,7 @@ class DbTransPlayerTest { currentTokens.erase(currentTokens.begin()); goal = *(currentTokens.begin()); } - CPPUNIT_ASSERT(checkToken(goal, LabelStr("sample3"), LabelStr("TestClass2.Sample"), + CPPUNIT_ASSERT(checkToken(goal, "sample3", "TestClass2.Sample", TokenId::noId(), getMandatoryStateDom())); oldTokens.insert(goal); /* Create a subgoal for each temporal relation. */ @@ -4893,7 +4907,7 @@ class DbTransPlayerTest { //!!Should use the master token's Id rather than TokenId::noId() here, but the player doesn't behave that way. //!!Is that a bug in the player or not? //!! May mean that this is an inappropriate overloading of the '' XML tag per Tania and I (17 Nov 2004) - CPPUNIT_ASSERT(checkToken(subgoal, LabelStr("_auto_"), LabelStr("TestClass2.Sample"), + CPPUNIT_ASSERT(checkToken(subgoal, "_auto_", "TestClass2.Sample", TokenId::noId(), getMandatoryStateDom())); CPPUNIT_ASSERT(verifyTokenRelation(goal, subgoal, *which)); /* Update list of old tokens. */ @@ -4914,7 +4928,8 @@ class DbTransPlayerTest { TEST_REWINDING_XML(transactions.str()); TokenSet::size_type newTokenCount = s_db->getTokens().size(); CPPUNIT_ASSERT(newTokenCount < oldTokenCount); - CPPUNIT_ASSERT((oldTokenCount - newTokenCount) == (TokenSet::size_type)(s_tempRels.size() + 1)); + CPPUNIT_ASSERT((oldTokenCount - newTokenCount) == + static_cast(s_tempRels.size() + 1)); TEST_PLAYING_XML(transactions.str()); CPPUNIT_ASSERT(oldTokenCount == s_db->getTokens().size()); @@ -4930,9 +4945,9 @@ class DbTransPlayerTest { /* Get an existing object. See testCreateObject(). */ ObjectId obj2b = s_db->getObject("testObj2b"); CPPUNIT_ASSERT(!obj2b.isNoId() && obj2b.isValid()); - CPPUNIT_ASSERT(obj2b->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2b->getName() == LabelStr("testObj2b")); - const unsigned int initialObjectTokenCount_B = obj2b->tokens().size(); + CPPUNIT_ASSERT(obj2b->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2b->getName() == "testObj2b"); + const unsigned long initialObjectTokenCount_B = obj2b->tokens().size(); TokenId constrainedToken = createToken("constrainedSample", true); TEST_PLAYING_XML(buildXMLObjTokTokStr("activate", "", "constrainedSample", "")); @@ -4972,10 +4987,10 @@ class DbTransPlayerTest { /* Create two rejectable tokens and do the same tests, but with testObj2a. */ ObjectId obj2a = s_db->getObject("testObj2a"); CPPUNIT_ASSERT(!obj2a.isNoId() && obj2a.isValid()); - CPPUNIT_ASSERT(obj2a->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2a->getName() == LabelStr("testObj2a")); + CPPUNIT_ASSERT(obj2a->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2a->getName() == "testObj2a"); ObjectDomain objDom2a(GET_DATA_TYPE(s_db,"TestClass2"),obj2a); - const unsigned int initialObjectTokenCount_A = obj2a->tokens().size(); + const unsigned long initialObjectTokenCount_A = obj2a->tokens().size(); TokenId rejectable = createToken("rejectableConstrainedSample", false); debugMsg("testConstraint", __FILE__ << ':' << __LINE__ << ": rejectable is " << rejectable); @@ -5031,15 +5046,15 @@ class DbTransPlayerTest { static void testFree() { ObjectId obj2a = s_db->getObject("testObj2a"); CPPUNIT_ASSERT(!obj2a.isNoId() && obj2a.isValid()); - CPPUNIT_ASSERT(obj2a->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2a->getName() == LabelStr("testObj2a")); + CPPUNIT_ASSERT(obj2a->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2a->getName() == "testObj2a"); ObjectDomain objDom2a(GET_DATA_TYPE(s_db,"TestClass2"),obj2a); - const unsigned int initialObjectTokenCount_A = obj2a->tokens().size(); + const unsigned long initialObjectTokenCount_A = obj2a->tokens().size(); ObjectId obj2b = s_db->getObject("testObj2b"); CPPUNIT_ASSERT(!obj2b.isNoId() && obj2b.isValid()); - CPPUNIT_ASSERT(obj2b->getType() == LabelStr("TestClass2")); - CPPUNIT_ASSERT(obj2b->getName() == LabelStr("testObj2b")); + CPPUNIT_ASSERT(obj2b->getType() == "TestClass2"); + CPPUNIT_ASSERT(obj2b->getName() == "testObj2b"); ObjectDomain objDom2b(GET_DATA_TYPE(s_db,"TestClass2"),obj2b); TokenSet tokens = obj2b->tokens(); debugMsg("testFree", __FILE__ << ':' << __LINE__ << ": there are " << tokens.size() << " tokens on testObj2b; should be 2."); @@ -5220,9 +5235,9 @@ class DbTransPlayerTest { /** * Helper function: map relation names to the constraints it implies on the two tokens given. * @note I think that this should be part of the base API, not part of the test code. - * --wedgingt@email.arc.nasa.gov 2004 Dec 13 + * --wedgingt 2004 Dec 13 */ - static void getConstraintsFromRelations(const TokenId& master, const TokenId& slave, const LabelStr& relation, + static void getConstraintsFromRelations(const TokenId master, const TokenId slave, const LabelStr& relation, std::list& firsts, std::list& seconds, std::list& intervals) { @@ -5327,7 +5342,7 @@ class DbTransPlayerTest { return; } - static bool verifyTokenRelation(const TokenId& master, const TokenId& slave, const LabelStr& relation) { + static bool verifyTokenRelation(const TokenId master, const TokenId slave, const LabelStr& relation) { std::list firstVars; std::list secondVars; std::list intervals; @@ -5376,19 +5391,19 @@ class DbTransPlayerTest { /** Create an XML string that creates a (complex) model class. */ static std::string buildXMLCreateClassStr(const std::string& className, const ArgList& args, - const char *file, const int& line); + const char *file, const unsigned long& line); /** Create an XML string that creates a model object. */ static std::string buildXMLCreateObjectStr(const std::string& className, const std::string& objName, const std::vector& args); /** Create an XML string that specifies a variable's domain. */ - static std::string buildXMLSpecifyVariableStr(const ConstrainedVariableId& var, const Domain& dom); + static std::string buildXMLSpecifyVariableStr(const ConstrainedVariableId var, const Domain& dom); /** * Create an XML string that resets a variable's specified domain. */ - static std::string buildXMLResetVariableStr(const ConstrainedVariableId& var); + static std::string buildXMLResetVariableStr(const ConstrainedVariableId var); /** * Create an XML string that creates a constraint between the listed variables. @@ -5399,7 +5414,7 @@ class DbTransPlayerTest { /** * Create an XML string that specifies the variable's domain via ''. */ - static std::string buildXMLInvokeSpecifyVariableStr(const ConstrainedVariableId& var, const Domain& dom); + static std::string buildXMLInvokeSpecifyVariableStr(const ConstrainedVariableId var, const Domain& dom); /** * Create an XML string that creates a goal token. @@ -5424,7 +5439,7 @@ class DbTransPlayerTest { static std::string buildXMLObjTokTokStr(const LabelStr& tag, const LabelStr& obj, const LabelStr& tok, const LabelStr& tok2); /** Create an XML string denoting/naming/identifying the variable. */ - static std::string buildXMLVariableStr(const ConstrainedVariableId& var); + static std::string buildXMLVariableStr(const ConstrainedVariableId var); /** Create an XML string describing the domain. */ static std::string buildXMLDomainStr(const Domain& dom); @@ -5493,13 +5508,13 @@ TokenId DbTransPlayerTest::s_rejectedToken; std::set DbTransPlayerTest::s_tempRels; /** Run a single test, reading the XML from the given string. */ -void DbTransPlayerTest::testPlayingXML(const std::string& xml, const char *file, const int& line) { +void DbTransPlayerTest::testPlayingXML(const std::string& xml, const char *, const int&) { CPPUNIT_ASSERT(s_dbPlayer != 0); std::istringstream iss(xml); s_dbPlayer->play(iss); } -void DbTransPlayerTest::testRewindingXML(const std::string& xml, const char* file, const int & line, +void DbTransPlayerTest::testRewindingXML(const std::string& xml, const char*, const int &, bool breakpoint) { CPPUNIT_ASSERT(s_dbPlayer != 0); std::istringstream iss(xml); @@ -5568,7 +5583,7 @@ std::string DbTransPlayerTest::buildXMLNameTypeStr(const std::string& tag, const } std::string DbTransPlayerTest::buildXMLCreateClassStr(const std::string& className, const ArgList& args, - const char *file, const int& line) { + const char *file, const unsigned long& line) { std::string str(""; ArgIter it = args.begin(); CPPUNIT_ASSERT(it != args.end()); - int l_line = line - args.size(); /* "Guess" that args was create line by line in same file. */ + unsigned long l_line = line - args.size(); /* "Guess" that args was create line by line in same file. */ for ( ; it != args.end(); it++) { str += " "); str += buildXMLVariableStr(var); str += " "; @@ -5650,7 +5665,7 @@ std::string DbTransPlayerTest::buildXMLSpecifyVariableStr(const ConstrainedVaria return(str); } -std::string DbTransPlayerTest::buildXMLResetVariableStr(const ConstrainedVariableId& var) { +std::string DbTransPlayerTest::buildXMLResetVariableStr(const ConstrainedVariableId var) { std::string str(""); str += buildXMLVariableStr(var); str += " "; @@ -5669,12 +5684,12 @@ std::string DbTransPlayerTest::buildXMLInvokeConstrainVarsStr(const std::string& return(str); } -std::string DbTransPlayerTest::buildXMLInvokeSpecifyVariableStr(const ConstrainedVariableId& var, +std::string DbTransPlayerTest::buildXMLInvokeSpecifyVariableStr(const ConstrainedVariableId var, const Domain& dom) { std::string str("parent().isNoId()) - str += var->getName().toString(); + str += var->getName(); else { if (TokenId::convertable(var->parent())) { //!!For token variables, the player's name for the token is needed: identifier="tokenName.varName" @@ -5684,9 +5699,9 @@ std::string DbTransPlayerTest::buildXMLInvokeSpecifyVariableStr(const Constraine CPPUNIT_ASSERT_MESSAGE("var's parent is neither token nor object", ObjectId::convertable(var->parent())); //!!I don't understand the details in DbClientTransactionPlayer.cc:parseVariable() well enough to figure this out yet //!!But here's a guess: - str += var->parent()->getName().toString(); + str += var->parent()->getName(); str += "."; - str += var->getName().toString(); + str += var->getName(); } str += "\"> "; str += buildXMLDomainStr(dom); @@ -5767,17 +5782,17 @@ std::string DbTransPlayerTest::buildXMLObjTokTokStr(const LabelStr& tag, const L return(str); } -std::string DbTransPlayerTest::buildXMLVariableStr(const ConstrainedVariableId& var) { +std::string DbTransPlayerTest::buildXMLVariableStr(const ConstrainedVariableId var) { std::string str(" <"); if (var->parent().isNoId()) { str += "id name =\""; - str += var->getName().toString(); + str += var->getName(); } else { str += "variable index=\""; std::ostringstream oss; oss << var->getIndex() << "\" "; if (ObjectId::convertable(var->parent())) - oss << "object=\"" << var->parent()->getName().toString(); + oss << "object=\"" << var->parent()->getName(); else { CPPUNIT_ASSERT_MESSAGE("unknown or unsupported (C++) type of parent of variable", TokenId::convertable(var->parent())); @@ -5803,7 +5818,7 @@ std::string DbTransPlayerTest::buildXMLDomainStr(const Domain& dom) { if (dom.isSingleton() && dom.isNumeric()) { str += "value"; str += " type=\""; - str += dom.getTypeName().toString(); + str += dom.getTypeName(); str += "\""; str += " name=\""; std::ostringstream oss; @@ -5814,7 +5829,7 @@ std::string DbTransPlayerTest::buildXMLDomainStr(const Domain& dom) { } if (dom.isInterval()) { str += "interval type=\""; - str += dom.getTypeName().toString(); + str += dom.getTypeName(); str += "\" min=\""; std::ostringstream oss2; std::fixed(oss2); @@ -5843,7 +5858,7 @@ std::string DbTransPlayerTest::buildXMLDomainStr(const Domain& dom) { str += oss4.str(); } str += "\" type=\""; - str += dom.getTypeName().toString(); + str += dom.getTypeName(); str += "\"/> "; } str += ""; diff --git a/src/PLASMA/PlanDatabase/test/db-test-module.hh b/src/PLASMA/PlanDatabase/test/db-test-module.hh index 52bd69042..ae6df2c0b 100644 --- a/src/PLASMA/PlanDatabase/test/db-test-module.hh +++ b/src/PLASMA/PlanDatabase/test/db-test-module.hh @@ -6,7 +6,7 @@ #include #include "Domains.hh" -using namespace EUROPA; + class PlanDatabaseModuleTests : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(PlanDatabaseModuleTests); @@ -37,7 +37,7 @@ class PlanDatabaseModuleTests : public CppUnit::TestFixture { void DBTransPlayerTest(void); }; -typedef SymbolDomain Locations; +typedef EUROPA::SymbolDomain Locations; const Locations& LocationsBaseDomain(); diff --git a/src/PLASMA/PlanDatabase/test/module-tests.cc b/src/PLASMA/PlanDatabase/test/module-tests.cc index b34eec7b7..ba7c9da9a 100644 --- a/src/PLASMA/PlanDatabase/test/module-tests.cc +++ b/src/PLASMA/PlanDatabase/test/module-tests.cc @@ -5,8 +5,9 @@ CPPUNIT_TEST_SUITE_REGISTRATION( PlanDatabaseModuleTests ); -int main( int argc, char **argv) +int main( int , char **) { + using namespace EUROPA; // Init data types so that id counts don't fail VoidDT::instance(); BoolDT::instance(); diff --git a/src/PLASMA/Resource/CMakeLists.txt b/src/PLASMA/Resource/CMakeLists.txt index a468309ff..c7386ae95 100644 --- a/src/PLASMA/Resource/CMakeLists.txt +++ b/src/PLASMA/Resource/CMakeLists.txt @@ -1,9 +1,10 @@ include(EuropaModule) +# set(internal_dependencies NDDL Solvers TemporalNetwork PlanDatabase) set(internal_dependencies NDDL RulesEngine Solvers TemporalNetwork PlanDatabase ConstraintEngine Utils TinyXml) set(internal_components Solvers NDDL) set(root_sources ModuleResource.cc) set(base_sources FVDetector.cc Instant.cc PSResource.cc Profile.cc ProfilePropagator.cc Resource.cc ResourceTokenRelation.cc Transaction.cc) -set(component_sources ClosedWorldFVDetector.cc DurativeTokens.cc Edge.cc FlowProfile.cc GenericFVDetector.cc Graph.cc GroundedFVDetector.cc GroundedProfile.cc IncrementalFlowProfile.cc InstantTokens.cc MaxFlow.cc Node.cc OpenWorldFVDetector.cc Reservoir.cc Reusable.cc TimetableProfile.cc Types.cc NDDL/InterpreterResources.cc NDDL/NddlResource.cc Solvers/ResourceMatching.cc Solvers/ResourceThreatDecisionPoint.cc Solvers/ResourceThreatManager.cc) +set(component_sources BoostFlowProfileGraph.cc ClosedWorldFVDetector.cc DurativeTokens.cc Edge.cc FlowProfile.cc FlowProfileGraph.cc GenericFVDetector.cc Graph.cc GroundedFVDetector.cc GroundedProfile.cc IncrementalFlowProfile.cc InstantTokens.cc MaxFlow.cc Node.cc OpenWorldFVDetector.cc Reservoir.cc Reusable.cc TimetableProfile.cc Types.cc NDDL/InterpreterResources.cc NDDL/NddlResource.cc Solvers/ResourceMatching.cc Solvers/ResourceThreatDecisionPoint.cc Solvers/ResourceThreatManager.cc) set(test_sources module-tests.cc rs-flow-test-module.cc rs-test-module.cc) common_module_prepends("${base_sources}" "${component_sources}" "${test_sources}" base_sources component_sources test_sources) diff --git a/src/PLASMA/Resource/ModuleResource.cc b/src/PLASMA/Resource/ModuleResource.cc index 8f501d2d5..a7501acb4 100644 --- a/src/PLASMA/Resource/ModuleResource.cc +++ b/src/PLASMA/Resource/ModuleResource.cc @@ -17,6 +17,10 @@ #include "ThreatDecisionPoint.hh" #include "ResourceThreatManager.hh" #include "Reusable.hh" +#include "BoostFlowProfile.hh" +#include "CESchema.hh" + +#include namespace EUROPA { @@ -38,102 +42,105 @@ namespace EUROPA { } - void ModuleResource::initialize(EngineId engine) - { - ConstraintEngine* ce = (ConstraintEngine*)(engine->getComponent("ConstraintEngine")); - Schema* schema = (Schema*)(engine->getComponent("Schema")); - new ProfilePropagator(LabelStr("Resource"), ce->getId()); - - ObjectTypeId objectOT = schema->getObjectType(Schema::rootObject()); - ObjectType* ot; - - // TODO: preserve class hierarchy, all Resource types should extend Resource, not Object - ot = new ObjectType("Reusable",objectOT,true /*isNative*/); - ot->addMember(FloatDT::instance(), "capacity"); - ot->addMember(FloatDT::instance(), "levelLimitMin"); - ot->addMember(FloatDT::instance(), "consumptionMax"); - ot->addMember(FloatDT::instance(), "consumptionRateMax"); - ot->addObjectFactory((new ReusableObjectFactory(ot->getId(),"Reusable"))->getId()); - ot->addObjectFactory((new ReusableObjectFactory(ot->getId(),"Reusable:float:float"))->getId()); - ot->addObjectFactory((new ReusableObjectFactory(ot->getId(),"Reusable:float:float:float"))->getId()); - ot->addObjectFactory((new ReusableObjectFactory(ot->getId(),"Reusable:float:float:float:float"))->getId()); - ot->addTokenType((new ReusableUsesTokenType(ot->getId(),"Reusable.uses"))->getId()); - schema->registerObjectType(ot->getId()); - - ot = new ObjectType("CBReusable",objectOT,true /*isNative*/); - ot->addMember(FloatDT::instance(), "capacity"); - ot->addMember(FloatDT::instance(), "levelLimitMin"); - ot->addMember(FloatDT::instance(), "consumptionMax"); - ot->addMember(FloatDT::instance(), "consumptionRateMax"); - ot->addObjectFactory((new CBReusableObjectFactory(ot->getId(),"CBReusable"))->getId()); - ot->addObjectFactory((new CBReusableObjectFactory(ot->getId(),"CBReusable:float:float"))->getId()); - ot->addObjectFactory((new CBReusableObjectFactory(ot->getId(),"CBReusable:float:float:float"))->getId()); - ot->addObjectFactory((new CBReusableObjectFactory(ot->getId(),"CBReusable:float:float:float:float"))->getId()); - schema->registerObjectType(ot->getId()); - REGISTER_CONSTRAINT( - ce->getCESchema(), - Uses, - Uses::CONSTRAINT_NAME(), - Uses::PROPAGATOR_NAME() - ); - - ot = new ObjectType("Reservoir",objectOT,true /*isNative*/); - ot->addMember(FloatDT::instance(), "initialCapacity"); - ot->addMember(FloatDT::instance(), "levelLimitMin"); - ot->addMember(FloatDT::instance(), "levelLimitMax"); - ot->addMember(FloatDT::instance(), "productionRateMax"); - ot->addMember(FloatDT::instance(), "productionMax"); - ot->addMember(FloatDT::instance(), "consumptionRateMax"); - ot->addMember(FloatDT::instance(), "consumptionMax"); - ot->addObjectFactory((new ReservoirObjectFactory(ot->getId(),"Reservoir"))->getId()); - ot->addObjectFactory((new ReservoirObjectFactory(ot->getId(),"Reservoir:float:float:float"))->getId()); - ot->addObjectFactory((new ReservoirObjectFactory(ot->getId(),"Reservoir:float:float:float:float:float"))->getId()); - ot->addObjectFactory((new ReservoirObjectFactory(ot->getId(),"Reservoir:float:float:float:float:float:float:float"))->getId()); - ot->addTokenType((new ReservoirProduceTokenType(ot->getId(),"Reservoir.produce"))->getId()); - ot->addTokenType((new ReservoirConsumeTokenType(ot->getId(),"Reservoir.consume"))->getId()); - schema->registerObjectType(ot->getId()); - - ot = new ObjectType("Unary",objectOT,true /*isNative*/); - ot->addMember(FloatDT::instance(),"consumptionMax"); - ot->addObjectFactory((new UnaryObjectFactory(ot->getId(),"Unary"))->getId()); - ot->addObjectFactory((new UnaryObjectFactory(ot->getId(),"Unary:float"))->getId()); - ot->addTokenType((new UnaryUseTokenType(ot->getId(),"Unary.use"))->getId()); - schema->registerObjectType(ot->getId()); - - FactoryMgr* pfm = new FactoryMgr(); - engine->addComponent("ProfileFactoryMgr",pfm); - REGISTER_PROFILE(pfm,TimetableProfile, TimetableProfile ); - REGISTER_PROFILE(pfm,FlowProfile, FlowProfile); - REGISTER_PROFILE(pfm,IncrementalFlowProfile, IncrementalFlowProfile ); - REGISTER_PROFILE(pfm,GroundedProfile, GroundedProfile ); - - // Solver - FactoryMgr* fvdfm = new FactoryMgr(); - engine->addComponent("FVDetectorFactoryMgr",fvdfm); - REGISTER_FVDETECTOR(fvdfm,OpenWorldFVDetector,OpenWorldFVDetector); - REGISTER_FVDETECTOR(fvdfm,ClosedWorldFVDetector,ClosedWorldFVDetector); - REGISTER_FVDETECTOR(fvdfm,GroundedFVDetector,GroundedFVDetector); - - SOLVERS::ComponentFactoryMgr* cfm = (SOLVERS::ComponentFactoryMgr*)engine->getComponent("ComponentFactoryMgr"); - REGISTER_FLAW_MANAGER(cfm,ResourceThreatManager, ResourceThreatManager); - REGISTER_FLAW_HANDLER(cfm,ResourceThreatDecisionPoint, ResourceThreatHandler); -// REGISTER_FLAW_HANDLER(cfm,SOLVERS::ResourceThreatDecisionPoint, ResourceThreat); - - SOLVERS::MatchFinderMgr* mfm = (EUROPA::SOLVERS::MatchFinderMgr*)engine->getComponent("MatchFinderMgr"); - REGISTER_MATCH_FINDER(mfm,EUROPA::SOLVERS::InstantMatchFinder,Instant::entityTypeName()); - - schema->registerMethod((new SetCapacity())->getId()); - schema->registerMethod((new SetLimit())->getId()); - } - - void ModuleResource::uninitialize(EngineId engine) - { - const char* fmgrs[] = {"ProfileFactoryMgr","FVDetectorFactoryMgr"}; - for (int i=0;i<2;i++) { - FactoryMgr* fm = (FactoryMgr*)engine->removeComponent(fmgrs[i]); - delete fm; - } +void ModuleResource::initialize(EngineId engine) { + ConstraintEngine* ce = boost::polymorphic_cast(engine->getComponent("ConstraintEngine")); + Schema* schema = boost::polymorphic_cast(engine->getComponent("Schema")); + new ProfilePropagator("Resource", ce->getId()); + + ObjectTypeId objectOT = schema->getObjectType(Schema::rootObject()); + ObjectType* ot; + + // TODO: preserve class hierarchy, all Resource types should extend Resource, not Object + ot = new ObjectType("Reusable",objectOT,true /*isNative*/); + ot->addMember(FloatDT::instance(), "capacity"); + ot->addMember(FloatDT::instance(), "levelLimitMin"); + ot->addMember(FloatDT::instance(), "consumptionMax"); + ot->addMember(FloatDT::instance(), "consumptionRateMax"); + ot->addObjectFactory((new ReusableObjectFactory(ot->getId(),"Reusable"))->getId()); + ot->addObjectFactory((new ReusableObjectFactory(ot->getId(),"Reusable:float:float"))->getId()); + ot->addObjectFactory((new ReusableObjectFactory(ot->getId(),"Reusable:float:float:float"))->getId()); + ot->addObjectFactory((new ReusableObjectFactory(ot->getId(),"Reusable:float:float:float:float"))->getId()); + ot->addTokenType((new ReusableUsesTokenType(ot->getId(),"Reusable.uses"))->getId()); + schema->registerObjectType(ot->getId()); + + ot = new ObjectType("CBReusable",objectOT,true /*isNative*/); + ot->addMember(FloatDT::instance(), "capacity"); + ot->addMember(FloatDT::instance(), "levelLimitMin"); + ot->addMember(FloatDT::instance(), "consumptionMax"); + ot->addMember(FloatDT::instance(), "consumptionRateMax"); + ot->addObjectFactory((new CBReusableObjectFactory(ot->getId(),"CBReusable"))->getId()); + ot->addObjectFactory((new CBReusableObjectFactory(ot->getId(),"CBReusable:float:float"))->getId()); + ot->addObjectFactory((new CBReusableObjectFactory(ot->getId(),"CBReusable:float:float:float"))->getId()); + ot->addObjectFactory((new CBReusableObjectFactory(ot->getId(),"CBReusable:float:float:float:float"))->getId()); + schema->registerObjectType(ot->getId()); + REGISTER_CONSTRAINT( + ce->getCESchema(), + Uses, + Uses::CONSTRAINT_NAME(), + Uses::PROPAGATOR_NAME() + ); + + ot = new ObjectType("Reservoir",objectOT,true /*isNative*/); + ot->addMember(FloatDT::instance(), "initialCapacity"); + ot->addMember(FloatDT::instance(), "levelLimitMin"); + ot->addMember(FloatDT::instance(), "levelLimitMax"); + ot->addMember(FloatDT::instance(), "productionRateMax"); + ot->addMember(FloatDT::instance(), "productionMax"); + ot->addMember(FloatDT::instance(), "consumptionRateMax"); + ot->addMember(FloatDT::instance(), "consumptionMax"); + ot->addObjectFactory((new ReservoirObjectFactory(ot->getId(),"Reservoir"))->getId()); + ot->addObjectFactory((new ReservoirObjectFactory(ot->getId(),"Reservoir:float:float:float"))->getId()); + ot->addObjectFactory((new ReservoirObjectFactory(ot->getId(),"Reservoir:float:float:float:float:float"))->getId()); + ot->addObjectFactory((new ReservoirObjectFactory(ot->getId(),"Reservoir:float:float:float:float:float:float:float"))->getId()); + ot->addTokenType((new ReservoirProduceTokenType(ot->getId(),"Reservoir.produce"))->getId()); + ot->addTokenType((new ReservoirConsumeTokenType(ot->getId(),"Reservoir.consume"))->getId()); + schema->registerObjectType(ot->getId()); + + ot = new ObjectType("Unary",objectOT,true /*isNative*/); + ot->addMember(FloatDT::instance(),"consumptionMax"); + ot->addObjectFactory((new UnaryObjectFactory(ot->getId(),"Unary"))->getId()); + ot->addObjectFactory((new UnaryObjectFactory(ot->getId(),"Unary:float"))->getId()); + ot->addTokenType((new UnaryUseTokenType(ot->getId(),"Unary.use"))->getId()); + schema->registerObjectType(ot->getId()); + + FactoryMgr* pfm = new FactoryMgr(); + engine->addComponent("ProfileFactoryMgr",pfm); + REGISTER_PROFILE(pfm,TimetableProfile, TimetableProfile ); + REGISTER_PROFILE(pfm, BoostFlowProfile, FlowProfile); + REGISTER_PROFILE(pfm, BoostFlowProfile, IncrementalFlowProfile); + // REGISTER_PROFILE(pfm,FlowProfile, FlowProfile); + // REGISTER_PROFILE(pfm,IncrementalFlowProfile, IncrementalFlowProfile ); + REGISTER_PROFILE(pfm,GroundedProfile, GroundedProfile ); + + // Solver + FactoryMgr* fvdfm = new FactoryMgr(); + engine->addComponent("FVDetectorFactoryMgr",fvdfm); + REGISTER_FVDETECTOR(fvdfm,OpenWorldFVDetector,OpenWorldFVDetector); + REGISTER_FVDETECTOR(fvdfm,ClosedWorldFVDetector,ClosedWorldFVDetector); + REGISTER_FVDETECTOR(fvdfm,GroundedFVDetector,GroundedFVDetector); + + SOLVERS::ComponentFactoryMgr* cfm = + boost::polymorphic_cast(engine->getComponent("ComponentFactoryMgr")); + REGISTER_FLAW_MANAGER(cfm,ResourceThreatManager, ResourceThreatManager); + REGISTER_FLAW_HANDLER(cfm,ResourceThreatDecisionPoint, ResourceThreatHandler); + // REGISTER_FLAW_HANDLER(cfm,SOLVERS::ResourceThreatDecisionPoint, ResourceThreat); + + SOLVERS::MatchFinderMgr* mfm = + boost::polymorphic_cast(engine->getComponent("MatchFinderMgr")); + REGISTER_MATCH_FINDER(mfm,EUROPA::SOLVERS::InstantMatchFinder,Instant::entityTypeName()); + + schema->registerMethod((new SetCapacity())->getId()); + schema->registerMethod((new SetLimit())->getId()); +} - // TODO: clean up other pieces added by this module +void ModuleResource::uninitialize(EngineId engine) { + const char* fmgrs[] = {"ProfileFactoryMgr","FVDetectorFactoryMgr"}; + for (unsigned int i=0;i<2;i++) { + FactoryMgr* fm = + boost::polymorphic_cast(engine->removeComponent(fmgrs[i])); + delete fm; } + + // TODO: clean up other pieces added by this module +} } diff --git a/src/PLASMA/Resource/ModuleResource.hh b/src/PLASMA/Resource/ModuleResource.hh index 671bf5b03..8c50ca9b2 100644 --- a/src/PLASMA/Resource/ModuleResource.hh +++ b/src/PLASMA/Resource/ModuleResource.hh @@ -1,6 +1,6 @@ -#ifndef _H_ModuleResource -#define _H_ModuleResource +#ifndef H_ModuleResource +#define H_ModuleResource #include "Module.hh" @@ -29,4 +29,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_ModuleResource */ +#endif /* #ifndef H_ModuleResource */ diff --git a/src/PLASMA/Resource/ResourceDefs.hh b/src/PLASMA/Resource/ResourceDefs.hh index cd79de8a5..88dc60471 100644 --- a/src/PLASMA/Resource/ResourceDefs.hh +++ b/src/PLASMA/Resource/ResourceDefs.hh @@ -1,5 +1,5 @@ -#ifndef _H_ResourceDefs -#define _H_ResourceDefs +#ifndef H_ResourceDefs +#define H_ResourceDefs #include "ConstraintEngineDefs.hh" #include "PlanDatabaseDefs.hh" diff --git a/src/PLASMA/Resource/base/FVDetector.hh b/src/PLASMA/Resource/base/FVDetector.hh index dfda57d8c..1e5e3eb06 100644 --- a/src/PLASMA/Resource/base/FVDetector.hh +++ b/src/PLASMA/Resource/base/FVDetector.hh @@ -1,5 +1,5 @@ -#ifndef _H_FVDetector -#define _H_FVDetector +#ifndef H_FVDetector +#define H_FVDetector /** * @file FVDetector.hh @@ -54,9 +54,9 @@ namespace EUROPA { */ virtual bool detect(const InstantId inst) = 0; - FVDetectorId& getId() {return m_id;} + FVDetectorId getId() {return m_id;} - const ResourceId& getResource() const {return m_res;} + const ResourceId getResource() const {return m_res;} virtual PSResourceProfile* getFDLevelProfile() = 0; virtual PSResourceProfile* getVDLevelProfile() = 0; @@ -93,24 +93,24 @@ namespace EUROPA { class FVDetectorArgs : public FactoryArgs { public: - const ResourceId& resource; - FVDetectorArgs(const ResourceId& r) : resource(r) {} + const ResourceId resource; + FVDetectorArgs(const ResourceId r) : resource(r) {} }; template class FVDetectorFactory : public Factory { public: - FVDetectorFactory(const EUROPA::LabelStr& name) : Factory(name) {} + FVDetectorFactory(const std::string& name) : Factory(name) {} - virtual EUROPA::FactoryObjId& createInstance(const EUROPA::FactoryArgs& fa) { - const FVDetectorArgs& args = (const FVDetectorArgs&)fa; - return (EUROPA::FactoryObjId&)(new FVDetectorType(args.resource))->getId(); + virtual EUROPA::FactoryObjId createInstance(const EUROPA::FactoryArgs& fa) { + const FVDetectorArgs& args = dynamic_cast(fa); + return (new FVDetectorType(args.resource))->getId(); } }; #define REGISTER_FVDETECTOR(MGR, CLASS, NAME) \ - (MGR->registerFactory((new EUROPA::FVDetectorFactory(EUROPA::LabelStr(#NAME)))->getId())); + (MGR->registerFactory((new EUROPA::FVDetectorFactory(#NAME))->getId())); } #endif diff --git a/src/PLASMA/Resource/base/Instant.cc b/src/PLASMA/Resource/base/Instant.cc index 251c0e2f1..56d3c2984 100644 --- a/src/PLASMA/Resource/base/Instant.cc +++ b/src/PLASMA/Resource/base/Instant.cc @@ -4,13 +4,14 @@ #include "ConstrainedVariable.hh" namespace EUROPA { - Instant::Instant(const eint time, const ProfileId prof) - : Entity(), m_id(this), m_time(time), m_profile(prof), m_lowerLevel(0), m_lowerLevelMax(0), m_upperLevelMin(0), m_upperLevel(0), - m_maxInstProduction(0), m_maxInstConsumption(0), m_minInstProduction(0), m_minInstConsumption(0), - m_maxCumulativeProduction(0), m_maxCumulativeConsumption(0), m_minCumulativeProduction(0), m_minCumulativeConsumption(0), - m_maxPrevProduction(0), m_maxPrevConsumption(0), m_minPrevProduction(0), m_minPrevConsumption(0), - m_upperFlawMagnitude(0), m_lowerFlawMagnitude(0), - m_violated(false), m_flawed(false), m_upperFlaw(false), m_lowerFlaw(false) {} +Instant::Instant(const eint time, const ProfileId prof) + : Entity(), m_id(this), m_time(time), m_profile(prof), m_lowerLevel(0), m_lowerLevelMax(0), m_upperLevelMin(0), m_upperLevel(0), + m_maxInstProduction(0), m_maxInstConsumption(0), m_minInstProduction(0), m_minInstConsumption(0), + m_maxCumulativeProduction(0), m_maxCumulativeConsumption(0), m_minCumulativeProduction(0), m_minCumulativeConsumption(0), + m_maxPrevProduction(0), m_maxPrevConsumption(0), m_minPrevProduction(0), m_minPrevConsumption(0), + m_upperFlawMagnitude(0), m_lowerFlawMagnitude(0), + m_violated(false), m_flawed(false), m_upperFlaw(false), m_lowerFlaw(false), + m_transactions(), m_endingTransactions(), m_startingTransactions() {} Instant::~Instant() { m_id.remove(); @@ -55,7 +56,6 @@ namespace EUROPA { } void Instant::removeTransaction(const TransactionId t) { - checkError(m_transactions.find(t) != m_transactions.end(), "Instant for time " << m_time << " has no transaction " << t); m_transactions.erase(t); m_endingTransactions.erase(t); m_startingTransactions.erase(t); diff --git a/src/PLASMA/Resource/base/Instant.hh b/src/PLASMA/Resource/base/Instant.hh index 7aeb0fa7e..0e444b5b0 100644 --- a/src/PLASMA/Resource/base/Instant.hh +++ b/src/PLASMA/Resource/base/Instant.hh @@ -1,5 +1,5 @@ -#ifndef _H_Instant -#define _H_Instant +#ifndef H_Instant +#define H_Instant /** * @file Instant.hh @@ -154,10 +154,10 @@ namespace EUROPA { * @param maxCumulativeConsumption The greatest amount of consumption that can have happened by this instant. * @param minCumulativeProduction The least amount of production that can have happened by this instant. * @param maxCumulativeProduction The greatest amount of production that can have happened by this instant. - * @param minPrevConsumption - * @param maxPrevConsumption - * @param minPrevProduction - * @param maxPrevProduction + * @param minPrevConsumption The lower bound of consumption before this instant. + * @param maxPrevConsumption The upper bound of consumption before this instant. + * @param minPrevProduction The lower bound of production before this instant. + * @param maxPrevProduction The upper bound of production before this instant. */ void update(edouble lowerLevelMin, edouble lowerLevelMax, edouble upperLevelMin, edouble upperLevelMax, edouble minInstConsumption, edouble maxInstConsumption, edouble minInstProduction, edouble maxInstProduction, @@ -200,13 +200,13 @@ namespace EUROPA { /** * @brief Set the violation status of this instant. - * @param violationed True if there is a violation, false otherwise. + * @param violated True if there is a violation, false otherwise. */ void setViolated(const bool violated) {m_violated = violated;} std::string toString() const; - const ProfileId& getProfile() const {return m_profile;} + const ProfileId getProfile() const {return m_profile;} protected: private: friend class Profile; @@ -246,17 +246,17 @@ namespace EUROPA { void applyBoundsDelta(const edouble& lbDelta, const edouble& ubDelta); InstantId m_id; - eint m_time; /* m_transactions; /* m_endingTransactions; /* m_startingTransactions; /* m_transactions; /**< The complete set of transactions */ + std::set m_endingTransactions; /**< The set of transactions whose upper bound is equal to the current time. */ + std::set m_startingTransactions; /**< The set of transactions whose lower bound is equal to the current time. */ }; } diff --git a/src/PLASMA/Resource/base/PSResource.cc b/src/PLASMA/Resource/base/PSResource.cc index 7b13f1578..e89d6686d 100644 --- a/src/PLASMA/Resource/base/PSResource.cc +++ b/src/PLASMA/Resource/base/PSResource.cc @@ -12,7 +12,7 @@ namespace EUROPA return dynamic_cast(obj); } - PSGenericProfile::PSGenericProfile(const ExplicitProfileId& profile) + PSGenericProfile::PSGenericProfile(const ExplicitProfileId profile) : m_profile(profile) { } @@ -46,7 +46,7 @@ namespace EUROPA return cast_double(m_profile->getValue(time).second); } - PSUsageProfile::PSUsageProfile(const ProfileId& profile) + PSUsageProfile::PSUsageProfile(const ProfileId profile) : m_profile(profile) { } @@ -65,17 +65,15 @@ namespace EUROPA return times; } - double PSUsageProfile::getLowerBound(TimePoint time) - { - IntervalDomain dom; - m_profile->getLevel((eint) time, dom); - return cast_double(dom.getLowerBound()); - } +double PSUsageProfile::getLowerBound(TimePoint time) { + IntervalDomain dom; + m_profile->getLevel(static_cast(time), dom); + return cast_double(dom.getLowerBound()); +} - double PSUsageProfile::getUpperBound(TimePoint time) - { - IntervalDomain dom; - m_profile->getLevel((eint) time, dom); - return cast_double(dom.getUpperBound()); - } +double PSUsageProfile::getUpperBound(TimePoint time) { + IntervalDomain dom; + m_profile->getLevel(static_cast(time), dom); + return cast_double(dom.getUpperBound()); +} } diff --git a/src/PLASMA/Resource/base/PSResource.hh b/src/PLASMA/Resource/base/PSResource.hh index 2ac04597f..76ab6f9f3 100644 --- a/src/PLASMA/Resource/base/PSResource.hh +++ b/src/PLASMA/Resource/base/PSResource.hh @@ -1,5 +1,5 @@ -#ifndef _H_PSResource -#define _H_PSResource +#ifndef H_PSResource +#define H_PSResource #include "PSPlanDatabase.hh" #include "ResourceDefs.hh" @@ -41,7 +41,7 @@ namespace EUROPA { class PSGenericProfile : public PSResourceProfile { public: - PSGenericProfile(const ExplicitProfileId& profile); + PSGenericProfile(const ExplicitProfileId profile); virtual ~PSGenericProfile() {} virtual PSList getTimes(); @@ -55,7 +55,7 @@ namespace EUROPA { class PSUsageProfile : public PSResourceProfile { public: - PSUsageProfile(const ProfileId& profile); + PSUsageProfile(const ProfileId profile); virtual ~PSUsageProfile() {} virtual PSList getTimes(); diff --git a/src/PLASMA/Resource/base/Profile.cc b/src/PLASMA/Resource/base/Profile.cc index fd3271206..844777df8 100644 --- a/src/PLASMA/Resource/base/Profile.cc +++ b/src/PLASMA/Resource/base/Profile.cc @@ -13,37 +13,50 @@ namespace EUROPA { - Profile::Profile(const PlanDatabaseId db, const FVDetectorId flawDetector) - : m_id(this) - , m_changeCount(0) - , m_needsRecompute(false) - , m_planDatabase(db) - , m_detector(flawDetector) +Profile::Profile(const PlanDatabaseId db, const FVDetectorId flawDetector) + : FactoryObj(), + m_id(this) + , m_changeCount(0) + , m_needsRecompute(false) + , m_constraintKeyLb(0) + , m_planDatabase(db) + , m_detector(flawDetector) + , m_transactions() + , m_variableListeners() + , m_otherListeners() + , m_transactionsByTime() + , m_temporalConstraints() + , m_removalListener() + , m_instants() + , m_recomputeInterval() { m_removalListener = (new ConstraintRemovalListener(db->getConstraintEngine(), m_id))->getId(); } - Profile::~Profile() { - debugMsg("Profile:~Profile", "In profile destructor for " << getId()); - delete (ConstraintEngineListener*) m_removalListener; - debugMsg("Profile:~Profile", "Cleaning up instants..."); - for(std::map::iterator it = m_instants.begin(); it != m_instants.end(); ++it) - delete (Instant*) it->second; - debugMsg("Profile:~Profile", "Cleaning up variable listeners..."); - for(std::multimap::iterator it = m_variableListeners.begin(); - it != m_variableListeners.end(); ++it) - it->second->discard(); - debugMsg("Profile:~Profile", "Cleaning up constraint addition listeners..."); - for(std::map::iterator it = m_otherListeners.begin(); - it != m_otherListeners.end(); ++it) - delete (ConstraintAdditionListener*) (it->second); +Profile::~Profile() { + debugMsg("Profile:~Profile", "In profile destructor for " << getId()); + delete static_cast(m_removalListener); + debugMsg("Profile:~Profile", "Cleaning up instants..."); + + cleanup(m_instants); + debugMsg("Profile:~Profile", "Cleaning up variable listeners..."); + for(std::multimap::iterator it = m_variableListeners.begin(); + it != m_variableListeners.end(); ++it) + it->second->discard(); + debugMsg("Profile:~Profile", "Cleaning up constraint addition listeners..."); + cleanup(m_otherListeners); + + if(m_recomputeInterval.isValid()) { + debugMsg("Profile:~Profile", "Deleting profile iterator " << m_recomputeInterval->getId() ); + delete static_cast(m_recomputeInterval); + } + m_id.remove(); +} - if(m_recomputeInterval.isValid()) { - debugMsg("Profile:~Profile", "Deleting profile iterator " << m_recomputeInterval->getId() ); - delete (ProfileIterator*) m_recomputeInterval; - } - m_id.remove(); - } +InstantId Profile::getInstant(const eint time) const { + std::map::const_iterator it = m_instants.find(time); + return (it == m_instants.end() ? InstantId::noId() : it->second); +} void Profile::addTransaction(const TransactionId t) { checkError(m_transactions.find(t) == m_transactions.end(), "Attempted to insert a transaction twice!"); @@ -52,8 +65,8 @@ namespace EUROPA { debugMsg("Profile:addTransaction", "Adding " << (t->isConsumer() ? "consumer " : "producer ") << "transaction " << t << " for time " << t->time()->toString() << " with quantity " << t->quantity()->toString()); - eint startTime = (eint) t->time()->lastDomain().getLowerBound(); - eint endTime = (eint) t->time()->lastDomain().getUpperBound(); + eint startTime = static_cast(t->time()->lastDomain().getLowerBound()); + eint endTime = static_cast(t->time()->lastDomain().getUpperBound()); //if instants for the start and end time don't already exist, add them addInstantsForBounds(t); @@ -79,201 +92,228 @@ namespace EUROPA { handleTransactionAdded(t); } - void Profile::handleTransactionAdded(const TransactionId e) { - //by default, create an iterator over all time - if(m_recomputeInterval.isValid()) { - debugMsg("Profile:addTransaction", "Deleting profile iterator " << m_recomputeInterval->getId() ); - delete (ProfileIterator*) m_recomputeInterval; - } - m_recomputeInterval = (new ProfileIterator(getId()))->getId(); - } +void Profile::handleTransactionAdded(const TransactionId) { + //by default, create an iterator over all time + if(m_recomputeInterval.isValid()) { + debugMsg("Profile:addTransaction", "Deleting profile iterator " << m_recomputeInterval->getId() ); + delete static_cast(m_recomputeInterval); + } + m_recomputeInterval = (new ProfileIterator(getId()))->getId(); +} bool Profile::containsChange(const InstantId instant) { return (instant->containsStartOrEnd()); } - void Profile::removeTransaction(const TransactionId t) { - if(m_transactions.find(t) == m_transactions.end()) - return; -// checkError(m_transactions.find(t) != m_transactions.end(), "Attempted to remove a transaction that isn't present!"); +void Profile::removeTransaction(const TransactionId t) { + if(m_transactions.find(t) == m_transactions.end()) + return; + // checkError(m_transactions.find(t) != m_transactions.end(), "Attempted to remove a transaction that isn't present!"); + + debugMsg("Profile:removeTransaction", + "Removing transaction " << t << " for time " << t->time()->toString() << + " with quantity " << t->quantity()->toString()); + eint startTime = + static_cast((t->time()->lastDomain().isEmpty() ? + t->time()->baseDomain() : t->time()->lastDomain()).getLowerBound()); + eint endTime = + static_cast((t->time()->lastDomain().isEmpty() ? + t->time()->baseDomain() : t->time()->lastDomain()).getUpperBound()); + checkError(startTime <= endTime, startTime << " > " << endTime); + ProfileIterator profIt(m_id, startTime, endTime); + std::vector emptyInstants; + //remove the transaction from its instants + while(!profIt.done()) { + debugMsg("Profile:removeTransaction", + "Removing transaction " << t << " from instant for time " << + profIt.getInstant()->getTime()); + profIt.getInstant()->removeTransaction(t); + //if the instant contains no transactions or doesn't represent the start or end of a transaction, it is empty and should be deleted. + if(profIt.getInstant()->getTransactions().empty() || + !containsChange(profIt.getInstant())) { + debugMsg("Profile:removeTransaction", + "Instant for time " << profIt.getInstant()->getTime() << " is empty."); + emptyInstants.push_back(profIt.getInstant()->getTime()); + } + profIt.next(); + } + + //remove any constraints on the transaction from the profile. + std::vector > removals; + for(ConstraintSet::const_iterator it = m_temporalConstraints.begin(); + it != m_temporalConstraints.end(); ++it) { + if((*it)->isVariableOf(t->time())) { + removals.push_back(std::make_pair(*it, + std::distance((*it)->getScope().begin(), + std::find((*it)->getScope().begin(), + (*it)->getScope().end(), + t->time())))); + } + } + for(std::vector >::const_iterator it = removals.begin(); + it != removals.end(); ++it) + handleConstraintMessage(it->first, t->time(), static_cast(it->second), false); + + m_transactions.erase(t); + m_transactionsByTime.erase(t->time()); + + //remove the listeners + checkError(m_variableListeners.find(t) != m_variableListeners.end(), + "Bizarre. No listeners for transaction."); + for(std::multimap::iterator it = m_variableListeners.find(t); + it != m_variableListeners.end() && it->first == t; ++it) { + debugMsg("Profile:removeTransaction", "Discarding " << it->second->toString()); + it->second->discard(); + } + + m_variableListeners.erase(t); + handleTransactionVariableDeletion(t); + + for(std::vector::const_iterator it = emptyInstants.begin(); it != emptyInstants.end(); ++it) { + std::map::iterator instIt = m_instants.find(*it); + //this can't be an error because the discard above constitues a relaxation of the variable, which will get handled in-situ + //and may remove instants in the emptyInstants vector. + //checkError(instIt != m_instants.end(), "Computed empty instant at " << *it << " but there is no such instant in the profile."); + if(instIt == m_instants.end()) + continue; + InstantId inst = instIt->second; + debugMsg("Profile:removeTransaction", "Removing instant at time " << inst->getTime()); + condDebugMsg(inst->getTransactions().empty(), "Profile:removeTransaction", "because it has no transactions."); + condDebugMsg(!containsChange(inst), "Profile:removeTransaction", "because it does not mark a change."); + m_instants.erase(*it); + m_detector->notifyDeleted(inst); + inst->discard();; + } + m_changeCount++; + m_needsRecompute = true; + handleTransactionRemoved(t); +} - debugMsg("Profile:removeTransaction", "Removing transaction " << t << " for time " << t->time()->toString() << " with quantity " << t->quantity()->toString()); +void Profile::handleTransactionRemoved(const TransactionId) { + //by default, create an iterator over all time + if(m_recomputeInterval.isValid()) { + debugMsg("Profile:handleTransactionRemoved", "Deleting profile iterator " << m_recomputeInterval->getId() ); + delete static_cast(m_recomputeInterval); + } + m_recomputeInterval = (new ProfileIterator(getId()))->getId(); +} - eint startTime = (eint) t->time()->lastDomain().getLowerBound(); - eint endTime = (eint) t->time()->lastDomain().getUpperBound(); - ProfileIterator profIt(m_id, startTime, endTime); +void Profile::transactionTimeChanged(const TransactionId e, + const DomainListener::ChangeType& change) { + checkError(e.isValid(), "Invalid transaction."); + checkError(m_transactions.find(e) != m_transactions.end(), "Unknown transaction " << e->time()->toString() << " " << e->quantity()->toString()); + + eint startTime = static_cast(e->time()->lastDomain().getLowerBound()); + eint endTime = static_cast(e->time()->lastDomain().getUpperBound()); + switch(change) { + case DomainListener::UPPER_BOUND_DECREASED: + case DomainListener::LOWER_BOUND_INCREASED: + case DomainListener::BOUNDS_RESTRICTED: + case DomainListener::RESTRICT_TO_SINGLETON: + case DomainListener::SET_TO_SINGLETON: { + debugMsg("Profile:handleTimeChanged", "Handling restriction of transaction " << e << " at time " << e->time()->toString() << " with quantity " << e->quantity()->toString()); + eint first, last; + std::map::iterator it; + for(it = m_instants.begin(); it != m_instants.end(); ++it) + if(it->second->getTransactions().find(e) != it->second->getTransactions().end()) + break; + checkError(it != m_instants.end(), "No instant containing this transaction."); + first = it->second->getTime(); + it = m_instants.upper_bound(first); + if(it != m_instants.end()) + for(; it != m_instants.end(); ++it) + if(it->second->getTransactions().find(e) == it->second->getTransactions().end()) + break; + --it; + last = it->second->getTime(); + debugMsg("Profile:handleTimeChanged", "Possibly removing transaction " << e << " from Instants in range [" << first << " " << last << "]"); + ProfileIterator profIt(m_id, first, last); std::vector emptyInstants; - //remove the transaction from its instants while(!profIt.done()) { - debugMsg("Profile:removeTransaction", "Removing transaction " << t << " from instant for time " << profIt.getInstant()->getTime()); - profIt.getInstant()->removeTransaction(t); - //if the instant contains no transactions or doesn't represent the start or end of a transaction, it is empty and should be deleted. - if(profIt.getInstant()->getTransactions().empty() || !containsChange(profIt.getInstant())) { - debugMsg("Profile:removeTransaction", "Instant for time " << profIt.getInstant()->getTime() << " is empty."); - emptyInstants.push_back(profIt.getInstant()->getTime()); + InstantId inst = profIt.getInstant(); + if(!e->time()->lastDomain().isMember(inst->getTime())) { + debugMsg("Profile:handleTimeChanged", "Removing transaction " << e << " from Instant at time " << inst->getTime()); + inst->removeTransaction(e); + if(inst->getTransactions().empty() || !containsChange(inst)) + emptyInstants.push_back(inst->getTime()); } + else + inst->updateTransaction(e); profIt.next(); } - //remove any constraints on the transaction from the profile. - std::vector > removals; - for(ConstraintSet::const_iterator it = m_temporalConstraints.begin(); it != m_temporalConstraints.end(); ++it) { - if((*it)->isVariableOf(t->time())) { - removals.push_back(std::make_pair(*it, - (int) std::distance((*it)->getScope().begin(), - std::find((*it)->getScope().begin(), (*it)->getScope().end(), - t->time())))); - } - } - for(std::vector >::const_iterator it = removals.begin(); it != removals.end(); ++it) - handleConstraintMessage(it->first, t->time(), it->second, false); - - m_transactions.erase(t); - m_transactionsByTime.erase(t->time()); - - //remove the listeners - checkError(m_variableListeners.find(t) != m_variableListeners.end(), - "Bizarre. No listeners for transaction."); - for(std::multimap::iterator it = m_variableListeners.find(t); - it != m_variableListeners.end() && it->first == t; ++it) { - debugMsg("Profile:removeTransaction", "Discarding " << it->second->toString()); - it->second->discard(); - } - - m_variableListeners.erase(t); - handleTransactionVariableDeletion(t); + //add instants for start and end and add overlapping transactions to them + addInstantsForBounds(e); - for(std::vector::const_iterator it = emptyInstants.begin(); it != emptyInstants.end(); ++it) { - std::map::iterator instIt = m_instants.find(*it); - //this can't be an error because the discard above constitues a relaxation of the variable, which will get handled in-situ - //and may remove instants in the emptyInstants vector. - //checkError(instIt != m_instants.end(), "Computed empty instant at " << *it << " but there is no such instant in the profile."); - if(instIt == m_instants.end()) - continue; + for(std::vector::iterator emptyIt = emptyInstants.begin(); + emptyIt != emptyInstants.end(); ++emptyIt) { + std::map::iterator instIt = m_instants.find(*emptyIt); + checkError(instIt != m_instants.end(), + "Computed empty instant at time " << *emptyIt << " but no such instant exists."); InstantId inst = instIt->second; - debugMsg("Profile:removeTransaction", "Removing instant at time " << inst->getTime()); - condDebugMsg(inst->getTransactions().empty(), "Profile:removeTransaction", "because it has no transactions."); - condDebugMsg(!containsChange(inst), "Profile:removeTransaction", "because it does not mark a change."); - m_instants.erase(*it); + debugMsg("Profile:handleTimeChanged", "Removing instant at time " << inst->getTime()); + condDebugMsg(inst->getTransactions().empty(), + "Profile:handleTimeChanged", "because it has no transactions."); + condDebugMsg(!containsChange(inst), + "Profile:handleTimeChanged", "because it does not mark a change."); + m_instants.erase(*emptyIt); m_detector->notifyDeleted(inst); - inst->discard();; + delete static_cast(inst); } - m_changeCount++; - m_needsRecompute = true; - handleTransactionRemoved(t); } - - void Profile::handleTransactionRemoved(const TransactionId e) { - //by default, create an iterator over all time - if(m_recomputeInterval.isValid()) - { - debugMsg("Profile:handleTransactionRemoved", "Deleting profile iterator " << m_recomputeInterval->getId() ); - delete (ProfileIterator*) m_recomputeInterval; - } - m_recomputeInterval = (new ProfileIterator(getId()))->getId(); - } - - void Profile::transactionTimeChanged(const TransactionId e, const DomainListener::ChangeType& change) { - checkError(e.isValid(), "Invalid transaction."); - checkError(m_transactions.find(e) != m_transactions.end(), "Unknown transaction " << e->time()->toString() << " " << e->quantity()->toString()); - - eint startTime = (eint) e->time()->lastDomain().getLowerBound(); - eint endTime = (eint) e->time()->lastDomain().getUpperBound(); - switch(change) { - case DomainListener::UPPER_BOUND_DECREASED: - case DomainListener::LOWER_BOUND_INCREASED: - case DomainListener::BOUNDS_RESTRICTED: - case DomainListener::RESTRICT_TO_SINGLETON: - case DomainListener::SET_TO_SINGLETON: { - debugMsg("Profile:handleTimeChanged", "Handling restriction of transaction " << e << " at time " << e->time()->toString() << " with quantity " << e->quantity()->toString()); - eint first, last; - std::map::iterator it; - for(it = m_instants.begin(); it != m_instants.end(); ++it) - if(it->second->getTransactions().find(e) != it->second->getTransactions().end()) - break; - checkError(it != m_instants.end(), "No instant containing this transaction."); - first = it->second->getTime(); - it = m_instants.upper_bound(first); - if(it != m_instants.end()) - for(; it != m_instants.end(); ++it) - if(it->second->getTransactions().find(e) == it->second->getTransactions().end()) - break; - --it; - last = it->second->getTime(); - debugMsg("Profile:handleTimeChanged", "Possibly removing transaction " << e << " from Instants in range [" << first << " " << last << "]"); - ProfileIterator profIt(m_id, first, last); - std::vector emptyInstants; - while(!profIt.done()) { - InstantId inst = profIt.getInstant(); - if(!e->time()->lastDomain().isMember(inst->getTime())) { - debugMsg("Profile:handleTimeChanged", "Removing transaction " << e << " from Instant at time " << inst->getTime()); - inst->removeTransaction(e); - if(inst->getTransactions().empty() || !containsChange(inst)) - emptyInstants.push_back(inst->getTime()); - } - else - inst->updateTransaction(e); - profIt.next(); - } - - //add instants for start and end and add overlapping transactions to them - addInstantsForBounds(e); - - for(std::vector::iterator it = emptyInstants.begin(); it != emptyInstants.end(); ++it) { - std::map::iterator instIt = m_instants.find(*it); - checkError(instIt != m_instants.end(), "Computed empty instant at time " << *it << " but no such instant exists."); - InstantId inst = instIt->second; - debugMsg("Profile:handleTimeChanged", "Removing instant at time " << inst->getTime()); - condDebugMsg(inst->getTransactions().empty(), "Profile:handleTimeChanged", "because it has no transactions."); - condDebugMsg(!containsChange(inst), "Profile:handleTimeChanged", "because it does not mark a change."); - m_instants.erase(*it); - m_detector->notifyDeleted(inst); - delete (Instant*) inst; - } + break; + case DomainListener::RESET: + case DomainListener::RELAXED: { + debugMsg("Profile:handleTimeChanged", + "Handling relaxation of transaction " << e << " at time " << + e->time()->toString() << " with quantity " << e->quantity()->toString()); + ProfileIterator it(m_id, startTime, endTime); + addInstantsForBounds(e); + std::vector emptyInstants; + while(!it.done()) { + InstantId inst = it.getInstant(); + if(!containsChange(inst)) + emptyInstants.push_back(inst->getTime()); + else if(inst->getTransactions().find(e) == inst->getTransactions().end()) + inst->addTransaction(e); + else + inst->updateTransaction(e); + it.next(); } - break; - case DomainListener::RESET: - case DomainListener::RELAXED: { - debugMsg("Profile:handleTimeChanged", "Handling relaxation of transaction " << e << " at time " << e->time()->toString() << " with quantity " << e->quantity()->toString()); - ProfileIterator it(m_id, startTime, endTime); - addInstantsForBounds(e); - std::vector emptyInstants; - while(!it.done()) { - InstantId inst = it.getInstant(); - if(!containsChange(inst)) - emptyInstants.push_back(inst->getTime()); - else if(inst->getTransactions().find(e) == inst->getTransactions().end()) - inst->addTransaction(e); - else - inst->updateTransaction(e); - it.next(); - } - for(std::vector::iterator it = emptyInstants.begin(); it != emptyInstants.end(); ++it) { - std::map::iterator instIt = m_instants.find(*it); - checkError(instIt != m_instants.end(), "Computed empty instant at time " << *it << " but no such instant exists."); - InstantId inst = instIt->second; - debugMsg("Profile:handleTimeChanged", "Removing instant at time " << inst->getTime()); - condDebugMsg(inst->getTransactions().empty(), "Profile:handleTimeChanged", "because it has no transactions."); - condDebugMsg(!containsChange(inst), "Profile:handleTimeChanged", "because it does not mark a change."); - m_instants.erase(*it); - m_detector->notifyDeleted(inst); - delete (Instant*) inst; - } + for(std::vector::iterator emptyIt = emptyInstants.begin(); + emptyIt != emptyInstants.end(); ++emptyIt) { + std::map::iterator instIt = m_instants.find(*emptyIt); + checkError(instIt != m_instants.end(), + "Computed empty instant at time " << *emptyIt << " but no such instant exists."); + InstantId inst = instIt->second; + debugMsg("Profile:handleTimeChanged", "Removing instant at time " << inst->getTime()); + condDebugMsg(inst->getTransactions().empty(), "Profile:handleTimeChanged", "because it has no transactions."); + condDebugMsg(!containsChange(inst), "Profile:handleTimeChanged", "because it does not mark a change."); + m_instants.erase(*emptyIt); + m_detector->notifyDeleted(inst); + delete static_cast(inst); } - break; - default: - break; - }; - m_changeCount++; - m_needsRecompute = true; - handleTransactionTimeChanged(e, change); } + break; + case DomainListener::REFTIME_CHANGED: + case DomainListener::VALUE_REMOVED: + case DomainListener::CLOSED: + case DomainListener::OPENED: + case DomainListener::EMPTIED: + default: + break; + }; + m_changeCount++; + m_needsRecompute = true; + handleTransactionTimeChanged(e, change); +} - void Profile::handleTransactionTimeChanged(const TransactionId e, const DomainListener::ChangeType& change) { + void Profile::handleTransactionTimeChanged(const TransactionId, + const DomainListener::ChangeType&) { //by default, create an iterator over all time if(m_recomputeInterval.isValid()) { debugMsg("Profile:handleTimeChanged", "Deleting profile iterator " << m_recomputeInterval->getId() ); - delete (ProfileIterator*) m_recomputeInterval; + delete static_cast(m_recomputeInterval); } m_recomputeInterval = (new ProfileIterator(getId()))->getId(); } @@ -284,11 +324,12 @@ namespace EUROPA { handleTransactionQuantityChanged(e, change); } - void Profile::handleTransactionQuantityChanged(const TransactionId e, const DomainListener::ChangeType& change) { + void Profile::handleTransactionQuantityChanged(const TransactionId, + const DomainListener::ChangeType&) { //by default, create an iterator over all time if(m_recomputeInterval.isValid()) { debugMsg("Profile:transactionQuantityChanged", "Deleting profile iterator " << m_recomputeInterval->getId() ); - delete (ProfileIterator*) m_recomputeInterval; + delete static_cast(m_recomputeInterval); } m_recomputeInterval = (new ProfileIterator(getId()))->getId(); } @@ -311,115 +352,127 @@ namespace EUROPA { return true; } - void Profile::handleConstraintMessage(const ConstraintId c, const ConstrainedVariableId var, int argIndex, bool addition) { - check_error(c->getScope().size() == 2 || c->getScope().size() == 3); - //do nothing if this variable is the distance argument in a temporalDistance constraint - if(c->getScope().size() == 3 && argIndex == 1) - return; - checkError((c->getScope().size() == 2 && (argIndex == 0 || argIndex == 1)) || - (c->getScope().size() == 3 && (argIndex == 0 || argIndex == 2)), "Invalid argument index: " << argIndex); - checkError(checkMessageConsistency(), "m_constraintsForNotification is inconsistent."); - - debugMsg("Profile:handleConstraintMessage", - "Received a " << (addition ? "addition" : "removal") << " message on " << std::endl << c->toLongString()); - //hoisted this common code out of the ifs. could be put back in for efficiency's sake. - int otherIndex = -1; - if(c->getScope().size() == 2) { - if(argIndex == 0) - otherIndex = 1; - else - otherIndex = 0; - } - else if(c->getScope().size() == 3) { - if(argIndex == 0) - otherIndex = 2; - else - otherIndex = 0; - } +void Profile::handleConstraintMessage(const ConstraintId c, + const ConstrainedVariableId, + unsigned int argIndex, bool addition) { + check_error(c->getScope().size() == 2 || c->getScope().size() == 3); + //do nothing if this variable is the distance argument in a temporalDistance constraint + if(c->getScope().size() == 3 && argIndex == 1) + return; + checkError((c->getScope().size() == 2 && (argIndex == 0 || argIndex == 1)) || + (c->getScope().size() == 3 && (argIndex == 0 || argIndex == 2)), "Invalid argument index: " << argIndex); + checkError(checkMessageConsistency(), "m_constraintsForNotification is inconsistent."); + + debugMsg("Profile:handleConstraintMessage", + "Received a " << (addition ? "addition" : "removal") << " message on " << std::endl << c->toLongString()); + //hoisted this common code out of the ifs. could be put back in for efficiency's sake. + unsigned int otherIndex = 0; + if(c->getScope().size() == 2) { + if(argIndex == 0) + otherIndex = 1; + else + otherIndex = 0; + } + else if(c->getScope().size() == 3) { + if(argIndex == 0) + otherIndex = 2; + else + otherIndex = 0; + } - std::map::iterator transIt = m_transactionsByTime.find(c->getScope()[otherIndex]); - if(transIt == m_transactionsByTime.end()) { - debugMsg("Profile:handleConstraintMessage", - "Variable at index " << otherIndex << " doesn't have a transaction in the profile."); - return; - } - TransactionId trans1 = transIt->second; - - transIt = m_transactionsByTime.find(c->getScope()[argIndex]); - if(transIt == m_transactionsByTime.end()) { - debugMsg("Profile:handleConstraintMessage", - "Variable at index " << argIndex << " doesn't have a transaction in the profile."); - return; - } - TransactionId trans2 = transIt->second; - - - if(addition) { - if(m_temporalConstraints.find(c) != m_temporalConstraints.end()) { - debugMsg("Profile:handleConstraintMessage", - "Already added constraint " << std::endl << c->toLongString()); - return; - } - m_temporalConstraints.insert(c); - m_changeCount++; - m_needsRecompute = true; - if(otherIndex < argIndex) - handleTemporalConstraintAdded(trans1, otherIndex, trans2, argIndex); - else - handleTemporalConstraintAdded(trans2, argIndex, trans1, otherIndex); - } - else { - if(m_temporalConstraints.find(c) == m_temporalConstraints.end()) { - debugMsg("Profile:handleConstraintMessage", - "Already removed constraint " << std::endl << c->toLongString()); - return; - } - if(m_temporalConstraints.erase(c) > 0) { - m_changeCount++; - m_needsRecompute = true; - if(otherIndex < argIndex) - handleTemporalConstraintRemoved(trans1, otherIndex, trans2, argIndex); - else - handleTemporalConstraintRemoved(trans2, argIndex, trans1, otherIndex); - } - } - - if(m_needsRecompute) - ((ProfilePropagator*)m_planDatabase->getConstraintEngine()->getPropagatorByName(VariableListener::PROPAGATOR_NAME()))->setUpdateRequired(true); + std::map::iterator transIt = m_transactionsByTime.find(c->getScope()[otherIndex]); + if(transIt == m_transactionsByTime.end()) { + debugMsg("Profile:handleConstraintMessage", + "Variable at index " << otherIndex << " doesn't have a transaction in the profile."); + return; + } + TransactionId trans1 = transIt->second; + + transIt = m_transactionsByTime.find(c->getScope()[argIndex]); + if(transIt == m_transactionsByTime.end()) { + debugMsg("Profile:handleConstraintMessage", + "Variable at index " << argIndex << " doesn't have a transaction in the profile."); + return; + } + TransactionId trans2 = transIt->second; + + + if(addition) { + if(m_temporalConstraints.find(c) != m_temporalConstraints.end()) { + debugMsg("Profile:handleConstraintMessage", + "Already added constraint " << std::endl << c->toLongString()); + return; + } + m_temporalConstraints.insert(c); + m_changeCount++; + m_needsRecompute = true; + if(otherIndex < argIndex) + handleTemporalConstraintAdded(trans1, otherIndex, trans2, argIndex); + else + handleTemporalConstraintAdded(trans2, argIndex, trans1, otherIndex); + } + else { + if(m_temporalConstraints.find(c) == m_temporalConstraints.end()) { + debugMsg("Profile:handleConstraintMessage", + "Already removed constraint " << std::endl << c->toLongString()); + return; + } + if(m_temporalConstraints.erase(c) > 0) { + m_changeCount++; + m_needsRecompute = true; + if(otherIndex < argIndex) + handleTemporalConstraintRemoved(trans1, otherIndex, trans2, argIndex); + else + handleTemporalConstraintRemoved(trans2, argIndex, trans1, otherIndex); } + } - void Profile::temporalConstraintAdded(const ConstraintId c, const ConstrainedVariableId var, int argIndex) { - handleConstraintMessage(c, var, argIndex, true); - } + if(m_needsRecompute) + id_cast(m_planDatabase->getConstraintEngine()-> + getPropagatorByName(VariableListener::PROPAGATOR_NAME()))-> + setUpdateRequired(true); +} - void Profile::handleTemporalConstraintAdded(const TransactionId predecessor, const int preArgIndex, - const TransactionId successor, const int sucArgIndex){ - if(m_recomputeInterval.isValid()) - delete (ProfileIterator*) m_recomputeInterval; - m_recomputeInterval = (new ProfileIterator(getId()))->getId(); - } +void Profile::temporalConstraintAdded(const ConstraintId c, + const ConstrainedVariableId var, + unsigned int argIndex) { + handleConstraintMessage(c, var, argIndex, true); +} - void Profile::temporalConstraintRemoved(const ConstraintId c, const ConstrainedVariableId var, int argIndex) { - handleConstraintMessage(c, var, argIndex, false); - } +void Profile::handleTemporalConstraintAdded(const TransactionId, const unsigned int, + const TransactionId, const unsigned int) { + if(m_recomputeInterval.isValid()) + delete static_cast(m_recomputeInterval); + m_recomputeInterval = (new ProfileIterator(getId()))->getId(); +} - void Profile::handleTemporalConstraintRemoved(const TransactionId predecessor, const int preArgIndex, - const TransactionId successor, const int sucArgIndex){ - if(m_recomputeInterval.isValid()) - delete (ProfileIterator*) m_recomputeInterval; - m_recomputeInterval = (new ProfileIterator(getId()))->getId(); - } +void Profile::temporalConstraintRemoved(const ConstraintId c, + const ConstrainedVariableId var, + unsigned int argIndex) { + handleConstraintMessage(c, var, argIndex, false); +} + +void Profile::handleTemporalConstraintRemoved(const TransactionId, const unsigned int, + const TransactionId, const unsigned int) { + if(m_recomputeInterval.isValid()) + delete static_cast(m_recomputeInterval); + m_recomputeInterval = (new ProfileIterator(getId()))->getId(); +} /** * @brief Remove */ - void Profile::handleTransactionVariableDeletion(const TransactionId& t){ - std::map::iterator listIt = m_otherListeners.find(t); - checkError(listIt != m_otherListeners.end(), - "Attempted to remove variable listener for transaction at time " << t->time()->toString() << " with quantity " << t->quantity()->toString() << "."); - delete (ConstraintAdditionListener*) listIt->second; - m_otherListeners.erase(t); - } + +void Profile::handleTransactionVariableDeletion(const TransactionId t){ + std::map::iterator listIt = + m_otherListeners.find(t); + checkError(listIt != m_otherListeners.end(), + "Attempted to remove variable listener for transaction at time " << + t->time()->toString() << " with quantity " << + t->quantity()->toString() << "."); + delete id_cast(listIt->second); + m_otherListeners.erase(t); +} void Profile::getLevel(const eint time, IntervalDomain& dest) { if(needsRecompute()) @@ -481,129 +534,135 @@ namespace EUROPA { handleRecompute(); } - void Profile::handleRecompute() - { - checkError(m_recomputeInterval.isValid(), - "Attempted to recompute levels over an invalid interval."); - condDebugMsg(m_recomputeInterval->done(), "Profile:recompute", "No instants over which to recompute."); - debugMsg("Profile:handleRecompute","Invoked"); - debugMsg("Profile:recompute:prePrint", std::endl << toString()); - - eint endTime = MINUS_INFINITY; - std::pair endDiff(0.0,0.0); - - if(!m_recomputeInterval->done()) { - InstantId prev = InstantId::noId(); - bool violation = false; - endTime = m_recomputeInterval->getEndTime(); - - //if there is no preceding instant, do a clean init - if(m_recomputeInterval->getInstant()->getTime() == m_instants.begin()->first) { - initRecompute(); - m_detector->initialize(); - } - else { - InstantId inst = m_recomputeInterval->getInstant(); - - if (inst->getTime() == endTime) { - endDiff.first = inst->getLowerLevel(); - endDiff.second = inst->getUpperLevel(); - } - - initRecompute(inst); - m_detector->initialize(inst); - - if (inst->getTime() == endTime) { - endDiff.first = inst->getLowerLevel() - endDiff.first; - endDiff.second = inst->getUpperLevel() - endDiff.second; - } - - // initRecompute(inst) above also recomputes the levels for the inst, so move forward: - violation = m_detector->detect(inst); - - prev = inst; - m_recomputeInterval->next(); - } - - while(!m_recomputeInterval->done() - && - !violation ) { - InstantId inst = m_recomputeInterval->getInstant(); - - if (inst->getTime() == endTime) { - endDiff.first = inst->getLowerLevel(); - endDiff.second = inst->getUpperLevel(); - } - - debugMsg("Profile:recompute", "Recomputing levels at instant " << inst->getTime()); - check_error(inst.isValid()); - recomputeLevels( prev, inst); - - if (inst->getTime() == endTime) { - endDiff.first = inst->getLowerLevel() - endDiff.first; - endDiff.second = inst->getUpperLevel() - endDiff.second; - } - - violation = m_detector->detect(inst); - - prev = inst; - m_recomputeInterval->next(); - } - } +void Profile::handleRecompute() { + checkError(m_recomputeInterval.isValid(), + "Attempted to recompute levels over an invalid interval."); + condDebugMsg(m_recomputeInterval->done(), "Profile:recompute", "No instants over which to recompute."); + debugMsg("Profile:handleRecompute","Invoked"); + debugMsg("Profile:recompute:prePrint", std::endl << toString()); + + eint endTime = MINUS_INFINITY; + std::pair endDiff(0.0,0.0); - debugMsg("Profile:recompute:postPrint", std::endl << toString()); - debugMsg("Profile:handleRecompute", "Deleting profile iterator " << m_recomputeInterval->getId() ); - delete (ProfileIterator*) m_recomputeInterval; - m_recomputeInterval = ProfileIteratorId::noId(); - m_needsRecompute = false; + if(!m_recomputeInterval->done()) { + InstantId prev = InstantId::noId(); + bool violation = false; + endTime = m_recomputeInterval->getEndTime(); - postHandleRecompute(endTime,endDiff); + //if there is no preceding instant, do a clean init + if(m_recomputeInterval->getInstant()->getTime() == m_instants.begin()->first) { + initRecompute(); + m_detector->initialize(); } + else { + InstantId inst = m_recomputeInterval->getInstant(); - void Profile::postHandleRecompute(const eint& endTime, const std::pair& endDiff) - { - debugMsg("Profile:postHandleRecompute", endTime << " [" << endDiff.first << "," << endDiff.second << "]"); - - if ((endDiff.first==0) && (endDiff.second==0)) - return; - - // Apply endDiff to (endTime,PLUS_INFINITY) - bool violation = false; - std::map::iterator it = m_instants.upper_bound(endTime); - for (;(it != m_instants.end()) && !violation;++it) { - InstantId inst = it->second; - inst->applyBoundsDelta(endDiff.first,endDiff.second); - violation = m_detector->detect(inst); - } + if (inst->getTime() == endTime) { + endDiff.first = inst->getLowerLevel(); + endDiff.second = inst->getUpperLevel(); + } + + initRecompute(inst); + m_detector->initialize(inst); + + if (inst->getTime() == endTime) { + endDiff.first = inst->getLowerLevel() - endDiff.first; + endDiff.second = inst->getUpperLevel() - endDiff.second; + } + + std::map::iterator it = getGreatestInstant(inst->getTime() - 1); + if(it != m_instants.end()) { + prev = it->second; + } + + // initRecompute(inst) above also recomputes the levels for the inst, so move forward: + // violation = m_detector->detect(inst); + + + // prev = inst; + // m_recomputeInterval->next(); } - void Profile::addInstantsForBounds(const TransactionId t) { - eint first = (eint) t->time()->lastDomain().getLowerBound(); - eint last = (eint) t->time()->lastDomain().getUpperBound(); + while(!m_recomputeInterval->done() + && + !violation ) { + InstantId inst = m_recomputeInterval->getInstant(); - { - std::map::iterator ite = m_instants.find( first ); + if (inst->getTime() == endTime) { + endDiff.first = inst->getLowerLevel(); + endDiff.second = inst->getUpperLevel(); + } - if( ite == m_instants.end() ) { - addInstant(first); - } - else { - InstantId& inst = (*ite).second; - inst->updateTransaction( t ); - } - } + debugMsg("Profile:recompute", "Recomputing levels at instant " << inst->getTime()); + check_error(inst.isValid()); + recomputeLevels( prev, inst); - { - std::map::iterator ite = m_instants.find( last ); - if( ite == m_instants.end() ) { - addInstant(last); - } - else { - InstantId& inst = (*ite).second; - inst->updateTransaction( t ); - } - } + if (inst->getTime() == endTime) { + endDiff.first = inst->getLowerLevel() - endDiff.first; + endDiff.second = inst->getUpperLevel() - endDiff.second; + } + + violation = m_detector->detect(inst); + + prev = inst; + m_recomputeInterval->next(); + } + } + + debugMsg("Profile:recompute:postPrint", std::endl << toString()); + debugMsg("Profile:handleRecompute", "Deleting profile iterator " << m_recomputeInterval->getId() ); + delete static_cast(m_recomputeInterval); + m_recomputeInterval = ProfileIteratorId::noId(); + m_needsRecompute = false; + + postHandleRecompute(endTime,endDiff); +} + +void Profile::postHandleRecompute(const eint& endTime, + const std::pair& endDiff) { + debugMsg("Profile:postHandleRecompute", + endTime << " [" << endDiff.first << "," << endDiff.second << "]"); + + if ((endDiff.first==0) && (endDiff.second==0)) + return; + + // Apply endDiff to (endTime,PLUS_INFINITY) + bool violation = false; + std::map::iterator it = m_instants.upper_bound(endTime); + for (;(it != m_instants.end()) && !violation;++it) { + InstantId inst = it->second; + inst->applyBoundsDelta(endDiff.first,endDiff.second); + violation = m_detector->detect(inst); + } +} + +void Profile::addInstantsForBounds(const TransactionId t) { + eint first = static_cast(t->time()->lastDomain().getLowerBound()); + eint last = static_cast(t->time()->lastDomain().getUpperBound()); + + { + std::map::iterator ite = m_instants.find( first ); + + if( ite == m_instants.end() ) { + addInstant(first); + } + else { + InstantId inst = (*ite).second; + inst->updateTransaction( t ); } + } + + { + std::map::iterator ite = m_instants.find( last ); + if( ite == m_instants.end() ) { + addInstant(last); + } + else { + InstantId inst = (*ite).second; + inst->updateTransaction( t ); + } + } +} void Profile::addInstant(const eint time) { checkError(m_instants.find(time) == m_instants.end(), "Attempted to add a redundant instant for time " << time); @@ -622,27 +681,27 @@ namespace EUROPA { } } - void Profile::removeInstant(const eint time) { - std::map::iterator pit = m_instants.find(time); - check_error(pit != m_instants.end()); - if (!containsChange(pit->second)) { - InstantId inst = pit->second; - debugMsg("Profile:removeInstant", - "Removing instant at time " << inst->getTime() - << " because it does not mark a change."); - m_instants.erase(pit); - m_detector->notifyDeleted(inst); - delete (Instant*) inst; - } - } +void Profile::removeInstant(const eint time) { + std::map::iterator pit = m_instants.find(time); + check_error(pit != m_instants.end()); + if (!containsChange(pit->second)) { + InstantId inst = pit->second; + debugMsg("Profile:removeInstant", + "Removing instant at time " << inst->getTime() + << " because it does not mark a change."); + m_instants.erase(pit); + m_detector->notifyDeleted(inst); + delete static_cast(inst); + } +} - void Profile::getTransactionsToOrder(const InstantId& inst, std::vector& results) { + void Profile::getTransactionsToOrder(const InstantId inst, std::vector& results) { check_error(inst.isValid()); check_error(results.empty()); results.insert(results.end(), inst->getTransactions().begin(), inst->getTransactions().end()); } - Profile::VariableListener::VariableListener(const ConstraintEngineId& constraintEngine, + Profile::VariableListener::VariableListener(const ConstraintEngineId constraintEngine, const ProfileId profile, const TransactionId trans, const std::vector& scope, const bool isQuantity) @@ -652,9 +711,9 @@ namespace EUROPA { debugMsg("Profile:VariableListener", "Created listener for profile " << m_profile << " and transaction " << m_trans << std::endl << toString()); } - bool Profile::VariableListener::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) { +bool Profile::VariableListener::canIgnore(const ConstrainedVariableId variable, + unsigned int, + const DomainListener::ChangeType& changeType) { check_error(variable.isValid(), toString()); check_error(m_profile.isValid(), toString()); check_error(m_trans.isValid(), toString()); @@ -669,7 +728,7 @@ namespace EUROPA { return false; } - Profile::ConstraintAdditionListener::ConstraintAdditionListener(const ConstrainedVariableId& var, TransactionId tid, ProfileId profile) + Profile::ConstraintAdditionListener::ConstraintAdditionListener(const ConstrainedVariableId var, TransactionId tid, ProfileId profile) : ConstrainedVariableListener(var), m_profile(profile), m_tid(tid) {} Profile::ConstraintAdditionListener::~ConstraintAdditionListener() { @@ -679,25 +738,27 @@ namespace EUROPA { m_profile->handleTransactionVariableDeletion(m_tid); } - void Profile::ConstraintAdditionListener::notifyConstraintAdded(const ConstraintId& constr, int argIndex) { - static const LabelStr temporal("Temporal"); - if(constr->getPropagator()->getName() == temporal) { - debugMsg("Profile:ConstraintAdditionListener", - getId() << " Notifying profile " << m_profile << " of addition of constraint " << constr->toString() << - " to variable " << m_var->toLongString() << " at index " << argIndex); - m_profile->temporalConstraintAdded(constr, m_var, argIndex); - } - } +void Profile::ConstraintAdditionListener::notifyConstraintAdded(const ConstraintId constr, + unsigned int argIndex) { + static const std::string temporal("Temporal"); + if(constr->getPropagator()->getName() == temporal) { + debugMsg("Profile:ConstraintAdditionListener", + getId() << " Notifying profile " << m_profile << " of addition of constraint " << constr->toString() << + " to variable " << m_var->toLongString() << " at index " << argIndex); + m_profile->temporalConstraintAdded(constr, m_var, argIndex); + } +} - void Profile::ConstraintAdditionListener::notifyConstraintRemoved(const ConstraintId& constr, int argIndex) { - static const LabelStr temporal("Temporal"); - if(constr->getPropagator()->getName() == temporal) { - debugMsg("Profile:ConstraintAdditionListener", - getId() << " Notifying profile " << m_profile << " of removal of constraint " << constr->toString() << - " from variable " << m_var->toLongString() << " at index " << argIndex); - m_profile->temporalConstraintRemoved(constr, m_var, argIndex); - } - } +void Profile::ConstraintAdditionListener::notifyConstraintRemoved(const ConstraintId constr, + unsigned int argIndex) { + static const std::string temporal("Temporal"); + if(constr->getPropagator()->getName() == temporal) { + debugMsg("Profile:ConstraintAdditionListener", + getId() << " Notifying profile " << m_profile << " of removal of constraint " << constr->toString() << + " from variable " << m_var->toLongString() << " at index " << argIndex); + m_profile->temporalConstraintRemoved(constr, m_var, argIndex); + } +} std::string Profile::toString() const { std::stringstream sstr; @@ -709,16 +770,17 @@ namespace EUROPA { edouble Profile::getInitCapacityLb() const { - return 0.0; + return 0.0; } edouble Profile::getInitCapacityUb() const { - return 0.0; + return 0.0; } ProfileIterator::ProfileIterator(const ProfileId prof, const eint startTime, const eint endTime) - : m_id(this), m_profile(prof), m_changeCount(prof->m_changeCount) { + : m_id(this), m_profile(prof), m_changeCount(prof->m_changeCount), + m_startTime(), m_endTime(), m_start(), m_end(), m_realEnd() { //if(m_profile->m_needsRecompute) //m_profile->handleRecompute(); debugMsg("ProfileIterator:ProfileIterator", "Creating iterator over interval [" << startTime << " " << endTime << "] with change count " << @@ -790,34 +852,33 @@ namespace EUROPA { return !done(); } - bool Profile::hasConstraint(const ConstraintId& constr) const { + bool Profile::hasConstraint(const ConstraintId constr) const { return m_temporalConstraints.find(constr) != m_temporalConstraints.end(); } - Profile::ConstraintRemovalListener::ConstraintRemovalListener(const ConstraintEngineId& ce, ProfileId profile) + Profile::ConstraintRemovalListener::ConstraintRemovalListener(const ConstraintEngineId ce, ProfileId profile) : ConstraintEngineListener(ce), m_profile(profile) {} - void Profile::ConstraintRemovalListener::notifyRemoved(const ConstraintId& constr) { - if(m_profile->hasConstraint(constr)) { - int index = 0; - for(std::vector::const_iterator it = constr->getScope().begin(); it != constr->getScope().end(); - ++it, ++index) - m_profile->handleConstraintMessage(constr, *it, index, false); - } - } +void Profile::ConstraintRemovalListener::notifyRemoved(const ConstraintId constr) { + if(m_profile->hasConstraint(constr)) { + unsigned int index = 0; + for(std::vector::const_iterator it = constr->getScope().begin(); + it != constr->getScope().end(); ++it, ++index) + m_profile->handleConstraintMessage(constr, *it, index, false); + } +} - ExplicitProfile::ExplicitProfile(edouble lb, edouble ub) - : m_id(this) - { - setValue(MINUS_INFINITY,lb,ub); - } +ExplicitProfile::ExplicitProfile(edouble lb, edouble ub) + : m_id(this), m_values() { + setValue(MINUS_INFINITY,lb,ub); +} ExplicitProfile::~ExplicitProfile() { m_id.remove(); } - ExplicitProfileId& ExplicitProfile::getId() + ExplicitProfileId ExplicitProfile::getId() { return m_id; } diff --git a/src/PLASMA/Resource/base/Profile.hh b/src/PLASMA/Resource/base/Profile.hh index 3a9bbf2ed..461105429 100644 --- a/src/PLASMA/Resource/base/Profile.hh +++ b/src/PLASMA/Resource/base/Profile.hh @@ -1,5 +1,5 @@ -#ifndef _H_Profile -#define _H_Profile +#ifndef H_Profile +#define H_Profile /** * @file Profile.hh @@ -11,12 +11,12 @@ #include "Domains.hh" #include "PlanDatabaseDefs.hh" +#include "ConstraintEngineListener.hh" #include "ConstraintEngineDefs.hh" #include "Constraint.hh" #include "CommonDefs.hh" #include "ResourceDefs.hh" #include "FVDetector.hh" -#include "LabelStr.hh" #include "Debug.hh" #include "Engine.hh" #include "Factory.hh" @@ -38,382 +38,386 @@ namespace EUROPA { * for causing subclasses to recalculate the profile. * When should we recalculate? */ - class Profile : public FactoryObj { - public: - - /** - * @brief Constructor. - * @param flawDetector The object responsible for detecting flaws and violations during level calculation. - */ - Profile(const PlanDatabaseId ce, const FVDetectorId flawDetector); - virtual ~Profile(); - ProfileId& getId() {return m_id;} - - /** - * @brief Adds a Transaction to the profile. Creates Instants for the lower and upper bounds of the timepoint if necessary, - * adds the Transaction to every Instant in the interval [timepoint.start timepoint.end], and marks the need for recalculation. - * This method also adds listeners to the quantity and timepoint in order to track changes in their values. - * @param e The Transaction. - */ - virtual void addTransaction(const TransactionId e); - - /** - * @brief Removes a Transaction from the profile. Removes the Transaction from all instants in the interval [timepoint.start timepoint.end], - * marks the need for recalculation, and removes the listeners on the quantity and timepoint. - * @brief e The Transaction. - */ - virtual void removeTransaction(const TransactionId e); - - /** - * @brief Get all the transactions in the profile. - */ - const std::set& getAllTransactions() const {return m_transactions;} - - /** - * @brief Gets the bounds of the profile at a given point in time. Calling this method may cause recalculation. - * @param time The time at which to get the level. - * @param dest The interval into which the computed levels are stored. - */ - virtual void getLevel(const eint time, IntervalDomain& dest); +class Profile : public FactoryObj { + public: + + /** + * @brief Constructor. + * @param flawDetector The object responsible for detecting flaws and violations during level calculation. + */ + Profile(const PlanDatabaseId ce, const FVDetectorId flawDetector); + virtual ~Profile(); + ProfileId getId() {return m_id;} + + /** + * @brief Adds a Transaction to the profile. Creates Instants for the lower and upper bounds of the timepoint if necessary, + * adds the Transaction to every Instant in the interval [timepoint.start timepoint.end], and marks the need for recalculation. + * This method also adds listeners to the quantity and timepoint in order to track changes in their values. + * @param e The Transaction. + */ + virtual void addTransaction(const TransactionId e); + + /** + * @brief Removes a Transaction from the profile. Removes the Transaction from all instants in the interval [timepoint.start timepoint.end], + * marks the need for recalculation, and removes the listeners on the quantity and timepoint. + * @param e The Transaction. + */ + virtual void removeTransaction(const TransactionId e); + + /** + * @brief Get all the transactions in the profile. + */ + const std::set& getAllTransactions() const {return m_transactions;} + + /** + * @brief Gets the bounds of the profile at a given point in time. Calling this method may cause recalculation. + * @param time The time at which to get the level. + * @param dest The interval into which the computed levels are stored. + */ + virtual void getLevel(const eint time, IntervalDomain& dest); - /** - * @brief Validates the data structures. Maybe this should be private. - */ - virtual bool isValid(); - - /** - * @brief Forces a recomputation of the profile. - */ - void recompute(); - - const PlanDatabaseId& getPlanDatabase() const {return m_planDatabase;} - - - virtual void getTransactionsToOrder(const InstantId& inst, std::vector& results); - - const ResourceId& getResource() const {return m_detector->getResource();} - - /** - * @brief Gets the Instant with the greatest time that is not greater than the given time. - * @return An iterator pointing to the instant. - */ - std::map::iterator getGreatestInstant(const eint time); - - /** - * @brief Gets the Instant with the least time not less than the given time. - * @return An iterator pointing to the instant. - */ - std::map::iterator getLeastInstant(const eint time); - - const std::map& getInstants() {return m_instants;} - - private: - friend class ProfilePropagator; - friend class ProfileIterator; - friend class Instant; - - /** - * @class VariableListener - * @brief Informs the profile of a change in either a quantity or time variable. - */ - class VariableListener : public Constraint { - public: - VariableListener(const ConstraintEngineId& constraintEngine, - const ProfileId profile, - const TransactionId trans, - const std::vector& scope, const bool isQuantity = false); - static const LabelStr& CONSTRAINT_NAME() { - static const LabelStr sl_const("ProfileVariableListener"); - return sl_const; - } - static const LabelStr& PROPAGATOR_NAME() { - static const LabelStr sl_const("Resource"); - return sl_const; - } - ProfileId getProfile() const {return m_profile;} - private: - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); - void handleExecute(){}; - ProfileId m_profile; - TransactionId m_trans; - bool m_isQuantity; - }; - - class ConstraintAdditionListener : public ConstrainedVariableListener { - public: - ConstraintAdditionListener(const ConstrainedVariableId& var, TransactionId tid, ProfileId profile); - ~ConstraintAdditionListener(); - void notifyDiscard(); - void notifyConstraintAdded(const ConstraintId& constr, int argIndex); - void notifyConstraintRemoved(const ConstraintId& constr, int argIndex); - private: - ProfileId m_profile; - TransactionId m_tid; - }; - - struct ConstraintMessage { - ConstrainedVariableId var; - int index; - bool addition; - ConstraintMessage(ConstrainedVariableId _var, int _index, bool _addition) - : var(_var), index(_index), addition(_addition) {} - }; - - /** - * @class ConstraintRemovalListener - * @brief Listens for removal messages on constraints. - * - * Because it's possible for the ConstraintAdditionListener to get removed before a constraint it's listening for, - * this class has been added to catch any final messages about removal. - */ - - class ConstraintRemovalListener : public ConstraintEngineListener { - public: - ConstraintRemovalListener(const ConstraintEngineId& ce, ProfileId profile); - void notifyRemoved(const ConstraintId& constr); - private: - ProfileId m_profile; - }; - - bool hasConstraint(const ConstraintId& constr) const; - - protected: - ProfileId m_id; - unsigned int m_changeCount; /* m_transactions; /* m_variableListeners; /* m_otherListeners; - std::map m_transactionsByTime; - ConstraintSet m_temporalConstraints; - ConstraintEngineListenerId m_removalListener; - std::map m_instants; /*& endDiff); - /** - * @brief Initialize a recomputation with level data from the given Instant. - */ - virtual void initRecompute(InstantId inst) = 0; - - /** - * @brief Initialize a recomputation with no level data. Used when there is no Instant preceeding the recomputation interval. - */ - virtual void initRecompute() = 0; - - /** - * @brief Recompute the levels for a particular Instant. - * @param inst The Instant to be recomputed. - */ - virtual void recomputeLevels( InstantId prev, InstantId inst ) = 0; - - /** - * @brief Helper method for subclasses to respond to a transaction being added. - * @param e The Transaction that was added - */ - virtual void handleTransactionAdded(const TransactionId e); - - /** - * @brief Helper method for subclasses to respond to a transaction being removed. - * @param e The Transaction that was removed - */ - virtual void handleTransactionRemoved(const TransactionId e); - - /** - * @brief Helper method for subclasses to respond to a transaction's timepoint changing. - * The base method handles the addition/removal of the transaction to/from instants. - * @param e The Transaction whose time variable changed. - * @param change The type of the change - */ - virtual void handleTransactionTimeChanged(const TransactionId e, const DomainListener::ChangeType& change); - - /** - * @brief Helper method for subclasses to respond to a transaction's quantity changing. - * @param e The Transaction whose quantity variable changed. - * @param change The type of the change - */ - virtual void handleTransactionQuantityChanged(const TransactionId e, const DomainListener::ChangeType& change); - - //NOTE: DON'T FORGET TO IMPLEMENT THE DEFAULT BEHAVIOR!!! - /** - * @brief Helper method for subclasses to respond to a temporal constraint being added between two transactions. - * @param e The transaction whose timepoint has been constrained. - * @param argIndex The index of the timepoint in the constraint. - */ - virtual void handleTemporalConstraintAdded(const TransactionId predecessor, const int preArgIndex, - const TransactionId successor, const int sucArgIndex); - - /** - * @brief Helper method for subclasses to respond to a temporal constraint being removed between two transactions. - * @param e The transaction whose timepoint has been removed from the constraint. - * @param argIndex The index of the timepoint in the constraint. - */ - virtual void handleTemporalConstraintRemoved(const TransactionId predecessor, const int preArgIndex, - const TransactionId successor, const int sucArgIndex); - - - /** - * @brief Helper method for subclasses to respond to a variable deletion (the listener on that variable may need destruction). - * @param t The transaction that has been removed. - */ - void handleTransactionVariableDeletion(const TransactionId& t); - - bool needsRecompute() const {return m_needsRecompute;} - - std::string toString() const; - - // PHM Some refactoring needed so that customized subclass can - // support reftimes. Does not change this class functionality. - /** - * @brief Determines whether an instant contains a "significant" - * transaction (i.e., at its upper/lower bound) that changes the - * profile at that instant. - * - * @param instant The instant - */ - virtual bool containsChange(const InstantId instant); - /** - * @brief Conditionally adds Instants for the upper and lower - * bounds of the Transaction's time. - * - * @param t The transaction - */ - virtual void addInstantsForBounds(const TransactionId t); - - /** - * @brief Create an instant for a time. - * @param time The time - */ - void addInstant(const eint time); - /** - * @brief Eliminate an instant for a time. - * @param time The time - */ - void removeInstant(const eint time); - - edouble getInitCapacityLb() const; - - edouble getInitCapacityUb() const; - - private: - /** - * @brief Handle an addition or removal message on a temporal constraint. - * Waits for two consecutive addition or removal messages in order to ensure that both variables in the scope of the - * constraint are resource-temporal variables. - * - * @param c The constraint. - * @param var The resource-related temporal variable the constraint is on. - * @param argIndex The index of the resource-related temporal variable in the scope of the constraint. - * @param addition True if the message is an addition, false otherwise. - */ - void handleConstraintMessage(const ConstraintId c, const ConstrainedVariableId var, int argIndex, bool addition); - - /** - * @brief Checks the m_constraintsForNotification map for internal consistency. - * @return true if the map is consistent. False otherwise. - */ - bool checkMessageConsistency(); - }; + /** + * @brief Validates the data structures. Maybe this should be private. + */ + virtual bool isValid(); - /** - * @class ProfileIterator - * @brief Used to iterate over a calculated profile. Each call to next() advances the iterator to the next point in time at which a - * level changes. Directly constructible only inside the Profile class. (Is this a good idea?) - */ - class ProfileIterator { - public: + /** + * @brief Forces a recomputation of the profile. + */ + void recompute(); + + const PlanDatabaseId getPlanDatabase() const {return m_planDatabase;} + + + virtual void getTransactionsToOrder(const InstantId inst, std::vector& results); + + const ResourceId getResource() const {return m_detector->getResource();} - /** - * @brief Constructor for an iterator over a profile. - * @param prof The profile to be iterated. - * @param startTime The time to begin iteration. The time of the first Instant is guaranteed to be the greatest time not greater than this value. - * @param endTime The time to end iteration. The time of the last Instant is guaranteed to be the greatest time not greater than this value. - */ - ProfileIterator(const ProfileId prof, const eint startTime = MINUS_INFINITY, const eint endTime = PLUS_INFINITY); + /** + * @brief Gets the Instant with the greatest time that is not greater than the given time. + * @return An iterator pointing to the instant. + */ + std::map::iterator getGreatestInstant(const eint time); + + /** + * @brief Gets the Instant with the least time not less than the given time. + * @return An iterator pointing to the instant. + */ + std::map::iterator getLeastInstant(const eint time); + + const std::map& getInstants() {return m_instants;} - ~ProfileIterator() {m_id.remove();} - - /** - * @brief Determine whether or not this ProfileIterator has iterated past its end time. - */ - bool done() const; - - /** - * @brief Gets the time of the current position of this ProfileIterator - * @return The time - */ - eint getTime() const; + InstantId getInstant(const eint time) const; + + private: + friend class ProfilePropagator; + friend class ProfileIterator; + friend class Instant; + + /** + * @class VariableListener + * @brief Informs the profile of a change in either a quantity or time variable. + */ + class VariableListener : public Constraint { + public: + VariableListener(const ConstraintEngineId constraintEngine, + const ProfileId profile, + const TransactionId trans, + const std::vector& scope, const bool isQuantity = false); + static const std::string& CONSTRAINT_NAME() { + static const std::string sl_const("ProfileVariableListener"); + return sl_const; + } + static const std::string& PROPAGATOR_NAME() { + static const std::string sl_const("Resource"); + return sl_const; + } + ProfileId getProfile() const {return m_profile;} + private: + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); + void handleExecute(){}; + ProfileId m_profile; + TransactionId m_trans; + bool m_isQuantity; + }; + + class ConstraintAdditionListener : public ConstrainedVariableListener { + public: + ConstraintAdditionListener(const ConstrainedVariableId var, TransactionId tid, ProfileId profile); + ~ConstraintAdditionListener(); + void notifyDiscard(); + void notifyConstraintAdded(const ConstraintId constr, unsigned int argIndex); + void notifyConstraintRemoved(const ConstraintId constr, unsigned int argIndex); + private: + ProfileId m_profile; + TransactionId m_tid; + }; + + struct ConstraintMessage { + ConstrainedVariableId var; + int index; + bool addition; + ConstraintMessage(ConstrainedVariableId _var, int _index, bool _addition) + : var(_var), index(_index), addition(_addition) {} + }; + + /** + * @class ConstraintRemovalListener + * @brief Listens for removal messages on constraints. + * + * Because it's possible for the ConstraintAdditionListener to get removed before a constraint it's listening for, + * this class has been added to catch any final messages about removal. + */ + + class ConstraintRemovalListener : public ConstraintEngineListener { + public: + ConstraintRemovalListener(const ConstraintEngineId ce, ProfileId profile); + void notifyRemoved(const ConstraintId constr); + private: + ProfileId m_profile; + }; + + bool hasConstraint(const ConstraintId constr) const; + + protected: + ProfileId m_id; + unsigned int m_changeCount; /**< The number of times that the profile has changed. Used to detect stale iterators.*/ + bool m_needsRecompute; /**< A flag indicating the necessity of profile recomputation*/ + unsigned int m_constraintKeyLb; /**< The lower bound on the constraint key when searching for new constraints. */ + PlanDatabaseId m_planDatabase; /**< The plan database. Used for creating the variable listeners. */ + FVDetectorId m_detector; /**< The flaw and violation detector. */ + std::set m_transactions; /**< The set of Transactions that impact this profile. */ + std::multimap m_variableListeners; /**< The listeners on the Transactions. */ + std::map m_otherListeners; + std::map m_transactionsByTime; + ConstraintSet m_temporalConstraints; + ConstraintEngineListenerId m_removalListener; + std::map m_instants; /**< A map from times to Instants. */ + ProfileIteratorId m_recomputeInterval; /**< The stored interval of recomputation.*/ + + bool hasTransactions() {return !m_transactions.empty();} + + void transactionTimeChanged(const TransactionId e, const DomainListener::ChangeType& change); + + void transactionQuantityChanged(const TransactionId e, const DomainListener::ChangeType& change); + + //these methods need to marshal the data between two calls + void temporalConstraintAdded(const ConstraintId c, const ConstrainedVariableId var, unsigned int argIndex); + + void temporalConstraintRemoved(const ConstraintId c, const ConstrainedVariableId var, unsigned int argIndex); + + /** + * @brief Recompute the profile. Iterates over a stored interval of time. + * It is expected that the first Instant in the interval actually precede the first change + * so that the flaw and violation detector can be initialized. + */ + void handleRecompute(); + /** + * @brief Hanlde invoked at the end of handleRecompute + */ + virtual void postHandleRecompute(const eint& endTime, const std::pair& endDiff); + /** + * @brief Initialize a recomputation with level data from the given Instant. + * This function is expected to re-compute the levels for the given instant! + */ + virtual void initRecompute(InstantId inst) = 0; + + /** + * @brief Initialize a recomputation with no level data. Used when there is no Instant preceeding the recomputation interval. + */ + virtual void initRecompute() = 0; + + /** + * @brief Recompute the levels for a particular Instant. + * @param inst The Instant to be recomputed. + */ + virtual void recomputeLevels( InstantId prev, InstantId inst ) = 0; + + /** + * @brief Helper method for subclasses to respond to a transaction being added. + * @param e The Transaction that was added + */ + virtual void handleTransactionAdded(const TransactionId e); + + /** + * @brief Helper method for subclasses to respond to a transaction being removed. + * @param e The Transaction that was removed + */ + virtual void handleTransactionRemoved(const TransactionId e); + + /** + * @brief Helper method for subclasses to respond to a transaction's timepoint changing. + * The base method handles the addition/removal of the transaction to/from instants. + * @param e The Transaction whose time variable changed. + * @param change The type of the change + */ + virtual void handleTransactionTimeChanged(const TransactionId e, const DomainListener::ChangeType& change); + + /** + * @brief Helper method for subclasses to respond to a transaction's quantity changing. + * @param e The Transaction whose quantity variable changed. + * @param change The type of the change + */ + virtual void handleTransactionQuantityChanged(const TransactionId e, const DomainListener::ChangeType& change); + + //NOTE: DON'T FORGET TO IMPLEMENT THE DEFAULT BEHAVIOR!!! + /** + * @brief Helper method for subclasses to respond to a temporal constraint being added between two transactions. + */ + virtual void handleTemporalConstraintAdded(const TransactionId predecessor, + const unsigned int preArgIndex, + const TransactionId successor, + const unsigned int sucArgIndex); + + /** + * @brief Helper method for subclasses to respond to a temporal constraint being removed between two transactions. + */ + virtual void handleTemporalConstraintRemoved(const TransactionId predecessor, + const unsigned int preArgIndex, + const TransactionId successor, + const unsigned int sucArgIndex); + + + /** + * @brief Helper method for subclasses to respond to a variable deletion (the listener on that variable may need destruction). + * @param t The transaction that has been removed. + */ + void handleTransactionVariableDeletion(const TransactionId t); + + bool needsRecompute() const {return m_needsRecompute;} + + std::string toString() const; + + // PHM Some refactoring needed so that customized subclass can + // support reftimes. Does not change this class functionality. + /** + * @brief Determines whether an instant contains a "significant" + * transaction (i.e., at its upper/lower bound) that changes the + * profile at that instant. + * + * @param instant The instant + */ + virtual bool containsChange(const InstantId instant); + /** + * @brief Conditionally adds Instants for the upper and lower + * bounds of the Transaction's time. + * + * @param t The transaction + */ + virtual void addInstantsForBounds(const TransactionId t); + + /** + * @brief Create an instant for a time. + * @param time The time + */ + void addInstant(const eint time); + /** + * @brief Eliminate an instant for a time. + * @param time The time + */ + void removeInstant(const eint time); + + edouble getInitCapacityLb() const; + + edouble getInitCapacityUb() const; + + private: + /** + * @brief Handle an addition or removal message on a temporal constraint. + * Waits for two consecutive addition or removal messages in order to ensure that both variables in the scope of the + * constraint are resource-temporal variables. + * + * @param c The constraint. + * @param var The resource-related temporal variable the constraint is on. + * @param argIndex The index of the resource-related temporal variable in the scope of the constraint. + * @param addition True if the message is an addition, false otherwise. + */ + void handleConstraintMessage(const ConstraintId c, const ConstrainedVariableId var, + unsigned int argIndex, bool addition); + + /** + * @brief Checks the m_constraintsForNotification map for internal consistency. + * @return true if the map is consistent. False otherwise. + */ + bool checkMessageConsistency(); +}; + +/** + * @class ProfileIterator + * @brief Used to iterate over a calculated profile. Each call to next() advances the iterator to the next point in time at which a + * level changes. Directly constructible only inside the Profile class. (Is this a good idea?) + */ +class ProfileIterator { + public: + + /** + * @brief Constructor for an iterator over a profile. + * @param prof The profile to be iterated. + * @param startTime The time to begin iteration. The time of the first Instant is guaranteed to be the greatest time not greater than this value. + * @param endTime The time to end iteration. The time of the last Instant is guaranteed to be the greatest time not greater than this value. + */ + ProfileIterator(const ProfileId prof, const eint startTime = MINUS_INFINITY, const eint endTime = PLUS_INFINITY); - /** - * @brief Gets the value of the lower bound of the profile at the current instant in time. - * @return The value of the profile. - */ - edouble getLowerBound() const; - - /** - * @brief Gets the value of the upper bound of the profile at the current instant in time. - * @return The value of the profile. - */ - edouble getUpperBound() const; - - /** - * @brief Gets the current instant. - * @return The instant. - */ - InstantId getInstant() const; - /** - * @brief Steps the ProfileIterator to the next instant in time. - * @return true if the ProfileIterator ends on a valid Instant, false otherwise. - */ - bool next(); - - ProfileIteratorId getId(){return m_id;} - - /** - * @brief Determines if the interval of the iterator is still in synch with the actual profile. - */ - bool isStale() const; - - eint getStartTime() const; - eint getEndTime() const; - - protected: - ProfileIteratorId m_id; - ProfileId m_profile; - unsigned int m_changeCount; /*::const_iterator m_start, m_end, m_realEnd; /*::const_iterator m_start, m_end, m_realEnd; /**< The start and end times over which this iterator goes*/ +}; class ProfileArgs : public FactoryArgs { public: - ProfileArgs(const PlanDatabaseId& db, const FVDetectorId& detector) + ProfileArgs(const PlanDatabaseId db, const FVDetectorId detector) : m_db(db) , m_detector(detector) { @@ -426,48 +430,47 @@ namespace EUROPA { template class ProfileFactory : public Factory { public: - ProfileFactory(const LabelStr& name) : Factory(name) {} + ProfileFactory(const std::string& name) : Factory(name) {} - virtual EUROPA::FactoryObjId& createInstance(const EUROPA::FactoryArgs& fa) + virtual EUROPA::FactoryObjId createInstance(const EUROPA::FactoryArgs& fa) { - const ProfileArgs& args = (const ProfileArgs&)fa; - return (EUROPA::FactoryObjId&) - (new ProfileType(args.m_db, args.m_detector))->getId(); + const ProfileArgs& args = dynamic_cast(fa); + return (new ProfileType(args.m_db, args.m_detector))->getId(); } }; #define REGISTER_PROFILE(MGR, CLASS, NAME) (MGR->registerFactory((new EUROPA::ProfileFactory(#NAME))->getId())); - /* - * A Profile keeps track of upper&lower bounds of a resource's attribute over time. - * An ExplicitProfile is a profile whose values are explicitly specified (instead of being computed from usage or other information) - * An ExplicitProfile is a piecewise constant function, we may consider supporting other types in the future. - * For the time being a resource's capacity will be represented using an ExplicitProfile. - * Limits could also be represented by an ExplicitProfile if we see the need to move beyond a single {upperBound,lowerBound} pair. - * - * TODO: Profile needs to be refactored into an interface that both the ExplicitProfile and (a new) ComputedProfile class can implement. - * The current Profile class represents the Level (or availability) profile for a resource and would be better characterized - * as a ComputedProfile - */ - class ExplicitProfile { - public: - ExplicitProfile(edouble lb, edouble ub); - virtual ~ExplicitProfile(); +/* + * A Profile keeps track of upper&lower bounds of a resource's attribute over time. + * An ExplicitProfile is a profile whose values are explicitly specified (instead of being computed from usage or other information) + * An ExplicitProfile is a piecewise constant function, we may consider supporting other types in the future. + * For the time being a resource's capacity will be represented using an ExplicitProfile. + * Limits could also be represented by an ExplicitProfile if we see the need to move beyond a single {upperBound,lowerBound} pair. + * + * TODO: Profile needs to be refactored into an interface that both the ExplicitProfile and (a new) ComputedProfile class can implement. + * The current Profile class represents the Level (or availability) profile for a resource and would be better characterized + * as a ComputedProfile + */ +class ExplicitProfile { + public: +ExplicitProfile(edouble lb, edouble ub); +virtual ~ExplicitProfile(); - ExplicitProfileId& getId(); +ExplicitProfileId getId(); - void setValue(eint time, edouble lb, edouble ub); - void removeValue(eint time); - // TODO: provide ExplicitProfileIterator instead? - const std::map< eint,std::pair >& getValues() const; +void setValue(eint time, edouble lb, edouble ub); +void removeValue(eint time); +// TODO: provide ExplicitProfileIterator instead? +const std::map< eint,std::pair >& getValues() const; - const std::pair& getValue(eint time) const; - const std::pair& getEarliestValue() const; +const std::pair& getValue(eint time) const; +const std::pair& getEarliestValue() const; - protected: - ExplicitProfileId m_id; - std::map< eint,std::pair > m_values; - }; + protected: +ExplicitProfileId m_id; +std::map< eint,std::pair > m_values; +}; } #endif diff --git a/src/PLASMA/Resource/base/ProfilePropagator.cc b/src/PLASMA/Resource/base/ProfilePropagator.cc index c3d8b80ee..592d3f774 100644 --- a/src/PLASMA/Resource/base/ProfilePropagator.cc +++ b/src/PLASMA/Resource/base/ProfilePropagator.cc @@ -7,11 +7,14 @@ namespace EUROPA { - ProfilePropagator::ProfilePropagator(const LabelStr& name, - const ConstraintEngineId& constraintEngine) + ProfilePropagator::ProfilePropagator(const std::string& name, + const ConstraintEngineId constraintEngine) : DefaultPropagator(name, constraintEngine) + , m_profiles() + , m_newConstraints() , m_updateRequired(false) , m_inBatchMode(false) + , m_batchListener(NULL) { } @@ -19,7 +22,7 @@ namespace EUROPA { { } - void ProfilePropagator::handleConstraintAdded(const ConstraintId& constraint) { + void ProfilePropagator::handleConstraintAdded(const ConstraintId constraint) { check_error(constraint.isValid()); if(constraint->getName() == Profile::VariableListener::CONSTRAINT_NAME()) { m_newConstraints.insert(constraint); @@ -28,7 +31,7 @@ namespace EUROPA { DefaultPropagator::handleConstraintAdded(constraint); } - void ProfilePropagator::handleConstraintRemoved(const ConstraintId& constraint) { + void ProfilePropagator::handleConstraintRemoved(const ConstraintId constraint) { check_error(constraint.isValid()); if(m_newConstraints.erase(constraint) > 0) m_updateRequired = true; @@ -70,7 +73,8 @@ namespace EUROPA { check_error(constraint.isValid()); check_error(Id::convertable(constraint)); debugMsg("ProfilePropagator:execute", "Handling addition of constraint " << constraint->toString()); - Profile::VariableListener* listener = (Profile::VariableListener*) constraint; + Profile::VariableListener* listener = + id_cast(constraint); check_error(listener != NULL); check_error(listener->getProfile().isValid()); debugMsg("ProfilePropagator:execute", "Adding profile " << listener->getProfile()); @@ -83,8 +87,13 @@ namespace EUROPA { if( !getConstraintEngine()->provenInconsistent() && profile->needsRecompute()) { - debugMsg("ProfilePropagator:execute", "Recomputing profile " << profile->getResource()->getName().toString()); - profile->recompute(); + condDebugMsg(profile->getResource() != ResourceId::noId(), + "ProfilePropagator:execute", + "Recomputing profile " << profile->getResource()->getName()); + condDebugMsg(profile->getResource() == ResourceId::noId(), + "ProfilePropagator:execute", + "Recomputing profile " << profile); + profile->recompute(); } } @@ -92,95 +101,95 @@ namespace EUROPA { debugMsg("ProfilePropagator:execute", "Executed ProfilePropagator"); } - void ProfilePropagator::execute(const ConstraintId& constraint) { - Propagator::execute(constraint); - if(constraint->getName() == Profile::VariableListener::CONSTRAINT_NAME()) { - Profile::VariableListener* listener = (Profile::VariableListener*) constraint; - if(listener->getProfile()->needsRecompute()) - m_updateRequired = true; - } - } +void ProfilePropagator::execute(const ConstraintId constraint) { + Propagator::execute(constraint); + if(constraint->getName() == Profile::VariableListener::CONSTRAINT_NAME()) { + Profile::VariableListener* listener = id_cast(constraint); + if(listener->getProfile()->needsRecompute()) + m_updateRequired = true; + } +} bool ProfilePropagator::updateRequired() const { return DefaultPropagator::updateRequired() || m_updateRequired; } - class BatchModeListener : public ConstraintEngineListener - { - public: - BatchModeListener(const ConstraintEngineId& constraintEngine, ProfilePropagator* propagator) - : ConstraintEngineListener(constraintEngine) - , m_propagator(propagator) - { - } - - virtual ~BatchModeListener() - { - debugMsg("ProfilePropagator:BatchModeListener", "BatchModeListener destroyed"); - } - - virtual void notifyAdded(const ConstraintId& constraint) - { - if (m_propagator->inBatchMode() && - (constraint->getName()==ResourceTokenRelation::CONSTRAINT_NAME())) { - debugMsg("ProfilePropagator:BatchModeListener", "Disabling " << constraint->getName().toString() << "(" << constraint->getKey() << ")"); - //ResourceTokenRelation* c = (ResourceTokenRelation*)constraint; - //c->disable(); - // TODO JRB: should be disable() but cast above refuses to work. - constraint->deactivate(); - } - } - - protected: - ProfilePropagator* m_propagator; - }; - - void ProfilePropagator::enterBatchMode() - { - if (m_inBatchMode) - return; - - debugMsg("ProfilePropagator:BatchMode", "Entering Batch Mode"); - - const std::set& constraints = getConstraints(); - std::set::const_iterator it; - for(it=constraints.begin();it != constraints.end(); ++it) { - if ((*it)->getName() == ResourceTokenRelation::CONSTRAINT_NAME()) { - ResourceTokenRelation* c = (ResourceTokenRelation*)(*it); - c->disable(); - } - } +class BatchModeListener : public ConstraintEngineListener { +private: + BatchModeListener(const BatchModeListener&); + BatchModeListener& operator=(const BatchModeListener&); + public: + BatchModeListener(const ConstraintEngineId constraintEngine, ProfilePropagator* propagator) + : ConstraintEngineListener(constraintEngine) + , m_propagator(propagator) + { + } + + virtual ~BatchModeListener() + { + debugMsg("ProfilePropagator:BatchModeListener", "BatchModeListener destroyed"); + } + + virtual void notifyAdded(const ConstraintId constraint) + { + if (m_propagator->inBatchMode() && + (constraint->getName()==ResourceTokenRelation::CONSTRAINT_NAME())) { + debugMsg("ProfilePropagator:BatchModeListener", "Disabling " << constraint->getName() << "(" << constraint->getKey() << ")"); + //ResourceTokenRelation* c = (ResourceTokenRelation*)constraint; + //c->disable(); + // TODO JRB: should be disable() but cast above refuses to work. + constraint->deactivate(); + } + } + + protected: + ProfilePropagator* m_propagator; +}; - disable(); +void ProfilePropagator::enterBatchMode() { + if (m_inBatchMode) + return; - m_batchListener = new BatchModeListener(getConstraintEngine(),this); - m_inBatchMode = true; + debugMsg("ProfilePropagator:BatchMode", "Entering Batch Mode"); - debugMsg("ProfilePropagator:BatchMode", "Entered Batch Mode"); + const std::set& constraints = getConstraints(); + std::set::const_iterator it; + for(it=constraints.begin();it != constraints.end(); ++it) { + if ((*it)->getName() == ResourceTokenRelation::CONSTRAINT_NAME()) { + ResourceTokenRelation* c = id_cast(*it); + c->disable(); } + } - void ProfilePropagator::exitBatchMode() - { - if (!m_inBatchMode) - return; + disable(); + + m_batchListener = new BatchModeListener(getConstraintEngine(),this); + m_inBatchMode = true; - debugMsg("ProfilePropagator:BatchMode", "Exiting Batch Mode"); + debugMsg("ProfilePropagator:BatchMode", "Entered Batch Mode"); +} - m_inBatchMode = false; - delete m_batchListener; - m_batchListener = NULL; +void ProfilePropagator::exitBatchMode() { + if (!m_inBatchMode) + return; - enable(); + debugMsg("ProfilePropagator:BatchMode", "Exiting Batch Mode"); - const std::set& constraints = getConstraints(); - std::set::const_iterator it; - for(it=constraints.begin();it != constraints.end(); ++it) { - if ((*it)->getName() == ResourceTokenRelation::CONSTRAINT_NAME()) { - ResourceTokenRelation* c = (ResourceTokenRelation*)(*it); - c->enable(); - } - } + m_inBatchMode = false; + delete m_batchListener; + m_batchListener = NULL; - debugMsg("ProfilePropagator:BatchMode", "Exited Batch Mode"); + enable(); + + const std::set& constraints = getConstraints(); + std::set::const_iterator it; + for(it=constraints.begin();it != constraints.end(); ++it) { + if ((*it)->getName() == ResourceTokenRelation::CONSTRAINT_NAME()) { + ResourceTokenRelation* c = id_cast(*it); + c->enable(); } + } + + debugMsg("ProfilePropagator:BatchMode", "Exited Batch Mode"); +} } diff --git a/src/PLASMA/Resource/base/ProfilePropagator.hh b/src/PLASMA/Resource/base/ProfilePropagator.hh index c5a71931c..fc8837d2f 100644 --- a/src/PLASMA/Resource/base/ProfilePropagator.hh +++ b/src/PLASMA/Resource/base/ProfilePropagator.hh @@ -1,5 +1,5 @@ -#ifndef _H_ProfilePropagator -#define _H_ProfilePropagator +#ifndef H_ProfilePropagator +#define H_ProfilePropagator #include "Propagators.hh" #include "ConstraintEngineDefs.hh" @@ -7,34 +7,37 @@ #include "ResourceDefs.hh" namespace EUROPA { - class ProfilePropagator : public DefaultPropagator { - public: - ProfilePropagator(const LabelStr& name, - const ConstraintEngineId& constraintEngine); +class ProfilePropagator : public DefaultPropagator { +private: + ProfilePropagator(const ProfilePropagator&); + ProfilePropagator& operator=(const ProfilePropagator&); + public: + ProfilePropagator(const std::string& name, + const ConstraintEngineId constraintEngine); - virtual ~ProfilePropagator(); + virtual ~ProfilePropagator(); - // Batch mode delays all propagation until Batch mode is exited - virtual void enterBatchMode(); - virtual void exitBatchMode(); - virtual bool inBatchMode() const { return m_inBatchMode; } + // Batch mode delays all propagation until Batch mode is exited + virtual void enterBatchMode(); + virtual void exitBatchMode(); + virtual bool inBatchMode() const { return m_inBatchMode; } - protected: - friend class Profile; - void setUpdateRequired(const bool update) {m_updateRequired = update;} - private: - void execute(); - void execute(const ConstraintId& constraint); - bool updateRequired() const; - void handleConstraintAdded(const ConstraintId& constraint); - void handleConstraintRemoved(const ConstraintId& constraint); + protected: + friend class Profile; + void setUpdateRequired(const bool update) {m_updateRequired = update;} + private: + void execute(); + void execute(const ConstraintId constraint); + bool updateRequired() const; + void handleConstraintAdded(const ConstraintId constraint); + void handleConstraintRemoved(const ConstraintId constraint); - std::set m_profiles; - std::set m_newConstraints; - bool m_updateRequired; - bool m_inBatchMode; - ConstraintEngineListener* m_batchListener; - }; + std::set m_profiles; + std::set m_newConstraints; + bool m_updateRequired; + bool m_inBatchMode; + ConstraintEngineListener* m_batchListener; +}; } #endif diff --git a/src/PLASMA/Resource/base/Resource.cc b/src/PLASMA/Resource/base/Resource.cc index aa43d254a..8d08f9ea4 100644 --- a/src/PLASMA/Resource/base/Resource.cc +++ b/src/PLASMA/Resource/base/Resource.cc @@ -12,11 +12,13 @@ #include "TemporalAdvisor.hh" #include "PlanDatabaseDefs.hh" +#include + #include #ifdef _MSC_VER # include using std::select2nd; -#elif __clang__ +#elif defined __clang__ # include template struct select2nd : public std::unary_function { @@ -31,84 +33,94 @@ struct select2nd : public std::unary_function namespace EUROPA { - Resource::Resource(const PlanDatabaseId& planDatabase, - const LabelStr& type, const LabelStr& name, - const LabelStr& detectorName, - const LabelStr& profileName, - edouble initCapacityLb, edouble initCapacityUb, - edouble lowerLimit, edouble upperLimit, - edouble maxInstProduction, edouble maxInstConsumption, - edouble maxProduction, edouble maxConsumption) - : Object(planDatabase, type, name, false) - { - init(initCapacityLb, initCapacityUb, - lowerLimit, upperLimit, - maxInstProduction, maxInstConsumption, - maxProduction, maxConsumption, - detectorName, - profileName - ); - } - - Resource::Resource(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open) - : Object(planDatabase, type, name, open) - { - } - - Resource::Resource(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open) - : Object(parent, type, localName, open) - { - } +Resource::Resource(const PlanDatabaseId planDatabase, + const std::string& type, const std::string& name, + const std::string& detectorName, + const std::string& profileName, + edouble initCapacityLb, edouble initCapacityUb, + edouble lowerLimit, edouble upperLimit, + edouble maxInstProduction, edouble maxInstConsumption, + edouble maxProduction, edouble maxConsumption) + : Object(planDatabase, type, name, false), + m_detector(), m_capacityProfile(), m_limitProfile(), m_profile(), + m_transactionsToTokens(), m_flawedTokens(), m_flawedInstants(), + m_maxInstProduction(maxInstProduction), m_maxInstConsumption(maxInstConsumption), + m_maxProduction(maxProduction), m_maxConsumption(maxConsumption) { + init(initCapacityLb, initCapacityUb, + lowerLimit, upperLimit, + maxInstProduction, maxInstConsumption, + maxProduction, maxConsumption, + detectorName, + profileName + ); +} - Resource::~Resource() - { - for(std::map::const_iterator it = m_transactionsToTokens.begin(); it != m_transactionsToTokens.end(); - ++it) { - if ((it->first->getOwner()).isNoId()) - delete (Transaction*) it->first; - } - - delete (Profile*) m_profile; - delete (ExplicitProfile*) m_limitProfile; - delete (ExplicitProfile*) m_capacityProfile; - delete (FVDetector*) m_detector; - } +Resource::Resource(const PlanDatabaseId planDatabase, const std::string& type, + const std::string& name, bool open) + : Object(planDatabase, type, name, open), + m_detector(), m_capacityProfile(), m_limitProfile(), m_profile(), + m_transactionsToTokens(), m_flawedTokens(), m_flawedInstants(), + m_maxInstProduction(), m_maxInstConsumption(), + m_maxProduction(), m_maxConsumption() {} + +Resource::Resource(const ObjectId parent, const std::string& type, + const std::string& localName, bool open) + : Object(parent, type, localName, open), + m_detector(), m_capacityProfile(), m_limitProfile(), m_profile(), + m_transactionsToTokens(), m_flawedTokens(), m_flawedInstants(), + m_maxInstProduction(), m_maxInstConsumption(), + m_maxProduction(), m_maxConsumption() {} + +Resource::~Resource() { + for(std::map::const_iterator it = m_transactionsToTokens.begin(); + it != m_transactionsToTokens.end(); ++it) { + if ((it->first->getOwner()).isNoId() || (it->first->getOwner() == getId())) + delete static_cast(it->first); + } + + delete static_cast(m_profile); + delete id_cast(m_limitProfile); + delete id_cast(m_capacityProfile); + delete static_cast(m_detector); +} - void Resource::init(const edouble initCapacityLb, const edouble initCapacityUb, - const edouble lowerLimit, const edouble upperLimit, - const edouble maxInstProduction, const edouble maxInstConsumption, - const edouble maxProduction, const edouble maxConsumption, - const LabelStr& detectorName, - const LabelStr& profileName) { - debugMsg("Resource:init", "In base init function."); - - m_maxInstProduction = (maxInstProduction == PLUS_INFINITY ? maxProduction : maxInstProduction); - m_maxProduction = maxProduction; - m_maxInstConsumption = (maxInstConsumption == PLUS_INFINITY ? maxConsumption : maxInstConsumption); - m_maxConsumption = maxConsumption; - - // TODO: make this more robust? - EngineId& engine = this->getPlanDatabase()->getEngine(); - - FactoryMgr* fvdfm = (FactoryMgr*)engine->getComponent("FVDetectorFactoryMgr"); - m_detector = fvdfm->createInstance(detectorName, FVDetectorArgs(getId())); - - m_capacityProfile = (new ExplicitProfile(initCapacityLb,initCapacityUb))->getId(); - m_limitProfile = (new ExplicitProfile(lowerLimit,upperLimit))->getId(); - - FactoryMgr* pfm = (FactoryMgr*)engine->getComponent("ProfileFactoryMgr"); - m_profile = pfm->createInstance( - profileName, - ProfileArgs(getPlanDatabase(),m_detector)); - - debugMsg("Resource:init", "Initialized Resource " << getName().toString() << "{" - << "initCapacity=[" << initCapacityLb << "," << initCapacityUb << "]," - << "usageLimits=[" << lowerLimit << "," << upperLimit << "]," - << "productionLimits=[max=" << m_maxProduction << ",maxInst=" << m_maxInstProduction << "]," - << "consumptionLimits=[max=" << m_maxConsumption << ",maxInst=" << m_maxInstConsumption << "]," - << "}" - ); - } +void Resource::init(const edouble initCapacityLb, const edouble initCapacityUb, + const edouble lowerLimit, const edouble upperLimit, + const edouble maxInstProduction, const edouble maxInstConsumption, + const edouble maxProduction, const edouble maxConsumption, + const std::string& detectorName, + const std::string& profileName) { + debugMsg("Resource:init", "In base init function."); + + m_maxInstProduction = (maxInstProduction == PLUS_INFINITY ? maxProduction : maxInstProduction); + m_maxProduction = maxProduction; + m_maxInstConsumption = (maxInstConsumption == PLUS_INFINITY ? maxConsumption : maxInstConsumption); + m_maxConsumption = maxConsumption; + + // TODO: make this more robust? + EngineId engine = this->getPlanDatabase()->getEngine(); + + FactoryMgr* fvdfm = + boost::polymorphic_cast(engine->getComponent("FVDetectorFactoryMgr")); + m_detector = fvdfm->createInstance(detectorName, FVDetectorArgs(getId())); + + m_capacityProfile = (new ExplicitProfile(initCapacityLb,initCapacityUb))->getId(); + m_limitProfile = (new ExplicitProfile(lowerLimit,upperLimit))->getId(); + + FactoryMgr* pfm = + boost::polymorphic_cast(engine->getComponent("ProfileFactoryMgr")); + m_profile = pfm->createInstance( + profileName, + ProfileArgs(getPlanDatabase(),m_detector)); + + debugMsg("Resource:init", "Initialized Resource " << getName() << "{" + << "initCapacity=[" << initCapacityLb << "," << initCapacityUb << "]," + << "usageLimits=[" << lowerLimit << "," << upperLimit << "]," + << "productionLimits=[max=" << m_maxProduction << ",maxInst=" << m_maxInstProduction << "]," + << "consumptionLimits=[max=" << m_maxConsumption << ",maxInst=" << m_maxInstConsumption << "]," + << "}" + ); +} void Resource::detectFV(const eint& time) { @@ -124,12 +136,12 @@ namespace EUROPA { detectFV(time); } - edouble Resource::getLowerLimit(const InstantId& inst) const + edouble Resource::getLowerLimit(const InstantId inst) const { return m_limitProfile->getValue(inst->getTime()).first; } - edouble Resource::getUpperLimit(const InstantId& inst) const + edouble Resource::getUpperLimit(const InstantId inst) const { return m_limitProfile->getValue(inst->getTime()).second; } @@ -140,7 +152,7 @@ namespace EUROPA { detectFV(time); } - void Resource::add(const TokenId& token) { + void Resource::add(const TokenId token) { if(tokens().find(token) != tokens().end()) return; debugMsg("Resource:add", "Adding " << token->toString()); @@ -150,7 +162,7 @@ namespace EUROPA { //Due to the fact that add/remove and addToProfile/removeFromProfile are invoked by two different constraints and //that those constraints almost always execute in a single order, this needs to be done carefully - void Resource::remove(const TokenId& token) { + void Resource::remove(const TokenId token) { if(tokens().find(token) == tokens().end()) return; debugMsg("Resource:remove", "Removing " << token->toString()); @@ -159,7 +171,7 @@ namespace EUROPA { removeTransactions(token); } - void Resource::removeFromProfile(const TokenId& tok) { + void Resource::removeFromProfile(const TokenId tok) { debugMsg("Resource:removeFromProfile", "Removing " << tok->toString()); std::map >::iterator it = m_flawedTokens.find(tok); if(it != m_flawedTokens.end()) { @@ -174,13 +186,13 @@ namespace EUROPA { } //can cache these results or perhaps compute the all-pairs incrementally in the instant - void Resource::getOrderingChoices(const TokenId& token, + void Resource::getOrderingChoices(const TokenId token, std::vector >& results, - unsigned int limit) { + unsigned long limit) { check_error(results.empty()); check_error(token.isValid()); check_error(limit > 0); - debugMsg("Resource:getOrderingChoices", "Getting " << limit << " ordering choices for " << token->getPredicateName().toString() << "(" << token->getKey() << ")"); + debugMsg("Resource:getOrderingChoices", "Getting " << limit << " ordering choices for " << token->getPredicateName() << "(" << token->getKey() << ")"); if(!getPlanDatabase()->getConstraintEngine()->propagate()) { debugMsg("Resource:getOrderingChoices", "No ordering choices: the constraint network is inconsistent."); @@ -241,8 +253,8 @@ namespace EUROPA { continue; debugMsg("Resource:getOrderingChoices", - "Considering order <" << predecessorToken->getPredicateName().toString() << "(" << predecessorToken->getKey() << "), " << - successorToken->getPredicateName().toString() << "(" << successorToken->getKey() << ")>"); + "Considering order <" << predecessorToken->getPredicateName() << "(" << predecessorToken->getKey() << "), " << + successorToken->getPredicateName() << "(" << successorToken->getKey() << ")>"); std::multimap::iterator checkFirst = pairs.lower_bound(predecessorToken); //if we have an entry for the predecessor @@ -312,30 +324,29 @@ namespace EUROPA { return retval; } - bool isConsumptionProblem(Resource::ProblemType problem) - { - return +namespace { +bool isConsumptionProblem(Resource::ProblemType problem) { + return problem == Resource::ConsumptionSumExceeded || problem == Resource::ConsumptionRateExceeded || problem == Resource::LevelTooLow; - } +} - bool isProductionProblem(Resource::ProblemType problem) - { - return +bool isProductionProblem(Resource::ProblemType problem) { + return problem == Resource::ProductionSumExceeded || problem == Resource::ProductionRateExceeded || problem == Resource::LevelTooHigh; - } +} +} /* * reset violations from instant inst */ - void Resource::resetViolations(InstantId inst) - { - // TODO: for now reset all violations, see if this can be made more efficient - resetViolations(); - } +void Resource::resetViolations(InstantId ) { + // TODO: for now reset all violations, see if this can be made more efficient + resetViolations(); +} /* * reset all violations @@ -433,7 +444,7 @@ namespace EUROPA { ResourceFlaws::iterator flawIt = m_flawedTokens.find(tok); if(flawIt == m_flawedTokens.end()) { debugMsg("Resource:notifyFlawed", - toString() << " Token " << tok->getPredicateName().toString() << "(" << tok->getKey() << ") is flawed at instant " << inst->getTime() << + toString() << " Token " << tok->getPredicateName() << "(" << tok->getKey() << ") is flawed at instant " << inst->getTime() << ". Notifying that an ordering is required."); m_flawedTokens.insert(std::pair >(tok, std::set())); flawIt = m_flawedTokens.find(tok); @@ -442,7 +453,7 @@ namespace EUROPA { } else { debugMsg("Resource:notifyFlawed", - toString() << " Received a redundant notification of a flaw for token " << tok->getPredicateName().toString() << "(" << tok->getKey() << ") at instant " << + toString() << " Received a redundant notification of a flaw for token " << tok->getPredicateName() << "(" << tok->getKey() << ") at instant " << inst->getTime() << ". Adding it to the set but not notifying."); flawIt->second.insert(inst); } @@ -477,13 +488,13 @@ namespace EUROPA { std::size_t size = tokIt->second.size(); tokIt->second.erase(inst); condDebugMsg(size > tokIt->second.size(), - "Resource:notifyNoLongerFlawed", toString() << " Removed the flaw at time " << inst->getTime() << " for token " << tok->getPredicateName().toString() << + "Resource:notifyNoLongerFlawed", toString() << " Removed the flaw at time " << inst->getTime() << " for token " << tok->getPredicateName() << "(" << tok->getKey() << ")"); if(size > tokIt->second.size() && !tokIt->second.empty()) { std::stringstream str; for(std::set::const_iterator it = tokIt->second.begin(); it != tokIt->second.end(); ++it) str << (*it)->getTime() << " "; - debugMsg("Resource:notifyNoLongerFlawed", toString() << " Remaining flaws for token " << tok->getPredicateName().toString() << + debugMsg("Resource:notifyNoLongerFlawed", toString() << " Remaining flaws for token " << tok->getPredicateName() << "(" << tok->getKey() << "): " << str.str()); } if(tokIt->second.empty()) @@ -493,7 +504,7 @@ namespace EUROPA { for(std::set::const_iterator it = flawlessTokens.begin(); it != flawlessTokens.end(); ++it) { TokenId tok = *it; check_error(tok.isValid()); - debugMsg("Resource:notifyNoLongerFlawed", toString() << " Notifying that the token " << tok->getPredicateName().toString() << "(" << + debugMsg("Resource:notifyNoLongerFlawed", toString() << " Notifying that the token " << tok->getPredicateName() << "(" << tok->getKey() << ") no longer requires an ordering."); notifyOrderingNoLongerRequired(tok); m_flawedTokens.erase(tok); @@ -501,6 +512,8 @@ namespace EUROPA { debugMsg("Resource:notifyNoLongerFlawed", toString() << " Have " << m_flawedTokens.size() << " remaining flawed tokens."); } +void Resource::notifyDeleted(const TokenId token) {Object::notifyDeleted(token);} + void Resource::notifyDeleted(const InstantId inst) { notifyNoLongerFlawed(inst); notifyNoLongerViolated(inst); @@ -510,11 +523,11 @@ namespace EUROPA { it->second.erase(inst); } - bool Resource::noFlawedTokensForInst(const InstantId& inst) const { + bool Resource::noFlawedTokensForInst(const InstantId inst) const { for(ResourceFlaws::const_iterator it = m_flawedTokens.begin(); it != m_flawedTokens.end(); ++it) { if(it->second.find(inst) != it->second.end()) { debugMsg("Resource:noFlawedTokensForInst", - "Found a flaw for instant " << inst->getTime() << " in token " << it->first->getPredicateName().toString() << "(" << it->first->getKey() << ")"); + "Found a flaw for instant " << inst->getTime() << " in token " << it->first->getPredicateName() << "(" << it->first->getKey() << ")"); return false; } } @@ -529,110 +542,110 @@ namespace EUROPA { debugMsg("Resource:getFlawedInstants", "Have " << m_flawedInstants.size() << " flawed instants. Returning " << results.size() << "."); } - void Resource::getOrderingChoices(const InstantId& inst, - std::vector >& results, - unsigned int limit) { - check_error(results.empty()); - check_error(inst.isValid()); - check_error(limit > 0); - check_error(m_flawedInstants.find(inst->getTime()) != m_flawedInstants.end()); - check_error(m_flawedInstants.find(inst->getTime())->second == inst); - - debugMsg("Resource:getOrderingChoices", "Getting " << limit << " ordering choices for " << inst->getTime() << "(" << inst->getKey() << ") on " << toString()); +void Resource::getOrderingChoices(const InstantId inst, + std::vector >& results, + unsigned long limit) { + check_error(results.empty()); + check_error(inst.isValid()); + check_error(limit > 0); + check_error(m_flawedInstants.find(inst->getTime()) != m_flawedInstants.end()); + check_error(m_flawedInstants.find(inst->getTime())->second == inst); - if(!getPlanDatabase()->getConstraintEngine()->propagate()) { - debugMsg("Resource:getOrderingChoices", "No ordering choices: the constraint network is inconsistent."); - return; - } + debugMsg("Resource:getOrderingChoices", "Getting " << limit << " ordering choices for " << inst->getTime() << "(" << inst->getKey() << ") on " << toString()); - const std::set& transactions = inst->getTransactions(); - unsigned int count = 0; - TemporalAdvisorId temporalAdvisor = getPlanDatabase()->getTemporalAdvisor(); - std::set > uniquePairs; + if(!getPlanDatabase()->getConstraintEngine()->propagate()) { + debugMsg("Resource:getOrderingChoices", "No ordering choices: the constraint network is inconsistent."); + return; + } - for(std::set::const_iterator preIt = transactions.begin(); preIt != transactions.end() && count < limit; ++preIt) { - TransactionId predecessor = *preIt; - check_error(predecessor.isValid()); - //for(std::set::const_iterator sucIt = transactions.begin(); sucIt != transactions.end() && count < limit; ++sucIt) { - std::vector sucTimevars; - for(std::map::const_iterator sucIt = m_transactionsToTokens.begin(); sucIt != m_transactionsToTokens.end() && count < limit; ++sucIt) { - TransactionId successor = sucIt->first; - check_error(successor.isValid()); - sucTimevars.push_back(TimeVarId(successor->time())); + const std::set& transactions = inst->getTransactions(); + unsigned int count = 0; + TemporalAdvisorId temporalAdvisor = getPlanDatabase()->getTemporalAdvisor(); + std::set > uniquePairs; + + for(std::set::const_iterator preIt = transactions.begin(); preIt != transactions.end() && count < limit; ++preIt) { + TransactionId predecessor = *preIt; + check_error(predecessor.isValid()); + //for(std::set::const_iterator sucIt = transactions.begin(); sucIt != transactions.end() && count < limit; ++sucIt) { + std::vector sucTimevars; + for(std::map::const_iterator sucIt = m_transactionsToTokens.begin(); sucIt != m_transactionsToTokens.end() && count < limit; ++sucIt) { + TransactionId successor = sucIt->first; + check_error(successor.isValid()); + sucTimevars.push_back(TimeVarId(successor->time())); + } + std::vector presucLbs; + std::vector presucUbs; + temporalAdvisor->getTemporalDistanceSigns(TimeVarId(predecessor->time()), + sucTimevars, presucLbs, presucUbs); + unsigned int i = 0; + + for(std::map::const_iterator sucIt = m_transactionsToTokens.begin(); sucIt != m_transactionsToTokens.end() && count < limit; ++sucIt) { + TransactionId successor = sucIt->first; + check_error(successor.isValid()); + + bool canPrecede = (presucUbs[i] >= 0);//temporalAdvisor->canPrecede(TimeVarId(predecessor->time()), TimeVarId(successor->time())); + bool mustPrecede = (presucLbs[i] >= 0); + bool canFollow = (presucLbs[i] <= 0); + bool mustFollow = (presucUbs[i] <= 0); + i++; + + debugMsg("Resource:getOrderingChoices", "Considering pair <" << predecessor->toString() << ", " << successor->toString()); + if(predecessor == successor || !predecessor->time()->lastDomain().intersects(successor->time()->lastDomain())) { + condDebugMsg(predecessor == successor, "Resource:getOrderingChoices", "Rejected pair because they are the same transaction."); + condDebugMsg(!predecessor->time()->lastDomain().intersects(successor->time()->lastDomain()), "Resource:getOrderingChoices", + "Rejected pair because successor does not overlap predecessor."); + continue; + } + //if(temporalAdvisor->canPrecede(TimeVarId(predecessor->time()), TimeVarId(successor->time())) && + //!transConstrainedToPrecede(predecessor, successor)) { + // //results.push_back(std::make_pair(predecessor, successor)); + if (canPrecede && !mustPrecede) { + bool added = uniquePairs.insert(std::make_pair(predecessor, successor)).second; + if(added) { + debugMsg("Resource:getOrderingChoices", "Added pair <" << predecessor->toString() << ", " << successor->toString()); + count++; } - std::vector presucLbs; - std::vector presucUbs; - temporalAdvisor->getTemporalDistanceSigns(TimeVarId(predecessor->time()), - sucTimevars, presucLbs, presucUbs); - int i = 0; - - for(std::map::const_iterator sucIt = m_transactionsToTokens.begin(); sucIt != m_transactionsToTokens.end() && count < limit; ++sucIt) { - TransactionId successor = sucIt->first; - check_error(successor.isValid()); - - bool canPrecede = (presucUbs[i] >= 0);//temporalAdvisor->canPrecede(TimeVarId(predecessor->time()), TimeVarId(successor->time())); - bool mustPrecede = (presucLbs[i] >= 0); - bool canFollow = (presucLbs[i] <= 0); - bool mustFollow = (presucUbs[i] <= 0); - i++; - - debugMsg("Resource:getOrderingChoices", "Considering pair <" << predecessor->toString() << ", " << successor->toString()); - if(predecessor == successor || !predecessor->time()->lastDomain().intersects(successor->time()->lastDomain())) { - condDebugMsg(predecessor == successor, "Resource:getOrderingChoices", "Rejected pair because they are the same transaction."); - condDebugMsg(!predecessor->time()->lastDomain().intersects(successor->time()->lastDomain()), "Resource:getOrderingChoices", - "Rejected pair because successor does not overlap predecessor."); - continue; - } - //if(temporalAdvisor->canPrecede(TimeVarId(predecessor->time()), TimeVarId(successor->time())) && - //!transConstrainedToPrecede(predecessor, successor)) { - // //results.push_back(std::make_pair(predecessor, successor)); - if (canPrecede && !mustPrecede) { - bool added = uniquePairs.insert(std::make_pair(predecessor, successor)).second; - if(added) { - debugMsg("Resource:getOrderingChoices", "Added pair <" << predecessor->toString() << ", " << successor->toString()); - count++; - } - else { - debugMsg("Resource:getOrderingChoices", "Pair is redundant."); - } - } - else { - //condDebugMsg(transConstrainedToPrecede(predecessor, successor), "Resource:getOrderingChoices", "Rejected pair because predecessor already constrained to precede successor."); - //condDebugMsg(!temporalAdvisor->canPrecede(TimeVarId(predecessor->time()), TimeVarId(successor->time())), "Resource:getOrderingChoices", - //"Rejected pair because predecessor cannot precede successor."); - condDebugMsg(mustPrecede, "Resource:getOrderingChoices", "Rejected pair because predecessor already constrained to precede successor."); - condDebugMsg(!canPrecede, "Resource:getOrderingChoices", - "Rejected pair because predecessor cannot precede successor."); - } - debugMsg("Resource:getOrderingChoices", "Considering pair <" << successor->toString() << ", " << predecessor->toString()); - //if(temporalAdvisor->canPrecede(TimeVarId(successor->time()), TimeVarId(predecessor->time())) && - //!transConstrainedToPrecede(successor, predecessor)) { - // //results.push_back(std::make_pair(successor, predecessor)); - if (canFollow && !mustFollow) { - bool added = uniquePairs.insert(std::make_pair(successor, predecessor)).second; - if(added) { - debugMsg("Resource:getOrderingChoices", "Added pair <" << successor->toString() << ", " << predecessor->toString()); - count++; - } - else { - debugMsg("Resource:getOrderingChoices", "Pair is redundant."); - } - } - else { - //condDebugMsg(transConstrainedToPrecede(successor, predecessor), "Resource:getOrderingChoices", "Rejected pair because predecessor already constrained to precede successor."); - //condDebugMsg(!temporalAdvisor->canPrecede(TimeVarId(successor->time()), TimeVarId(predecessor->time())), "Resource:getOrderingChoices", - //"Rejected pair because predecessor cannot precede successor."); - condDebugMsg(mustFollow, "Resource:getOrderingChoices", "Rejected pair because predecessor already constrained to precede successor."); - condDebugMsg(!canFollow, "Resource:getOrderingChoices", - "Rejected pair because predecessor cannot precede successor."); - } + else { + debugMsg("Resource:getOrderingChoices", "Pair is redundant."); + } + } + else { + //condDebugMsg(transConstrainedToPrecede(predecessor, successor), "Resource:getOrderingChoices", "Rejected pair because predecessor already constrained to precede successor."); + //condDebugMsg(!temporalAdvisor->canPrecede(TimeVarId(predecessor->time()), TimeVarId(successor->time())), "Resource:getOrderingChoices", + //"Rejected pair because predecessor cannot precede successor."); + condDebugMsg(mustPrecede, "Resource:getOrderingChoices", "Rejected pair because predecessor already constrained to precede successor."); + condDebugMsg(!canPrecede, "Resource:getOrderingChoices", + "Rejected pair because predecessor cannot precede successor."); + } + debugMsg("Resource:getOrderingChoices", "Considering pair <" << successor->toString() << ", " << predecessor->toString()); + //if(temporalAdvisor->canPrecede(TimeVarId(successor->time()), TimeVarId(predecessor->time())) && + //!transConstrainedToPrecede(successor, predecessor)) { + // //results.push_back(std::make_pair(successor, predecessor)); + if (canFollow && !mustFollow) { + bool added = uniquePairs.insert(std::make_pair(successor, predecessor)).second; + if(added) { + debugMsg("Resource:getOrderingChoices", "Added pair <" << successor->toString() << ", " << predecessor->toString()); + count++; + } + else { + debugMsg("Resource:getOrderingChoices", "Pair is redundant."); } } - results.insert(results.end(), uniquePairs.begin(), uniquePairs.end()); - debugMsg("Resource:getOrderingChoices", "Ultimately found " << results.size() << " orderings."); + else { + //condDebugMsg(transConstrainedToPrecede(successor, predecessor), "Resource:getOrderingChoices", "Rejected pair because predecessor already constrained to precede successor."); + //condDebugMsg(!temporalAdvisor->canPrecede(TimeVarId(successor->time()), TimeVarId(predecessor->time())), "Resource:getOrderingChoices", + //"Rejected pair because predecessor cannot precede successor."); + condDebugMsg(mustFollow, "Resource:getOrderingChoices", "Rejected pair because predecessor already constrained to precede successor."); + condDebugMsg(!canFollow, "Resource:getOrderingChoices", + "Rejected pair because predecessor cannot precede successor."); + } + } } + results.insert(results.end(), uniquePairs.begin(), uniquePairs.end()); + debugMsg("Resource:getOrderingChoices", "Ultimately found " << results.size() << " orderings."); +} - bool Resource::transConstrainedToPrecede(const TransactionId& predecessor, const TransactionId& successor) { + bool Resource::transConstrainedToPrecede(const TransactionId predecessor, const TransactionId successor) { IntervalIntDomain dom = getPlanDatabase()->getTemporalAdvisor()->getTemporalDistanceDomain(TimeVarId(predecessor->time()), TimeVarId(successor->time()), true); return dom.getLowerBound() >= 0; // ConstrainedVariableId pre = predecessor->time(); @@ -690,36 +703,35 @@ namespace EUROPA { return m_detector->getVDLevelProfile(); } - PSList Resource::getOrderingChoices(TimePoint t) - { - PSList retval; +PSList Resource::getOrderingChoices(TimePoint t) { + PSList retval; - InstantId instant; + InstantId instant; - ProfileIterator it(getProfile()); - while(!it.done()) { - TimePoint inst = (TimePoint) cast_basis(it.getTime()); - if (inst == t) { - instant = it.getInstant(); - break; - } - it.next(); - } - - if (instant.isNoId()) { - // TODO: log error - return retval; - } - - std::vector > results; - getOrderingChoices(instant,results); - for (unsigned int i = 0;itime()->parent()->getKey())); - retval.push_back(cast_int(successor->time()->parent()->getKey())); + ProfileIterator it(getProfile()); + while(!it.done()) { + TimePoint inst = static_cast(cast_basis(it.getTime())); + if (inst == t) { + instant = it.getInstant(); + break; } + it.next(); + } + if (instant.isNoId()) { + // TODO: log error return retval; } + + std::vector > results; + getOrderingChoices(instant,results); + for (unsigned int i = 0;i(cast_int(predecessor->time()->parent()->getKey()))); + retval.push_back(static_cast(cast_int(successor->time()->parent()->getKey()))); + } + + return retval; +} } diff --git a/src/PLASMA/Resource/base/Resource.hh b/src/PLASMA/Resource/base/Resource.hh index bbd5e8c00..6fc0f9cad 100644 --- a/src/PLASMA/Resource/base/Resource.hh +++ b/src/PLASMA/Resource/base/Resource.hh @@ -1,5 +1,5 @@ -#ifndef _H_Resource -#define _H_Resource +#ifndef H_Resource +#define H_Resource /** * @file Resource.hh @@ -39,9 +39,9 @@ namespace EUROPA { /** * @brief Constructor. This is primarily a convenience constructor for resource interactions outside of a model. - * @param planDatabase @see Object - * @param type @see Object - * @param name @see Object + * @param planDatabase The plan database + * @param type The type of the resource + * @param name The name of the instance * @param initCapacityLb The lower bound of the Resource's initial level. (For example, a battery may be only half charged initially.) * @param initCapacityUb The upper bound of the Resource's initial level. (For example, a battery may be only half charged initially.) * @param lowerLimit The lower capacity limit. (For example, a battery can't have less than no energy stored, or it might be considered unsafe to allow @@ -51,12 +51,13 @@ namespace EUROPA { * @param maxInstConsumption The maximum amount of consumption possible at an instant. (For example, a power bus might only allow 2.5A to be drawn at one instant.) * @param maxProduction The maximum amount of production possible on this resource. * @param maxConsumption The maximum amount of consumption possible on this resource. + * @see Object */ - Resource(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - const LabelStr& detectorName, - const LabelStr& profileName, + Resource(const PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + const std::string& detectorName, + const std::string& profileName, edouble initCapacityLb = 0, edouble initCapacityUb = 0, edouble lowerLimit = MINUS_INFINITY, @@ -82,25 +83,25 @@ namespace EUROPA { * @brief Constructor * @see Object */ - Resource(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open); + Resource(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open); /** * @brief Constructor * @see Object */ - Resource(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open); + Resource(const ObjectId parent, const std::string& type, const std::string& localName, bool open); virtual ~Resource(); /** * @brief Accessor for the lower limit on level */ - edouble getLowerLimit(const InstantId& inst) const; + edouble getLowerLimit(const InstantId inst) const; /** * @brief Accessor for the upper limit on level */ - edouble getUpperLimit(const InstantId& inst) const; + edouble getUpperLimit(const InstantId inst) const; /** * @brief Accessor for the maximum consumption possible at an instant. @@ -132,7 +133,7 @@ namespace EUROPA { void setLimit(const eint& time, const edouble& lb, const edouble &ub); - virtual void add(const TokenId& token); + virtual void add(const TokenId token); /** * @brief Remove a token from the resource. @@ -144,23 +145,23 @@ namespace EUROPA { * * @param token The token to remove. */ - virtual void remove(const TokenId& token); + virtual void remove(const TokenId token); - virtual void getOrderingChoices(const TokenId& token, + virtual void getOrderingChoices(const TokenId token, std::vector >& results, #ifdef _MSC_VER - unsigned int limit = UINT_MAX + unsigned long limit = UINT_MAX #else - unsigned int limit = std::numeric_limits::max() + unsigned long limit = std::numeric_limits::max() #endif //_MSC_VER ); - virtual void getOrderingChoices(const InstantId& inst, + virtual void getOrderingChoices(const InstantId inst, std::vector >& results, #ifdef _MSC_VER - unsigned int limit = UINT_MAX + unsigned long limit = UINT_MAX #else - unsigned int limit = std::numeric_limits::max() + unsigned long limit = std::numeric_limits::max() #endif //_MSC_VER ); @@ -172,7 +173,7 @@ namespace EUROPA { //ResourceId getId() {return m_id;} //subclasses will need to override getOrderingChoices, getTokensToOrder - int getFlawCount(const TokenId& token) const; + int getFlawCount(const TokenId token) const; static const char* getProblemString(ProblemType t) { return problemLabels[t]; } @@ -202,13 +203,14 @@ namespace EUROPA { */ void init(const edouble initCapacityLb, const edouble initCapacityUb, const edouble lowerLimit, const edouble upperLimit, const edouble maxInstProduction, const edouble maxInstConsumption, - const edouble maxProduction, const edouble maxConsumption, const LabelStr& detectorName, const LabelStr& profileName); + const edouble maxProduction, const edouble maxConsumption, const std::string& detectorName, const std::string& profileName); /** * @brief Receive notification that an Instant has been removed from the profile. * @param inst The deleted Instant. */ virtual void notifyDeleted(const InstantId inst); + void notifyDeleted(const TokenId token); /** * @brief Receive notification of a violation at an instant. The subclass should take appropriate @@ -239,21 +241,21 @@ namespace EUROPA { void resetViolations(InstantId inst); void resetViolations(); - virtual void addToProfile(const TokenId& tok) = 0; - virtual void removeFromProfile(const TokenId& tok); - virtual void createTransactions(const TokenId& tok) = 0; - virtual void removeTransactions(const TokenId& tok) = 0; + virtual void addToProfile(const TokenId tok) = 0; + virtual void removeFromProfile(const TokenId tok); + virtual void createTransactions(const TokenId tok) = 0; + virtual void removeTransactions(const TokenId tok) = 0; protected: - FVDetectorId m_detector; /* m_transactionsToTokens; std::map > m_flawedTokens; std::map m_flawedInstants; - edouble m_maxInstProduction, m_maxInstConsumption; /*& scope, - const TokenId& tok) - : Constraint(CONSTRAINT_NAME(), PROPAGATOR_NAME(), constraintEngine, scope) - , m_token(tok) - , m_violationProblem(Resource::NoProblem) - { +ResourceTokenRelation::ResourceTokenRelation(const ConstraintEngineId constraintEngine, + const std::vector& scope, + const TokenId tok) + : Constraint(CONSTRAINT_NAME(), PROPAGATOR_NAME(), constraintEngine, scope) + , m_token(tok) + , m_resource() + , m_violationTime() + , m_violationProblem(Resource::NoProblem) +{ checkError(scope.size() == 2, "Require both state and object variables, in that order."); checkError(scope[0] == tok->getState() && scope[1] == tok->getObject(), "Require both state and object variables, in that order."); @@ -83,34 +85,32 @@ namespace EUROPA { m_resource = ResourceId::noId(); } - bool ResourceTokenRelation::canIgnore( - const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) - { - debugMsg("ResourceTokenRelation:canIgnore", - m_token->toString() << " Received notification of change type " << changeType << " on variable " << - variable->toString()); - - ConstrainedVariableId state = m_variables[STATE_VAR]; - ConstrainedVariableId object = m_variables[OBJECT_VAR]; - - debugMsg("ResourceTokenRelation:canIgnore", "Current state: " << std::endl << - " " << object->toString() << std::endl << - " " << state->toString()); - - // if this is a singleton message - if(changeType == DomainListener::RESTRICT_TO_SINGLETON || - changeType == DomainListener::SET_TO_SINGLETON || - variable->lastDomain().isSingleton()) { - safeConnect(); - } - else if (changeType == DomainListener::RESET || changeType == DomainListener::RELAXED) { - safeDisconnect(); - } - - return true; - } +bool ResourceTokenRelation::canIgnore(const ConstrainedVariableId variable, + unsigned int , + const DomainListener::ChangeType& changeType) { + debugMsg("ResourceTokenRelation:canIgnore", + m_token->toString() << " Received notification of change type " << changeType << " on variable " << + variable->toString()); + + ConstrainedVariableId state = m_variables[STATE_VAR]; + ConstrainedVariableId object = m_variables[OBJECT_VAR]; + + debugMsg("ResourceTokenRelation:canIgnore", "Current state: " << std::endl << + " " << object->toString() << std::endl << + " " << state->toString()); + + // if this is a singleton message + if(changeType == DomainListener::RESTRICT_TO_SINGLETON || + changeType == DomainListener::SET_TO_SINGLETON || + variable->lastDomain().isSingleton()) { + safeConnect(); + } + else if (changeType == DomainListener::RESET || changeType == DomainListener::RELAXED) { + safeDisconnect(); + } + + return true; +} // TODO: these should be handleDeactivate and handleActivate, but need to fix ViolationManager first void ResourceTokenRelation::enable() @@ -126,12 +126,14 @@ namespace EUROPA { disconnect(); } - void ResourceTokenRelation::notifyViolated(Resource::ProblemType problem, const InstantId inst) - { - m_violationProblem = problem; - m_violationTime = inst->getTime(); - Constraint::notifyViolated(); - } +void ResourceTokenRelation::notifyViolated() {Constraint::notifyViolated();} + +void ResourceTokenRelation::notifyViolated(Resource::ProblemType problem, + const InstantId inst) { + m_violationProblem = problem; + m_violationTime = inst->getTime(); + Constraint::notifyViolated(); +} void ResourceTokenRelation::notifyNoLongerViolated() { @@ -147,7 +149,7 @@ namespace EUROPA { std::ostringstream os; os << Resource::getProblemString(m_violationProblem) - << " for resource " << m_resource->getName().toString() + << " for resource " << m_resource->getName() << " at instant " << m_violationTime; return os.str(); @@ -162,15 +164,15 @@ namespace EUROPA { return std::pair(m_violationTime,m_violationProblem); } - const std::vector& ResourceTokenRelation::getModifiedVariables(const ConstrainedVariableId& variable) const - { - static std::vector s_emptyScope; - return s_emptyScope; - } +const std::vector& +ResourceTokenRelation::getModifiedVariables(const ConstrainedVariableId) const { + static std::vector s_emptyScope; + return s_emptyScope; +} - const std::vector& ResourceTokenRelation::getModifiedVariables() const - { - static std::vector s_emptyScope; - return s_emptyScope; - } +const std::vector& +ResourceTokenRelation::getModifiedVariables() const { + static std::vector s_emptyScope; + return s_emptyScope; +} } diff --git a/src/PLASMA/Resource/base/ResourceTokenRelation.hh b/src/PLASMA/Resource/base/ResourceTokenRelation.hh index 3c8ee7c42..76c5fa6b4 100644 --- a/src/PLASMA/Resource/base/ResourceTokenRelation.hh +++ b/src/PLASMA/Resource/base/ResourceTokenRelation.hh @@ -1,5 +1,5 @@ -#ifndef _H_ResourceTokenRelation -#define _H_ResourceTokenRelation +#ifndef H_ResourceTokenRelation +#define H_ResourceTokenRelation #include "ConstraintEngineDefs.hh" #include "Constraint.hh" @@ -7,7 +7,6 @@ #include "PlanDatabaseDefs.hh" #include "ResourceDefs.hh" #include "Resource.hh" -#include "LabelStr.hh" #include @@ -17,16 +16,16 @@ namespace EUROPA { //when the state is singleton and ACTIVE and object is singleton, then adds the token to the profile class ResourceTokenRelation : public Constraint { public: - ResourceTokenRelation(const ConstraintEngineId& constraintEngine, + ResourceTokenRelation(const ConstraintEngineId constraintEngine, const std::vector& scope, - const TokenId& tok); + const TokenId tok); ~ResourceTokenRelation(); - static const LabelStr& CONSTRAINT_NAME() { - static const LabelStr sl_const("ResourceObjectRelation"); + static const std::string& CONSTRAINT_NAME() { + static const std::string sl_const("ResourceObjectRelation"); return sl_const; } - static const LabelStr& PROPAGATOR_NAME() { - static const LabelStr sl_const("Resource"); + static const std::string& PROPAGATOR_NAME() { + static const std::string sl_const("Resource"); return sl_const; } static const int STATE_VAR = 0; @@ -39,10 +38,11 @@ namespace EUROPA { std::pair getViolationInfo() const; // This constraint doesn't modify any variables through inference - virtual const std::vector& getModifiedVariables(const ConstrainedVariableId& variable) const; + virtual const std::vector& getModifiedVariables(const ConstrainedVariableId variable) const; virtual const std::vector& getModifiedVariables() const; protected: + virtual void notifyViolated(); virtual void notifyViolated(Resource::ProblemType problem, const InstantId inst); virtual void notifyNoLongerViolated(); @@ -59,8 +59,8 @@ namespace EUROPA { private: void handleDiscard(); - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); void handleExecute(){} TokenId m_token; diff --git a/src/PLASMA/Resource/base/Transaction.cc b/src/PLASMA/Resource/base/Transaction.cc index d992dfb5d..212a98a7a 100644 --- a/src/PLASMA/Resource/base/Transaction.cc +++ b/src/PLASMA/Resource/base/Transaction.cc @@ -6,16 +6,20 @@ */ #include "Transaction.hh" #include "Debug.hh" +#include "ConstrainedVariable.hh" +#include "Domain.hh" namespace EUROPA { - Transaction::Transaction(ConstrainedVariableId time, ConstrainedVariableId quantity, bool isConsumer, EntityId owner) - : m_id(this) - , m_time(time) - , m_quantity(quantity) - , m_isConsumer(isConsumer) - , m_owner(owner) - { - } +Transaction::Transaction(ConstrainedVariableId _time, ConstrainedVariableId _quantity, + bool _isConsumer, EntityId owner) + : m_id(this) + , m_time(_time) + , m_quantity(_quantity) + , m_isConsumer(_isConsumer) + , m_owner(owner) { + checkRuntimeError(_quantity->lastDomain().getLowerBound() >= 0.0, + "All transactions require positive quantity variables."); +} Transaction::~Transaction() { diff --git a/src/PLASMA/Resource/base/Transaction.hh b/src/PLASMA/Resource/base/Transaction.hh index c1eb4612e..6d1c27915 100644 --- a/src/PLASMA/Resource/base/Transaction.hh +++ b/src/PLASMA/Resource/base/Transaction.hh @@ -1,5 +1,5 @@ -#ifndef _H_Transaction -#define _H_Transaction +#ifndef H_Transaction +#define H_Transaction /** * @file Transaction.hh @@ -29,7 +29,8 @@ namespace EUROPA { * @param isConsumer Because all transactions have positive quantities, it is necessary to indicate that a transaction is * consuming the resource in some way other than a negative quantity. This flag is what indicates it. */ - Transaction(ConstrainedVariableId time, ConstrainedVariableId quantity, bool isConsumer, EntityId owner=EntityId::noId()); + Transaction(ConstrainedVariableId time, ConstrainedVariableId quantity, + bool isConsumer, EntityId owner); ~Transaction(); /** @@ -49,12 +50,12 @@ namespace EUROPA { TransactionId getId() const {return m_id;} std::string toString() const; - EntityId& getOwner() {return m_owner;} + EntityId getOwner() {return m_owner;} protected: TransactionId m_id; - ConstrainedVariableId m_time, m_quantity; /*(); + } +}; +} + +#endif diff --git a/src/PLASMA/Resource/component/BoostFlowProfileGraph.cc b/src/PLASMA/Resource/component/BoostFlowProfileGraph.cc new file mode 100644 index 000000000..64443ffe6 --- /dev/null +++ b/src/PLASMA/Resource/component/BoostFlowProfileGraph.cc @@ -0,0 +1,256 @@ +#include "BoostFlowProfileGraph.hh" +#include "Debug.hh" +#include "ConstrainedVariable.hh" +#include "Domain.hh" + +#include +// #include +#include +// #include + +namespace EUROPA { + +BoostFlowProfileGraph::BoostFlowProfileGraph(const TransactionId source, + const TransactionId sink, + bool lowerLevel) + : FlowProfileGraph(source, sink, lowerLevel), m_graph(), m_transactionToVertex(), + m_vertexToTransaction(), m_activeTransactions(), m_source(), m_sink(), + m_recalculate(false) { + using namespace boost; + initializeGraph(source, sink); +} + +void BoostFlowProfileGraph::initializeGraph(const TransactionId source, + const TransactionId sink) { + + m_graph.clear(); + m_transactionToVertex.clear(); + m_vertexToTransaction.clear(); + m_source = addNode(source); + m_sink = addNode(sink); + +} + +BoostFlowProfileGraph::Vertex +BoostFlowProfileGraph::addNode(const TransactionId t) { + std::map::const_iterator found = m_transactionToVertex.find(t); + if(found != m_transactionToVertex.end()) + return found->second; + Vertex retval = add_vertex(m_graph); + debugMsg("BoostFlowProfileGraph:addNode", "Added " << retval << " for " << t); + m_transactionToVertex.insert(std::make_pair(t, retval)); + m_vertexToTransaction.insert(std::make_pair(retval, t)); + return retval; +} + +BoostFlowProfileGraph::Vertex +BoostFlowProfileGraph::getNode(const TransactionId t) const { + std::map::const_iterator it = m_transactionToVertex.find(t); + checkError(it != m_transactionToVertex.end(), + "Failed to find a vertex for " << t); + return it->second; +} + +TransactionId BoostFlowProfileGraph::getTransaction(const Vertex& v) const { + std::map::const_iterator it = m_vertexToTransaction.find(v); + checkError(it != m_vertexToTransaction.end(), + "Failed to find a transaction for " << v); + return it->second; +} + +BoostFlowProfileGraph::Edge BoostFlowProfileGraph::addEdge(const TransactionId t1, + const TransactionId t2, + const edouble capacity, + const edouble reverseCapacity) { + debugMsg("BoostFlowProfileGraph:addEdge", + (isLowerLevel() ? "" : "") << t1 << " -> " << t2 << " [" << + capacity << "]"); + debugMsg("BoostFlowProfileGraph:addEdge", + (isLowerLevel() ? "" : "") << t2 << " -> " << t1 << " [" << + reverseCapacity << "]"); + + using namespace boost; + property_map::type rev = get(edge_reverse, m_graph); + Vertex v1 = getNode(t1); + Vertex v2 = getNode(t2); + + std::pair found = edge(v1, v2, m_graph); + if(found.second == true) + return found.first; + Edge e1 = add_edge(v1, v2, m_graph).first; + Edge e2 = add_edge(v2, v1, m_graph).first; + + + put(edge_capacity, m_graph, e1, cast_basis(capacity)); + put(edge_capacity, m_graph, e2, cast_basis(reverseCapacity)); + + debugMsg("BoostFlowProfileGraph:addEdge", + (isLowerLevel() ? "" : "") << e1 << " [" << + get(edge_capacity, m_graph, e1) << "]"); + debugMsg("BoostFlowProfileGraph:addEdge", + (isLowerLevel() ? "" : "") << e2 << " [" << + get(edge_capacity, m_graph, e2) << "]"); + + rev[e1] = e2; + rev[e2] = e1; + return e1; +} + +void BoostFlowProfileGraph::enableAt(const TransactionId t1, const TransactionId t2) { + if(m_transactionToVertex.find(t1) == m_transactionToVertex.end() || + m_transactionToVertex.find(t2) == m_transactionToVertex.end()) + return; + m_recalculate = true; + addEdge(t1, t2, PLUS_INFINITY, PLUS_INFINITY); +} + +void BoostFlowProfileGraph::enableAtOrBefore(const TransactionId t1, + const TransactionId t2) { + if(m_transactionToVertex.find(t1) == m_transactionToVertex.end() || + m_transactionToVertex.find(t2) == m_transactionToVertex.end()) + return; + m_recalculate = true; + addEdge(t1, t2, 0, PLUS_INFINITY); +} + +void BoostFlowProfileGraph::disable(const TransactionId transaction) { + std::vector::iterator it = + std::find(m_activeTransactions.begin(), m_activeTransactions.end(), transaction); + if(it != m_activeTransactions.end()) + m_activeTransactions.erase(it); +} + +void BoostFlowProfileGraph::addTransactionToGraph(const TransactionId t) { + if(t == getTransaction(m_sink) || t == getTransaction(m_source)) + return; + debugMsg("BoostFlowProfileGraph:addTransactionToGraph", + (isLowerLevel() ? "" : "") << "Adding " << t); + + edouble edgeCapacity = 0.0; + TransactionId source, target; + + if(isLowerLevel() == t->isConsumer()) { + source = getTransaction(m_source); + target = t; + edgeCapacity = t->quantity()->lastDomain().getUpperBound(); + } + else { + source = t; + target = getTransaction(m_sink); + edgeCapacity = t->quantity()->lastDomain().getLowerBound(); + } + + check_error(source != TransactionId::noId()); + check_error(target != TransactionId::noId()); + + addNode(t); + addEdge(source, target, edgeCapacity, 0.0); +} + +void BoostFlowProfileGraph::enableTransaction(const TransactionId t, + const InstantId inst, + TransactionId2InstantId ) { + debugMsg("BoostFlowProfileGraph:enableTransaction", + (isLowerLevel() ? "" : "") << "Enabling " << + (t->isConsumer() ? "consumer " : "producer ") << t << "" << t->toString() << + " at " << inst->getTime()); + + // edouble edgeCapacity = 0.0; + + if(std::find(m_activeTransactions.begin(), m_activeTransactions.end(), t) == + m_activeTransactions.end()) { + m_activeTransactions.push_back(t); + } + m_recalculate = true; +} + +edouble BoostFlowProfileGraph::getResidualFromSource(const TransactionIdTransactionIdPair2Order& at, + const TransactionIdTransactionIdPair2Order& other) { + using namespace boost; + reset(); + for(std::vector::const_iterator it = m_activeTransactions.begin(); + it != m_activeTransactions.end(); ++it) { + addTransactionToGraph(*it); + } + for(TransactionIdTransactionIdPair2Order::const_iterator it = at.begin(); + it != at.end(); ++it) { + enableAt(it->first.first, it->first.second); + } + for(TransactionIdTransactionIdPair2Order::const_iterator it = other.begin(); + it != other.end(); ++it) { + debugMsg("BoostFlowProfileGraph:getResidualFromSource", + it->first.first << + (it->second == AFTER_OR_AT ? " after-or-at " : + (it->second == BEFORE_OR_AT ? " before-or-at " : + (it->second == NOT_ORDERED ? " unordered " : + (it->second == STRICTLY_AT ? " at " : " unknown ")))) << + it->first.second); + switch(it->second) { + case AFTER_OR_AT: + enableAtOrBefore(it->first.second, it->first.first); + break; + case BEFORE_OR_AT: + enableAtOrBefore(it->first.first, it->first.second); + case NOT_ORDERED: + break; + case STRICTLY_AT: + enableAt(it->first.first, it->first.second); + case UNKNOWN: + break; + } + } + return getResidualFromSource(); +} + +edouble BoostFlowProfileGraph::getResidualFromSource() { + using namespace boost; + debugMsg("BoostFlowProfileGraph:getResidualFromSource", + (isLowerLevel() ? "" : "") << "Getting residual..."); + edouble residual = 0.0; + if(num_vertices(m_graph) <= 2) { + m_recalculate = false; + return residual; + } + if(m_recalculate) { + double flow = boykov_kolmogorov_max_flow(m_graph, m_source, m_sink); + debugMsg("BoostFlowProfileGraph:getResidualFromSource", "Total flow: " << flow); + property_map::type flowMap = get(edge_flow, m_graph); + property_map::type capcityMap = get(edge_capacity, m_graph); + Graph::edge_iterator it, end; + for(tie(it, end) = edges(m_graph); it != end; ++it) { + debugMsg("BoostFlowProfileGraph:getResidualFromSource", + getTransaction(source(*it, m_graph)) << " -> " << + getTransaction(target(*it, m_graph)) << + " [" << flowMap[*it] << ":" << capcityMap[*it] << "]"); + } + m_recalculate = false; + } + property_map::type + residualCapacity = get(edge_residual_capacity, m_graph); + Graph::out_edge_iterator outIt, outEnd; + tie(outIt, outEnd) = out_edges(m_source, m_graph); + for(; outIt != outEnd; ++outIt) { + residual += residualCapacity[*outIt]; + debugMsg("BoostFlowProfileGraph:getResidualFromSource", + getTransaction(source(*outIt, m_graph)) << " -> " << + getTransaction(target(*outIt, m_graph)) << + " [" << residualCapacity[*outIt] << "]: " << residual); + } + + return residual; +} + +void BoostFlowProfileGraph::removeTransaction(const TransactionId id) { + using namespace boost; + debugMsg("BoostFlowProfileGraph:removeTransaction", + (isLowerLevel() ? "" : "") << "Removing " << id); + disable(id); + m_recalculate = true; +} + +void BoostFlowProfileGraph::reset() { + initializeGraph(getTransaction(m_source), getTransaction(m_sink)); +} + +} + diff --git a/src/PLASMA/Resource/component/BoostFlowProfileGraph.hh b/src/PLASMA/Resource/component/BoostFlowProfileGraph.hh new file mode 100644 index 000000000..0396169c8 --- /dev/null +++ b/src/PLASMA/Resource/component/BoostFlowProfileGraph.hh @@ -0,0 +1,159 @@ +#ifndef H_BoostFlowProfileGraph +#define H_BoostFlowProfileGraph + +#include "FlowProfileGraph.hh" +#include "Types.hh" + +#include +#include + +#include +#include +#include + +namespace EUROPA { +class BoostFlowProfileGraph : public FlowProfileGraph { + public: + /** + * @brief Creates a directed graph with a a source and a sink intended to calculate the + * lower level envelope in case a lowerLevel is true otherwise intended to calculate the + * upper level envelope. + */ + BoostFlowProfileGraph(const TransactionId source, const TransactionId sink, bool lowerLevel); + /** + * @brief Destructor + */ + ~BoostFlowProfileGraph() {} + /** + * @brief Creates bi-directional edge between \a t1 and \a t2 with infinite capacity + * as a result of a concurrent constraint between the two transactions + */ + void enableAt(const TransactionId t1, const TransactionId t2); + /** + * @brief Creates directed edge between \a t1 and \a t2 with infinite capacity + * as a result of a before or at constraint between the two transactions (reverse + * capacity set to zero) + */ + void enableAtOrBefore(const TransactionId t1, const TransactionId t2); + /** + * @brief Creates a node in the network and creates an edge: + * + * \verbatim + * | lower level | upper level + * --------------------------------------------------------------------------------------------------------- + * transaction is consumer | w = q.upper | w = q.lower + * --------------------------------------------------------------------------------------------------------- + * transaction is producer | w = q.lower | w = q.upper + * --------------------------------------------------------------------------------------------------------- + * \endverbatim + */ + void enableTransaction(const TransactionId transaction, const InstantId inst, + TransactionId2InstantId contributions); + /** + * @brief Returns true if \a transaction is enabled in the invoking + * instance + */ + bool isEnabled(const TransactionId ) const {return true;} + /** + * @brief Disables \a transaction, if enabled, for the invoking instance + */ + void disable( const TransactionId transaction ); + /** + * @brief Will push any flow wich flows through the node corresponding with \a transaction + * back to the source of the edge the flow originates from. + * + * When we move from one instant to another we retract all the transactions whose end time + * is equal to the new instant time and the transaction is still in the network. This method + * will push any flow going through this node back to where it is coming from after which we + * try again to push the flow to the sink. + + * Will error out if no node corresponding to \a transaction is in the network or if the node + * is not enabled. + * + * If a recalculation of the maximum flow is required this method will do nothing. + * \todo verify if this is really required or perhaps we should error out? + */ + void pushFlow( const TransactionId ) {return;} + /** + * @brief Returns the cummulative residual capacity originating from the source. + * + * Iterates over all outgoing edges from the source and sums the residual capicity of each + * edge. Might trigger a maximum flow (re) calculation if required. + */ + edouble getResidualFromSource(); + edouble getResidualFromSource(const TransactionIdTransactionIdPair2Order& at, + const TransactionIdTransactionIdPair2Order& other); + + /** + * @brief Disables every node reachable from the source in the residual network. Returns the sum + * of the contribution of each disabled node. The contribution is determined as following: + * \verbatim + * | lower level | upper level + * --------------------------------------------------------------------------------------------------------- + * transaction is consumer | q.upper | q.lower + * --------------------------------------------------------------------------------------------------------- + * transaction is producer | q.lower | q.upper + * --------------------------------------------------------------------------------------------------------- + * \endverbatim + * + * where q is the quantity variable associated with the transactions associated with the node. The parameter \a + * contributions, which maps a TransactionId to a InstantId is maps every transaction associated with a disabled + * node to \a instant. + */ + edouble disableReachableResidualGraph( TransactionId2InstantId, const InstantId ) {return 0.0;} + /** + * @brief Removes transaction \a id from the network. + */ + void removeTransaction(const TransactionId id); + /** + * @brief Resets the invoking instance. + * + * Resetting entails disabling all the nodes, implying disabling all the edges, except for the + * source and the sink. + * + */ + void reset(); + /** + * @brief Restore flow invokes the maximum flow algorithm without resetting the existing distances + * and existing flows on the nodes. + * + * Restore flows is done after extracting all the nodes that expire (go from pending to closed set + * at an instant) from the network by pushing flow back. + */ + void restoreFlow() {} + private: + + typedef boost::adjacency_list_traits Traits; + // typedef boost::adjacency_list_traits Traits; + typedef Traits::vertex_descriptor Vertex; + typedef Traits::edge_descriptor Edge; + typedef boost::adjacency_list > > >, + + boost::property > > > > Graph; + + // do these need to return references? + Vertex addNode(const TransactionId t); + Vertex getNode(const TransactionId t) const; + TransactionId getTransaction(const Vertex& v) const; + Edge addEdge(const TransactionId t1, const TransactionId t2, const edouble capacity, + const edouble reverseCapacity); + void initializeGraph(const TransactionId source, const TransactionId sink); + void addTransactionToGraph(const TransactionId t); + + Graph m_graph; + std::map m_transactionToVertex; + std::map m_vertexToTransaction; + std::vector m_activeTransactions; + Vertex m_source, m_sink; + bool m_recalculate; +}; +} +#endif diff --git a/src/PLASMA/Resource/component/ClosedWorldFVDetector.cc b/src/PLASMA/Resource/component/ClosedWorldFVDetector.cc index 94faaa96e..4267e5d58 100644 --- a/src/PLASMA/Resource/component/ClosedWorldFVDetector.cc +++ b/src/PLASMA/Resource/component/ClosedWorldFVDetector.cc @@ -7,12 +7,12 @@ ClosedWorldFVDetector::ClosedWorldFVDetector(const ResourceId res) { } -void ClosedWorldFVDetector::getFDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const +void ClosedWorldFVDetector::getFDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const { getDefaultLevelBounds(inst,lb,ub); } -void ClosedWorldFVDetector::getVDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const +void ClosedWorldFVDetector::getVDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const { getDefaultLevelBounds(inst,lb,ub); } diff --git a/src/PLASMA/Resource/component/ClosedWorldFVDetector.hh b/src/PLASMA/Resource/component/ClosedWorldFVDetector.hh index f8acac7be..1db73373a 100644 --- a/src/PLASMA/Resource/component/ClosedWorldFVDetector.hh +++ b/src/PLASMA/Resource/component/ClosedWorldFVDetector.hh @@ -1,5 +1,5 @@ -#ifndef _H_ClosedWorldFVDetector -#define _H_ClosedWorldFVDetector +#ifndef H_ClosedWorldFVDetector +#define H_ClosedWorldFVDetector #include "GenericFVDetector.hh" namespace EUROPA { @@ -9,8 +9,8 @@ namespace EUROPA { ClosedWorldFVDetector(const ResourceId res); protected: - virtual void getFDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const; // Level Bounds for FlawDetection - virtual void getVDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const; // Level Bounds for ViolationDetection + virtual void getFDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const; // Level Bounds for FlawDetection + virtual void getVDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const; // Level Bounds for ViolationDetection }; } diff --git a/src/PLASMA/Resource/component/DurativeTokens.cc b/src/PLASMA/Resource/component/DurativeTokens.cc index 1756b7583..366d0170e 100644 --- a/src/PLASMA/Resource/component/DurativeTokens.cc +++ b/src/PLASMA/Resource/component/DurativeTokens.cc @@ -3,110 +3,123 @@ #include "ResourceTokenRelation.hh" namespace EUROPA { - ReusableToken::ReusableToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReusableToken::ReusableToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain, const IntervalIntDomain& endBaseDomain, const IntervalIntDomain& durationBaseDomain, const IntervalDomain& quantityBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed, - bool activate) - : IntervalToken(planDatabase, predicateName, false, false, startBaseDomain, endBaseDomain, durationBaseDomain, - objectName, false) { - check_error(quantityBaseDomain.getLowerBound() >= 0 && quantityBaseDomain.getUpperBound() <= PLUS_INFINITY); - commonInit(closed, activate, quantityBaseDomain); + bool _activate) + : IntervalToken(planDatabase, predicateName, false, false, startBaseDomain, + endBaseDomain, durationBaseDomain, objectName, false), + m_quantity(), m_activate(_activate) { + check_error(quantityBaseDomain.getLowerBound() >= 0 && + quantityBaseDomain.getUpperBound() <= PLUS_INFINITY); + commonInit(closed, _activate, quantityBaseDomain); } - ReusableToken::ReusableToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReusableToken::ReusableToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain, const IntervalIntDomain& endBaseDomain, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed, - bool activate) - : IntervalToken(planDatabase, predicateName, false, false, startBaseDomain, endBaseDomain, durationBaseDomain, objectName, false) { - commonInit(closed, activate, IntervalDomain(0, PLUS_INFINITY)); + bool _activate) + : IntervalToken(planDatabase, predicateName, false, false, startBaseDomain, + endBaseDomain, durationBaseDomain, objectName, false), + m_quantity(), m_activate(_activate) { + commonInit(closed, _activate, IntervalDomain(0, PLUS_INFINITY)); } - ReusableToken::ReusableToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const IntervalDomain& quantityBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate) - : IntervalToken(planDatabase, predicateName, rejectable, isFact, startBaseDomain, endBaseDomain, durationBaseDomain, - objectName, false) { - check_error(quantityBaseDomain.getLowerBound() >= 0 && quantityBaseDomain.getUpperBound() <= PLUS_INFINITY); - commonInit(closed, activate, quantityBaseDomain); - } +ReusableToken::ReusableToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const IntervalDomain& quantityBaseDomain, + const std::string& objectName, + bool closed, + bool _activate) +: IntervalToken(planDatabase, predicateName, rejectable, _isFact, startBaseDomain, + endBaseDomain, durationBaseDomain, objectName, false), + m_quantity(), m_activate(_activate) { + check_error(quantityBaseDomain.getLowerBound() >= 0 && + quantityBaseDomain.getUpperBound() <= PLUS_INFINITY); + commonInit(closed, _activate, quantityBaseDomain); +} - ReusableToken::ReusableToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate) - : IntervalToken(planDatabase, predicateName, rejectable, isFact, startBaseDomain, endBaseDomain, durationBaseDomain, objectName, false) { - commonInit(closed, activate, IntervalDomain(0, PLUS_INFINITY)); - } +ReusableToken::ReusableToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const std::string& objectName, + bool closed, + bool _activate) +: IntervalToken(planDatabase, predicateName, rejectable, _isFact, startBaseDomain, + endBaseDomain, durationBaseDomain, objectName, false), + m_quantity(), m_activate(_activate) { + commonInit(closed, _activate, IntervalDomain(0, PLUS_INFINITY)); +} - ReusableToken::ReusableToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate) - : IntervalToken(master, relation, predicateName, startBaseDomain, endBaseDomain, durationBaseDomain, objectName, false) { - commonInit(closed, activate, IntervalDomain(0, PLUS_INFINITY)); - } +ReusableToken::ReusableToken(const TokenId _master, + const std::string& relation, + const std::string& predicateName, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const std::string& objectName, + bool closed, + bool _activate) + : IntervalToken(_master, relation, predicateName, startBaseDomain, endBaseDomain, + durationBaseDomain, objectName, false), + m_quantity(), m_activate(_activate) { + commonInit(closed, _activate, IntervalDomain(0, PLUS_INFINITY)); +} - ReusableToken::ReusableToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const IntervalDomain& quantityBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate) - : IntervalToken(master, relation, predicateName, startBaseDomain, endBaseDomain, durationBaseDomain, objectName, false) { - commonInit(closed, activate, quantityBaseDomain); - } +ReusableToken::ReusableToken(const TokenId _master, + const std::string& relation, + const std::string& predicateName, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const IntervalDomain& quantityBaseDomain, + const std::string& objectName, + bool closed, + bool _activate) +: IntervalToken(_master, relation, predicateName, startBaseDomain, endBaseDomain, + durationBaseDomain, objectName, false), + m_quantity(), m_activate(_activate) { + commonInit(closed, _activate, quantityBaseDomain); +} - void ReusableToken::commonInit(bool closed, bool activate, const IntervalDomain& quantityBaseDomain) { - m_activate = activate; - if(activate) { - StateDomain restrictDomain; - restrictDomain.insert(Token::ACTIVE); - m_state->restrictBaseDomain(restrictDomain); - } - m_quantity = (new TokenVariable(m_id, m_allVariables.size(), - m_planDatabase->getConstraintEngine(), - quantityBaseDomain, - false, true, LabelStr("quantity")))->getId(); - m_allVariables.push_back(m_quantity); - ConstraintId relation = (new ResourceTokenRelation(m_planDatabase->getConstraintEngine(), - makeScope(m_state, m_object), - getId()))->getId(); - m_standardConstraints.insert(relation); - if(closed) - close(); - } +void ReusableToken::commonInit(bool closed, bool _activate, + const IntervalDomain& quantityBaseDomain) { + m_activate = _activate; + if(_activate) { + StateDomain restrictDomain; + restrictDomain.insert(Token::ACTIVE); + m_state->restrictBaseDomain(restrictDomain); + } + m_quantity = (new TokenVariable(m_id, m_allVariables.size(), + m_planDatabase->getConstraintEngine(), + quantityBaseDomain, + false, true, "quantity"))->getId(); + m_allVariables.push_back(m_quantity); + ConstraintId relation = (new ResourceTokenRelation(m_planDatabase->getConstraintEngine(), + makeScope(m_state, m_object), + getId()))->getId(); + m_standardConstraints.insert(relation); + if(closed) + close(); +} void ReusableToken::close() { IntervalToken::close(); @@ -114,40 +127,46 @@ namespace EUROPA { activateInternal(); } - const ConstrainedVariableId& ReusableToken::getQuantity() const { + const ConstrainedVariableId ReusableToken::getQuantity() const { return m_quantity; } - UnaryToken::UnaryToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate) - : ReusableToken(planDatabase, predicateName, startBaseDomain, endBaseDomain, durationBaseDomain, IntervalDomain(1), objectName, closed, activate) {} +UnaryToken::UnaryToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const std::string& objectName, + bool closed, + bool _activate) + : ReusableToken(planDatabase, predicateName, startBaseDomain, endBaseDomain, + durationBaseDomain, IntervalDomain(1), objectName, closed, + _activate) {} - UnaryToken::UnaryToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate) - : ReusableToken(planDatabase, predicateName, rejectable, isFact, startBaseDomain, endBaseDomain, durationBaseDomain, IntervalDomain(1), objectName, closed, activate) {} +UnaryToken::UnaryToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const std::string& objectName, + bool closed, + bool _activate) + : ReusableToken(planDatabase, predicateName, rejectable, _isFact, startBaseDomain, + endBaseDomain, durationBaseDomain, IntervalDomain(1), objectName, + closed, _activate) {} - UnaryToken::UnaryToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, - const IntervalIntDomain& startBaseDomain, - const IntervalIntDomain& endBaseDomain, - const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate) - : ReusableToken(master, relation, predicateName, startBaseDomain, endBaseDomain, durationBaseDomain, IntervalDomain(1), objectName, closed, activate) {} +UnaryToken::UnaryToken(const TokenId _master, + const std::string& relation, + const std::string& predicateName, + const IntervalIntDomain& startBaseDomain, + const IntervalIntDomain& endBaseDomain, + const IntervalIntDomain& durationBaseDomain, + const std::string& objectName, + bool closed, + bool _activate) + : ReusableToken(_master, relation, predicateName, startBaseDomain, endBaseDomain, + durationBaseDomain, IntervalDomain(1), objectName, closed, + _activate) {} } diff --git a/src/PLASMA/Resource/component/DurativeTokens.hh b/src/PLASMA/Resource/component/DurativeTokens.hh index 7e95102ac..d8bf73a42 100644 --- a/src/PLASMA/Resource/component/DurativeTokens.hh +++ b/src/PLASMA/Resource/component/DurativeTokens.hh @@ -1,5 +1,5 @@ -#ifndef _H_DurativeTokens -#define _H_DurativeTokens +#ifndef H_DurativeTokens +#define H_DurativeTokens #include "ResourceDefs.hh" #include "EventToken.hh" @@ -7,70 +7,70 @@ namespace EUROPA { class ReusableToken : public IntervalToken { public: - ReusableToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReusableToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain = IntervalIntDomain(), const IntervalIntDomain& endBaseDomain = IntervalIntDomain(), const IntervalIntDomain& durationBaseDomain = IntervalIntDomain(1, PLUS_INFINITY), const IntervalDomain& quantityBaseDomain = IntervalDomain(0, PLUS_INFINITY), - const LabelStr& objectName = Token::noObject(), + const std::string& objectName = Token::noObject(), bool closed = true, bool activate = true); - ReusableToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReusableToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain, const IntervalIntDomain& endBaseDomain, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed, bool activate = true); - ReusableToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, + ReusableToken(const TokenId master, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain, const IntervalIntDomain& endBaseDomain, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed, bool activate = true); - ReusableToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, + ReusableToken(const TokenId master, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain, const IntervalIntDomain& endBaseDomain, const IntervalIntDomain& durationBaseDomain, const IntervalDomain& quantityBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed, bool activate = true); - ReusableToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReusableToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, const IntervalIntDomain& startBaseDomain = IntervalIntDomain(), const IntervalIntDomain& endBaseDomain = IntervalIntDomain(), const IntervalIntDomain& durationBaseDomain = IntervalIntDomain(1, PLUS_INFINITY), const IntervalDomain& quantityBaseDomain = IntervalDomain(0, PLUS_INFINITY), - const LabelStr& objectName = Token::noObject(), + const std::string& objectName = Token::noObject(), bool closed = true, bool activate = true); - ReusableToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReusableToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, const IntervalIntDomain& startBaseDomain, const IntervalIntDomain& endBaseDomain, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed, bool activate = true); - const ConstrainedVariableId& getQuantity() const; + const ConstrainedVariableId getQuantity() const; void print(std::ostream& os); virtual void close(); protected: @@ -81,33 +81,33 @@ namespace EUROPA { class UnaryToken : public ReusableToken { public: - UnaryToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + UnaryToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain = IntervalIntDomain(), const IntervalIntDomain& endBaseDomain = IntervalIntDomain(), const IntervalIntDomain& durationBaseDomain = IntervalIntDomain(1, PLUS_INFINITY), - const LabelStr& objectName = Token::noObject(), + const std::string& objectName = Token::noObject(), bool closed = true, bool activate = true); - UnaryToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + UnaryToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, const IntervalIntDomain& startBaseDomain = IntervalIntDomain(), const IntervalIntDomain& endBaseDomain = IntervalIntDomain(), const IntervalIntDomain& durationBaseDomain = IntervalIntDomain(1, PLUS_INFINITY), - const LabelStr& objectName = Token::noObject(), + const std::string& objectName = Token::noObject(), bool closed = true, bool activate = true); - UnaryToken(const TokenId& master, - const LabelStr& relation, - const LabelStr& predicateName, + UnaryToken(const TokenId master, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& startBaseDomain, const IntervalIntDomain& endBaseDomain, const IntervalIntDomain& durationBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool closed, bool activate = true); }; diff --git a/src/PLASMA/Resource/component/Edge.cc b/src/PLASMA/Resource/component/Edge.cc index 4dbaef581..a43811ad7 100644 --- a/src/PLASMA/Resource/component/Edge.cc +++ b/src/PLASMA/Resource/component/Edge.cc @@ -72,8 +72,9 @@ namespace EUROPA std::ostream& operator<<( std::ostream& os, const Edge& fe ) { + std::ios::fmtflags f(os.flags()); os << fe.getIdentity() << " {" << fe.getCapacity() << "} (enabled: " << std::boolalpha << fe.isEnabled() << ")"; - + os.flags(f); return os; } } diff --git a/src/PLASMA/Resource/component/Edge.hh b/src/PLASMA/Resource/component/Edge.hh index 143102c97..87fef1f09 100644 --- a/src/PLASMA/Resource/component/Edge.hh +++ b/src/PLASMA/Resource/component/Edge.hh @@ -14,90 +14,89 @@ namespace EUROPA { - class Edge - { - friend class Graph; - friend class Node; - public: - /** - * @brief Constructor - * @arg source - * @arg target - * @arg capacity - * @arg enabled - * - */ - Edge( Node* source, Node* target, edouble capacity, bool enabled = true ); - /** - * @brief Destructor - * - */ - ~Edge(); - /*! - * @brief Returns the maximum capacity of an Edge (infinity) - */ - static edouble getMaxCapacity(); - /** - * @brief Returns the capacity of the invoking edge - * - */ - inline edouble getCapacity() const; - /** - * @brief Sets the capacity of the invoking edge - * @arg cap The new capacity of the invoking edge - * - */ - inline void setCapacity( edouble cap ); - /** - * @brief Returns the source of the invoking edge - * - */ - inline Node* getSource() const; - /** - * @brief Returns the target of the invoking edge - */ - inline Node* getTarget() const; - /** - * @brief Enables the invoking edge - * - */ - void setEnabled(); - /** - * @brief Disables the invoking edge - * - */ - void setDisabled(); - /** - * @brief Returns true of the invoking edge is enabled otherwise returns false - * - */ - inline bool isEnabled() const; - /** - * @brief Returns the identity of the invoking edge - * - */ - EdgeIdentity getIdentity() const; - /** - * @brief Creates a unique identity for an edge going from \a source to \a target - * @arg source Source of the edge - * @arg target Target of the edge - * @par: Errors: - * @li source equals 0 - * @li target equals 0 - */ - static EdgeIdentity getIdentity( Node* source, Node* target ); - private: +class Edge { +private: + Edge(const Edge&); + Edge& operator=(const Edge&); + friend class Graph; + friend class Node; + public: + /** + * @brief Constructor + * @arg source + * @arg target + * @arg capacity + * @arg enabled + * + */ + Edge( Node* source, Node* target, edouble capacity, bool enabled = true ); + /** + * @brief Destructor + * + */ + ~Edge(); + /*! + * @brief Returns the maximum capacity of an Edge (infinity) + */ + static edouble getMaxCapacity(); + /** + * @brief Returns the capacity of the invoking edge + * + */ + inline edouble getCapacity() const; + /** + * @brief Sets the capacity of the invoking edge + * @arg cap The new capacity of the invoking edge + * + */ + inline void setCapacity( edouble cap ); + /** + * @brief Returns the source of the invoking edge + * + */ + inline Node* getSource() const; + /** + * @brief Returns the target of the invoking edge + */ + inline Node* getTarget() const; + /** + * @brief Enables the invoking edge + * + */ + void setEnabled(); + /** + * @brief Disables the invoking edge + * + */ + void setDisabled(); + /** + * @brief Returns true of the invoking edge is enabled otherwise returns false + * + */ + inline bool isEnabled() const; + /** + * @brief Returns the identity of the invoking edge + * + */ + EdgeIdentity getIdentity() const; + /** + * @brief Creates a unique identity for an edge going from \a source to \a target + * @arg source Source of the edge + * @arg target Target of the edge + * @par: Errors: + * @li source equals 0 + * @li target equals 0 + */ + static EdgeIdentity getIdentity( Node* source, Node* target ); + private: - edouble m_Capacity; - bool m_Enabled; + edouble m_Capacity; + bool m_Enabled; - Node* m_Source; - Node* m_Target; - }; + Node* m_Source; + Node* m_Target; +}; - /** - * @brief - */ std::ostream& operator<<( std::ostream& os, const Edge& fe ); edouble Edge::getCapacity() const diff --git a/src/PLASMA/Resource/component/EdgeIterator.hh b/src/PLASMA/Resource/component/EdgeIterator.hh index 8b81242fb..4c008a287 100644 --- a/src/PLASMA/Resource/component/EdgeIterator.hh +++ b/src/PLASMA/Resource/component/EdgeIterator.hh @@ -1,5 +1,5 @@ -#ifndef _EDGE_ITERATOR_HEADER_ -#define _EDGE_ITERATOR_HEADER_ +#ifndef EDGE_ITERATOR_HEADER_ +#define EDGE_ITERATOR_HEADER_ /** * @file EdgeIterator.hh @@ -14,24 +14,15 @@ namespace EUROPA { - /** - * @brief - */ class EdgeIterator { public: - /** - * @brief - */ inline bool ok() const; - /** - * @brief - */ inline Edge* operator*() const; protected: /** - * @brief - * @par edges + * @brief Edge iterator + * @par edges The edges to iterate over * @par mustBeEnabled If true iterates over enabled edges otherwise iterates over all edges */ EdgeIterator( const EdgeList& edges, bool mustBeEnabled ): @@ -59,17 +50,13 @@ namespace EUROPA return 0; } - - /** - * @brief - */ class EdgeOutIterator: public EdgeIterator { public: /** - * @brief - * @par node + * @brief Out edge iterator + * @par node The node to iterate from * @par mustBeEnabled If true iterates over enabled edges otherwise iterates over all edges */ EdgeOutIterator( const Node& node, bool mustBeEnabled = true ): @@ -82,7 +69,7 @@ namespace EUROPA } } - void operator++() + EdgeOutIterator& operator++() { ++m_Iterator; @@ -91,20 +78,18 @@ namespace EUROPA while( m_Iterator != m_End && ( !(*m_Iterator)->isEnabled() || !(*m_Iterator)->getTarget()->isEnabled() ) ) ++m_Iterator; } + return *this; } }; - /** - * @brief - */ class EdgeInIterator: public EdgeIterator { public: /** - * @brief - * @par node + * @brief In-edge iterator + * @par node The node to iterate from * @par mustBeEnabled If true iterates over enabled edges otherwise iterates over all edges */ EdgeInIterator( const Node& node, bool mustBeEnabled = true ): @@ -117,7 +102,7 @@ namespace EUROPA } } - void operator++() + EdgeInIterator& operator++() { ++m_Iterator; @@ -126,6 +111,7 @@ namespace EUROPA while( m_Iterator != m_End && ( !(*m_Iterator)->isEnabled() || !(*m_Iterator)->getSource()->isEnabled() ) ) ++m_Iterator; } + return *this; } }; diff --git a/src/PLASMA/Resource/component/FlowProfile.cc b/src/PLASMA/Resource/component/FlowProfile.cc index 9c9ff0c4c..29f4bd4ec 100644 --- a/src/PLASMA/Resource/component/FlowProfile.cc +++ b/src/PLASMA/Resource/component/FlowProfile.cc @@ -16,6 +16,7 @@ #include "Debug.hh" #include "Domains.hh" #include "FlowProfile.hh" +#include "FlowProfileGraph.hh" #include "Graph.hh" #include "Instant.hh" #include "Node.hh" @@ -27,250 +28,45 @@ #include "Utils.hh" #include "Variable.hh" -namespace EUROPA -{ - FlowProfileGraph::FlowProfileGraph( const TransactionId& source, const TransactionId& sink, bool lowerlevel ): - m_lowerLevel( lowerlevel ), - m_recalculate( false ), - m_graph( 0 ), - m_source( 0 ), - m_sink( 0 ) - { - m_graph = new Graph(); - m_source = m_graph->createNode( source ); - m_sink = m_graph->createNode( sink ); - m_maxflow = new MaximumFlowAlgorithm( m_graph, m_source, m_sink ); - } - - FlowProfileGraph::~FlowProfileGraph() - { - delete m_maxflow; - m_maxflow = 0; - - delete m_graph; - m_graph = 0; - - m_source = 0; - m_sink = 0; - } - - void FlowProfileGraph::enableAt( const TransactionId& t1, const TransactionId& t2 ) - { - debugMsg("FlowProfileGraph:enableAt","Transaction " - << t1->time()->toString() << " and transaction " - << t2->time()->toString() << " lower level: " - << std::boolalpha << m_lowerLevel ); - - - if( 0 == m_graph->getNode( t1 ) ) - return; - - if( 0 == m_graph->getNode( t2 ) ) - return; - - m_recalculate = true; - - m_graph->createEdge( t1, t2, Edge::getMaxCapacity() ); - m_graph->createEdge( t2, t1, Edge::getMaxCapacity() ); - } - - void FlowProfileGraph::enableAtOrBefore( const TransactionId& t1, const TransactionId& t2 ) - { - debugMsg("FlowProfileGraph:enableAtOrBefore","Transaction " - << t1->time()->toString() << " and transaction " - << t2->time()->toString() << " lower level: " - << std::boolalpha << m_lowerLevel ); - - - if( 0 == m_graph->getNode( t1 ) ) - return; - - if( 0 == m_graph->getNode( t2 ) ) - return; - - m_recalculate = true; - - m_graph->createEdge( t1, t2, 0 ); - m_graph->createEdge( t2, t1, Edge::getMaxCapacity() ); - } - - bool FlowProfileGraph::isEnabled( const TransactionId& transaction ) const - { - Node* node = m_graph->getNode( transaction ); - - return 0 == node ? false : node->isEnabled(); - } - - void FlowProfileGraph::enableTransaction( const TransactionId& t, const InstantId& i, TransactionId2InstantId& contributions ) - { - debugMsg("FlowProfileGraph:enableTransaction","Transaction (" - << t->getId() << ") " - << t->time()->toString() << " lower level: " - << std::boolalpha << m_lowerLevel ); - - TransactionId source = TransactionId::noId(); - TransactionId target = TransactionId::noId(); - - edouble edgeCapacity = 0; - - if( ( m_lowerLevel && t->isConsumer() ) - || - (!m_lowerLevel && !t->isConsumer() ) ) - { - // connect to the source of the graph - source = m_source->getIdentity(); - target = t; - - edgeCapacity = t->quantity()->lastDomain().getUpperBound(); - } - else - { - // connect to the sink of the graph - source = t; - target = m_sink->getIdentity(); - - edgeCapacity = t->quantity()->lastDomain().getLowerBound(); - } - - if( 0 == edgeCapacity ) - { - debugMsg("FlowProfileGraph:enableTransaction","Transaction " - << t << " starts contributing at " - << i->getTime() << " lower level " << std::boolalpha << m_lowerLevel ); - - contributions[ t ] = i; - - return; - } - - check_error( TransactionId::noId() != source ); - check_error( TransactionId::noId() != target ); - - m_recalculate = true; - - m_graph->createNode( t, true ); - m_graph->createEdge( source, target, edgeCapacity ); - m_graph->createEdge( target, source, 0 ); - } - - void FlowProfileGraph::removeTransaction( const TransactionId& id ) - { - debugMsg("FlowProfileGraph:removeTransaction","Transaction (" - << id->getId() << ") lower level: " - << std::boolalpha << m_lowerLevel ); - - m_recalculate = true; - - m_graph->removeNode( id ); - } - - void FlowProfileGraph::reset() - { - m_recalculate = true; - - m_graph->setDisabled(); - - m_sink->setEnabled(); - m_source->setEnabled(); - } - - - edouble FlowProfileGraph::getResidualFromSource() - { - edouble residual = 0.0; - - if( m_recalculate ) - { - m_maxflow->execute(); - - m_recalculate = false; - } - - EdgeOutIterator ite( *m_source ); - - for( ; ite.ok(); ++ite ) - { - Edge* edge = *ite; - - residual += m_maxflow->getResidual( edge ); - } - - return residual; - } - - void FlowProfileGraph::disable( const TransactionId& id ) - { - debugMsg("FlowProfileGraph:disable","Transaction (" - << id->getId() << ") lower level: " - << std::boolalpha << m_lowerLevel ); - - Node* node = m_graph->getNode( id ); - - check_error( 0 != node ); - check_error( node->isEnabled() ); - - node->setDisabled(); - } - - void FlowProfileGraph::pushFlow( const TransactionId& id ) - { - Node* node = m_graph->getNode( id ); - - check_error( 0 != node ); - check_error( node->isEnabled() ); - - if( !m_recalculate ) - { - debugMsg("FlowProfileGraph:pushFlow","Transaction (" - << id->getId() << ") lower level: " - << std::boolalpha << m_lowerLevel ); - - m_maxflow->pushFlowBack( node ); - } - else - { - debugMsg("FlowProfileGraph:pushFlow","Transaction (" - << id->getId() << ") lower level: " - << std::boolalpha << m_lowerLevel - << " skipping pushing flow back because a recalculation is required."); - - } - } - - void FlowProfileGraph::restoreFlow() - { - m_maxflow->execute( false ); - } - - - +namespace EUROPA { //------------------------------- - FlowProfile::FlowProfile( const PlanDatabaseId db, const FVDetectorId flawDetector): - Profile( db, flawDetector), - m_lowerLevelGraph( 0 ), - m_upperLevelGraph( 0 ), - m_recalculateLowerLevel( false ), - m_recalculateUpperLevel( false ) - { - m_recomputeInterval = (new ProfileIterator(getId()))->getId(); - - // every node in the maximum flow graph is identified by the id of the associated Transaction - // we make a dummy transaction for the source and sink nodes of the graphs - Variable * dummy1 = - new Variable( db->getConstraintEngine(), IntervalIntDomain(0, 0)); - Variable * dummy2 = - new Variable( db->getConstraintEngine(), IntervalIntDomain(0, 0)); - Variable * dummy3 = - new Variable( db->getConstraintEngine(), IntervalIntDomain(0, 0)); - Variable * dummy4 = - new Variable( db->getConstraintEngine(), IntervalIntDomain(0, 0)); - - m_dummySourceTransaction = ( new Transaction(dummy1->getId(), dummy2->getId(), false ) )->getId(); - m_dummySinkTransaction = ( new Transaction(dummy3->getId(), dummy4->getId(), false) )->getId(); - - initializeGraphs(); - } +FlowProfile::FlowProfile( const PlanDatabaseId db, const FVDetectorId flawDetector): + Profile( db, flawDetector), + m_previousTimeBounds(), + m_dummySourceTransaction(), + m_dummySinkTransaction(), + m_lowerLevelGraph(NULL), + m_upperLevelGraph(NULL), + m_lowerClosedLevel(0), + m_upperClosedLevel(0), + m_recalculateLowerLevel( false ), + m_recalculateUpperLevel( false ), + m_orderings(), + m_orderedAt(), + m_lowerLevelContribution(), + m_upperLevelContribution() +{ + m_recomputeInterval = (new ProfileIterator(getId()))->getId(); + + // every node in the maximum flow graph is identified by the id of the associated Transaction + // we make a dummy transaction for the source and sink nodes of the graphs + Variable * dummy1 = + new Variable( db->getConstraintEngine(), IntervalIntDomain(0, 0)); + Variable * dummy2 = + new Variable( db->getConstraintEngine(), IntervalIntDomain(0, 0)); + Variable * dummy3 = + new Variable( db->getConstraintEngine(), IntervalIntDomain(0, 0)); + Variable * dummy4 = + new Variable( db->getConstraintEngine(), IntervalIntDomain(0, 0)); + + m_dummySourceTransaction = + (new Transaction(dummy1->getId(), dummy2->getId(), false, EntityId::noId()))->getId(); + m_dummySinkTransaction = + (new Transaction(dummy3->getId(), dummy4->getId(), false, EntityId::noId()))->getId(); + + initializeGraphs(); +} FlowProfile::~FlowProfile() { @@ -280,58 +76,106 @@ namespace EUROPA delete m_upperLevelGraph; m_upperLevelGraph = 0; - delete (Transaction*) m_dummySinkTransaction; - delete (Transaction*) m_dummySourceTransaction; - } - - bool FlowProfile::getEarliestLowerLevelInstant( const TransactionId& t, InstantId& i ) - { - check_error( t.isValid()); - - TransactionId2InstantId::iterator ite = m_lowerLevelContribution.find( t ); - - if( m_lowerLevelContribution.end() == ite ) - return false; - - i = (*ite).second; - - return true; + delete static_cast(m_dummySinkTransaction); + delete static_cast(m_dummySourceTransaction); } - bool FlowProfile::getEarliestUpperLevelInstant( const TransactionId& t, InstantId& i ) - { - check_error( t.isValid()); - - TransactionId2InstantId::iterator ite = m_upperLevelContribution.find( t ); - - if( m_upperLevelContribution.end() == ite ) - return false; - - i = (*ite).second; - - return true; +bool FlowProfile::getEarliestLowerLevelInstant(const TransactionId t, InstantId& i) { + check_error( t.isValid()); + + if(t->isConsumer()) { + i = getInstant(t->time()->lastDomain().getLowerBound()); + return true; + } + else { + std::map::const_iterator end = + m_instants.upper_bound(t->time()->lastDomain().getUpperBound()); + for(std::map::const_iterator start = + m_instants.lower_bound(t->time()->lastDomain().getLowerBound()); + start != end; ++start) { + InstantId inst = start->second; + for(std::set::const_iterator it = + inst->getTransactions().begin(); + it != inst->getTransactions().end(); ++it) { + if((*it)->isConsumer()) { + switch(getOrdering(t, *it)) { + case BEFORE_OR_AT: + case STRICTLY_AT: + i = inst; + return true; + case AFTER_OR_AT: + case NOT_ORDERED: + case UNKNOWN: + break; + } + } + } } + i = getInstant(t->time()->lastDomain().getUpperBound()); + return true; + } +} - void FlowProfile::initializeGraphs() - { - delete m_lowerLevelGraph; - - m_lowerLevelGraph = new FlowProfileGraph( m_dummySourceTransaction, m_dummySinkTransaction, true ); - - delete m_upperLevelGraph; - - m_upperLevelGraph = new FlowProfileGraph( m_dummySourceTransaction, m_dummySinkTransaction, false ); +bool FlowProfile::getEarliestUpperLevelInstant(const TransactionId t, InstantId& i) { + check_error( t.isValid()); + + if(!t->isConsumer()) { + i = getInstant(t->time()->lastDomain().getLowerBound()); + return true; + } + else { + std::map::const_iterator end = + m_instants.upper_bound(t->time()->lastDomain().getUpperBound()); + for(std::map::const_iterator start = + m_instants.lower_bound(t->time()->lastDomain().getLowerBound()); + start != end; ++start) { + InstantId inst = start->second; + for(std::set::const_iterator it = + inst->getTransactions().begin(); + it != inst->getTransactions().end(); ++it) { + if(!(*it)->isConsumer()) { + switch(getOrdering(t, *it)) { + case BEFORE_OR_AT: + case STRICTLY_AT: + i = inst; + return true; + case AFTER_OR_AT: + case NOT_ORDERED: + case UNKNOWN: + break; + } + } + } } + i = getInstant(t->time()->lastDomain().getUpperBound()); + return true; + } +} - void FlowProfile::initRecompute( InstantId inst ) - { - check_error(inst.isValid()); - - debugMsg("FlowProfile:initRecompute","Instant (" << inst->getId() << ") at time " - << inst->getTime() ); - +void FlowProfile::initRecompute(InstantId inst) { + check_error(inst.isValid()); + + debugMsg("FlowProfile:initRecompute","Instant (" << inst->getId() << ") at time " + << inst->getTime() ); + m_lowerClosedLevel = getInitCapacityLb(); + m_upperClosedLevel = getInitCapacityUb(); + + for(std::set::const_iterator it = m_transactions.begin(); + it != m_transactions.end(); ++it) { + if((*it)->time()->lastDomain().getUpperBound() < inst->getTime()) { + m_upperClosedLevel = m_upperClosedLevel + + ((*it)->isConsumer() ? + -((*it)->quantity()->lastDomain().getLowerBound()) : + (*it)->quantity()->lastDomain().getUpperBound()); + + m_lowerClosedLevel = m_lowerClosedLevel + + ((*it)->isConsumer() ? + -((*it)->quantity()->lastDomain().getUpperBound()) : + (*it)->quantity()->lastDomain().getLowerBound()); } + } +} void FlowProfile::initRecompute() { @@ -357,129 +201,130 @@ namespace EUROPA m_recalculateUpperLevel = false; } - void FlowProfile::recomputeLevels( InstantId prev, InstantId inst ) +void FlowProfile::recomputeLevels(InstantId prev, InstantId inst) { + check_error( prev.isValid() || InstantId::noId() == prev ); + check_error( inst.isValid() ); + + debugMsg("FlowProfile:recomputeLevels","Computing instant (" + << inst->getId() << ") at time " + << inst->getTime() << " closed levels [" + << m_lowerClosedLevel << "," + << m_upperClosedLevel << "]"); + + const std::set& transactions = inst->getTransactions(); + + std::set::const_iterator iter = transactions.begin(); + std::set::const_iterator end = transactions.end(); + + for( ; iter != end; ++iter ) + { + const TransactionId transaction1 = (*iter); + + // inst->getTransactions returns all transaction overlapping inst->getTime + // right inclusive + if( transaction1->time()->lastDomain().getUpperBound() == inst->getTime() ) { - check_error( prev.isValid() || InstantId::noId() == prev ); - check_error( inst.isValid() ); + debugMsg("FlowProfile::recomputeLevels","Transaction (" + << transaction1->getId() << ") " + << transaction1->time()->toString() << " " + << transaction1->quantity()->toString() << " enters closed set."); - debugMsg("FlowProfile:recomputeLevels","Computing instant (" - << inst->getId() << ") at time " - << inst->getTime() << " closed levels [" - << m_lowerClosedLevel << "," - << m_upperClosedLevel << "]"); + if( m_recalculateLowerLevel ) + m_lowerLevelGraph->removeTransaction( transaction1 ); - const std::set& transactions = inst->getTransactions(); + if( m_recalculateUpperLevel ) + m_upperLevelGraph->removeTransaction( transaction1 ); - std::set::const_iterator iter = transactions.begin(); - std::set::const_iterator end = transactions.end(); + // if upperbound equals the instant time the transaction enters the closed set + if( transaction1->isConsumer() ) + { + if( m_recalculateUpperLevel ) + m_upperClosedLevel -= transaction1->quantity()->lastDomain().getLowerBound(); - for( ; iter != end; ++iter ) - { - const TransactionId& transaction1 = (*iter); + if( m_recalculateLowerLevel ) + m_lowerClosedLevel -= transaction1->quantity()->lastDomain().getUpperBound(); + } + else + { + if( m_recalculateUpperLevel ) + m_upperClosedLevel += transaction1->quantity()->lastDomain().getUpperBound(); - // inst->getTransactions returns all transaction overlapping inst->getTime - // right inclusive - if( transaction1->time()->lastDomain().getUpperBound() == inst->getTime() ) - { - debugMsg("FlowProfile::recomputeLevels","Transaction (" - << transaction1->getId() << ") " - << transaction1->time()->toString() << " " - << transaction1->quantity()->toString() << " enters closed set."); - - if( m_recalculateLowerLevel ) - m_lowerLevelGraph->removeTransaction( transaction1 ); - - if( m_recalculateUpperLevel ) - m_upperLevelGraph->removeTransaction( transaction1 ); - - // if upperbound equals the instant time the transaction enters the closed set - if( transaction1->isConsumer() ) - { - if( m_recalculateUpperLevel ) - m_upperClosedLevel -= transaction1->quantity()->lastDomain().getLowerBound(); - - if( m_recalculateLowerLevel ) - m_lowerClosedLevel -= transaction1->quantity()->lastDomain().getUpperBound(); - } - else - { - if( m_recalculateUpperLevel ) - m_upperClosedLevel += transaction1->quantity()->lastDomain().getUpperBound(); - - if( m_recalculateLowerLevel ) - m_lowerClosedLevel += transaction1->quantity()->lastDomain().getLowerBound(); - } - } - else - { - if( transaction1->time()->lastDomain().getLowerBound() == inst->getTime() ) - { - enableTransaction( transaction1, inst ); - - std::set::const_iterator secondIter = transactions.begin(); - - for( ; secondIter != end; ++secondIter ) - { - const TransactionId& transaction2 = (*secondIter); - - if( transaction1 != transaction2 ) - { - if( transaction2->time()->lastDomain().getUpperBound() != inst->getTime() ) - { - enableTransaction( transaction2, inst ); - - debugMsg("FlowProfile:recomputeLevels","Determining ordering of pending transaction (" - << transaction1->getId() << ") " - << transaction1->time()->toString() << " and pending transaction (" - << transaction2->getId() << ") " - << transaction2->time()->toString() ); - - Order order = getOrdering( transaction1, transaction2 ); - - if( STRICTLY_AT == order ) - { - handleOrderedAt( transaction1, transaction2 ); - } - else if( BEFORE_OR_AT == order ) - { - handleOrderedAtOrBefore( transaction1, transaction2 ); - } - else - { - debugMsg("FlowProfile::recomputeLevels","Transaction (" - << transaction1->getId() << ") and Transaction (" - << transaction2->getId() << ") not constrained"); - } - } - } - } - } - } - } + if( m_recalculateLowerLevel ) + m_lowerClosedLevel += transaction1->quantity()->lastDomain().getLowerBound(); + } + } + else + { + // if( transaction1->time()->lastDomain().getLowerBound() == inst->getTime() ) + // { + enableTransaction( transaction1, inst ); + + std::set::const_iterator secondIter = transactions.begin(); + + for( ; secondIter != end; ++secondIter ) + { + const TransactionId transaction2 = (*secondIter); + + if( transaction1 != transaction2 ) + { + if( transaction2->time()->lastDomain().getUpperBound() != inst->getTime() ) + { + enableTransaction( transaction2, inst ); + + debugMsg("FlowProfile:recomputeLevels", + "Determining ordering of pending transaction (" + << transaction1->getId() << ") " + << transaction1->time()->toString() << + " and pending transaction (" + << transaction2->getId() << ") " + << transaction2->time()->toString() ); + + Order order = getOrdering( transaction1, transaction2 ); + + if( STRICTLY_AT == order ) + { + handleOrderedAt( transaction1, transaction2 ); + } + else if( BEFORE_OR_AT == order ) + { + handleOrderedAtOrBefore( transaction1, transaction2 ); + } + else + { + debugMsg("FlowProfile::recomputeLevels","Transaction (" + << transaction1->getId() << ") and Transaction (" + << transaction2->getId() << ") not constrained"); + } + } + } + } + // } + } + } - edouble lowerLevel = inst->getLowerLevel(); + edouble lowerLevel = inst->getLowerLevel(); - if( m_recalculateLowerLevel ) - lowerLevel = m_lowerClosedLevel - m_lowerLevelGraph->getResidualFromSource(); + if( m_recalculateLowerLevel ) + lowerLevel = m_lowerClosedLevel - m_lowerLevelGraph->getResidualFromSource(m_orderedAt, m_orderings); - edouble upperLevel = inst->getUpperLevel(); + edouble upperLevel = inst->getUpperLevel(); - if( m_recalculateUpperLevel ) - upperLevel = m_upperClosedLevel + m_upperLevelGraph->getResidualFromSource(); + if( m_recalculateUpperLevel ) + upperLevel = m_upperClosedLevel + m_upperLevelGraph->getResidualFromSource(m_orderedAt, m_orderings); - debugMsg("FlowProfile::recomputeLevels","Computed levels for instance at time " - << inst->getTime() << "[" - << lowerLevel << "," - << upperLevel << "]"); + debugMsg("FlowProfile::recomputeLevels","Computed levels for instance at time " + << inst->getTime() << "[" + << lowerLevel << "," + << upperLevel << "]"); - inst->update( lowerLevel, lowerLevel, upperLevel, upperLevel, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 ); - } + inst->update( lowerLevel, lowerLevel, upperLevel, upperLevel, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0 ); +} - FlowProfile::Order FlowProfile::getOrdering( const TransactionId t1, const TransactionId t2 ) +Order FlowProfile::getOrdering( const TransactionId t1, const TransactionId t2 ) { // in case constraint added and already constrained to be before or after we no longer have to // recalculate @@ -493,6 +338,7 @@ namespace EUROPA if( ite != m_orderedAt.end() ) { + debugMsg("FlowProfile:getOrdering", "Cached " << t1 << " = " << t2); return (*ite).second; } @@ -500,6 +346,8 @@ namespace EUROPA if( ite != m_orderings.end() ) { + debugMsg("FlowProfile:getOrdering", + "Cached " << t1 << " " << ite->second << " " << t2); return (*ite).second; } @@ -509,6 +357,8 @@ namespace EUROPA if( ite != m_orderings.end() ) { + debugMsg("FlowProfile:getOrdering", + "Cached " << t2 << " " << ite->second << " " << t1 << ", reversing"); if( (*ite).second == BEFORE_OR_AT ) return AFTER_OR_AT; @@ -542,7 +392,7 @@ namespace EUROPA else { const IntervalIntDomain distance = m_planDatabase->getTemporalAdvisor()->getTemporalDistanceDomain( t1->time(), t2->time(), true ); - + debugMsg("FlowProfile:getOrdering", "Got a distance of " << distance.toString()); if( distance.getLowerBound() == 0 && distance.getUpperBound() == 0 ) { returnValue = STRICTLY_AT; @@ -601,45 +451,47 @@ namespace EUROPA m_upperLevelGraph->enableAtOrBefore( t1, t2 ); } - void FlowProfile::handleTransactionAdded(const TransactionId t) - { - check_error( t.isValid() ); +void FlowProfile::handleTransactionAdded(const TransactionId t) { + check_error( t.isValid() ); - debugMsg("FlowProfile:handleTransactionAdded","TransactionId (" - << t->getId() << ") time " - << t->time()->lastDomain() << " quantity " - << t->quantity()->lastDomain() << " consumer: " - << std::boolalpha << t->isConsumer() ); + debugMsg("FlowProfile:handleTransactionAdded","TransactionId (" + << t->getId() << ") time " + << t->time()->lastDomain() << " quantity " + << t->quantity()->lastDomain() << " consumer: " + << std::boolalpha << t->isConsumer() ); - m_recalculateLowerLevel = true; - m_recalculateUpperLevel = true; + m_recalculateLowerLevel = true; + m_recalculateUpperLevel = true; - eint startRecalculation = PLUS_INFINITY; - eint endRecalculation = MINUS_INFINITY; + eint startRecalculation = PLUS_INFINITY; + eint endRecalculation = MINUS_INFINITY; - if( ProfileIteratorId::noId() != m_recomputeInterval ) - { - startRecalculation = std::min( m_recomputeInterval->getStartTime(), (eint) t->time()->lastDomain().getLowerBound() ); - } - else - { - startRecalculation = (eint) t->time()->lastDomain().getLowerBound(); - } + if( ProfileIteratorId::noId() != m_recomputeInterval ) + { + startRecalculation = std::min( m_recomputeInterval->getStartTime(), + static_cast(t->time()->lastDomain().getLowerBound())); + } + else + { + startRecalculation = static_cast(t->time()->lastDomain().getLowerBound()); + } - // startRecalculation = MINUS_INFINITY; - endRecalculation = PLUS_INFINITY; + // startRecalculation = MINUS_INFINITY; + endRecalculation = PLUS_INFINITY; - if( ProfileIteratorId::noId() != m_recomputeInterval ) - delete (ProfileIterator*) m_recomputeInterval; + if( ProfileIteratorId::noId() != m_recomputeInterval ) + delete static_cast(m_recomputeInterval); - m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); + m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); - m_previousTimeBounds[ t ] = std::make_pair( (eint) t->time()->lastDomain().getLowerBound() , (eint) t->time()->lastDomain().getUpperBound() ); + m_previousTimeBounds[ t ] = + std::make_pair(static_cast(t->time()->lastDomain().getLowerBound()), + static_cast(t->time()->lastDomain().getUpperBound())); - debugMsg("FlowProfile:handleTransactionAdded","Set interval to [" << startRecalculation << "," << endRecalculation << "]"); - } + debugMsg("FlowProfile:handleTransactionAdded","Set interval to [" << startRecalculation << "," << endRecalculation << "]"); +} - void FlowProfile::enableTransaction( const TransactionId t, const InstantId inst ) +void FlowProfile::enableTransaction( const TransactionId t, const InstantId inst ) { debugMsg("FlowProfile:enableTransaction","TransactionId (" << t->getId() << ")"); @@ -647,183 +499,196 @@ namespace EUROPA m_upperLevelGraph->enableTransaction( t, inst, m_upperLevelContribution ); } - void FlowProfile::handleTransactionRemoved( const TransactionId t ) { - check_error(t.isValid()); - - debugMsg("FlowProfile:handleTransactionRemoved","TransactionId (" << t->getId() << ")"); - - m_recalculateLowerLevel = true; - m_recalculateUpperLevel = true; - - m_lowerLevelGraph->removeTransaction( t ); - m_upperLevelGraph->removeTransaction( t ); - - m_lowerLevelContribution.erase( t ); - m_upperLevelContribution.erase( t ); - - eint startRecalculation = PLUS_INFINITY; - eint endRecalculation = MINUS_INFINITY; - - if( ProfileIteratorId::noId() != m_recomputeInterval ) - { - startRecalculation = std::min( m_recomputeInterval->getStartTime(), (eint) t->time()->lastDomain().getLowerBound() ); - } - else - { - startRecalculation = (eint) t->time()->lastDomain().getLowerBound(); - } +void FlowProfile::handleTransactionRemoved( const TransactionId t ) { + check_error(t.isValid()); - endRecalculation = PLUS_INFINITY; + debugMsg("FlowProfile:handleTransactionRemoved","TransactionId (" << t->getId() << ")"); - if(m_recomputeInterval.isValid()) - delete (ProfileIterator*) m_recomputeInterval; + m_recalculateLowerLevel = true; + m_recalculateUpperLevel = true; - m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); + m_lowerLevelGraph->removeTransaction( t ); + m_upperLevelGraph->removeTransaction( t ); - m_previousTimeBounds.erase( t ); - } + m_lowerLevelContribution.erase( t ); + m_upperLevelContribution.erase( t ); - void FlowProfile::handleTransactionTimeChanged(const TransactionId t, const DomainListener::ChangeType& type) - { - check_error(t.isValid()); + eint startRecalculation = PLUS_INFINITY; + eint endRecalculation = MINUS_INFINITY; - m_recalculateLowerLevel = true; - m_recalculateUpperLevel = true; + if( ProfileIteratorId::noId() != m_recomputeInterval ) + { + startRecalculation = std::min( m_recomputeInterval->getStartTime(), + static_cast(t->time()->lastDomain().getLowerBound())); + } + else + { + startRecalculation = static_cast(t->time()->lastDomain().getLowerBound()); + } - eint startRecalculation = PLUS_INFINITY; - eint endRecalculation = MINUS_INFINITY; + endRecalculation = PLUS_INFINITY; - switch( type) { - case DomainListener::UPPER_BOUND_DECREASED: - case DomainListener::RESTRICT_TO_SINGLETON: - case DomainListener::SET_TO_SINGLETON: - case DomainListener::LOWER_BOUND_INCREASED: - case DomainListener::BOUNDS_RESTRICTED: - { - TransactionId2IntIntPair::const_iterator ite = m_previousTimeBounds.find( t ); + if(m_recomputeInterval.isValid()) + delete static_cast(m_recomputeInterval); - // we should have the previous value! - check_error( ite != m_previousTimeBounds.end() ); + m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); - eint previousStart = (*ite).second.first; - eint previousEnd = (*ite).second.second; + m_previousTimeBounds.erase( t ); +} - if( ProfileIteratorId::noId() != m_recomputeInterval ) - { - startRecalculation = std::min( m_recomputeInterval->getStartTime(), previousStart ); - endRecalculation = std::max( m_recomputeInterval->getEndTime(), previousEnd ); - } - else - { - startRecalculation = previousStart; - endRecalculation = previousEnd; - } - } +void FlowProfile::handleTransactionTimeChanged(const TransactionId t, + const DomainListener::ChangeType& type) { + check_error(t.isValid()); + + m_recalculateLowerLevel = true; + m_recalculateUpperLevel = true; + + eint startRecalculation = PLUS_INFINITY; + eint endRecalculation = MINUS_INFINITY; + + switch( type) { + case DomainListener::UPPER_BOUND_DECREASED: + case DomainListener::RESTRICT_TO_SINGLETON: + case DomainListener::SET_TO_SINGLETON: + case DomainListener::LOWER_BOUND_INCREASED: + case DomainListener::BOUNDS_RESTRICTED: + { + TransactionId2IntIntPair::const_iterator ite = m_previousTimeBounds.find( t ); + + // we should have the previous value! + check_error( ite != m_previousTimeBounds.end() ); + + eint previousStart = (*ite).second.first; + eint previousEnd = (*ite).second.second; + + if( ProfileIteratorId::noId() != m_recomputeInterval ) + { + startRecalculation = std::min( m_recomputeInterval->getStartTime(), previousStart ); + endRecalculation = std::max( m_recomputeInterval->getEndTime(), previousEnd ); + } + else + { + startRecalculation = previousStart; + endRecalculation = previousEnd; + } + } break; - case DomainListener::RESET: - case DomainListener::RELAXED: - { - if( ProfileIteratorId::noId() != m_recomputeInterval ) - { - startRecalculation = std::min( m_recomputeInterval->getStartTime(), (eint) t->time()->lastDomain().getLowerBound() ); - endRecalculation = std::max( m_recomputeInterval->getEndTime(), (eint) t->time()->lastDomain().getUpperBound() ); - } - else - { - startRecalculation = (eint) t->time()->lastDomain().getLowerBound(); - endRecalculation = (eint) t->time()->lastDomain().getUpperBound(); - } - } + case DomainListener::RESET: + case DomainListener::RELAXED: + { + if( ProfileIteratorId::noId() != m_recomputeInterval ) { + startRecalculation = std::min(m_recomputeInterval->getStartTime(), + static_cast(t->time()->lastDomain().getLowerBound())); + endRecalculation = std::max(m_recomputeInterval->getEndTime(), + static_cast(t->time()->lastDomain().getUpperBound())); + } + else { + startRecalculation = static_cast(t->time()->lastDomain().getLowerBound()); + endRecalculation = static_cast(t->time()->lastDomain().getUpperBound()); + } + } break; - default: - break; - }; - - if(m_recomputeInterval.isValid()) - delete (ProfileIterator*) m_recomputeInterval; - - m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); + case DomainListener::REFTIME_CHANGED: + case DomainListener::VALUE_REMOVED: + case DomainListener::CLOSED: + case DomainListener::OPENED: + case DomainListener::EMPTIED: + default: + break; + }; - debugMsg("FlowProfile:handleTransactionTimeChanged","TransactionId (" << t->getId() << ") change " << type ); - } + if(m_recomputeInterval.isValid()) + delete static_cast(m_recomputeInterval); - void FlowProfile::handleTransactionQuantityChanged(const TransactionId t, const DomainListener::ChangeType& type) - { - check_error(t.isValid()); + m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); - switch( type) { - case DomainListener::UPPER_BOUND_DECREASED: - { - if( t->isConsumer() ) - { - m_recalculateLowerLevel = true; - } - else - { - m_recalculateUpperLevel = true; - } + debugMsg("FlowProfile:handleTransactionTimeChanged","TransactionId (" << t->getId() << ") change " << type ); +} - } +void FlowProfile::handleTransactionQuantityChanged(const TransactionId t, + const DomainListener::ChangeType& type) { + check_error(t.isValid()); + + switch( type) { + case DomainListener::UPPER_BOUND_DECREASED: + { + if( t->isConsumer() ) + { + m_recalculateLowerLevel = true; + } + else + { + m_recalculateUpperLevel = true; + } + + } break; - case DomainListener::RESET: - case DomainListener::RELAXED: - case DomainListener::RESTRICT_TO_SINGLETON: - case DomainListener::SET_TO_SINGLETON: - { - m_recalculateLowerLevel = true; - m_recalculateUpperLevel = true; - } + case DomainListener::RESET: + case DomainListener::RELAXED: + case DomainListener::RESTRICT_TO_SINGLETON: + case DomainListener::SET_TO_SINGLETON: + { + m_recalculateLowerLevel = true; + m_recalculateUpperLevel = true; + } break; + case DomainListener::LOWER_BOUND_INCREASED: + { + if( t->isConsumer() ) + { + m_recalculateUpperLevel = true; + } + else + { + m_recalculateLowerLevel = true; + } + + } break; - case DomainListener::LOWER_BOUND_INCREASED: - { - if( t->isConsumer() ) - { - m_recalculateUpperLevel = true; - } - else - { - m_recalculateLowerLevel = true; - } + case DomainListener::BOUNDS_RESTRICTED: + { + m_recalculateLowerLevel = true; + m_recalculateUpperLevel = true; - } + } break; - case DomainListener::BOUNDS_RESTRICTED: - { - m_recalculateLowerLevel = true; - m_recalculateUpperLevel = true; - - } + case DomainListener::VALUE_REMOVED: + case DomainListener::CLOSED: + case DomainListener::REFTIME_CHANGED: + case DomainListener::OPENED: + case DomainListener::EMPTIED: + default: break; - default: - break; - }; - - eint startRecalculation = PLUS_INFINITY; - eint endRecalculation = MINUS_INFINITY; - - if( ProfileIteratorId::noId() != m_recomputeInterval ) - { - startRecalculation = std::min( m_recomputeInterval->getStartTime(), (eint) t->time()->lastDomain().getLowerBound() ); - endRecalculation = std::max( m_recomputeInterval->getEndTime(), (eint) t->time()->lastDomain().getUpperBound() ); - } - else - { - startRecalculation = (eint) t->time()->lastDomain().getLowerBound(); - endRecalculation = (eint) t->time()->lastDomain().getUpperBound(); - } - - if(m_recomputeInterval.isValid()) - delete (ProfileIterator*) m_recomputeInterval; - - m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); - - debugMsg("FlowProfile:handleTransactionQuantityChanged","TransactionId (" << t->getId() << ") change " << type << " to " << t->quantity()->toString() ); - } + }; + + eint startRecalculation = PLUS_INFINITY; + eint endRecalculation = MINUS_INFINITY; + + if( ProfileIteratorId::noId() != m_recomputeInterval ) + { + startRecalculation = std::min(m_recomputeInterval->getStartTime(), + static_cast(t->time()->lastDomain().getLowerBound())); + endRecalculation = std::max(m_recomputeInterval->getEndTime(), + static_cast(t->time()->lastDomain().getUpperBound())); + } + else + { + startRecalculation = static_cast(t->time()->lastDomain().getLowerBound()); + endRecalculation = static_cast(t->time()->lastDomain().getUpperBound()); + } + + if(m_recomputeInterval.isValid()) + delete static_cast(m_recomputeInterval); + + m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); + + debugMsg("FlowProfile:handleTransactionQuantityChanged","TransactionId (" << t->getId() << ") change " << type << " to " << t->quantity()->toString() ); +} - void FlowProfile::handleTemporalConstraintAdded( const TransactionId predecessor, const int preArgIndex, - const TransactionId successor, const int sucArgIndex) - { +void FlowProfile::handleTemporalConstraintAdded(const TransactionId predecessor, + const unsigned int , + const TransactionId successor, + const unsigned int ) { debugMsg("FlowProfile:handleTemporalConstraintAdded","TransactionId1 (" << predecessor->getId() << ") before TransactionId2 (" << successor->getId() << ")"); check_error(predecessor.isValid()); @@ -834,19 +699,27 @@ namespace EUROPA eint startRecalculation = PLUS_INFINITY; eint endRecalculation = MINUS_INFINITY; - if( ProfileIteratorId::noId() != m_recomputeInterval ) - { - startRecalculation = std::min( m_recomputeInterval->getStartTime(), std::min( (eint) predecessor->time()->lastDomain().getLowerBound(), (eint) successor->time()->lastDomain().getLowerBound() ) ); - endRecalculation = std::max( m_recomputeInterval->getEndTime(), std::max( (eint) predecessor->time()->lastDomain().getUpperBound(), (eint) successor->time()->lastDomain().getUpperBound() ) ); - } - else - { - startRecalculation = std::min( (eint) predecessor->time()->lastDomain().getLowerBound(), (eint) successor->time()->lastDomain().getLowerBound() ); - endRecalculation = std::max( (eint) predecessor->time()->lastDomain().getUpperBound(), (eint) successor->time()->lastDomain().getUpperBound() ); - } + if( ProfileIteratorId::noId() != m_recomputeInterval ) { + startRecalculation = + std::min( m_recomputeInterval->getStartTime(), + std::min(static_cast(predecessor->time()->lastDomain().getLowerBound()), + static_cast(successor->time()->lastDomain().getLowerBound()))); + endRecalculation = + std::max(m_recomputeInterval->getEndTime(), + std::max(static_cast(predecessor->time()->lastDomain().getUpperBound()), + static_cast(successor->time()->lastDomain().getUpperBound()))); + } + else { + startRecalculation = + std::min(static_cast(predecessor->time()->lastDomain().getLowerBound()), + static_cast(successor->time()->lastDomain().getLowerBound())); + endRecalculation = + std::max(static_cast(predecessor->time()->lastDomain().getUpperBound()), + static_cast(successor->time()->lastDomain().getUpperBound())); + } if(m_recomputeInterval.isValid()) - delete (ProfileIterator*) m_recomputeInterval; + delete static_cast(m_recomputeInterval); m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); @@ -855,41 +728,53 @@ namespace EUROPA } - void FlowProfile::handleTemporalConstraintRemoved( const TransactionId predecessor, const int preArgIndex, - const TransactionId successor, const int sucArgIndex) - { - debugMsg("FlowProfile:handleTemporalConstraintRemoved","TransactionId1 (" << predecessor->getId() << ") before TransactionId2 (" << successor->getId() << ")"); - - check_error(predecessor.isValid()); - check_error(successor.isValid()); - - m_orderings.clear(); - m_orderedAt.clear(); - - eint startRecalculation = PLUS_INFINITY; - eint endRecalculation = MINUS_INFINITY; - - if( ProfileIteratorId::noId() != m_recomputeInterval ) - { - eint start = m_recomputeInterval->getStartTime(); - eint end = m_recomputeInterval->getEndTime(); - - startRecalculation = std::min( start, std::min( (eint) predecessor->time()->lastDomain().getLowerBound(), (eint) successor->time()->lastDomain().getLowerBound() ) ); - endRecalculation = std::max( end, std::max( (eint) predecessor->time()->lastDomain().getUpperBound(), (eint) successor->time()->lastDomain().getUpperBound() ) ); - } - else - { - startRecalculation = std::min( (eint) predecessor->time()->lastDomain().getLowerBound(), (eint) successor->time()->lastDomain().getLowerBound() ); - endRecalculation = std::max( (eint) predecessor->time()->lastDomain().getUpperBound(), (eint) successor->time()->lastDomain().getUpperBound() ); - } - - - if(m_recomputeInterval.isValid()) - delete (ProfileIterator*) m_recomputeInterval; - - m_recomputeInterval = (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); - - m_recalculateLowerLevel = true; - m_recalculateUpperLevel = true; - } +void FlowProfile::handleTemporalConstraintRemoved(const TransactionId predecessor, + const unsigned int , + const TransactionId successor, + const unsigned int ) { + debugMsg("FlowProfile:handleTemporalConstraintRemoved", + "TransactionId1 (" << predecessor->getId() << + ") before TransactionId2 (" << successor->getId() << ")"); + + check_error(predecessor.isValid()); + check_error(successor.isValid()); + + m_orderings.clear(); + m_orderedAt.clear(); + + eint startRecalculation = PLUS_INFINITY; + eint endRecalculation = MINUS_INFINITY; + + if( ProfileIteratorId::noId() != m_recomputeInterval ) { + eint start = m_recomputeInterval->getStartTime(); + eint end = m_recomputeInterval->getEndTime(); + + startRecalculation = + std::min(start, + std::min(static_cast(predecessor->time()->lastDomain().getLowerBound()), + static_cast(successor->time()->lastDomain().getLowerBound()))); + endRecalculation = + std::max(end, + std::max(static_cast(predecessor->time()->lastDomain().getUpperBound()), + static_cast(successor->time()->lastDomain().getUpperBound()))); + } + else { + startRecalculation = + std::min(static_cast(predecessor->time()->lastDomain().getLowerBound()), + static_cast(successor->time()->lastDomain().getLowerBound())); + endRecalculation = + std::max(static_cast(predecessor->time()->lastDomain().getUpperBound()), + static_cast(successor->time()->lastDomain().getUpperBound())); + } + + + if(m_recomputeInterval.isValid()) + delete static_cast(m_recomputeInterval); + + m_recomputeInterval = + (new ProfileIterator( getId(), startRecalculation, endRecalculation ))->getId(); + + m_recalculateLowerLevel = true; + m_recalculateUpperLevel = true; +} } diff --git a/src/PLASMA/Resource/component/FlowProfile.hh b/src/PLASMA/Resource/component/FlowProfile.hh index 1b7e7608e..d5eef4b94 100644 --- a/src/PLASMA/Resource/component/FlowProfile.hh +++ b/src/PLASMA/Resource/component/FlowProfile.hh @@ -15,244 +15,16 @@ #include "ResourceDefs.hh" #include "Types.hh" #include "TemporalPropagator.hh" +#include "FlowProfileGraph.hh" #ifdef _MSC_VER # include #endif namespace EUROPA { - class Graph; - class MaximumFlowAlgorithm; - class Node; - - /** - * @brief Graph structure to determine the subset of pending transactions at time T - * which has the largest contribution to an envelope (see FlowProfile) - */ - class FlowProfileGraph - { - public: - /** - * @brief Creates a directed graph with a \a source and a \sink intended to calculate the - * lower level envelope in case \a lowerLevel is true otherwise intended to calculate the - * upper level envelope. - */ - FlowProfileGraph( const TransactionId& source, const TransactionId& sink, bool lowerLevel ); - /** - * @brief Destructor - */ - ~FlowProfileGraph(); - /** - * @brief Creates bi-directional edge between \a t1 and \a t2 with infinite capacity - * as a result of a concurrent constraint between the two transactions - */ - void enableAt( const TransactionId& t1, const TransactionId& t2 ); - /** - * @brief Creates directed edge between \a t1 and \a t2 with infinite capacity - * as a result of a before or at constraint between the two transactions (reverse - * capacity set to zero) - */ - void enableAtOrBefore( const TransactionId& t1, const TransactionId& t2 ); - /** - * @brief Creates a node in the network and creates an edge: - * - * \verbatim - * | lower level | upper level - * --------------------------------------------------------------------------------------------------------- - * transaction is consumer | w = q.upper | w = q.lower - * --------------------------------------------------------------------------------------------------------- - * transaction is producer | w = q.lower | w = q.upper - * --------------------------------------------------------------------------------------------------------- - * \endverbatim - */ - void enableTransaction( const TransactionId& transaction, const InstantId& inst, TransactionId2InstantId& contributions ); - /** - * @brief Returns true if \a transaction is enabled in the invoking - * instance - */ - bool isEnabled( const TransactionId& transaction ) const; - /** - * @brief Disables \a transaction, if enabled, for the invoking instance - */ - void disable( const TransactionId& transaction ) ; - /** - * @brief Will push any flow wich flows through the node corresponding with \a transaction - * back to the source of the edge the flow originates from. - * - * When we move from one instant to another we retract all the transactions whose end time - * is equal to the new instant time and the transaction is still in the network. This method - * will push any flow going through this node back to where it is coming from after which we - * try again to push the flow to the sink. - - * Will error out if no node corresponding to \a transaction is in the network or if the node - * is not enabled. - * - * If a recalculation of the maximum flow is required this method will do nothing. - * \todo verify if this is really required or perhaps we should error out? - */ - void pushFlow( const TransactionId& transaction ); - /** - * @brief Returns the cummulative residual capacity originating from the source. - * - * Iterates over all outgoing edges from the source and sums the residual capicity of each - * edge. Might trigger a maximum flow (re) calculation if required. - */ - edouble getResidualFromSource(); - /** - * @brief Disables every node reachable from the source in the residual network. Returns the sum - * of the contribution of each disabled node. The contribution is determined as following: - * \verbatim - * | lower level | upper level - * --------------------------------------------------------------------------------------------------------- - * transaction is consumer | q.upper | q.lower - * --------------------------------------------------------------------------------------------------------- - * transaction is producer | q.lower | q.upper - * --------------------------------------------------------------------------------------------------------- - * \endverbatim - * - * where q is the quantity variable associated with the transactions associated with the node. The parameter \a - * contributions, which maps a TransactionId to a InstantId is maps every transaction associated with a disabled - * node to \a instant. - */ - inline edouble disableReachableResidualGraph( TransactionId2InstantId& contributions, const InstantId& instant ); - /** - * @brief Returns true if the invoking instance calculates the lower level, otherwise returns false which indicates - * the invoking instance is calculating the upper level. - */ - bool isLowerLevel() const { return m_lowerLevel; } - /** - * @brief Removes transaction \a id from the network. - */ - void removeTransaction( const TransactionId& id ); - /** - * @brief Resets the invoking instance. - * - * Resetting entails disabling all the nodes, implying disabling all the edges, except for the - * source and the sink. - * - */ - void reset(); - /** - * @brief Restore flow invokes the maximum flow algorithm without resetting the existing distances - * and existing flows on the nodes. - * - * Restore flows is done after extracting all the nodes that expire (go from pending to closed set - * at an instant) from the network by pushing flow back. - */ - void restoreFlow(); - private: - /** - * @brief Helper function for disableReachableResidualGraph - */ - inline void visitNeighbors( const Node* node, edouble& residual, Node2Bool& visited, TransactionId2InstantId& contributions, const InstantId& instant ); - /*! - * @brief Boolean indicating if the instance is intended to calculate the lower level - */ - bool m_lowerLevel; - /*! - * @brief Boolean indicating if the maximum flow solution needs to be recalculated - */ - bool m_recalculate; - /*! - * @brief - */ - MaximumFlowAlgorithm* m_maxflow; - /*! - * @brief Bi directional graph datastructure - */ - Graph* m_graph; - /*! - * @brief Source for the maximum flow problem - */ - Node* m_source; - /*! - * @brief Sink for the maximum flow problem - */ - Node* m_sink; - }; - - edouble FlowProfileGraph::disableReachableResidualGraph( TransactionId2InstantId& contributions, const InstantId& instant ) - { - debugMsg("FlowProfileGraph:disableReachableResidualGraph","Lower level: " - << std::boolalpha << m_lowerLevel ); - - edouble residual = 0.0; - - if( m_recalculate ) - { - debugMsg("FlowProfileGraph:disableReachableResidualGraph","Lower level: " - << std::boolalpha << m_lowerLevel << ", recalculate invoked."); - - m_maxflow->execute(); - - Node2Bool visited; - - visited[ m_source ] = true; - - visitNeighbors( m_source, residual, visited, contributions, instant ); - } - - return residual; - } - - void FlowProfileGraph::visitNeighbors( const Node* node, edouble& residual, Node2Bool& visited, TransactionId2InstantId& contributions, const InstantId& instant ) - { - EdgeOutIterator ite( *node ); - - for( ; ite.ok(); ++ite ) - { - Edge* edge = *ite; - - Node* target = edge->getTarget(); - - if( false == visited[ target ] ) - { - if( 0 != m_maxflow->getResidual( edge ) ) - { - visited[ target ] = true; - - if( target != m_source && target != m_sink ) - { - debugMsg("FlowProfileGraph:visitNeighbors","Disabling node with transaction (" - << target->getIdentity()->getId() << ") lower level " << std::boolalpha << m_lowerLevel ); - - target->setDisabled(); - - const TransactionId& t = target->getIdentity(); - - debugMsg("FlowProfileGraph::visitNeighbors","Transaction " - << t << " starts contributing at " - << instant->getTime() << " lower level " << std::boolalpha << m_lowerLevel ); - - contributions[ t ] = instant; - - int sign = t->isConsumer() ? -1 : +1; - - if( ( m_lowerLevel && t->isConsumer() ) - || - (!m_lowerLevel && !t->isConsumer() ) ) - { - debugMsg("FlowProfileGraph:visitNeighbors","Adding " - << sign * t->quantity()->lastDomain().getUpperBound() << " to the level."); - - residual += sign * t->quantity()->lastDomain().getUpperBound(); - } - else - { - debugMsg("FlowProfileGraph:visitNeighbors","Adding " - << sign* t->quantity()->lastDomain().getLowerBound() << " to the level."); - - residual += sign * t->quantity()->lastDomain().getLowerBound(); - } - - visitNeighbors( target, residual, visited, contributions, instant ); - } - } - } - } - } - - +class Graph; +class MaximumFlowAlgorithm; +class Node; /** * @brief Calculates the lower and upper level envelope of a resource. @@ -292,152 +64,123 @@ namespace EUROPA * See 'N Muscettola. Computing the Envelope for Stepwise-Constant * Resource Allocations. CP 2002, LNCS 2470, pp 139-154, 2002' */ - class FlowProfile: - public Profile - { - public: - /** - * @brief Constructor - */ - FlowProfile( const PlanDatabaseId db, const FVDetectorId flawDetector); - /** - * @brief Destructor - */ - virtual ~FlowProfile(); - /** - * @brief Retrieves the first (earliest) instant the transaction \t starts contributing to - * lower level. Will return true in case a instant has been associated with a transaction - * and will in that case store the instant in parameter \i. Returns false if no instant - * has been associated with transaction t. - */ - bool getEarliestLowerLevelInstant( const TransactionId& t, InstantId& i ); - /** - * @brief Retrieves the first (earliest) instant the transaction \t starts contributing to - * upper level. Will return true in case a instant has been associated with a transaction - * and will in that case store the instant in parameter \i. Returns false if no instant - * has been associated with transaction t. - */ - bool getEarliestUpperLevelInstant( const TransactionId& t, InstantId& i ); - protected: - /** - * @brief Indicates the ordering between two time variables associated with a transaction - */ - enum Order { - AFTER_OR_AT = 0, /*!< Indicates one transaction is strictly after or at the same time with another transaction. */ - BEFORE_OR_AT,/*!< Indicates one transaction is strictly before or at the same time with another transaction. */ - NOT_ORDERED,/*!< Indicates one transaction is not ordered with another transaction. */ - STRICTLY_AT,/*!< Indicates one transaction is strictly at the same time with another transaction. */ - UNKNOWN - }; - /** - * @brief Deletes pre-existing FlowProfileGraphs for the lower and upper level and allocates new ones. - */ - void initializeGraphs(); - /** - * @brief - */ - virtual void postHandleRecompute(const eint& endTime, const std::pair& endDiff); - /** - * @brief Enables a transaction t. A transaction is enabled a time T to calculate the - * envelopes for instant at time T if the lower bound of the time equals T (this is assuming - * envelopes are calculated from earliest to latest instant). Another way of formulating this - * is that a transaction is enabled at the time it moves from the open set to the pending set - * or straight to the closed set if the time is a singleton. - */ - void enableTransaction( const TransactionId t, const InstantId i ); - /** - * @brief Helper method for subclasses to respond to a temporal constraint being added between two transactions. - * @param e The transaction whose timepoint has been constrained. - * @param argIndex The index of the timepoint in the constraint. - */ - void handleTemporalConstraintAdded(const TransactionId predecessor, const int preArgIndex, - const TransactionId successor, const int sucArgIndex); - - /** - * @brief Helper method for subclasses to respond to a temporal constraint being removed between two transactions. - * @param e The transaction whose timepoint has been removed from the constraint. - * @param argIndex The index of the timepoint in the constraint. - */ - void handleTemporalConstraintRemoved(const TransactionId predecessor, const int preArgIndex, - const TransactionId successor, const int sucArgIndex); - /** - * @brief Updates the maximum flow graphs in case transactions t1 and t2 are now strictly ordered. - */ - void handleOrderedAt( const TransactionId t1, const TransactionId t2 ); - /** - * @brief Updates the maximum flow graphs in case transactions t1 and t2 are now weakly ordered. - */ - void handleOrderedAtOrBefore( const TransactionId t1, const TransactionId t2 ); - /** - * @brief - */ - void handleTransactionAdded( const TransactionId t); - /** - * @brief - * @return - */ - void handleTransactionRemoved( const TransactionId t); - /** - * @brief - * @return - */ - void handleTransactionTimeChanged( const TransactionId t, const DomainListener::ChangeType& type ); - /** - * @brief - * @return - */ - void handleTransactionQuantityChanged( const TransactionId t, const DomainListener::ChangeType& type ); - /** - * @brief - * @return - */ - void initRecompute(InstantId inst); - /** - * @brief - * @return - */ - void initRecompute(); - /** - * @brief - * @return - */ - Order getOrdering( const TransactionId t1, const TransactionId t2 ); - /** - * @brief - * @return - */ - void recomputeLevels(InstantId prev, InstantId inst); - - typedef std::pair< eint, eint > IntIntPair; +class FlowProfile: public Profile { +private: + FlowProfile(const FlowProfile&); + FlowProfile& operator=(const FlowProfile&); + public: + /** + * @brief Constructor + */ + FlowProfile( const PlanDatabaseId db, const FVDetectorId flawDetector); + /** + * @brief Destructor + */ + virtual ~FlowProfile(); + /** + * @brief Retrieves the first (earliest) instant the transaction starts contributing to + * lower level. Will return true in case a instant has been associated with a transaction + * and will in that case store the instant in parameter. Returns false if no instant + * has been associated with transaction t. + */ + bool getEarliestLowerLevelInstant( const TransactionId t, InstantId& i ); + /** + * @brief Retrieves the first (earliest) instant the transaction starts contributing to + * upper level. Will return true in case a instant has been associated with a transaction + * and will in that case store the instant in parameter. Returns false if no instant + * has been associated with transaction t. + */ + bool getEarliestUpperLevelInstant( const TransactionId t, InstantId& i ); + /** + * @brief Deletes pre-existing FlowProfileGraphs for the lower and upper level and allocates new ones. + */ + template + void initializeGraphs() { + if(m_lowerLevelGraph != NULL) + delete m_lowerLevelGraph; + m_lowerLevelGraph = new FlowGraphType(m_dummySourceTransaction, + m_dummySinkTransaction, true); + + if(m_upperLevelGraph != NULL) + delete m_upperLevelGraph; + m_upperLevelGraph = new FlowGraphType(m_dummySourceTransaction, + m_dummySinkTransaction, false); + } + + + protected: + virtual void postHandleRecompute(const eint& endTime, const std::pair& endDiff); + /** + * @brief Enables a transaction t. A transaction is enabled a time T to calculate the + * envelopes for instant at time T if the lower bound of the time equals T (this is assuming + * envelopes are calculated from earliest to latest instant). Another way of formulating this + * is that a transaction is enabled at the time it moves from the open set to the pending set + * or straight to the closed set if the time is a singleton. + */ + void enableTransaction( const TransactionId t, const InstantId i ); + /** + * @brief Helper method for subclasses to respond to a temporal constraint being added between two transactions. + */ + void handleTemporalConstraintAdded(const TransactionId predecessor, + const unsigned int preArgIndex, + const TransactionId successor, + const unsigned int sucArgIndex); + + /** + * @brief Helper method for subclasses to respond to a temporal constraint being removed between two transactions. + */ + void handleTemporalConstraintRemoved(const TransactionId predecessor, + const unsigned int preArgIndex, + const TransactionId successor, + const unsigned int sucArgIndex); + /** + * @brief Updates the maximum flow graphs in case transactions t1 and t2 are now strictly ordered. + */ + void handleOrderedAt( const TransactionId t1, const TransactionId t2 ); + /** + * @brief Updates the maximum flow graphs in case transactions t1 and t2 are now weakly ordered. + */ + void handleOrderedAtOrBefore( const TransactionId t1, const TransactionId t2 ); + + void handleTransactionAdded( const TransactionId t); + void handleTransactionRemoved( const TransactionId t); + void handleTransactionTimeChanged( const TransactionId t, + const DomainListener::ChangeType& type ); + void handleTransactionQuantityChanged( const TransactionId t, + const DomainListener::ChangeType& type ); + void initRecompute(InstantId inst); + void initRecompute(); + Order getOrdering( const TransactionId t1, const TransactionId t2 ); + void recomputeLevels(InstantId prev, InstantId inst); + + typedef std::pair< eint, eint > IntIntPair; #ifdef _MSC_VER - typedef std::map< TransactionId, IntIntPair > TransactionId2IntIntPair; + typedef std::map< TransactionId, IntIntPair > TransactionId2IntIntPair; #else - typedef hash_src::hash_map< TransactionId, IntIntPair, TransactionIdHash > TransactionId2IntIntPair; + typedef boost::unordered_map< TransactionId, IntIntPair, TransactionIdHash > TransactionId2IntIntPair; #endif //_MSC_VER - TransactionId2IntIntPair m_previousTimeBounds; + TransactionId2IntIntPair m_previousTimeBounds; - TransactionId m_dummySourceTransaction; - TransactionId m_dummySinkTransaction; + TransactionId m_dummySourceTransaction; + TransactionId m_dummySinkTransaction; - FlowProfileGraph* m_lowerLevelGraph; - FlowProfileGraph* m_upperLevelGraph; + FlowProfileGraph* m_lowerLevelGraph; + FlowProfileGraph* m_upperLevelGraph; - edouble m_lowerClosedLevel; - edouble m_upperClosedLevel; + edouble m_lowerClosedLevel; + edouble m_upperClosedLevel; - bool m_recalculateLowerLevel; - bool m_recalculateUpperLevel; + bool m_recalculateLowerLevel; + bool m_recalculateUpperLevel; - typedef std::pair TransactionIdTransactionIdPair; - typedef std::map< TransactionIdTransactionIdPair, Order > TransactionIdTransactionIdPair2Order; - TransactionIdTransactionIdPair2Order m_orderings; - TransactionIdTransactionIdPair2Order m_orderedAt; + TransactionIdTransactionIdPair2Order m_orderings; + TransactionIdTransactionIdPair2Order m_orderedAt; - TransactionId2InstantId m_lowerLevelContribution; - TransactionId2InstantId m_upperLevelContribution; - }; + TransactionId2InstantId m_lowerLevelContribution; + TransactionId2InstantId m_upperLevelContribution; +}; } #endif //FLOW_PROFILE_HEADER__ diff --git a/src/PLASMA/Resource/component/FlowProfileGraph.cc b/src/PLASMA/Resource/component/FlowProfileGraph.cc new file mode 100644 index 000000000..17848fb3d --- /dev/null +++ b/src/PLASMA/Resource/component/FlowProfileGraph.cc @@ -0,0 +1,316 @@ +#include "FlowProfileGraph.hh" + +#include "Debug.hh" +#include "Edge.hh" +#include "EdgeIterator.hh" +#include "MaxFlow.hh" +#include "Node.hh" +#include "Number.hh" +#include "ConstrainedVariable.hh" +#include "Domain.hh" + +namespace EUROPA { +FlowProfileGraph::FlowProfileGraph(const TransactionId , + const TransactionId , + bool lowerLevel) + : m_lowerLevel(lowerLevel), m_recalculate(false) {} + +FlowProfileGraphImpl::FlowProfileGraphImpl(const TransactionId source, + const TransactionId sink, bool lowerLevel) + : FlowProfileGraph(source, sink, lowerLevel), m_maxflow(NULL), m_graph( 0 ), + m_source( 0 ), m_sink( 0 ) { + m_graph = new Graph(); + m_source = m_graph->createNode( source ); + m_sink = m_graph->createNode( sink ); + m_maxflow = new MaximumFlowAlgorithm( m_graph, m_source, m_sink ); +} + +FlowProfileGraphImpl::~FlowProfileGraphImpl() +{ + delete m_maxflow; + m_maxflow = 0; + + delete m_graph; + m_graph = 0; + + m_source = 0; + m_sink = 0; +} + +void FlowProfileGraphImpl::enableAt( const TransactionId t1, const TransactionId t2 ) +{ + debugMsg("FlowProfileGraph:enableAt","Transaction " + << t1->time()->toString() << " and transaction " + << t2->time()->toString() << " lower level: " + << std::boolalpha << m_lowerLevel ); + + + if( 0 == m_graph->getNode( t1 ) ) + return; + + if( 0 == m_graph->getNode( t2 ) ) + return; + + m_recalculate = true; + + m_graph->createEdge( t1, t2, Edge::getMaxCapacity() ); + m_graph->createEdge( t2, t1, Edge::getMaxCapacity() ); +} + +void FlowProfileGraphImpl::enableAtOrBefore( const TransactionId t1, const TransactionId t2 ) +{ + debugMsg("FlowProfileGraph:enableAtOrBefore","Transaction " + << t1->time()->toString() << " and transaction " + << t2->time()->toString() << " lower level: " + << std::boolalpha << m_lowerLevel ); + + + if( 0 == m_graph->getNode( t1 ) ) + return; + + if( 0 == m_graph->getNode( t2 ) ) + return; + + m_recalculate = true; + + m_graph->createEdge( t1, t2, 0 ); + m_graph->createEdge( t2, t1, Edge::getMaxCapacity() ); +} + +bool FlowProfileGraphImpl::isEnabled( const TransactionId transaction ) const +{ + Node* node = m_graph->getNode( transaction ); + + return 0 == node ? false : node->isEnabled(); +} + +void FlowProfileGraphImpl::enableTransaction( const TransactionId t, const InstantId i, TransactionId2InstantId contributions ) +{ + debugMsg("FlowProfileGraph:enableTransaction","Transaction (" + << t->getId() << ") " + << t->time()->toString() << " lower level: " + << std::boolalpha << m_lowerLevel ); + + TransactionId source = TransactionId::noId(); + TransactionId target = TransactionId::noId(); + + edouble edgeCapacity = 0; + + if( ( m_lowerLevel && t->isConsumer() ) + || + (!m_lowerLevel && !t->isConsumer() ) ) + { + // connect to the source of the graph + source = m_source->getIdentity(); + target = t; + + edgeCapacity = t->quantity()->lastDomain().getUpperBound(); + } + else + { + // connect to the sink of the graph + source = t; + target = m_sink->getIdentity(); + + edgeCapacity = t->quantity()->lastDomain().getLowerBound(); + } + + if( 0 == edgeCapacity ) + { + debugMsg("FlowProfileGraph:enableTransaction","Transaction " + << t << " starts contributing at " + << i->getTime() << " lower level " << std::boolalpha << m_lowerLevel ); + + contributions[ t ] = i; + + return; + } + + check_error( TransactionId::noId() != source ); + check_error( TransactionId::noId() != target ); + + m_recalculate = true; + + m_graph->createNode( t, true ); + m_graph->createEdge( source, target, edgeCapacity ); + m_graph->createEdge( target, source, 0 ); +} + +void FlowProfileGraphImpl::removeTransaction( const TransactionId id ) +{ + debugMsg("FlowProfileGraph:removeTransaction","Transaction (" + << id->getId() << ") lower level: " + << std::boolalpha << m_lowerLevel ); + + m_recalculate = true; + + m_graph->removeNode( id ); +} + +void FlowProfileGraphImpl::reset() +{ + m_recalculate = true; + + m_graph->setDisabled(); + + m_sink->setEnabled(); + m_source->setEnabled(); +} + + +edouble FlowProfileGraphImpl::getResidualFromSource() +{ + edouble residual = 0.0; + + if( m_recalculate ) + { + m_maxflow->execute(); + + m_recalculate = false; + } + + EdgeOutIterator ite( *m_source ); + + for( ; ite.ok(); ++ite ) + { + Edge* edge = *ite; + + residual += m_maxflow->getResidual( edge ); + } + + return residual; +} + +void FlowProfileGraphImpl::disable( const TransactionId id ) +{ + debugMsg("FlowProfileGraph:disable","Transaction (" + << id->getId() << ") lower level: " + << std::boolalpha << m_lowerLevel ); + + Node* node = m_graph->getNode( id ); + + check_error( 0 != node ); + check_error( node->isEnabled() ); + + node->setDisabled(); +} + +void FlowProfileGraphImpl::pushFlow( const TransactionId id ) +{ + Node* node = m_graph->getNode( id ); + + check_error( 0 != node ); + check_error( node->isEnabled() ); + + if( !m_recalculate ) + { + debugMsg("FlowProfileGraph:pushFlow","Transaction (" + << id->getId() << ") lower level: " + << std::boolalpha << m_lowerLevel ); + + m_maxflow->pushFlowBack( node ); + } + else + { + debugMsg("FlowProfileGraph:pushFlow","Transaction (" + << id->getId() << ") lower level: " + << std::boolalpha << m_lowerLevel + << " skipping pushing flow back because a recalculation is required."); + + } +} + +void FlowProfileGraphImpl::restoreFlow() +{ + m_maxflow->execute( false ); +} + + +edouble FlowProfileGraphImpl::disableReachableResidualGraph( TransactionId2InstantId contributions, const InstantId instant ) +{ + debugMsg("FlowProfileGraph:disableReachableResidualGraph","Lower level: " + << std::boolalpha << m_lowerLevel ); + + edouble residual = 0.0; + + if( m_recalculate ) + { + debugMsg("FlowProfileGraph:disableReachableResidualGraph","Lower level: " + << std::boolalpha << m_lowerLevel << ", recalculate invoked."); + + m_maxflow->execute(); + + Node2Bool visited; + + visited[ m_source ] = true; + + visitNeighbors( m_source, residual, visited, contributions, instant ); + } + + return residual; +} + +void FlowProfileGraphImpl::visitNeighbors(const Node* node, edouble& residual, + Node2Bool& visited, + TransactionId2InstantId contributions, + const InstantId instant) { + EdgeOutIterator ite( *node ); + + for( ; ite.ok(); ++ite ) + { + Edge* edge = *ite; + + Node* target = edge->getTarget(); + + if( false == visited[ target ] ) + { + if( 0 != m_maxflow->getResidual( edge ) ) + { + visited[ target ] = true; + + if( target != m_source && target != m_sink ) + { + debugMsg("FlowProfileGraph:visitNeighbors", + "Disabling node with transaction (" + << target->getIdentity()->getId() << ") lower level " << + std::boolalpha << m_lowerLevel << " due to " << *edge); + + target->setDisabled(); + + const TransactionId t = target->getIdentity(); + + debugMsg("FlowProfileGraph::visitNeighbors","Transaction " + << t << " starts contributing at " + << instant->getTime() << " lower level " << std::boolalpha << + m_lowerLevel ); + + contributions[ t ] = instant; + + int sign = t->isConsumer() ? -1 : +1; + + if( ( m_lowerLevel && t->isConsumer() ) + || + (!m_lowerLevel && !t->isConsumer() ) ) + { + debugMsg("FlowProfileGraph:visitNeighbors","Adding " + << sign * t->quantity()->lastDomain().getUpperBound() << + " to the level."); + + residual += sign * t->quantity()->lastDomain().getUpperBound(); + } + else + { + debugMsg("FlowProfileGraph:visitNeighbors","Adding " + << sign* t->quantity()->lastDomain().getLowerBound() << + " to the level."); + + residual += sign * t->quantity()->lastDomain().getLowerBound(); + } + + visitNeighbors( target, residual, visited, contributions, instant ); + } + } + } + } +} +} diff --git a/src/PLASMA/Resource/component/FlowProfileGraph.hh b/src/PLASMA/Resource/component/FlowProfileGraph.hh new file mode 100644 index 000000000..23cedc29a --- /dev/null +++ b/src/PLASMA/Resource/component/FlowProfileGraph.hh @@ -0,0 +1,189 @@ +#ifndef H_FlowProfileGraph +#define H_FlowProfileGraph + + +#include "Types.hh" + +namespace EUROPA { + +class Graph; +class MaximumFlowAlgorithm; +class Node; + +/** + * @brief Graph structure to determine the subset of pending transactions at time T + * which has the largest contribution to an envelope (see FlowProfile) + */ +class FlowProfileGraph +{ + public: + /** + * @brief Creates a directed graph with a source and a sink intended to calculate the + * lower level envelope in case lowerLevel is true otherwise intended to calculate the + * upper level envelope. + */ + FlowProfileGraph( const TransactionId source, const TransactionId sink, bool lowerLevel ); + /** + * @brief Destructor + */ + virtual ~FlowProfileGraph() {} + /** + * @brief Creates bi-directional edge between \a t1 and \a t2 with infinite capacity + * as a result of a concurrent constraint between the two transactions + */ + virtual void enableAt( const TransactionId t1, const TransactionId t2 ) = 0; + /** + * @brief Creates directed edge between \a t1 and \a t2 with infinite capacity + * as a result of a before or at constraint between the two transactions (reverse + * capacity set to zero) + */ + virtual void enableAtOrBefore( const TransactionId t1, const TransactionId t2 ) = 0; + /** + * @brief Creates a node in the network and creates an edge: + * + * \verbatim + * | lower level | upper level + * --------------------------------------------------------------------------------------------------------- + * transaction is consumer | w = q.upper | w = q.lower + * --------------------------------------------------------------------------------------------------------- + * transaction is producer | w = q.lower | w = q.upper + * --------------------------------------------------------------------------------------------------------- + * \endverbatim + */ + virtual void enableTransaction( const TransactionId transaction, const InstantId inst, TransactionId2InstantId contributions ) = 0; + /** + * @brief Returns true if \a transaction is enabled in the invoking + * instance + */ + virtual bool isEnabled( const TransactionId transaction ) const = 0; + /** + * @brief Disables \a transaction, if enabled, for the invoking instance + */ + virtual void disable( const TransactionId transaction ) = 0; + /** + * @brief Will push any flow wich flows through the node corresponding with \a transaction + * back to the source of the edge the flow originates from. + * + * When we move from one instant to another we retract all the transactions whose end time + * is equal to the new instant time and the transaction is still in the network. This method + * will push any flow going through this node back to where it is coming from after which we + * try again to push the flow to the sink. + + * Will error out if no node corresponding to \a transaction is in the network or if the node + * is not enabled. + * + * If a recalculation of the maximum flow is required this method will do nothing. + * \todo verify if this is really required or perhaps we should error out? + */ + virtual void pushFlow( const TransactionId transaction ) = 0; + /** + * @brief Returns the cummulative residual capacity originating from the source. + * + * Iterates over all outgoing edges from the source and sums the residual capicity of each + * edge. Might trigger a maximum flow (re) calculation if required. + */ + virtual edouble getResidualFromSource() = 0; + virtual edouble getResidualFromSource(const TransactionIdTransactionIdPair2Order& at, + const TransactionIdTransactionIdPair2Order& other) = 0; + /** + * @brief Disables every node reachable from the source in the residual network. Returns the sum + * of the contribution of each disabled node. The contribution is determined as following: + * \verbatim + * | lower level | upper level + * --------------------------------------------------------------------------------------------------------- + * transaction is consumer | q.upper | q.lower + * --------------------------------------------------------------------------------------------------------- + * transaction is producer | q.lower | q.upper + * --------------------------------------------------------------------------------------------------------- + * \endverbatim + * + * where q is the quantity variable associated with the transactions associated with the node. The parameter \a + * contributions, which maps a TransactionId to a InstantId is maps every transaction associated with a disabled + * node to \a instant. + */ + virtual edouble disableReachableResidualGraph( TransactionId2InstantId contributions, const InstantId instant ) = 0; + /** + * @brief Returns true if the invoking instance calculates the lower level, otherwise returns false which indicates + * the invoking instance is calculating the upper level. + */ + bool isLowerLevel() const { return m_lowerLevel; } + /** + * @brief Removes transaction \a id from the network. + */ + virtual void removeTransaction( const TransactionId id ) = 0; + /** + * @brief Resets the invoking instance. + * + * Resetting entails disabling all the nodes, implying disabling all the edges, except for the + * source and the sink. + * + */ + virtual void reset() = 0; + /** + * @brief Restore flow invokes the maximum flow algorithm without resetting the existing distances + * and existing flows on the nodes. + * + * Restore flows is done after extracting all the nodes that expire (go from pending to closed set + * at an instant) from the network by pushing flow back. + */ + virtual void restoreFlow() = 0; + protected: + /*! + * @brief Boolean indicating if the instance is intended to calculate the lower level + */ + bool m_lowerLevel; + /*! + * @brief Boolean indicating if the maximum flow solution needs to be recalculated + */ + bool m_recalculate; +}; + +class FlowProfileGraphImpl : public FlowProfileGraph { +private: + FlowProfileGraphImpl(const FlowProfileGraphImpl&); + FlowProfileGraphImpl& operator=(const FlowProfileGraphImpl&); + public: + FlowProfileGraphImpl(const TransactionId source, const TransactionId sink, bool lowerLevel); + ~FlowProfileGraphImpl(); + void enableAt( const TransactionId t1, const TransactionId t2 ); + void enableAtOrBefore(const TransactionId t1, const TransactionId t2); + void enableTransaction(const TransactionId transaction, const InstantId inst, + TransactionId2InstantId contributions); + bool isEnabled(const TransactionId transaction) const; + void disable(const TransactionId transaction); + void pushFlow( const TransactionId transaction ); + edouble getResidualFromSource(); + edouble getResidualFromSource(const TransactionIdTransactionIdPair2Order&, + const TransactionIdTransactionIdPair2Order&) { + return getResidualFromSource(); + } + + edouble disableReachableResidualGraph(TransactionId2InstantId contributions, const InstantId instant); + void removeTransaction(const TransactionId id); + void reset(); + void restoreFlow(); + private: + /** + * @brief Helper function for disableReachableResidualGraph + */ + void visitNeighbors( const Node* node, edouble& residual, Node2Bool& visited, TransactionId2InstantId contributions, const InstantId instant ); + + MaximumFlowAlgorithm* m_maxflow; + /*! + * @brief Bi directional graph datastructure + */ + Graph* m_graph; + /*! + * @brief Source for the maximum flow problem + */ + Node* m_source; + /*! + * @brief Sink for the maximum flow problem + */ + Node* m_sink; + +}; + +} + +#endif diff --git a/src/PLASMA/Resource/component/GenericFVDetector.cc b/src/PLASMA/Resource/component/GenericFVDetector.cc index 40e2774e2..25375551c 100644 --- a/src/PLASMA/Resource/component/GenericFVDetector.cc +++ b/src/PLASMA/Resource/component/GenericFVDetector.cc @@ -6,18 +6,19 @@ namespace EUROPA { - GenericFVDetector::GenericFVDetector(const ResourceId res) : FVDetector(res) { - m_maxInstConsumption = res->getMaxInstConsumption(); - m_maxInstProduction = res->getMaxInstProduction(); - m_maxCumulativeConsumption = res->getMaxConsumption(); - m_maxCumulativeProduction = res->getMaxProduction(); - debugMsg("GenericFVDetector:GenericFVDetector", "Created FVDetector for " << res->toString()); - debugMsg("GenericFVDetector:GenericFVDetector", "Got values: " - << " max instantaneous consumption(" << m_maxInstConsumption << ")" - << " max instantaneous production(" << m_maxInstProduction << ")" - << " max consumption(" << m_maxCumulativeConsumption << ")" - << " max production(" << m_maxCumulativeProduction << ")"); - } +GenericFVDetector::GenericFVDetector(const ResourceId res) + : FVDetector(res), + m_maxInstConsumption(res->getMaxInstConsumption()), + m_maxInstProduction(res->getMaxInstProduction()), + m_maxCumulativeConsumption(res->getMaxConsumption()), + m_maxCumulativeProduction(res->getMaxProduction()) { + debugMsg("GenericFVDetector:GenericFVDetector", "Created FVDetector for " << res->toString()); + debugMsg("GenericFVDetector:GenericFVDetector", "Got values: " + << " max instantaneous consumption(" << m_maxInstConsumption << ")" + << " max instantaneous production(" << m_maxInstProduction << ")" + << " max consumption(" << m_maxCumulativeConsumption << ")" + << " max production(" << m_maxCumulativeProduction << ")"); +} Resource::ProblemType GenericFVDetector::getResourceViolation(const InstantId inst) const { @@ -199,7 +200,7 @@ namespace EUROPA { } } - void GenericFVDetector::getLimitBounds(const InstantId& inst, edouble& lb, edouble& ub) const + void GenericFVDetector::getLimitBounds(const InstantId inst, edouble& lb, edouble& ub) const { // TODO: make 1 call instead of 2? lb = m_res->getLowerLimit(inst); @@ -207,7 +208,7 @@ namespace EUROPA { } // TODO: Level(t) = Capacity(t) - Usage(t) - void GenericFVDetector::getDefaultLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const + void GenericFVDetector::getDefaultLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const { const std::pair& capacityBounds = m_res->getCapacityProfile()->getValue(inst->getTime()); @@ -220,16 +221,18 @@ namespace EUROPA { ub = capacityBounds.second + usageUb; debugMsg("GenericFVDetector:getDeafultLevelBounds", - m_res->getName().toString() << " - time:" << inst->getTime() << " " + m_res->getName() << " - time:" << inst->getTime() << " " << "Capacity[" << capacityBounds.first << "," << capacityBounds.second << "] " << "Usage[" << usageLb << "," << usageUb << "] " << "Level[" << lb << "," << ub << "]"); } - GenericFVProfile::GenericFVProfile(GenericFVDetector* fvd, const ProfileId& profile, bool isFDProfile) + GenericFVProfile::GenericFVProfile(GenericFVDetector* fvd, const ProfileId profile, bool isFDProfile) : m_detector(fvd) , m_profile(profile) , m_isFDProfile(isFDProfile) + , m_times() + , m_bounds() { update(); } diff --git a/src/PLASMA/Resource/component/GenericFVDetector.hh b/src/PLASMA/Resource/component/GenericFVDetector.hh index 227400608..2ac4b9afb 100644 --- a/src/PLASMA/Resource/component/GenericFVDetector.hh +++ b/src/PLASMA/Resource/component/GenericFVDetector.hh @@ -1,5 +1,5 @@ -#ifndef _H_GenericFVDetector -#define _H_GenericFVDetector +#ifndef H_GenericFVDetector +#define H_GenericFVDetector #include "FVDetector.hh" #include "Instant.hh" @@ -50,34 +50,36 @@ namespace EUROPA { void handleResourceFlaws(const InstantId inst); virtual void handleResourceLevelFlaws(const InstantId inst); - virtual void getLimitBounds(const InstantId& inst, edouble& lb, edouble& ub) const; - void getDefaultLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const; + virtual void getLimitBounds(const InstantId inst, edouble& lb, edouble& ub) const; + void getDefaultLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const; // Requires sub-classing to handle open vs. closed world assumption - virtual void getFDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const = 0; // Level Bounds for FlawDetection - virtual void getVDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const = 0; // Level Bounds for ViolationDetection + virtual void getFDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const = 0; // Level Bounds for FlawDetection + virtual void getVDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const = 0; // Level Bounds for ViolationDetection friend class GenericFVProfile; }; - class GenericFVProfile : public PSResourceProfile - { - public: - GenericFVProfile(GenericFVDetector* fvd, const ProfileId& profile, bool isFDProfile); - virtual ~GenericFVProfile() {} +class GenericFVProfile : public PSResourceProfile { +private: + GenericFVProfile(const GenericFVProfile&); + GenericFVProfile& operator=(const GenericFVProfile&); + public: + GenericFVProfile(GenericFVDetector* fvd, const ProfileId profile, bool isFDProfile); + virtual ~GenericFVProfile() {} - virtual PSList getTimes(); - virtual double getLowerBound(TimePoint time); - virtual double getUpperBound(TimePoint time); + virtual PSList getTimes(); + virtual double getLowerBound(TimePoint time); + virtual double getUpperBound(TimePoint time); - protected: - GenericFVDetector* m_detector; - ProfileId m_profile; - bool m_isFDProfile; - PSList m_times; - std::map > m_bounds; + protected: + GenericFVDetector* m_detector; + ProfileId m_profile; + bool m_isFDProfile; + PSList m_times; + std::map > m_bounds; - void update(); - }; + void update(); +}; } #endif diff --git a/src/PLASMA/Resource/component/Graph.cc b/src/PLASMA/Resource/component/Graph.cc index fe171a12f..8659fcf4a 100644 --- a/src/PLASMA/Resource/component/Graph.cc +++ b/src/PLASMA/Resource/component/Graph.cc @@ -19,9 +19,7 @@ namespace EUROPA { - Graph::Graph() - { - } +Graph::Graph() : m_Nodes() {} Graph::~Graph() { @@ -58,7 +56,7 @@ namespace EUROPA node = new Node( identity ); graphDebug("Created node " - << *node ); + << *node << " initially " << (enabled ? "enabled" : "disabled")); m_Nodes[ identity ] = node; } @@ -135,6 +133,7 @@ namespace EUROPA void Graph::setDisabled() { + graphDebug("Disabling whole graph.") NodeIdentity2Node::iterator ite = m_Nodes.begin(); NodeIdentity2Node::iterator end = m_Nodes.end(); diff --git a/src/PLASMA/Resource/component/Graph.hh b/src/PLASMA/Resource/component/Graph.hh index 1377831b0..b16fd0ae2 100644 --- a/src/PLASMA/Resource/component/Graph.hh +++ b/src/PLASMA/Resource/component/Graph.hh @@ -15,53 +15,23 @@ namespace EUROPA { - /** - * @brief - */ class Graph { friend class NodeIterator; public: - /** - * @brief - */ Graph(); - /** - * @brief - */ ~Graph(); - /** - * @brief - */ Node* getNode( const NodeIdentity& identity ) const; - /** - * @brief - */ Node* createNode( const NodeIdentity& identity, bool enabled = true ); - /** - * @brief - */ void removeNode( const NodeIdentity& identity ); - /** - * @brief - */ inline Edge* getEdge( Node* source, Node* target ) const; - /** - * @brief - */ void createEdge( const NodeIdentity& source, const NodeIdentity& target, edouble capacity, bool enabled = true ); - /** - * @brief - */ inline const NodeIdentity2Node& getNodes() const; /*! * @brief Disables all the nodes and edges of the invoking graph */ void setDisabled(); private: - /** - * @brief - */ Edge* createEdge( Node* source, Node* target, edouble capacity, bool enabled = true ); NodeIdentity2Node m_Nodes; diff --git a/src/PLASMA/Resource/component/GroundedFVDetector.cc b/src/PLASMA/Resource/component/GroundedFVDetector.cc index 6a985ea49..80b91158d 100644 --- a/src/PLASMA/Resource/component/GroundedFVDetector.cc +++ b/src/PLASMA/Resource/component/GroundedFVDetector.cc @@ -12,7 +12,7 @@ GroundedFVDetector::GroundedFVDetector(const ResourceId res) // Here we handle the LowerLevelMax and UpperLevelMin which, in GroundedProfile are hacked to represent // the grounded min/max instead of the traditional meaning implied by their names. -void GroundedFVDetector::getFDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const +void GroundedFVDetector::getFDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const { const std::pair& capacityBounds = m_res->getCapacityProfile()->getValue(inst->getTime()); @@ -23,7 +23,7 @@ void GroundedFVDetector::getFDLevelBounds(const InstantId& inst, edouble& lb, ed ub = capacityBounds.second + usageUb; } -void GroundedFVDetector::getVDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const +void GroundedFVDetector::getVDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const { getDefaultLevelBounds(inst,lb,ub); } diff --git a/src/PLASMA/Resource/component/GroundedFVDetector.hh b/src/PLASMA/Resource/component/GroundedFVDetector.hh index 1b3c28b4c..8edee403d 100644 --- a/src/PLASMA/Resource/component/GroundedFVDetector.hh +++ b/src/PLASMA/Resource/component/GroundedFVDetector.hh @@ -1,5 +1,5 @@ -#ifndef _H_GroundedFVDetector -#define _H_GroundedFVDetector +#ifndef H_GroundedFVDetector +#define H_GroundedFVDetector #include "GenericFVDetector.hh" namespace EUROPA { @@ -9,8 +9,8 @@ namespace EUROPA { GroundedFVDetector(const ResourceId res); protected: - virtual void getFDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const; // Level Bounds for FlawDetection - virtual void getVDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const; // Level Bounds for ViolationDetection + virtual void getFDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const; // Level Bounds for FlawDetection + virtual void getVDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const; // Level Bounds for ViolationDetection }; } diff --git a/src/PLASMA/Resource/component/GroundedProfile.cc b/src/PLASMA/Resource/component/GroundedProfile.cc index f48973f50..9b431313e 100644 --- a/src/PLASMA/Resource/component/GroundedProfile.cc +++ b/src/PLASMA/Resource/component/GroundedProfile.cc @@ -29,7 +29,7 @@ void GroundedProfile::handleTransactionStart(bool isConsumer, const edouble & lb } } -void GroundedProfile::handleTransactionEnd(bool isConsumer, const edouble & lb, const edouble & ub) +void GroundedProfile::handleTransactionEnd(bool isConsumer, const edouble & lb, const edouble &) { if(isConsumer) { m_upperLevelMax -= lb; diff --git a/src/PLASMA/Resource/component/GroundedProfile.hh b/src/PLASMA/Resource/component/GroundedProfile.hh index 9d7c966ab..f211081e0 100644 --- a/src/PLASMA/Resource/component/GroundedProfile.hh +++ b/src/PLASMA/Resource/component/GroundedProfile.hh @@ -1,5 +1,5 @@ -#ifndef _H_GroundedProfile -#define _H_GroundedProfile +#ifndef H_GroundedProfile +#define H_GroundedProfile #include "ResourceDefs.hh" #include "Profile.hh" diff --git a/src/PLASMA/Resource/component/IncrementalFlowProfile.cc b/src/PLASMA/Resource/component/IncrementalFlowProfile.cc index f4455664e..e2c442b8e 100644 --- a/src/PLASMA/Resource/component/IncrementalFlowProfile.cc +++ b/src/PLASMA/Resource/component/IncrementalFlowProfile.cc @@ -25,6 +25,7 @@ #include "TemporalAdvisor.hh" #include "Utils.hh" #include "Variable.hh" +#include "FlowProfileGraph.hh" namespace EUROPA { @@ -64,7 +65,7 @@ namespace EUROPA m_upperClosedLevel = getInitCapacityUb(); } - initializeGraphs(); + initializeGraphs(); std::set enabledLower; std::set enabledUpper; @@ -79,7 +80,7 @@ namespace EUROPA for( ; iter != end; ++iter ) { - const TransactionId& transaction = (*iter); + const TransactionId transaction = (*iter); InstantId startLowerLevel; bool isContributingToLowerLevel = getEarliestLowerLevelInstant( transaction, startLowerLevel ); @@ -117,13 +118,13 @@ namespace EUROPA for( ; iter != end; ++iter ) { - const TransactionId& transaction1 = (*iter); + const TransactionId transaction1 = (*iter); std::set::const_iterator iter2 = iter; for( ; iter2 != end; ++iter2 ) { - const TransactionId& transaction2 = (*iter2); + const TransactionId transaction2 = (*iter2); if( transaction1 != transaction2 ) { @@ -159,13 +160,13 @@ namespace EUROPA for( ; iter != end; ++iter ) { - const TransactionId& transaction1 = (*iter); + const TransactionId transaction1 = (*iter); std::set::const_iterator iter2 = iter; for( ; iter2 != end; ++iter2 ) { - const TransactionId& transaction2 = (*iter2); + const TransactionId transaction2 = (*iter2); if( transaction1 != transaction2 ) { @@ -204,119 +205,118 @@ namespace EUROPA debugMsg("IncrementalFlowProfile::initRecompute",""); - initializeGraphs(); + initializeGraphs(); // initial level m_lowerClosedLevel = getInitCapacityLb(); m_upperClosedLevel = getInitCapacityUb(); } - bool IncrementalFlowProfile::enableOrderings( const InstantId& inst ) +bool IncrementalFlowProfile::enableOrderings( const InstantId inst ) { + debugMsg("IncrementalFlowProfile:enableOrderings","Instant Id (" << inst->getId() << ")"); + + bool returnValue = false; + + const std::set& startingTransactions = inst->getStartingTransactions(); + + std::set::const_iterator ite = startingTransactions.begin(); + std::set::const_iterator end = startingTransactions.end(); + + for( ; ite != end; ++ite ) + { + const TransactionId transaction1 = (*ite); + + if( !transaction1->time()->lastDomain().isSingleton() ) { - debugMsg("IncrementalFlowProfile:enableOrderings","Instant Id (" << inst->getId() << ")"); + enableTransaction( transaction1, inst ); + + returnValue = true; + + const std::set& transactions = inst->getTransactions(); - bool returnValue = false; + std::set::const_iterator iter = transactions.begin(); + std::set::const_iterator iterEnd = transactions.end(); - const std::set& startingTransactions = inst->getStartingTransactions(); + for( ; iter != iterEnd; ++iter ) + { + const TransactionId transaction2 = (*iter); - std::set::const_iterator ite = startingTransactions.begin(); - std::set::const_iterator end = startingTransactions.end(); + bool ordering12Calculated = false; + Order ordering12 = UNKNOWN; - for( ; ite != end; ++ite ) + if( m_recalculateLowerLevel ) { - const TransactionId& transaction1 = (*ite); + if( transaction1 != transaction2 + && + !transaction2->time()->lastDomain().isSingleton() + && + transaction2->time()->lastDomain().getUpperBound() != inst->getTime() + && + (transaction2->time()->lastDomain().getLowerBound() == inst->getTime() || m_lowerLevelGraph->isEnabled( transaction2 ) ) ) + { + ordering12 = getOrdering( transaction1, transaction2 ); + ordering12Calculated = true; - if( !transaction1->time()->lastDomain().isSingleton() ) + if( STRICTLY_AT == ordering12 ) + { + m_lowerLevelGraph->enableAt( transaction1, transaction2 ); + } + else if( BEFORE_OR_AT == ordering12 ) + { + m_lowerLevelGraph->enableAtOrBefore( transaction1, transaction2 ); + } + else if( AFTER_OR_AT == ordering12 ) { - enableTransaction( transaction1, inst ); - - returnValue = true; - - const std::set& transactions = inst->getTransactions(); - - std::set::const_iterator iter = transactions.begin(); - std::set::const_iterator end = transactions.end(); - - for( ; iter != end; ++iter ) - { - const TransactionId& transaction2 = (*iter); - - bool ordering12Calculated = false; - Order ordering12 = UNKNOWN; - - if( m_recalculateLowerLevel ) - { - if( transaction1 != transaction2 - && - !transaction2->time()->lastDomain().isSingleton() - && - transaction2->time()->lastDomain().getUpperBound() != inst->getTime() - && - (transaction2->time()->lastDomain().getLowerBound() == inst->getTime() || m_lowerLevelGraph->isEnabled( transaction2 ) ) ) - { - ordering12 = getOrdering( transaction1, transaction2 ); - ordering12Calculated = true; - - if( STRICTLY_AT == ordering12 ) - { - m_lowerLevelGraph->enableAt( transaction1, transaction2 ); - } - else if( BEFORE_OR_AT == ordering12 ) - { - m_lowerLevelGraph->enableAtOrBefore( transaction1, transaction2 ); - } - else if( AFTER_OR_AT == ordering12 ) - { - m_lowerLevelGraph->enableAtOrBefore( transaction2, transaction1 ); - } - else - { - debugMsg("IncrementalFlowProfile:enableOrderings","Transaction (" - << transaction1->getId() << ") and Transaction (" - << transaction2->getId() << ") not constrained"); - } - } - } - - if( m_recalculateUpperLevel ) - { - if( transaction1 != transaction2 - && - !transaction2->time()->lastDomain().isSingleton() - && - transaction2->time()->lastDomain().getUpperBound() != inst->getTime() - && - ( transaction2->time()->lastDomain().getLowerBound() == inst->getTime() || m_upperLevelGraph->isEnabled( transaction2 ) ) ) - { - if( !ordering12Calculated ) - ordering12 = getOrdering( transaction1, transaction2 ); - - if( STRICTLY_AT == ordering12 ) - { - m_upperLevelGraph->enableAt( transaction1, transaction2 ); - } - else if( BEFORE_OR_AT == ordering12 ) - { - m_upperLevelGraph->enableAtOrBefore( transaction1, transaction2 ); - } - else if( AFTER_OR_AT == ordering12 ) - { - m_upperLevelGraph->enableAtOrBefore( transaction2, transaction1 ); - } - else - { - debugMsg("IncrementalFlowProfile:enableOrderings","Transaction (" - << transaction1->getId() << ") and Transaction (" - << transaction2->getId() << ") not constrained"); - } - } - } - } + m_lowerLevelGraph->enableAtOrBefore( transaction2, transaction1 ); } + else + { + debugMsg("IncrementalFlowProfile:enableOrderings","Transaction (" + << transaction1->getId() << ") and Transaction (" + << transaction2->getId() << ") not constrained"); + } + } } - return returnValue; + if( m_recalculateUpperLevel ) + { + if( transaction1 != transaction2 + && + !transaction2->time()->lastDomain().isSingleton() + && + transaction2->time()->lastDomain().getUpperBound() != inst->getTime() + && + ( transaction2->time()->lastDomain().getLowerBound() == inst->getTime() || m_upperLevelGraph->isEnabled( transaction2 ) ) ) + { + if( !ordering12Calculated ) + ordering12 = getOrdering( transaction1, transaction2 ); + + if( STRICTLY_AT == ordering12 ) + { + m_upperLevelGraph->enableAt( transaction1, transaction2 ); + } + else if( BEFORE_OR_AT == ordering12 ) + { + m_upperLevelGraph->enableAtOrBefore( transaction1, transaction2 ); + } + else if( AFTER_OR_AT == ordering12 ) + { + m_upperLevelGraph->enableAtOrBefore( transaction2, transaction1 ); + } + else + { + debugMsg("IncrementalFlowProfile:enableOrderings","Transaction (" + << transaction1->getId() << ") and Transaction (" + << transaction2->getId() << ") not constrained"); + } + } + } + } } + } + + return returnValue; +} void IncrementalFlowProfile::recomputeLevels( InstantId prev, InstantId inst ) { @@ -333,208 +333,228 @@ namespace EUROPA recomputeLevels( inst, lowerLevel, upperLevel ); } - void IncrementalFlowProfile::recomputeLevels( InstantId inst, edouble lowerLevel, edouble upperLevel ) - { - // static int counter = 0; - // counter++; +void IncrementalFlowProfile::recomputeLevels( InstantId inst, edouble lowerLevel, + edouble upperLevel ) +{ + // static int counter = 0; + // counter++; - // debugMsg("Performance::recomputeLevels", "Invocation counter = " << counter ); + // debugMsg("Performance::recomputeLevels", "Invocation counter = " << counter ); - debugMsg("IncrementalFlowProfile::recomputeLevels","Instant (" - << inst->getId() << ") at time " - << inst->getTime() << " start levels [" - << lowerLevel << "," - << upperLevel << "]"); + debugMsg("IncrementalFlowProfile::recomputeLevels","Instant (" + << inst->getId() << ") at time " + << inst->getTime() << " start levels [" + << lowerLevel << "," + << upperLevel << "]"); - bool expansion = enableOrderings( inst ); + bool expansion = enableOrderings( inst ); + { + if( expansion ) + { + if( m_recalculateLowerLevel ) { - if( expansion ) - { - if( m_recalculateLowerLevel ) - { - edouble delta = m_lowerLevelGraph->disableReachableResidualGraph( m_lowerLevelContribution, inst ); + edouble delta = + m_lowerLevelGraph->disableReachableResidualGraph(m_lowerLevelContribution, + inst ); - debugMsg("IncrementalFlowProfile::recomputeLevels","Expansion leads to delta lower level of " - << delta ); + debugMsg("IncrementalFlowProfile::recomputeLevels", + "Expansion leads to delta lower level of " << delta ); - lowerLevel += delta; - } + lowerLevel += delta; + } - if( m_recalculateUpperLevel ) - { - edouble delta = m_upperLevelGraph->disableReachableResidualGraph( m_upperLevelContribution, inst ); + if( m_recalculateUpperLevel ) + { + edouble delta = + m_upperLevelGraph->disableReachableResidualGraph( m_upperLevelContribution, + inst ); - debugMsg("IncrementalFlowProfile::recomputeLevels","Expansion leads to delta upper level of " - << delta ); + debugMsg("IncrementalFlowProfile::recomputeLevels", + "Expansion leads to delta upper level of " << delta ); - upperLevel += delta; - } - } + upperLevel += delta; } + } + } - const std::set& endingTransactions = inst->getEndingTransactions(); + const std::set& endingTransactions = inst->getEndingTransactions(); - bool contraction = false; + bool contraction = false; - { - std::set::const_iterator ite = endingTransactions.begin(); - std::set::const_iterator end = endingTransactions.end(); + { + std::set::const_iterator ite = endingTransactions.begin(); + std::set::const_iterator end = endingTransactions.end(); - for( ; ite != end; ++ite ) - { - const TransactionId& ended = (*ite); - - if( m_recalculateLowerLevel ) - { - bool enteredClosedSet = false; + for( ; ite != end; ++ite ) + { + const TransactionId ended = (*ite); - // if it is still enabled it is not yet contributing to the level - if( m_lowerLevelGraph->isEnabled( ended ) ) - { - debugMsg("IncrementalFlowProfile::recomputeLevels","Contracting from lower graph transaction (" - << ended->getId() << ") " - << ended->time()->toString() << " " - << ended->quantity()->toString() ); - - enteredClosedSet = true; - contraction = true; - m_lowerLevelGraph->pushFlow( ended ); - m_lowerLevelGraph->disable( ended ); - } - else if( ended->time()->lastDomain().isSingleton() ) - { - debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" - << ended->getId() << ") straight from open to closed set"); + if( m_recalculateLowerLevel ) + { + bool enteredClosedSet = false; - enteredClosedSet = true; - } + // if it is still enabled it is not yet contributing to the level + if( m_lowerLevelGraph->isEnabled( ended ) ) + { + debugMsg("IncrementalFlowProfile::recomputeLevels", + "Contracting from lower graph transaction (" + << ended->getId() << ") " + << ended->time()->toString() << " " + << ended->quantity()->toString() ); + + enteredClosedSet = true; + contraction = true; + m_lowerLevelGraph->pushFlow( ended ); + m_lowerLevelGraph->disable( ended ); + } + else if( ended->time()->lastDomain().isSingleton() ) + { + debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" + << ended->getId() << ") straight from open to closed set"); - if( enteredClosedSet ) - { - debugMsg("IncrementalFlowProfile:recomputeLevels","Transaction " - << ended << " starts contributing at " - << inst->getTime() << " lower level true"); + enteredClosedSet = true; + } - m_lowerLevelContribution[ ended ] = inst; + if( enteredClosedSet ) + { + debugMsg("IncrementalFlowProfile:recomputeLevels","Transaction " + << ended << " starts contributing at " + << inst->getTime() << " lower level true"); - if( ended->isConsumer() ) - { - lowerLevel -= ended->quantity()->lastDomain().getUpperBound(); + m_lowerLevelContribution[ ended ] = inst; - debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" - << ended->getId() << ") decreases lower level by " - << ended->quantity()->lastDomain().getUpperBound() << " (new level " - << lowerLevel << ")"); - } - else - { - lowerLevel += ended->quantity()->lastDomain().getLowerBound(); + if( ended->isConsumer() ) + { + lowerLevel -= ended->quantity()->lastDomain().getUpperBound(); + debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" + << ended->getId() << ") decreases lower level by " + << ended->quantity()->lastDomain().getUpperBound() << + " (new level " + << lowerLevel << ")"); + } + else + { + lowerLevel += ended->quantity()->lastDomain().getLowerBound(); - debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" - << ended->getId() << ") increases lower level by " - << ended->quantity()->lastDomain().getLowerBound() << " (new level " - << lowerLevel << ")"); - } - } - } - if( m_recalculateUpperLevel ) - { - bool enteredClosedSet = false; + debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" + << ended->getId() << ") increases lower level by " + << ended->quantity()->lastDomain().getLowerBound() << + " (new level " + << lowerLevel << ")"); + } + } + } - if( m_upperLevelGraph->isEnabled( ended ) ) - { - debugMsg("IncrementalFlowProfile::recomputeLevels","Contracting from upper graph transaction (" - << ended->getId() << ") " - << ended->time()->toString() << " " - << ended->quantity()->toString() ); - - enteredClosedSet = true; - contraction = true; - m_upperLevelGraph->pushFlow( ended ); - m_upperLevelGraph->disable( ended ); - } - else if( ended->time()->lastDomain().isSingleton() ) - { - debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" - << ended->getId() << ") straight from open to closed set"); + if( m_recalculateUpperLevel ) + { + bool enteredClosedSet = false; - enteredClosedSet = true; - } + if( m_upperLevelGraph->isEnabled( ended ) ) + { + debugMsg("IncrementalFlowProfile::recomputeLevels", + "Contracting from upper graph transaction (" + << ended->getId() << ") " + << ended->time()->toString() << " " + << ended->quantity()->toString() ); + + enteredClosedSet = true; + contraction = true; + m_upperLevelGraph->pushFlow( ended ); + m_upperLevelGraph->disable( ended ); + } + else if( ended->time()->lastDomain().isSingleton() ) + { + debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" + << ended->getId() << ") straight from open to closed set"); - if( enteredClosedSet ) - { - debugMsg("IncrementalFlowProfile:recomputeLevels","Transaction " - << ended << " starts contributing at " - << inst->getTime() << " lower level false"); + enteredClosedSet = true; + } - m_upperLevelContribution[ ended ] = inst; + if( enteredClosedSet ) + { + debugMsg("IncrementalFlowProfile:recomputeLevels","Transaction " + << ended << " starts contributing at " + << inst->getTime() << " lower level false"); - if( ended->isConsumer() ) - { - upperLevel -= ended->quantity()->lastDomain().getLowerBound(); + m_upperLevelContribution[ ended ] = inst; - debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" - << ended->getId() << ") decreases upper level by " - << ended->quantity()->lastDomain().getLowerBound() << " (new level " - << upperLevel << ")"); - } - else - { - upperLevel += ended->quantity()->lastDomain().getUpperBound(); + if( ended->isConsumer() ) + { + upperLevel -= ended->quantity()->lastDomain().getLowerBound(); - debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" - << ended->getId() << ") increases upper level by " - << ended->quantity()->lastDomain().getUpperBound() << " (new level " - << upperLevel << ")"); } - } - } + debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" + << ended->getId() << ") decreases upper level by " + << ended->quantity()->lastDomain().getLowerBound() << + " (new level " + << upperLevel << ")"); } - - if( contraction ) + else { - if( m_recalculateLowerLevel ) - { - m_lowerLevelGraph->restoreFlow(); + upperLevel += ended->quantity()->lastDomain().getUpperBound(); - edouble delta = m_lowerLevelGraph->disableReachableResidualGraph( m_lowerLevelContribution, inst ); + debugMsg("IncrementalFlowProfile::recomputeLevels","Transaction (" + << ended->getId() << ") increases upper level by " + << ended->quantity()->lastDomain().getUpperBound() << + " (new level " + << upperLevel << ")"); } + } + } + } - debugMsg("IncrementalFlowProfile::recomputeLevels","Contraction leads to delta lower level of " - << delta ); + if( contraction ) + { + if( m_recalculateLowerLevel ) + { + m_lowerLevelGraph->restoreFlow(); - lowerLevel += delta; - } + edouble delta = + m_lowerLevelGraph->disableReachableResidualGraph( m_lowerLevelContribution, + inst ); - if( m_recalculateUpperLevel ) - { - m_upperLevelGraph->restoreFlow(); + debugMsg("IncrementalFlowProfile::recomputeLevels", + "Contraction leads to delta lower level of " + << delta ); - edouble delta = m_upperLevelGraph->disableReachableResidualGraph( m_upperLevelContribution, inst ); + lowerLevel += delta; + } - debugMsg("IncrementalFlowProfile::recomputeLevels","Contraction leads to delta upper level of " - << delta ); + if( m_recalculateUpperLevel ) + { + m_upperLevelGraph->restoreFlow(); - upperLevel += delta; - } - } + edouble delta = + m_upperLevelGraph->disableReachableResidualGraph( m_upperLevelContribution, + inst ); + + debugMsg("IncrementalFlowProfile::recomputeLevels", + "Contraction leads to delta upper level of " + << delta ); + + upperLevel += delta; } + } + } - debugMsg("IncrementalFlowProfile::recomputeLevels","Computed levels for instance at time " - << inst->getTime() << "[" - << lowerLevel << "," - << upperLevel << "]"); + debugMsg("IncrementalFlowProfile::recomputeLevels", + "Computed levels for instance at time " + << inst->getTime() << "[" + << lowerLevel << "," + << upperLevel << "]"); - debugMsg("IncrementalFlowProfile::calculatedLevels","Computed levels for instance at time " - << inst->getTime() << "[" - << lowerLevel << "," - << upperLevel << "]"); + debugMsg("IncrementalFlowProfile::calculatedLevels", + "Computed levels for instance at time " + << inst->getTime() << "[" + << lowerLevel << "," + << upperLevel << "]"); - inst->update( lowerLevel, lowerLevel, upperLevel, upperLevel, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 ); } + inst->update( lowerLevel, lowerLevel, upperLevel, upperLevel, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0 ); +} } diff --git a/src/PLASMA/Resource/component/IncrementalFlowProfile.hh b/src/PLASMA/Resource/component/IncrementalFlowProfile.hh index e26471094..594336538 100644 --- a/src/PLASMA/Resource/component/IncrementalFlowProfile.hh +++ b/src/PLASMA/Resource/component/IncrementalFlowProfile.hh @@ -17,30 +17,12 @@ namespace EUROPA public FlowProfile { public: - /** - * @brief - */ IncrementalFlowProfile( const PlanDatabaseId db, const FVDetectorId flawDetector); - /** - * @brief - */ virtual ~IncrementalFlowProfile(); - /** - * @brief - */ void initRecompute( InstantId inst ); - /** - * @brief - */ void initRecompute(); - /** - * @brief - */ void recomputeLevels( InstantId prev, InstantId inst ); - /** - * @brief - */ - bool enableOrderings( const InstantId& inst ); + bool enableOrderings( const InstantId inst ); private: void recomputeLevels( InstantId inst, edouble lowerLevel, edouble upperLevel ); diff --git a/src/PLASMA/Resource/component/InstantTokens.cc b/src/PLASMA/Resource/component/InstantTokens.cc index 1abcbf9d3..6136b7d08 100644 --- a/src/PLASMA/Resource/component/InstantTokens.cc +++ b/src/PLASMA/Resource/component/InstantTokens.cc @@ -3,67 +3,70 @@ #include "ResourceTokenRelation.hh" namespace EUROPA { - ReservoirToken::ReservoirToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReservoirToken::ReservoirToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const IntervalIntDomain& timeBaseDomain, const IntervalDomain& quantityBaseDomain, - bool isConsumer, + bool _isConsumer, bool closed, - bool activate) + bool _activate) : EventToken(planDatabase, predicateName, false, false, timeBaseDomain, - Token::noObject(), false), m_isConsumer(isConsumer) { + Token::noObject(), false), + m_quantity(), m_isConsumer(_isConsumer), m_activate(_activate) { check_error(quantityBaseDomain.getLowerBound() >= 0 && quantityBaseDomain.getUpperBound() <= PLUS_INFINITY); - commonInit(closed, activate, quantityBaseDomain); + commonInit(closed, _activate, quantityBaseDomain); //m_quantity->restrictBaseDomain(quantityBaseDomain); } - ReservoirToken::ReservoirToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReservoirToken::ReservoirToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, - bool isFact, + bool _isFact, const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, - bool isConsumer, + const std::string& objectName, + bool _isConsumer, bool closed, - bool activate) + bool _activate) : EventToken(planDatabase, predicateName, - rejectable, isFact, timeBaseDomain, objectName, false), m_isConsumer(isConsumer) { - commonInit(closed, activate, IntervalDomain( 0, PLUS_INFINITY ) ); + rejectable, _isFact, timeBaseDomain, objectName, false), + m_quantity(), m_isConsumer(_isConsumer), m_activate(_activate) { + commonInit(closed, _activate, IntervalDomain( 0, PLUS_INFINITY ) ); } - ReservoirToken::ReservoirToken(const TokenId& parent, - const LabelStr& relation, - const LabelStr& predicateName, + ReservoirToken::ReservoirToken(const TokenId parent, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, - bool isConsumer, + const std::string& objectName, + bool _isConsumer, bool closed, - bool activate) - : EventToken(parent, relation, predicateName, timeBaseDomain, objectName, false), m_isConsumer(isConsumer) { - commonInit(closed, activate, IntervalDomain( 0, PLUS_INFINITY )); + bool _activate) + : EventToken(parent, relation, predicateName, timeBaseDomain, objectName, false), + m_quantity(), m_isConsumer(_isConsumer), m_activate(_activate) { + commonInit(closed, _activate, IntervalDomain( 0, PLUS_INFINITY )); } - void ReservoirToken::commonInit(bool closed, bool activate, const IntervalDomain& quantityBaseDomain) { - m_activate = activate; - if(activate) { - StateDomain restrictDomain; - restrictDomain.insert(Token::ACTIVE); - m_state->restrictBaseDomain(restrictDomain); - } - m_quantity = (new TokenVariable(m_id, m_allVariables.size(), - m_planDatabase->getConstraintEngine(), - quantityBaseDomain, - false, true, LabelStr("quantity")))->getId(); - m_allVariables.push_back(m_quantity); - ConstraintId relation = (new ResourceTokenRelation(m_planDatabase->getConstraintEngine(), - makeScope(m_state, m_object), - getId()))->getId(); - m_standardConstraints.insert(relation); - if(closed) - close(); - } +void ReservoirToken::commonInit(bool closed, bool _activate, const IntervalDomain& quantityBaseDomain) { + m_activate = _activate; + if(m_activate) { + StateDomain restrictDomain; + restrictDomain.insert(Token::ACTIVE); + m_state->restrictBaseDomain(restrictDomain); + } + m_quantity = (new TokenVariable(m_id, m_allVariables.size(), + m_planDatabase->getConstraintEngine(), + quantityBaseDomain, + false, true, "quantity"))->getId(); + m_allVariables.push_back(m_quantity); + ConstraintId relation = (new ResourceTokenRelation(m_planDatabase->getConstraintEngine(), + makeScope(m_state, m_object), + getId()))->getId(); + m_standardConstraints.insert(relation); + if(closed) + close(); +} void ReservoirToken::close() { EventToken::close(); @@ -71,7 +74,7 @@ namespace EUROPA { activateInternal(); } - const ConstrainedVariableId& ReservoirToken::getQuantity() const { + const ConstrainedVariableId ReservoirToken::getQuantity() const { return m_quantity; } diff --git a/src/PLASMA/Resource/component/InstantTokens.hh b/src/PLASMA/Resource/component/InstantTokens.hh index 8e1e8940b..4de0214c3 100644 --- a/src/PLASMA/Resource/component/InstantTokens.hh +++ b/src/PLASMA/Resource/component/InstantTokens.hh @@ -1,5 +1,5 @@ -#ifndef _H_InstantTokens -#define _H_InstantTokens +#ifndef H_InstantTokens +#define H_InstantTokens #include "ResourceDefs.hh" #include "EventToken.hh" @@ -7,34 +7,34 @@ namespace EUROPA { class ReservoirToken : public EventToken { public: - ReservoirToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReservoirToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, const IntervalIntDomain& timeBaseDomain = IntervalIntDomain(), const IntervalDomain& quantityBaseDomain = IntervalDomain(0, PLUS_INFINITY), bool isConsumer = false, bool closed = true, bool activate = true); - ReservoirToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, + ReservoirToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool isConsumer, bool closed, bool activate = true); - ReservoirToken(const TokenId& parent, - const LabelStr& relation, - const LabelStr& predicateName, + ReservoirToken(const TokenId parent, + const std::string& relation, + const std::string& predicateName, const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, + const std::string& objectName, bool isConsumer, bool closed, bool activate = true); - const ConstrainedVariableId& getQuantity() const; + const ConstrainedVariableId getQuantity() const; bool isConsumer() const; void print(std::ostream& os); virtual void close(); @@ -46,69 +46,74 @@ namespace EUROPA { bool m_activate; }; - class ConsumerToken : public ReservoirToken { - public: - ConsumerToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - const IntervalIntDomain& timeBaseDomain = IntervalIntDomain(), - const IntervalDomain quantityBaseDomain = IntervalDomain(0, PLUS_INFINITY), - bool closed = true, - bool activate = true) - : ReservoirToken(planDatabase, predicateName, timeBaseDomain, quantityBaseDomain, true, closed, activate) { - } - ConsumerToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate = true) - : ReservoirToken(planDatabase, predicateName, rejectable, isFact, timeBaseDomain, objectName, true, closed, activate) { - } +class ConsumerToken : public ReservoirToken { + public: + ConsumerToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + const IntervalIntDomain& timeBaseDomain = IntervalIntDomain(), + const IntervalDomain quantityBaseDomain = IntervalDomain(0, PLUS_INFINITY), + bool closed = true, + bool _activate = true) + : ReservoirToken(planDatabase, predicateName, timeBaseDomain, + quantityBaseDomain, true, closed, _activate) { + } + ConsumerToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + const IntervalIntDomain& timeBaseDomain, + const std::string& objectName, + bool closed, + bool _activate = true) + : ReservoirToken(planDatabase, predicateName, rejectable, _isFact, + timeBaseDomain, objectName, true, closed, _activate) { + } - ConsumerToken(const TokenId& parent, - const LabelStr& relation, - const LabelStr& predicateName, - const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate = true) - : ReservoirToken(parent, relation, predicateName, timeBaseDomain, objectName, true, closed, activate) { - } - }; + ConsumerToken(const TokenId parent, + const std::string& relation, + const std::string& predicateName, + const IntervalIntDomain& timeBaseDomain, + const std::string& objectName, + bool closed, + bool _activate = true) + : ReservoirToken(parent, relation, predicateName, timeBaseDomain, objectName, true, closed, _activate) { + } +}; - class ProducerToken : public ReservoirToken { - public: - ProducerToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - const IntervalIntDomain& timeBaseDomain = IntervalIntDomain(), - const IntervalDomain quantityBaseDomain = IntervalDomain(0, PLUS_INFINITY), - bool closed = true, - bool activate = true) - : ReservoirToken(planDatabase, predicateName, timeBaseDomain, quantityBaseDomain, false, closed, activate) { - } - ProducerToken(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate = true) - : ReservoirToken(planDatabase, predicateName, rejectable, isFact, timeBaseDomain, objectName, false, closed, activate) { - } +class ProducerToken : public ReservoirToken { + public: + ProducerToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + const IntervalIntDomain& timeBaseDomain = IntervalIntDomain(), + const IntervalDomain quantityBaseDomain = IntervalDomain(0, PLUS_INFINITY), + bool closed = true, + bool _activate = true) + : ReservoirToken(planDatabase, predicateName, timeBaseDomain, quantityBaseDomain, + false, closed, _activate) { + } + ProducerToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + const IntervalIntDomain& timeBaseDomain, + const std::string& objectName, + bool closed, + bool _activate = true) + : ReservoirToken(planDatabase, predicateName, rejectable, _isFact, + timeBaseDomain, objectName, false, closed, _activate) { + } - ProducerToken(const TokenId& parent, - const LabelStr& relation, - const LabelStr& predicateName, - const IntervalIntDomain& timeBaseDomain, - const LabelStr& objectName, - bool closed, - bool activate = true) - : ReservoirToken(parent, relation, predicateName, timeBaseDomain, objectName, false, closed, activate) { - } - }; + ProducerToken(const TokenId parent, + const std::string& relation, + const std::string& predicateName, + const IntervalIntDomain& timeBaseDomain, + const std::string& objectName, + bool closed, + bool _activate = true) + : ReservoirToken(parent, relation, predicateName, timeBaseDomain, objectName, + false, closed, _activate) { + } +}; } diff --git a/src/PLASMA/Resource/component/Jamfile b/src/PLASMA/Resource/component/Jamfile index a0dba5b12..05bf3dceb 100644 --- a/src/PLASMA/Resource/component/Jamfile +++ b/src/PLASMA/Resource/component/Jamfile @@ -11,6 +11,8 @@ ModuleComponent Resource MaxFlow.cc Types.cc FlowProfile.cc + FlowProfileGraph.cc + BoostFlowProfileGraph.cc IncrementalFlowProfile.cc GroundedProfile.cc InstantTokens.cc diff --git a/src/PLASMA/Resource/component/MaxFlow.cc b/src/PLASMA/Resource/component/MaxFlow.cc index 5c0ac8c70..d40f75a53 100644 --- a/src/PLASMA/Resource/component/MaxFlow.cc +++ b/src/PLASMA/Resource/component/MaxFlow.cc @@ -15,25 +15,61 @@ namespace EUROPA { - MaximumFlowAlgorithm::MaximumFlowAlgorithm( Graph* g, Node* source, Node* sink ): - m_Graph( g ), - m_Source( source ), - m_Sink( sink ), - m_NodeListIterator( m_Nodes.end() ) - { - checkError( g != 0, "Null not allowed as input for g" ); - checkError( source != 0, "Null not allowed as input for source" ); - checkError( sink != 0, "Null not allowed as input for sink" ); - checkError( g->getNode( source->getIdentity() ) != 0, "Source is not part of the graph" ); - checkError( g->getNode( sink->getIdentity() ) != 0, "Sink is not part of the graph"); - - graphDebug("Maximum flow instance created with source " - << *source << " and sink " - << *sink ); - } - - void MaximumFlowAlgorithm::print( std::ostream& os ) const - { - - } +MaximumFlowAlgorithm::MaximumFlowAlgorithm( Graph* g, Node* source, Node* sink ): + m_CurrentOutEdgeOnNode(), + m_EndOutEdgeOnNode(), + m_ExcessOnNode(), + m_DistanceOnNode(), + m_OnEdge(), + m_Nodes(), + m_Graph( g ), + m_Source( source ), + m_Sink( sink ), + m_NodeListIterator( m_Nodes.end() ) +{ + checkError( g != 0, "Null not allowed as input for g" ); + checkError( source != 0, "Null not allowed as input for source" ); + checkError( sink != 0, "Null not allowed as input for sink" ); + checkError( g->getNode( source->getIdentity() ) != 0, "Source is not part of the graph" ); + checkError( g->getNode( sink->getIdentity() ) != 0, "Sink is not part of the graph"); + + graphDebug("Maximum flow instance created with source " + << *source << " and sink " + << *sink ); +} + +void MaximumFlowAlgorithm::print( std::ostream& ) const +{ + +} + +eint MaximumFlowAlgorithm::distanceOnNode(Node* n) const { + Node2Long::const_iterator it = m_DistanceOnNode.find(n); + checkError(it != m_DistanceOnNode.end(), "Failed to find distance for " << *n); + return it->second; +} + +//edouble MaximumFlowAlgorithm::flow(Edge* e) const { +//} + +edouble MaximumFlowAlgorithm::getExcess(Node* n) const { + Node2Double::const_iterator it = m_ExcessOnNode.find(n); + checkError(it != m_ExcessOnNode.end(), "Failed to find excess for " << *n); + return it->second; +} + +EdgeList::const_iterator MaximumFlowAlgorithm::currentOutEdgeOnNode(Node* n) const { + Node2EdgeListIteratorMap::const_iterator it = m_CurrentOutEdgeOnNode.find(n); + checkError(it != m_CurrentOutEdgeOnNode.end(), + "Failed to find a current out-edge iterator for " << *n); + return it->second; +} + +EdgeList::const_iterator MaximumFlowAlgorithm::endOutEdgeOnNode(Node* n) const { + Node2EdgeListIteratorMap::const_iterator it = m_EndOutEdgeOnNode.find(n); + checkError(it != m_EndOutEdgeOnNode.end(), + "Failed to find an end out-edge iterator for " << *n); + return it->second; +} + } diff --git a/src/PLASMA/Resource/component/MaxFlow.hh b/src/PLASMA/Resource/component/MaxFlow.hh index 728785c5a..8fdfcf8ad 100644 --- a/src/PLASMA/Resource/component/MaxFlow.hh +++ b/src/PLASMA/Resource/component/MaxFlow.hh @@ -15,6 +15,8 @@ #include "NodeIterator.hh" #include "EdgeIterator.hh" +#include + #ifndef LONG_MAX // Would prefer to declare a static const variable, but that would be // bad style inside a header, so there's another 'ifndef LONG_MAX' @@ -24,461 +26,434 @@ namespace EUROPA { - /** - * @brief - */ - class MaximumFlowAlgorithm - { - public: - /** - * @brief - */ - MaximumFlowAlgorithm( Graph* g, Node* source, Node* sink ); - /** - * @brief - */ - Graph* getGraph() const { return m_Graph; } - /** - * @brief - */ - Node* getSource() const { return m_Source; } - /** - * @brief - */ - Node* getSink() const { return m_Sink; } - /** - * @brief - */ - inline void execute( bool reset = true ); - /** - * @brief - */ - void print( std::ostream& os ) const; - /** - * @brief - */ - inline edouble getMaxFlow() const; - /** - * @brief - */ - inline edouble getFlow( Edge* edge ) const; - /** - * @brief - */ - inline void pushFlowBack( Node* node ); - /** - * @brief - */ - inline edouble getResidual( Edge* edge ) const; - private: - /** - * @brief - */ - inline void disCharge( Node* node ); - /** - * @brief - */ - inline void initializePre( bool reset = true ); - /** - * @brief - */ - inline bool isAdmissible( Edge* edge ); - /** - * @brief - */ - inline void push( Edge* edge ); - /** - * @brief - */ - inline void reLabel( Node* n ); - /** - * @brief - */ - inline Node* getNextInList(); - /** - * @brief - */ - inline void resetToFront(); - -#ifdef _MSC_VER - typedef map< Node*, EdgeList::const_iterator > Node2EdgeListIteratorMap; -#else - typedef hash_src::hash_map< Node*, EdgeList::const_iterator, NodeHash > Node2EdgeListIteratorMap; -#endif //_MSC_VER - - Node2EdgeListIteratorMap m_CurrentOutEdgeOnNode; - Node2EdgeListIteratorMap m_EndOutEdgeOnNode; - - Node2Double m_ExcessOnNode; - Node2Long m_DistanceOnNode; - Edge2DoubleMap m_OnEdge; - - NodeList m_Nodes; - Graph* m_Graph; - Node* m_Source; - Node* m_Sink; - - NodeList::iterator m_NodeListIterator; - }; - - edouble MaximumFlowAlgorithm::getMaxFlow() const - { - if( m_ExcessOnNode.find( m_Sink ) == m_ExcessOnNode.end() ) - return 0.0; - - return m_ExcessOnNode.find( m_Sink )->second; - } +class MaximumFlowAlgorithm +{ +private: + MaximumFlowAlgorithm(const MaximumFlowAlgorithm&); + MaximumFlowAlgorithm& operator=(const MaximumFlowAlgorithm&); + public: + MaximumFlowAlgorithm( Graph* g, Node* source, Node* sink ); + Graph* getGraph() const { return m_Graph; } + Node* getSource() const { return m_Source; } + Node* getSink() const { return m_Sink; } + inline void execute( bool reset = true ); + void print( std::ostream& os ) const; + inline edouble getMaxFlow() const; + inline edouble getFlow( Edge* edge ) const; + inline void pushFlowBack( Node* node ); + inline edouble getResidual( Edge* edge ) const; + private: + + eint distanceOnNode(Node* n) const; + //inline edouble flow(Edge* e) const; + edouble getExcess(Node* n) const; + EdgeList::const_iterator currentOutEdgeOnNode(Node* n) const; + EdgeList::const_iterator endOutEdgeOnNode(Node* n) const; + + inline void disCharge( Node* node ); + inline void initializePre( bool reset = true ); + inline bool isAdmissible( Edge* edge ) const; + inline void push( Edge* edge ); + inline void reLabel( Node* n ); + inline Node* getNextInList(); + inline void resetToFront(); + + #ifdef _MSC_VER + typedef map< Node*, EdgeList::const_iterator > Node2EdgeListIteratorMap; + #else + typedef boost::unordered_map< Node*, EdgeList::const_iterator, NodeHash > Node2EdgeListIteratorMap; + #endif //_MSC_VER + + Node2EdgeListIteratorMap m_CurrentOutEdgeOnNode; + Node2EdgeListIteratorMap m_EndOutEdgeOnNode; + + Node2Double m_ExcessOnNode; + Node2Long m_DistanceOnNode; + Edge2DoubleMap m_OnEdge; + + NodeList m_Nodes; + Graph* m_Graph; + Node* m_Source; + Node* m_Sink; + + NodeList::iterator m_NodeListIterator; + }; + + edouble MaximumFlowAlgorithm::getMaxFlow() const + { + if( m_ExcessOnNode.find( m_Sink ) == m_ExcessOnNode.end() ) + return 0.0; + + return m_ExcessOnNode.find( m_Sink )->second; + } + + edouble MaximumFlowAlgorithm::getFlow( Edge* edge ) const + { + Edge2DoubleMap::const_iterator it = m_OnEdge.find(edge); + checkError(it != m_OnEdge.end(), "Failed to find flow for edge " << *edge); + return it->second; + } + + edouble MaximumFlowAlgorithm::getResidual( Edge* edge ) const + { + return edge->getCapacity() - getFlow( edge ); + } + + + Node* MaximumFlowAlgorithm::getNextInList() + { + Node* node = NULL; + + if( m_NodeListIterator == m_Nodes.end() ) + { + m_NodeListIterator = m_Nodes.begin(); + } + else + { + ++m_NodeListIterator; + } + + NodeList::iterator end = m_Nodes.end(); + + while( m_NodeListIterator != end && + !(*m_NodeListIterator)->isEnabled() ) + { + ++m_NodeListIterator; + } - edouble MaximumFlowAlgorithm::getFlow( Edge* edge ) const - { - return m_OnEdge.find( edge )->second; - } + if( m_NodeListIterator != end ) + node = *m_NodeListIterator; - edouble MaximumFlowAlgorithm::getResidual( Edge* edge ) const - { - return edge->getCapacity() - getFlow( edge ); - } + return node; + } + void MaximumFlowAlgorithm::resetToFront() + { + if( m_NodeListIterator != m_Nodes.end() ) + { + Node* n = (*m_NodeListIterator); + m_Nodes.erase( m_NodeListIterator ); + m_Nodes.push_front( n ); - Node* MaximumFlowAlgorithm::getNextInList() - { - Node* node = 0; + m_NodeListIterator = m_Nodes.end(); + } + } - if( m_NodeListIterator == m_Nodes.end() ) - { - m_NodeListIterator = m_Nodes.begin(); - } - else - { - ++m_NodeListIterator; - } - NodeList::iterator end = m_Nodes.end(); + void MaximumFlowAlgorithm::execute( bool reset ) + { + graphDebug("Start execute, reset is " << std::boolalpha << reset ); - while( m_NodeListIterator != end && - !(*m_NodeListIterator)->isEnabled() ) - { - ++m_NodeListIterator; - } + initializePre( reset ); - if( m_NodeListIterator != end ) - node = *m_NodeListIterator; + Node* n = getNextInList(); - return node; - } + while( n != NULL ) + { + eint oldDistance = distanceOnNode( n ); - void MaximumFlowAlgorithm::resetToFront() - { - if( m_NodeListIterator != m_Nodes.end() ) - { - Node* n = (*m_NodeListIterator); - m_Nodes.erase( m_NodeListIterator ); - m_Nodes.push_front( n ); + disCharge( n ); - m_NodeListIterator = m_Nodes.end(); - } - } + if( distanceOnNode( n ) > oldDistance ) + { + resetToFront(); + } + n = getNextInList(); + } - void MaximumFlowAlgorithm::execute( bool reset ) - { - graphDebug("Start execute, reset is " << std::boolalpha << reset ); + graphDebug("End execute, max flow: " + << getMaxFlow() ); + } - initializePre( reset ); + void MaximumFlowAlgorithm::initializePre( bool reset ) + { + graphDebug("Start initializePre " << this); - Node* n = getNextInList(); + checkError( m_Source->isEnabled(),"Source '" << *m_Source << "' is not enabled."); + checkError( m_Sink->isEnabled(),"Sink '" << *m_Sink << "' is not enabled." ); - while( n != 0 ) - { - eint oldDistance = m_DistanceOnNode[ n ]; + if( reset ) + { + m_CurrentOutEdgeOnNode.clear(); + m_EndOutEdgeOnNode.clear(); + m_DistanceOnNode.clear(); + m_ExcessOnNode.clear(); - disCharge( n ); + m_OnEdge.clear(); - if( m_DistanceOnNode[ n ] > oldDistance ) - { - resetToFront(); - } + m_Nodes.clear(); + } - n = getNextInList(); - } + const NodeIdentity2Node& nodes = m_Graph->getNodes(); - graphDebug("End execute, max flow: " - << getMaxFlow() ); - } + NodeIdentity2Node::const_iterator nIte = nodes.begin(); + NodeIdentity2Node::const_iterator nEnd = nodes.end(); - void MaximumFlowAlgorithm::initializePre( bool reset ) - { - graphDebug("Start initializePre"); + for( ; nIte != nEnd; ++nIte ) + { + Node* node = (*nIte).second; - checkError( m_Source->isEnabled(),"Source '" << *m_Source << "' is not enabled."); - checkError( m_Sink->isEnabled(),"Sink '" << *m_Sink << "' is not enabled." ); + graphDebug("Initializing node " + << *node << " of " << nodes.size()); - if( reset ) - { - m_CurrentOutEdgeOnNode.clear(); - m_EndOutEdgeOnNode.clear(); - m_DistanceOnNode.clear(); - m_ExcessOnNode.clear(); + if( node->isEnabled() ) + { + m_CurrentOutEdgeOnNode[ node ] = node->getOutEdges().begin(); + m_EndOutEdgeOnNode[ node ] = node->getOutEdges().end(); - m_OnEdge.clear(); + while( m_CurrentOutEdgeOnNode[ node ] != m_EndOutEdgeOnNode[ node ] && + !(*m_CurrentOutEdgeOnNode[ node ])->getTarget()->isEnabled() ) + ++m_CurrentOutEdgeOnNode[ node ]; - m_Nodes.clear(); - } + if( reset ) + { + if( node != m_Source && node != m_Sink ) + m_Nodes.push_back( node ); - const NodeIdentity2Node& nodes = m_Graph->getNodes(); + graphDebug("Setting distance and excess for node " + << *node << " to 1 and 0.0"); - NodeIdentity2Node::const_iterator nIte = nodes.begin(); - NodeIdentity2Node::const_iterator nEnd = nodes.end(); + m_DistanceOnNode[ node ] = 1; + m_ExcessOnNode[ node ] = 0.0; - for( ; nIte != nEnd; ++nIte ) - { - Node* node = (*nIte).second; + const EdgeList& outEdges = node->getOutEdges(); - graphDebug("Initializing node " - << *node ); + EdgeList::const_iterator fIte = outEdges.begin(); + EdgeList::const_iterator fEnd = outEdges.end(); - if( node->isEnabled() ) + for( ; fIte != fEnd; ++fIte ) { - m_CurrentOutEdgeOnNode[ node ] = node->getOutEdges().begin(); - m_EndOutEdgeOnNode[ node ] = node->getOutEdges().end(); - - while( m_CurrentOutEdgeOnNode[ node ] != m_EndOutEdgeOnNode[ node ] && !(*m_CurrentOutEdgeOnNode[ node ])->getTarget()->isEnabled() ) - ++m_CurrentOutEdgeOnNode[ node ]; + Edge* edge = *fIte; - if( reset ) + if( edge->isEnabled() ) { - if( node != m_Source && node != m_Sink ) - m_Nodes.push_back( node ); - - graphDebug("Setting distance and excess for node " - << *node << " to 1 and 0.0"); + graphDebug("Initializing flow on edge " + << *edge << " to be 0"); - m_DistanceOnNode[ node ] = 1; - m_ExcessOnNode[ node ] = 0.0; + m_OnEdge[ edge ] = 0.0; - const EdgeList& outEdges = node->getOutEdges(); + checkError( 0 != m_Graph->getEdge( edge->getTarget(), edge->getSource() ) + && + m_Graph->getEdge( edge->getTarget(), edge->getSource() )->isEnabled(), + "No (enabled) reverse edge for edge '" << *edge << "'"); - EdgeList::const_iterator fIte = outEdges.begin(); - EdgeList::const_iterator fEnd = outEdges.end(); - - for( ; fIte != fEnd; ++fIte ) - { - Edge* edge = *fIte; - - if( edge->isEnabled() ) - { - graphDebug("Initializing flow on edge " - << *edge << " to be 0"); - - m_OnEdge[ edge ] = 0.0; - - checkError( 0 != m_Graph->getEdge( edge->getTarget(), edge->getSource() ) - && - m_Graph->getEdge( edge->getTarget(), edge->getSource() )->isEnabled(), - "No (enabled) reverse edge for edge '" << *edge << "'"); - - m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] = 0.0; - } - } + m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] = 0.0; } } } + } + } - m_DistanceOnNode[ m_Sink ] = 0; - m_DistanceOnNode[ m_Source ] = (long) m_Nodes.size(); + m_DistanceOnNode[ m_Sink ] = 0; + m_DistanceOnNode[ m_Source ] = static_cast(m_Nodes.size()); - m_NodeListIterator = m_Nodes.end(); + m_NodeListIterator = m_Nodes.end(); - EdgeOutIterator edgeOutIte( *m_Source ); + EdgeOutIterator edgeOutIte( *m_Source ); - for( ; edgeOutIte.ok(); ++edgeOutIte ) - { - Edge* edge = *edgeOutIte; + for( ; edgeOutIte.ok(); ++edgeOutIte ) + { + Edge* edge = *edgeOutIte; - // check edge is enabled + // check edge is enabled - edouble flow = m_OnEdge[ edge ]; - edouble residual = edge->getCapacity() - flow; + edouble flow = getFlow(edge); + edouble residual = edge->getCapacity() - flow; - graphDebug("Initializing flow from source " - << *m_Source << " for edge " - << *edge << ", flow is " - << flow << " residual is " - << residual ); + graphDebug("Initializing flow from source " + << *m_Source << " for edge " + << *edge << ", flow is " + << flow << " residual is " + << residual ); - if( residual != 0 ) - { - m_OnEdge[ edge ] = flow + residual; - m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] = - (flow + residual); + if( residual != 0 ) + { + m_OnEdge[ edge ] = flow + residual; + m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] = - (flow + residual); - Node* target = edge->getTarget(); + Node* target = edge->getTarget(); - edouble excess = m_ExcessOnNode[ target ]; + edouble excess = getExcess(target); - m_ExcessOnNode[ target ] = excess + residual; + m_ExcessOnNode[ target ] = excess + residual; - graphDebug("Initializing flow on edge " - << *edge << " to be " - << m_OnEdge[ edge ] << " (reverse flow " - << m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] << ") and excess on node " - << *target << " to be " - << m_ExcessOnNode[ target ] ); + graphDebug("Initializing flow on edge " + << *edge << " to be " + << getFlow(edge) << " (reverse flow " + << getFlow(m_Graph->getEdge( edge->getTarget(), edge->getSource() )) << + ") and excess on node " + << *target << " to be " + << getExcess(target) ); - } - } - - graphDebug("End initializePre"); } + } - void MaximumFlowAlgorithm::disCharge( Node* node ) - { - checkError( 0 != node, "Node is null, null is not allowed as input"); - checkError( node->isEnabled(), "Node '" << *node << "' not enabled."); + graphDebug("End initializePre"); +} - graphDebug("Discharge invoked for node " - << *node << " witch excess " - << m_ExcessOnNode[ node ] ); +void MaximumFlowAlgorithm::disCharge( Node* node ) +{ + checkError( 0 != node, "Node is null, null is not allowed as input"); + checkError( node->isEnabled(), "Node '" << *node << "' not enabled."); - while( m_ExcessOnNode[ node ] != 0 ) - { - Edge* edge = 0; + graphDebug("Discharge invoked for node " + << *node << " witch excess " + << getExcess(node) ); - EdgeList::const_iterator ite = m_CurrentOutEdgeOnNode[ node ]; + while( getExcess(node) != 0 ) + { + Edge* edge = NULL; - if( ite != m_EndOutEdgeOnNode[ node ] ) - edge = (*ite); + EdgeList::const_iterator ite = currentOutEdgeOnNode(node); - assert( edge != 0 ); + if( ite != endOutEdgeOnNode(node) ) + edge = (*ite); - if( isAdmissible( edge ) ) - { - push( edge ); - } - else - { - reLabel( node ); + assert( edge != NULL ); - ++ite; + if( isAdmissible( edge ) ) + { + push( edge ); + } + else + { + reLabel( node ); - if( ite == m_EndOutEdgeOnNode[ node ] ) - { - ite = node->getOutEdges().begin(); - } + ++ite; - m_CurrentOutEdgeOnNode[node] = ite; - } + if( ite == endOutEdgeOnNode(node) ) + { + ite = node->getOutEdges().begin(); } + while(ite != endOutEdgeOnNode(node) && !(*ite)->getTarget()->isEnabled()) + ++ite; + + m_CurrentOutEdgeOnNode[node] = ite; } + } - bool MaximumFlowAlgorithm::isAdmissible( Edge* edge ) - { - graphDebug("Checking edge " - << *edge << " if admissable, flow is " - << m_OnEdge[ edge ] << " distance of source is " - << m_DistanceOnNode[ edge->getSource() ] << " distance of target is " - << m_DistanceOnNode[ edge->getTarget() ] ); +} +bool MaximumFlowAlgorithm::isAdmissible( Edge* edge ) const +{ + Edge2DoubleMap::const_iterator flowIt = m_OnEdge.find(edge); + Node2Long::const_iterator sourceDistanceIt = + m_DistanceOnNode.find(edge->getSource()); + Node2Long::const_iterator targetDistanceIt = + m_DistanceOnNode.find(edge->getTarget()); + checkError(flowIt != m_OnEdge.end(), + "Failed to find flow for " << *edge); + checkError(sourceDistanceIt != m_DistanceOnNode.end(), + "Failed to find distance for source node " << *(edge->getSource())); + checkError(targetDistanceIt != m_DistanceOnNode.end(), + "Failed to find distance for target node " << *(edge->getTarget())); + graphDebug("Checking edge " + << *edge << " if admissable, flow is " + << flowIt->second << " distance of source is " + << sourceDistanceIt->second << " distance of target is " + << targetDistanceIt->second); + + + return (flowIt->second < edge->getCapacity()) && + (sourceDistanceIt->second == targetDistanceIt->second + 1); +} - return ( m_OnEdge[ edge ] < edge->getCapacity() ) - && - ( m_DistanceOnNode[ edge->getSource() ] == m_DistanceOnNode[ edge->getTarget() ] + 1 ); - } +void MaximumFlowAlgorithm::pushFlowBack( Node* node ) +{ + EdgeInIterator ite( *node ); - void MaximumFlowAlgorithm::pushFlowBack( Node* node ) - { - EdgeInIterator ite( *node ); + for( ; ite.ok(); ++ite ) + { + Edge* edge = *ite; - for( ; ite.ok(); ++ite ) - { - Edge* edge = *ite; + Node* source = edge->getSource(); - Node* source = edge->getSource(); + edouble flow_pushed_back = getFlow( edge ); - edouble flow_pushed_back = getFlow( edge ); - - if( flow_pushed_back > 0 && edge->getCapacity() != 0 ) - { - m_ExcessOnNode[ source ] = m_ExcessOnNode[ source ] + flow_pushed_back; - m_OnEdge[ edge ] = 0.0; - m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] = 0.0; - } - } + if( flow_pushed_back > 0 && edge->getCapacity() != 0 ) + { + m_ExcessOnNode[ source ] = getExcess(source) + flow_pushed_back; + m_OnEdge[ edge ] = 0.0; + m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] = 0.0; } + } +} - void MaximumFlowAlgorithm::push( Edge* edge ) - { - Node* source = edge->getSource(); - Node* target = edge->getTarget(); +void MaximumFlowAlgorithm::push( Edge* edge ) +{ + Node* source = edge->getSource(); + Node* target = edge->getTarget(); - edouble excess = m_ExcessOnNode[ source ]; - edouble residual = edge->getCapacity() - m_OnEdge[ edge ]; + edouble excess = getExcess(source); + edouble residual = edge->getCapacity() - getFlow(edge); - assert( residual >= 0 ); + assert( residual >= 0 ); - edouble delta = (excess > residual ) ? residual : excess; + edouble delta = (excess > residual ) ? residual : excess; - edouble newFlow = m_OnEdge[ edge ] + delta; - m_OnEdge[ edge ] = newFlow; - m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] = - newFlow; + edouble newFlow = getFlow(edge) + delta; + m_OnEdge[ edge ] = newFlow; + m_OnEdge[ m_Graph->getEdge( edge->getTarget(), edge->getSource() ) ] = - newFlow; - m_ExcessOnNode[ target ] = m_ExcessOnNode[ target ] + delta; - m_ExcessOnNode[ source ] = m_ExcessOnNode[ source ] - delta; + m_ExcessOnNode[ target ] = getExcess(target) + delta; + m_ExcessOnNode[ source ] = getExcess(source) - delta; - graphDebug("Pushed flow " - << delta << " on edge " - << *edge << " makes excess on node " - << *source << " " - << m_ExcessOnNode[ source ] << " and on " - << *target << " " - << m_ExcessOnNode[ target ] ); + graphDebug("Pushed flow " + << delta << " on edge " + << *edge << " makes excess on node " + << *source << " " + << getExcess(source) << " and on " + << *target << " " + << getExcess(target) ); - } +} - void MaximumFlowAlgorithm::reLabel( Node* n ) - { - graphDebug("Relabel node " - << *n ); +void MaximumFlowAlgorithm::reLabel( Node* n ) +{ + graphDebug("Relabel node " + << *n ); - eint minLabel = std::numeric_limits::max(); + eint minLabel = std::numeric_limits::max(); - EdgeOutIterator edgeOutIte( *n ); + EdgeOutIterator edgeOutIte( *n ); - for( ; edgeOutIte.ok(); ++edgeOutIte ) - { - Edge* edge = *edgeOutIte; + for( ; edgeOutIte.ok(); ++edgeOutIte ) + { + Edge* edge = *edgeOutIte; - Node* target = edge->getTarget(); + Node* target = edge->getTarget(); - graphDebug("Relabel node " - << *n << " checking edge " - << *edge << " to relabel, flow on edge is " - << m_OnEdge[ edge ] ); - //m_OnEdge[ edge ] < edge->getCapacity() - if( getResidual( edge ) > 0 ) - { - eint label = m_DistanceOnNode[ target ]; + graphDebug("Relabel node " + << *n << " checking edge " + << *edge << " to relabel, flow on edge is " + << getFlow(edge) ); + //m_OnEdge[ edge ] < edge->getCapacity() + if( getResidual( edge ) > 0 ) + { + eint label = distanceOnNode( target ); - if( minLabel >= label ) - { - graphDebug("Node " - << *target << " is labeled with label " - << label ); + if( minLabel >= label ) + { + graphDebug("Node " + << *target << " is labeled with label " + << label ); - minLabel = label; - } - } + minLabel = label; } + } + } - //at this point all distance-labels for the connected nodes are smaller or equal to node n - m_DistanceOnNode[ n ] = minLabel + 1; + //at this point all distance-labels for the connected nodes are smaller or equal to node n + m_DistanceOnNode[ n ] = minLabel + 1; - graphDebug("(Re)labeled node " - << *n << " to have distance " - << m_DistanceOnNode[ n ] ); - } + graphDebug("(Re)labeled node " + << *n << " to have distance " + << distanceOnNode( n ) ); +} } #endif //MAXIMUM_FLOW_ALGORITHM_HEADER_FILE_ diff --git a/src/PLASMA/Resource/component/NDDL/InterpreterResources.cc b/src/PLASMA/Resource/component/NDDL/InterpreterResources.cc index 01bd108db..d734a4768 100644 --- a/src/PLASMA/Resource/component/NDDL/InterpreterResources.cc +++ b/src/PLASMA/Resource/component/NDDL/InterpreterResources.cc @@ -1,10 +1,11 @@ #include "InterpreterResources.hh" #include "NddlResource.hh" +#include "PSVarValue.hh" namespace EUROPA { - ReusableObjectFactory::ReusableObjectFactory(const ObjectTypeId& objType, const LabelStr& signature) + ReusableObjectFactory::ReusableObjectFactory(const ObjectTypeId objType, const std::string& signature) : NativeObjectFactory(objType,signature) { } @@ -14,9 +15,9 @@ namespace EUROPA { } ObjectId ReusableObjectFactory::makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { Id instance = (new NDDL::NddlReusable(planDb, objectType, objectName,true))->getId(); @@ -40,32 +41,32 @@ namespace EUROPA { } instance->handleDefaults(false /*don't close the object yet*/); - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native " << m_className.toString() << ":" << objectName.toString() << " type:" << objectType.toString()); + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native " << m_className << ":" << objectName << " type:" << objectType); return instance; } - ReusableUsesTokenType::ReusableUsesTokenType(const ObjectTypeId& ot,const LabelStr& predicateName) - : NativeTokenType(ot,predicateName) - { - addArg(FloatDT::instance(),"quantity"); - addArg(IntDT::instance(),"time"); - } +ReusableUsesTokenType::ReusableUsesTokenType(const ObjectTypeId ot,const std::string& predicateName) + : NativeTokenType(ot,predicateName) +{ + addArg(FloatDT::instance(),"quantity"); + addArg(IntDT::instance(),"time"); +} - TokenId ReusableUsesTokenType::createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable, bool isFact) const - { - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reusable.uses"); - return (new NDDL::NddlReusable::uses(planDb,name,rejectable,isFact,true))->getId(); - } +TokenId ReusableUsesTokenType::createInstance(const PlanDatabaseId planDb, + const std::string& name, bool rejectable, bool isFact) const { + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reusable.uses"); + return (new NDDL::NddlReusable::uses(planDb,name,rejectable,isFact,true))->getId(); +} - TokenId ReusableUsesTokenType::createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const - { - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reusable.uses"); - return (new NDDL::NddlReusable::uses(master,name,relation,true))->getId(); - } +TokenId ReusableUsesTokenType::createInstance(const TokenId master, const std::string& name, + const std::string& relation) const { + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reusable.uses"); + return (new NDDL::NddlReusable::uses(master,name,relation,true))->getId(); +} - CBReusableObjectFactory::CBReusableObjectFactory(const ObjectTypeId& objType, const LabelStr& signature) + CBReusableObjectFactory::CBReusableObjectFactory(const ObjectTypeId objType, const std::string& signature) : NativeObjectFactory(objType,signature) { } @@ -75,9 +76,9 @@ namespace EUROPA { } ObjectId CBReusableObjectFactory::makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { Id instance = (new NDDL::NddlCBReusable(planDb, objectType, objectName,true))->getId(); @@ -101,12 +102,12 @@ namespace EUROPA { } instance->handleDefaults(false /*don't close the object yet*/); - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native " << m_className.toString() << ":" << objectName.toString() << " type:" << objectType.toString()); + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native " << m_className << ":" << objectName << " type:" << objectType); return instance; } - ReservoirObjectFactory::ReservoirObjectFactory(const ObjectTypeId& objType, const LabelStr& signature) + ReservoirObjectFactory::ReservoirObjectFactory(const ObjectTypeId objType, const std::string& signature) : NativeObjectFactory(objType,signature) { } @@ -116,9 +117,9 @@ namespace EUROPA { } ObjectId ReservoirObjectFactory::makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { Id instance = (new NDDL::NddlReservoir(planDb, objectType, objectName,true))->getId(); @@ -142,51 +143,54 @@ namespace EUROPA { } instance->handleDefaults(false /*don't close the object yet*/); - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native " << m_className.toString() << ":" << objectName.toString() << " type:" << objectType.toString()); + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native " << m_className << ":" << objectName << " type:" << objectType); return instance; } - ReservoirProduceTokenType::ReservoirProduceTokenType(const ObjectTypeId& ot,const LabelStr& predicateName) - : NativeTokenType(ot,predicateName) - { - addArg(FloatDT::instance(),"quantity"); - addArg(IntDT::instance(),"time"); - } +ReservoirProduceTokenType::ReservoirProduceTokenType(const ObjectTypeId ot, + const std::string& predicateName) + : NativeTokenType(ot,predicateName) { + addArg(FloatDT::instance(),"quantity"); + addArg(IntDT::instance(),"time"); +} - TokenId ReservoirProduceTokenType::createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable, bool isFact) const - { - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reservoir.produce"); - return (new NDDL::NddlReservoir::produce(planDb,name,rejectable,isFact,true))->getId(); - } +TokenId ReservoirProduceTokenType::createInstance(const PlanDatabaseId planDb, + const std::string& name, bool rejectable, + bool isFact) const { + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reservoir.produce"); + return (new NDDL::NddlReservoir::produce(planDb,name,rejectable,isFact,true))->getId(); +} - TokenId ReservoirProduceTokenType::createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const - { - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reservoir.produce"); - return (new NDDL::NddlReservoir::produce(master,name,relation,true))->getId(); - } +TokenId ReservoirProduceTokenType::createInstance(const TokenId master, const std::string& name, + const std::string& relation) const { + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reservoir.produce"); + return (new NDDL::NddlReservoir::produce(master,name,relation,true))->getId(); +} - ReservoirConsumeTokenType::ReservoirConsumeTokenType(const ObjectTypeId& ot,const LabelStr& predicateName) - : NativeTokenType(ot,predicateName) - { - addArg(FloatDT::instance(),"quantity"); - addArg(IntDT::instance(),"time"); - } +ReservoirConsumeTokenType::ReservoirConsumeTokenType(const ObjectTypeId ot, + const std::string& predicateName) + : NativeTokenType(ot,predicateName) { + addArg(FloatDT::instance(),"quantity"); + addArg(IntDT::instance(),"time"); +} - TokenId ReservoirConsumeTokenType::createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable, bool isFact) const - { - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reservoir.consume"); - return (new NDDL::NddlReservoir::consume(planDb,name,rejectable,isFact,true))->getId(); - } +TokenId ReservoirConsumeTokenType::createInstance(const PlanDatabaseId planDb, + const std::string& name, bool rejectable, + bool isFact) const { + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reservoir.consume"); + return (new NDDL::NddlReservoir::consume(planDb,name,rejectable,isFact,true))->getId(); +} - TokenId ReservoirConsumeTokenType::createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const - { - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reservoir.consume"); - return (new NDDL::NddlReservoir::consume(master,name,relation,true))->getId(); - } +TokenId ReservoirConsumeTokenType::createInstance(const TokenId master, + const std::string& name, + const std::string& relation) const { + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Reservoir.consume"); + return (new NDDL::NddlReservoir::consume(master,name,relation,true))->getId(); +} - UnaryObjectFactory::UnaryObjectFactory(const ObjectTypeId& objType, const LabelStr& signature) + UnaryObjectFactory::UnaryObjectFactory(const ObjectTypeId objType, const std::string& signature) : NativeObjectFactory(objType,signature) { } @@ -196,9 +200,9 @@ namespace EUROPA { } ObjectId UnaryObjectFactory::makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const { Id instance = (new NDDL::NddlUnary(planDb, objectType, objectName,true))->getId(); @@ -218,24 +222,25 @@ namespace EUROPA { } instance->handleDefaults(false /*don't close the object yet*/); - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native " << m_className.toString() << ":" << objectName.toString() << " type:" << objectType.toString()); + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native " << m_className << ":" << objectName << " type:" << objectType); return instance; } - TokenId UnaryUseTokenType::createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable, bool isFact) const - { - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Unary.Use"); - return (new NDDL::NddlUnary::use(planDb,name,rejectable,isFact,true))->getId(); - } +TokenId UnaryUseTokenType::createInstance(const PlanDatabaseId planDb, + const std::string& name, bool rejectable, + bool isFact) const { + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Unary.Use"); + return (new NDDL::NddlUnary::use(planDb,name,rejectable,isFact,true))->getId(); +} - TokenId UnaryUseTokenType::createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const - { - debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Unary.Use"); - return (new NDDL::NddlUnary::use(master,name,relation,true))->getId(); - } +TokenId UnaryUseTokenType::createInstance(const TokenId master, const std::string& name, + const std::string& relation) const { + debugMsg("XMLInterpreter:NativeObjectFactory","Created Native Unary.Use"); + return (new NDDL::NddlUnary::use(master,name,relation,true))->getId(); +} - DataRef SetCapacity::eval(EvalContext& context, const std::vector& args) const +DataRef SetCapacity::eval(EvalContext& , const std::vector& args) const { check_runtime_error(args.size()==4,"SetCapacity expects 4 parameters"); @@ -268,12 +273,12 @@ namespace EUROPA { return signature; } - const DataTypeId& SetCapacity::getReturnType() + const DataTypeId SetCapacity::getReturnType() { return VoidDT::instance(); } - DataRef SetLimit::eval(EvalContext& context, const std::vector& args) const +DataRef SetLimit::eval(EvalContext& , const std::vector& args) const { check_runtime_error(args.size()==4,"SetLimit expects 4 parameters"); @@ -306,7 +311,7 @@ namespace EUROPA { return signature; } - const DataTypeId& SetLimit::getReturnType() + const DataTypeId SetLimit::getReturnType() { return VoidDT::instance(); } diff --git a/src/PLASMA/Resource/component/NDDL/InterpreterResources.hh b/src/PLASMA/Resource/component/NDDL/InterpreterResources.hh index 5ff006478..a84468bd2 100644 --- a/src/PLASMA/Resource/component/NDDL/InterpreterResources.hh +++ b/src/PLASMA/Resource/component/NDDL/InterpreterResources.hh @@ -1,5 +1,5 @@ -#ifndef _H_TransactionInterpreterResources -#define _H_TransactionInterpreterResources +#ifndef H_TransactionInterpreterResources +#define H_TransactionInterpreterResources #include "Interpreter.hh" @@ -8,98 +8,102 @@ namespace EUROPA { class ReusableObjectFactory : public NativeObjectFactory { public: - ReusableObjectFactory(const ObjectTypeId& objType, const LabelStr& signature); + ReusableObjectFactory(const ObjectTypeId objType, const std::string& signature); virtual ~ReusableObjectFactory(); protected: virtual ObjectId makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const; }; - class ReusableUsesTokenType: public NativeTokenType - { - public: - ReusableUsesTokenType(const ObjectTypeId& ot,const LabelStr& predicateName); +class ReusableUsesTokenType: public NativeTokenType { + public: + ReusableUsesTokenType(const ObjectTypeId ot,const std::string& predicateName); - private: - virtual TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable , bool isFact) const; - virtual TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const; - }; + private: + virtual TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, + bool rejectable , bool isFact) const; + virtual TokenId createInstance(const TokenId master, const std::string& name, + const std::string& relation) const; +}; class CBReusableObjectFactory : public NativeObjectFactory { public: - CBReusableObjectFactory(const ObjectTypeId& objType, const LabelStr& signature); + CBReusableObjectFactory(const ObjectTypeId objType, const std::string& signature); virtual ~CBReusableObjectFactory(); protected: virtual ObjectId makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const; }; class ReservoirObjectFactory : public NativeObjectFactory { public: - ReservoirObjectFactory(const ObjectTypeId& objType, const LabelStr& signature); + ReservoirObjectFactory(const ObjectTypeId objType, const std::string& signature); virtual ~ReservoirObjectFactory(); protected: virtual ObjectId makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const; }; - class ReservoirProduceTokenType: public NativeTokenType - { - public: - ReservoirProduceTokenType(const ObjectTypeId& ot,const LabelStr& predicateName); - - private: - virtual TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable , bool isFact) const; - virtual TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const; - }; - - class ReservoirConsumeTokenType: public NativeTokenType - { - public: - ReservoirConsumeTokenType(const ObjectTypeId& ot,const LabelStr& predicateName); - - private: - virtual TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable , bool isFact) const; - virtual TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const; - }; +class ReservoirProduceTokenType: public NativeTokenType { + public: + ReservoirProduceTokenType(const ObjectTypeId ot,const std::string& predicateName); + + private: + virtual TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, + bool rejectable , bool isFact) const; + virtual TokenId createInstance(const TokenId master, const std::string& name, + const std::string& relation) const; +}; + +class ReservoirConsumeTokenType: public NativeTokenType { + public: + ReservoirConsumeTokenType(const ObjectTypeId ot,const std::string& predicateName); + + private: + virtual TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, + bool rejectable , bool isFact) const; + virtual TokenId createInstance(const TokenId master, const std::string& name, + const std::string& relation) const; +}; class UnaryObjectFactory : public NativeObjectFactory { public: - UnaryObjectFactory(const ObjectTypeId& objType, const LabelStr& signature); + UnaryObjectFactory(const ObjectTypeId objType, const std::string& signature); virtual ~UnaryObjectFactory(); protected: virtual ObjectId makeNewObject( - const PlanDatabaseId& planDb, - const LabelStr& objectType, - const LabelStr& objectName, + const PlanDatabaseId planDb, + const std::string& objectType, + const std::string& objectName, const std::vector& arguments) const; }; - class UnaryUseTokenType: public NativeTokenType - { - public: - UnaryUseTokenType(const ObjectTypeId& ot,const LabelStr& predicateName) : NativeTokenType(ot,predicateName) {} +class UnaryUseTokenType: public NativeTokenType { + public: + UnaryUseTokenType(const ObjectTypeId ot,const std::string& predicateName) : NativeTokenType(ot,predicateName) {} - private: - virtual TokenId createInstance(const PlanDatabaseId& planDb, const LabelStr& name, bool rejectable , bool isFact) const; - virtual TokenId createInstance(const TokenId& master, const LabelStr& name, const LabelStr& relation) const; - }; + private: + virtual TokenId createInstance(const PlanDatabaseId planDb, const std::string& name, + bool rejectable , bool isFact) const; + virtual TokenId createInstance(const TokenId master, const std::string& name, + const std::string& relation) const; +}; class SetCapacity : public Method { @@ -110,7 +114,7 @@ namespace EUROPA { virtual DataRef eval(EvalContext& context, const std::vector& args) const; virtual const std::vector& getSignature(); - virtual const DataTypeId& getReturnType(); + virtual const DataTypeId getReturnType(); }; class SetLimit : public Method @@ -122,7 +126,7 @@ namespace EUROPA { virtual DataRef eval(EvalContext& context, const std::vector& args) const; virtual const std::vector& getSignature(); - virtual const DataTypeId& getReturnType(); + virtual const DataTypeId getReturnType(); }; } diff --git a/src/PLASMA/Resource/component/NDDL/NddlResource.cc b/src/PLASMA/Resource/component/NDDL/NddlResource.cc index fb73ba4cd..77dd412a5 100644 --- a/src/PLASMA/Resource/component/NDDL/NddlResource.cc +++ b/src/PLASMA/Resource/component/NDDL/NddlResource.cc @@ -10,6 +10,9 @@ #include "Instant.hh" #include "Profile.hh" +#define inf PLUS_INFINITY + +using namespace EUROPA; namespace NDDL { // ------------------------------------------------------------------------------------------------------- @@ -19,21 +22,21 @@ namespace NDDL { static const std::string PARAM_PROFILE_TYPE("profileType"); static const std::string PARAM_DETECTOR_TYPE("detectorType"); -bool isValidCombo(const std::string& profileName, const std::string& detectorName) -{ - if(profileName == "GroundedProfile" && detectorName != "GroundedFVDetector") - return false; +namespace { +bool isValidCombo(const std::string& profileName, const std::string& detectorName) { + if(profileName == "GroundedProfile" && detectorName != "GroundedFVDetector") + return false; - return true; + return true; } // For getting either the profile or detector name specified by the given parameter. We also check that each is valid, and that the two // are valid to use together -std::pair getProfileAndDetectorNames(const Object* res, const std::string& defaultProfile, const std::string& defaultDetector) +std::pair getProfileAndDetectorNames(const Object* res, const std::string& defaultProfile, const std::string& defaultDetector) { - std::string pFullName = res->getName().toString()+"."+PARAM_PROFILE_TYPE; - std::string dFullName = res->getName().toString()+"."+PARAM_DETECTOR_TYPE; + std::string pFullName = res->getName()+"."+PARAM_PROFILE_TYPE; + std::string dFullName = res->getName()+"."+PARAM_DETECTOR_TYPE; ConstrainedVariableId pNameVar = res->getVariable(pFullName); ConstrainedVariableId dNameVar = res->getVariable(dFullName); @@ -54,19 +57,28 @@ std::pair getProfileAndDetectorNames(const Object* res, con check_error(isValidCombo(pName.toString(), dName.toString()), "Invalid combination of profile " + pName.toString() + " and detector " + dName.toString()); return std::make_pair(pName, dName); } - +} // ------------------------------------------------------------------------------------------------------- - NddlUnaryToken::NddlUnaryToken(const PlanDatabaseId& planDatabase, const LabelStr& predicateName, const bool& rejectable, const bool& isFact, const bool& close) - : EUROPA::UnaryToken(planDatabase, predicateName, rejectable, isFact, IntervalIntDomain(), IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), - EUROPA::Token::noObject(), false, false) { - commonInit(close); - } +NddlUnaryToken::NddlUnaryToken(const PlanDatabaseId planDatabase, + const std::string& predicateName, + const bool& rejectable, const bool& _isFact, + const bool& _close) + : EUROPA::UnaryToken(planDatabase, predicateName, rejectable, _isFact, + IntervalIntDomain(), IntervalIntDomain(), + IntervalIntDomain(1, PLUS_INFINITY), + EUROPA::Token::noObject(), false, false), + state(), object(), tStart(), tEnd(), tDuration() { + commonInit(_close); +} - NddlUnaryToken::NddlUnaryToken(const TokenId& master, const LabelStr& predicateName, const LabelStr& relation, const bool& close) - : EUROPA::UnaryToken(master, relation, predicateName, IntervalIntDomain(), IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), - EUROPA::Token::noObject(), false, false) { - commonInit(close); +NddlUnaryToken::NddlUnaryToken(const TokenId _master, const std::string& predicateName, + const std::string& relation, const bool& _close) + : EUROPA::UnaryToken(_master, relation, predicateName, IntervalIntDomain(), + IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), + EUROPA::Token::noObject(), false, false), + state(), object(), tStart(), tEnd(), tDuration() { + commonInit(_close); } void NddlUnaryToken::handleDefaults(const bool&) {} @@ -81,17 +93,17 @@ std::pair getProfileAndDetectorNames(const Object* res, con close(); } - NddlUnary::NddlUnary(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - bool open) - : EUROPA::Reusable(planDatabase, type, name, open) {} +NddlUnary::NddlUnary(const PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + bool open) + : EUROPA::Reusable(planDatabase, type, name, open), consumptionMax() {} - NddlUnary::NddlUnary(const ObjectId& parent, - const LabelStr& type, - const LabelStr& name, - bool open) - : EUROPA::Reusable(parent, type, name, open) {} +NddlUnary::NddlUnary(const ObjectId parent, + const std::string& type, + const std::string& name, + bool open) + : EUROPA::Reusable(parent, type, name, open), consumptionMax() {} void NddlUnary::close() { @@ -100,11 +112,11 @@ std::pair getProfileAndDetectorNames(const Object* res, con static const std::string PARAM_CONSUMPTION_MAX("consumptionMax"); check_error(m_variables.size() >= ARG_COUNT); - check_error(m_variables[CMAX]->getName().toString().find(PARAM_CONSUMPTION_MAX) != std::string::npos); + check_error(m_variables[CMAX]->getName().find(PARAM_CONSUMPTION_MAX) != std::string::npos); check_error(m_variables[CMAX]->derivedDomain().isSingleton()); - std::pair pd = getProfileAndDetectorNames(this, "IncrementalFlowProfile", "ClosedWorldFVDetector"); + std::pair pd = getProfileAndDetectorNames(this, "IncrementalFlowProfile", "ClosedWorldFVDetector"); init(1, 1, //capacity lb, capacity ub 0, 1,//lower limit, upper limit @@ -130,28 +142,32 @@ std::pair getProfileAndDetectorNames(const Object* res, con consumptionMax = addVariable(IntervalDomain(PLUS_INFINITY, PLUS_INFINITY, FloatDT::instance()), "consumptionMax"); } - NddlUnary::use::use(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - bool close) - : EUROPA::ReusableToken(planDatabase, predicateName, IntervalIntDomain(), IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0), Token::noObject(), false) { - handleDefaults(close); - } +NddlUnary::use::use(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool , + bool , + bool _close) + : EUROPA::ReusableToken(planDatabase, predicateName, IntervalIntDomain(), + IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0), Token::noObject(), false), + state(), object(), tStart(), tEnd(), tDuration() { + handleDefaults(_close); +} - NddlUnary::use::use(const TokenId& master, - const LabelStr& predicateName, - const LabelStr& relation, - bool close) - : EUROPA::ReusableToken(master, relation, predicateName, IntervalIntDomain(), IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0), Token::noObject(), false) { - handleDefaults(close); - } +NddlUnary::use::use(const TokenId _master, + const std::string& predicateName, + const std::string& relation, + bool _close) + : EUROPA::ReusableToken(_master, relation, predicateName, IntervalIntDomain(), + IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0), Token::noObject(), false), + state(), object(), tStart(), tEnd(), tDuration() { + handleDefaults(_close); +} - void NddlUnary::use::close() { - EUROPA::ReusableToken::close(); - } +void NddlUnary::use::close() { + EUROPA::ReusableToken::close(); +} void NddlUnary::use::handleDefaults(bool autoClose) { state = getState(); @@ -166,17 +182,19 @@ std::pair getProfileAndDetectorNames(const Object* res, con /*===============*/ - NddlReusable::NddlReusable(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - bool open) - : EUROPA::Reusable(planDatabase, type, name, open) {} +NddlReusable::NddlReusable(const PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + bool open) + : EUROPA::Reusable(planDatabase, type, name, open), + capacity(), levelLimitMin(), consumptionRateMax(), consumptionMax() {} - NddlReusable::NddlReusable(const ObjectId& parent, - const LabelStr& type, - const LabelStr& name, - bool open) - : EUROPA::Reusable(parent, type, name, open) {} +NddlReusable::NddlReusable(const ObjectId parent, + const std::string& type, + const std::string& name, + bool open) + : EUROPA::Reusable(parent, type, name, open), + capacity(), levelLimitMin(), consumptionRateMax(), consumptionMax() {} void NddlReusable::close() { static const unsigned int C = 0; @@ -190,17 +208,17 @@ std::pair getProfileAndDetectorNames(const Object* res, con static const std::string PARAM_CONSUMPTION_MAX("consumptionMax"); check_error(m_variables.size() >= ARG_COUNT); - check_error(m_variables[C]->getName().toString().find(PARAM_CAPACITY) != std::string::npos); - check_error(m_variables[LLMIN]->getName().toString().find(PARAM_LEVEL_LIMIT_MIN) != std::string::npos); - check_error(m_variables[CRMAX]->getName().toString().find(PARAM_CONSUMPTION_RATE_MAX) != std::string::npos); - check_error(m_variables[CMAX]->getName().toString().find(PARAM_CONSUMPTION_MAX) != std::string::npos); + check_error(m_variables[C]->getName().find(PARAM_CAPACITY) != std::string::npos); + check_error(m_variables[LLMIN]->getName().find(PARAM_LEVEL_LIMIT_MIN) != std::string::npos); + check_error(m_variables[CRMAX]->getName().find(PARAM_CONSUMPTION_RATE_MAX) != std::string::npos); + check_error(m_variables[CMAX]->getName().find(PARAM_CONSUMPTION_MAX) != std::string::npos); check_error(m_variables[C]->derivedDomain().isSingleton()); check_error(m_variables[LLMIN]->derivedDomain().isSingleton()); check_error(m_variables[CRMAX]->derivedDomain().isSingleton()); check_error(m_variables[CMAX]->derivedDomain().isSingleton()); - std::pair pd = getProfileAndDetectorNames(this, "IncrementalFlowProfile", "ClosedWorldFVDetector"); + std::pair pd = getProfileAndDetectorNames(this, "IncrementalFlowProfile", "ClosedWorldFVDetector"); // Since there is no production, upper level flaws will never occur in a Reusable. // We set the Upper Limit to PLUS_INIFINITY to indicate that. @@ -259,23 +277,27 @@ std::pair getProfileAndDetectorNames(const Object* res, con consumptionMax = addVariable(IntervalDomain(PLUS_INFINITY, PLUS_INFINITY, FloatDT::instance()), "consumptionMax"); } - NddlReusable::uses::uses(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - bool close) - : EUROPA::ReusableToken(planDatabase, predicateName, IntervalIntDomain(), IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), - Token::noObject(), false) { - handleDefaults(close); +NddlReusable::uses::uses(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool , + bool , + bool _close) + : EUROPA::ReusableToken(planDatabase, predicateName, IntervalIntDomain(), + IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), + Token::noObject(), false), + state(), object(), tStart(), tEnd(), tDuration(), quantity() { + handleDefaults(_close); } - NddlReusable::uses::uses(const TokenId& master, - const LabelStr& predicateName, - const LabelStr& relation, - bool close) - : EUROPA::ReusableToken(master, relation, predicateName, IntervalIntDomain(), IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), - Token::noObject(), false) { - handleDefaults(close); +NddlReusable::uses::uses(const TokenId _master, + const std::string& predicateName, + const std::string& relation, + bool _close) + : EUROPA::ReusableToken(_master, relation, predicateName, IntervalIntDomain(), + IntervalIntDomain(), IntervalIntDomain(1, PLUS_INFINITY), + Token::noObject(), false), + state(), object(), tStart(), tEnd(), tDuration(), quantity() { + handleDefaults(_close); } void NddlReusable::uses::close() { @@ -296,17 +318,19 @@ std::pair getProfileAndDetectorNames(const Object* res, con /*===============*/ - NddlCBReusable::NddlCBReusable(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - bool open) - : EUROPA::CBReusable(planDatabase, type, name, open) {} +NddlCBReusable::NddlCBReusable(const PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + bool open) + : EUROPA::CBReusable(planDatabase, type, name, open), + capacity(), levelLimitMin(), consumptionRateMax(), consumptionMax() {} - NddlCBReusable::NddlCBReusable(const ObjectId& parent, - const LabelStr& type, - const LabelStr& name, - bool open) - : EUROPA::CBReusable(parent, type, name, open) {} +NddlCBReusable::NddlCBReusable(const ObjectId parent, + const std::string& type, + const std::string& name, + bool open) + : EUROPA::CBReusable(parent, type, name, open), + capacity(), levelLimitMin(), consumptionRateMax(), consumptionMax(){} void NddlCBReusable::close() { static const unsigned int C = 0; @@ -320,17 +344,17 @@ std::pair getProfileAndDetectorNames(const Object* res, con static const std::string PARAM_CONSUMPTION_MAX("consumptionMax"); check_error(m_variables.size() >= ARG_COUNT); - check_error(m_variables[C]->getName().toString().find(PARAM_CAPACITY) != std::string::npos); - check_error(m_variables[LLMIN]->getName().toString().find(PARAM_LEVEL_LIMIT_MIN) != std::string::npos); - check_error(m_variables[CRMAX]->getName().toString().find(PARAM_CONSUMPTION_RATE_MAX) != std::string::npos); - check_error(m_variables[CMAX]->getName().toString().find(PARAM_CONSUMPTION_MAX) != std::string::npos); + check_error(m_variables[C]->getName().find(PARAM_CAPACITY) != std::string::npos); + check_error(m_variables[LLMIN]->getName().find(PARAM_LEVEL_LIMIT_MIN) != std::string::npos); + check_error(m_variables[CRMAX]->getName().find(PARAM_CONSUMPTION_RATE_MAX) != std::string::npos); + check_error(m_variables[CMAX]->getName().find(PARAM_CONSUMPTION_MAX) != std::string::npos); check_error(m_variables[C]->derivedDomain().isSingleton()); check_error(m_variables[LLMIN]->derivedDomain().isSingleton()); check_error(m_variables[CRMAX]->derivedDomain().isSingleton()); check_error(m_variables[CMAX]->derivedDomain().isSingleton()); - std::pair pd = getProfileAndDetectorNames(this, "IncrementalFlowProfile", "ClosedWorldFVDetector"); + std::pair pd = getProfileAndDetectorNames(this, "IncrementalFlowProfile", "ClosedWorldFVDetector"); // Since there is no production, upper level flaws will never occur in a Reusable. // We set the Upper Limit to PLUS_INIFINITY to indicate that. @@ -396,17 +420,23 @@ std::pair getProfileAndDetectorNames(const Object* res, con /*===============*/ - NddlReservoir::NddlReservoir(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - bool open) - : EUROPA::Reservoir(planDatabase, type, name, open) {} - - NddlReservoir::NddlReservoir(const ObjectId parent, - const LabelStr& type, - const LabelStr& name, - bool open) - : EUROPA::Reservoir(parent, type, name, open) {} +NddlReservoir::NddlReservoir(const PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + bool open) + : EUROPA::Reservoir(planDatabase, type, name, open), + initialCapacity(), levelLimitMin(), levelLimitMax(), + productionRateMax(), productionMax(), consumptionRateMax(), consumptionMax() + {} + +NddlReservoir::NddlReservoir(const ObjectId parent, + const std::string& type, + const std::string& name, + bool open) + : EUROPA::Reservoir(parent, type, name, open), + initialCapacity(), levelLimitMin(), levelLimitMax(), + productionRateMax(), productionMax(), consumptionRateMax(), consumptionMax() +{} void NddlReservoir::close() { static const int IC = 0; @@ -428,13 +458,13 @@ std::pair getProfileAndDetectorNames(const Object* res, con // Ensure the binding of variable names is as expected check_error(m_variables.size() >= ARG_COUNT); - check_error(m_variables[IC]->getName().toString().find(PARAM_INITIAL_CAPACITY) != std::string::npos); - check_error(m_variables[LLMIN]->getName().toString().find(PARAM_LEVEL_LIMIT_MIN) != std::string::npos); - check_error(m_variables[LLMAX]->getName().toString().find(PARAM_LEVEL_LIMIT_MAX) != std::string::npos); - check_error(m_variables[PRMAX]->getName().toString().find(PARAM_PRODUCTION_RATE_MAX) != std::string::npos); - check_error(m_variables[PMAX]->getName().toString().find(PARAM_PRODUCTION_MAX) != std::string::npos); - check_error(m_variables[CRMAX]->getName().toString().find(PARAM_CONSUMPTION_RATE_MAX) != std::string::npos); - check_error(m_variables[CMAX]->getName().toString().find(PARAM_CONSUMPTION_MAX) != std::string::npos); + check_error(m_variables[IC]->getName().find(PARAM_INITIAL_CAPACITY) != std::string::npos); + check_error(m_variables[LLMIN]->getName().find(PARAM_LEVEL_LIMIT_MIN) != std::string::npos); + check_error(m_variables[LLMAX]->getName().find(PARAM_LEVEL_LIMIT_MAX) != std::string::npos); + check_error(m_variables[PRMAX]->getName().find(PARAM_PRODUCTION_RATE_MAX) != std::string::npos); + check_error(m_variables[PMAX]->getName().find(PARAM_PRODUCTION_MAX) != std::string::npos); + check_error(m_variables[CRMAX]->getName().find(PARAM_CONSUMPTION_RATE_MAX) != std::string::npos); + check_error(m_variables[CMAX]->getName().find(PARAM_CONSUMPTION_MAX) != std::string::npos); // Ensure all values have been set to singletons already @@ -446,7 +476,7 @@ std::pair getProfileAndDetectorNames(const Object* res, con check_error(m_variables[CRMAX]->derivedDomain().isSingleton()); check_error(m_variables[CMAX]->derivedDomain().isSingleton()); - std::pair pd = getProfileAndDetectorNames(this, "IncrementalFlowProfile", "ClosedWorldFVDetector"); + std::pair pd = getProfileAndDetectorNames(this, "IncrementalFlowProfile", "ClosedWorldFVDetector"); init(m_variables[IC]->derivedDomain().getSingletonValue(), m_variables[IC]->derivedDomain().getSingletonValue(), m_variables[LLMIN]->derivedDomain().getSingletonValue(), m_variables[LLMAX]->derivedDomain().getSingletonValue(), @@ -524,22 +554,26 @@ std::pair getProfileAndDetectorNames(const Object* res, con } - NddlReservoir::produce::produce(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - bool close) - : EUROPA::ProducerToken(planDatabase, predicateName, rejectable, isFact, IntervalIntDomain(), Token::noObject(), false) { - handleDefaults(close); - } +NddlReservoir::produce::produce(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + bool _close) + : EUROPA::ProducerToken(planDatabase, predicateName, rejectable, _isFact, + IntervalIntDomain(), Token::noObject(), false), + state(), object(), tStart(), tEnd(), tDuration(), time(), quantity() { + handleDefaults(_close); +} - NddlReservoir::produce::produce(const TokenId& master, - const LabelStr& predicateName, - const LabelStr& relation, - bool close) - : EUROPA::ProducerToken(master, relation, predicateName, IntervalIntDomain(), Token::noObject(), false) { - handleDefaults(close); - } +NddlReservoir::produce::produce(const TokenId _master, + const std::string& predicateName, + const std::string& relation, + bool _close) + : EUROPA::ProducerToken(_master, relation, predicateName, IntervalIntDomain(), + Token::noObject(), false), + state(), object(), tStart(), tEnd(), tDuration(), time(), quantity() { + handleDefaults(_close); +} void NddlReservoir::produce::close() { EUROPA::ProducerToken::close(); @@ -558,22 +592,26 @@ std::pair getProfileAndDetectorNames(const Object* res, con close(); } - NddlReservoir::consume::consume(const PlanDatabaseId& planDatabase, - const LabelStr& predicateName, - bool rejectable, - bool isFact, - bool close) - : EUROPA::ConsumerToken(planDatabase, predicateName, rejectable, isFact, IntervalIntDomain(), Token::noObject(), false) { - handleDefaults(close); - } - - NddlReservoir::consume::consume(const TokenId& master, - const LabelStr& predicateName, - const LabelStr& relation, - bool close) - : EUROPA::ConsumerToken(master, relation, predicateName, IntervalIntDomain(), Token::noObject(), false) { - handleDefaults(close); - } +NddlReservoir::consume::consume(const PlanDatabaseId planDatabase, + const std::string& predicateName, + bool rejectable, + bool _isFact, + bool _close) + : EUROPA::ConsumerToken(planDatabase, predicateName, rejectable, _isFact, + IntervalIntDomain(), Token::noObject(), false), + state(), object(), tStart(), tEnd(), tDuration(), time(), quantity() { + handleDefaults(_close); + } + +NddlReservoir::consume::consume(const TokenId _master, + const std::string& predicateName, + const std::string& relation, + bool _close) + : EUROPA::ConsumerToken(_master, relation, predicateName, IntervalIntDomain(), + Token::noObject(), false), + state(), object(), tStart(), tEnd(), tDuration(), time(), quantity() { + handleDefaults(_close); +} void NddlReservoir::consume::close() { EUROPA::ConsumerToken::close(); diff --git a/src/PLASMA/Resource/component/NDDL/NddlResource.hh b/src/PLASMA/Resource/component/NDDL/NddlResource.hh index a12c0d502..011216a18 100644 --- a/src/PLASMA/Resource/component/NDDL/NddlResource.hh +++ b/src/PLASMA/Resource/component/NDDL/NddlResource.hh @@ -15,222 +15,256 @@ namespace NDDL { typedef EUROPA::ObjectDomain ResuableDomain; typedef EUROPA::ObjectDomain ReservoirDomain; - class NddlUnaryToken : public EUROPA::UnaryToken { - public: - NddlUnaryToken(const PlanDatabaseId& planDatabase, const LabelStr& predicateName, const bool& rejectable = false, const bool& isFact=false, const bool& close = false); - NddlUnaryToken(const TokenId& master, const LabelStr& predicateName, const LabelStr& relation, const bool& close = false); - - StateVarId state; - ObjectVarId object; - TempVarId tStart; - TempVarId tEnd; - TempVarId tDuration; - protected: - virtual void handleDefaults(const bool&); - private: - void commonInit(const bool& autoClose); - }; - - class NddlUnary : public EUROPA::Reusable { - public: - NddlUnary(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - bool open); - NddlUnary(const ObjectId& parent, - const LabelStr& type, - const LabelStr& name, - bool open); - - virtual ~NddlUnary(){} +class NddlUnaryToken : public EUROPA::UnaryToken { + public: + NddlUnaryToken(const EUROPA::PlanDatabaseId planDatabase, + const std::string& predicateName, const bool& rejectable = false, + const bool& isFact=false, const bool& close = false); + NddlUnaryToken(const EUROPA::TokenId master, + const std::string& predicateName, + const std::string& relation, const bool& close = false); + + EUROPA::StateVarId state; + EUROPA::ObjectVarId object; + EUROPA::TempVarId tStart; + EUROPA::TempVarId tEnd; + EUROPA::TempVarId tDuration; + protected: + virtual void handleDefaults(const bool&); + private: + void commonInit(const bool& autoClose); +}; + +class NddlUnary : public EUROPA::Reusable { + public: + NddlUnary(const EUROPA::PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + bool open); + NddlUnary(const EUROPA::ObjectId parent, + const std::string& type, + const std::string& name, + bool open); + + virtual ~NddlUnary(){} + + virtual void close(); + + virtual void constructor(const std::vector& args) { + Reusable::constructor(args); + } + virtual void constructor(EUROPA::edouble c_max); + virtual void constructor(); + + void handleDefaults(bool autoClose = true); + + EUROPA::ConstrainedVariableId consumptionMax; + + class use : public EUROPA::ReusableToken { + public: + use(const EUROPA::PlanDatabaseId planDatabase, const std::string& predicateName, + bool rejectable, bool isFact, bool close); + use(const EUROPA::TokenId master, const std::string& predicateName, + const std::string& relation, bool close); + + EUROPA::StateVarId state; + EUROPA::ObjectVarId object; + EUROPA::TempVarId tStart; + EUROPA::TempVarId tEnd; + EUROPA::TempVarId tDuration; virtual void close(); - - virtual void constructor(edouble c_max); - virtual void constructor(); - - void handleDefaults(bool autoClose = true); - - ConstrainedVariableId consumptionMax; - - class use : public EUROPA::ReusableToken { - public: - use(const PlanDatabaseId& planDatabase, const LabelStr& predicateName, bool rejectable, bool isFact, bool close); - use(const TokenId& master, const LabelStr& predicateName, const LabelStr& relation, bool close); - - StateVarId state; - ObjectVarId object; - TempVarId tStart; - TempVarId tEnd; - TempVarId tDuration; - - virtual void close(); - protected: - virtual void handleDefaults(bool autoClose = true); - private: - }; + protected: + virtual void handleDefaults(bool autoClose = true); + private: }; - - class NddlReusable : public EUROPA::Reusable { - public: - NddlReusable(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - bool open); - NddlReusable(const ObjectId& parent, - const LabelStr& type, - const LabelStr& name, - bool open); - - virtual ~NddlReusable(){} - +}; + +class NddlReusable : public EUROPA::Reusable { + public: + NddlReusable(const EUROPA::PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + bool open); + NddlReusable(const EUROPA::ObjectId parent, + const std::string& type, + const std::string& name, + bool open); + + virtual ~NddlReusable(){} + + virtual void close(); + + virtual void constructor(const std::vector& args) { + Reusable::constructor(args); + } + virtual void constructor(EUROPA::edouble c, EUROPA::edouble ll_min); + virtual void constructor(EUROPA::edouble c, EUROPA::edouble ll_min, + EUROPA::edouble cr_max); + virtual void constructor(EUROPA::edouble c, EUROPA::edouble ll_min, + EUROPA::edouble c_max, EUROPA::edouble cr_max); + virtual void constructor(); + + void handleDefaults(bool autoClose = true); + + EUROPA::ConstrainedVariableId capacity; + EUROPA::ConstrainedVariableId levelLimitMin; + EUROPA::ConstrainedVariableId consumptionRateMax; + EUROPA::ConstrainedVariableId consumptionMax; + + class uses : public EUROPA::ReusableToken { + public: + uses(const EUROPA::PlanDatabaseId planDatabase, const std::string& predicateName, + bool rejectable, bool isFact, bool close); + uses(const EUROPA::TokenId master, const std::string& predicateName, + const std::string& relation, bool close); + + EUROPA::StateVarId state; + EUROPA::ObjectVarId object; + EUROPA::TempVarId tStart; + EUROPA::TempVarId tEnd; + EUROPA::TempVarId tDuration; + + EUROPA::ConstrainedVariableId quantity; virtual void close(); - - virtual void constructor(edouble c, edouble ll_min); - virtual void constructor(edouble c, edouble ll_min, edouble cr_max); - virtual void constructor(edouble c, edouble ll_min, edouble c_max, edouble cr_max); - virtual void constructor(); - - void handleDefaults(bool autoClose = true); - - ConstrainedVariableId capacity; - ConstrainedVariableId levelLimitMin; - ConstrainedVariableId consumptionRateMax; - ConstrainedVariableId consumptionMax; - - class uses : public EUROPA::ReusableToken { - public: - uses(const PlanDatabaseId& planDatabase, const LabelStr& predicateName, bool rejectable, bool isFact, bool close); - uses(const TokenId& master, const LabelStr& predicateName, const LabelStr& relation, bool close); - - StateVarId state; - ObjectVarId object; - TempVarId tStart; - TempVarId tEnd; - TempVarId tDuration; - - ConstrainedVariableId quantity; - virtual void close(); - protected: - virtual void handleDefaults(bool autoClose = true); - private: - }; + protected: + virtual void handleDefaults(bool autoClose = true); + private: }; - - class NddlCBReusable : public EUROPA::CBReusable { - public: - NddlCBReusable(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - bool open); - NddlCBReusable(const ObjectId& parent, - const LabelStr& type, - const LabelStr& name, - bool open); - - virtual ~NddlCBReusable(){} +}; + +class NddlCBReusable : public EUROPA::CBReusable { + public: + NddlCBReusable(const EUROPA::PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + bool open); + NddlCBReusable(const EUROPA::ObjectId parent, + const std::string& type, + const std::string& name, + bool open); + + virtual ~NddlCBReusable(){} + + virtual void close(); + + virtual void constructor(const std::vector& args) { + CBReusable::constructor(args); + } + virtual void constructor(EUROPA::edouble c, EUROPA::edouble ll_min); + virtual void constructor(EUROPA::edouble c, EUROPA::edouble ll_min, + EUROPA::edouble cr_max); + virtual void constructor(EUROPA::edouble c, EUROPA::edouble ll_min, + EUROPA::edouble c_max, EUROPA::edouble cr_max); + virtual void constructor(); + + void handleDefaults(bool autoClose = true); + + EUROPA::ConstrainedVariableId capacity; + EUROPA::ConstrainedVariableId levelLimitMin; + EUROPA::ConstrainedVariableId consumptionRateMax; + EUROPA::ConstrainedVariableId consumptionMax; +}; + +class NddlReservoir : public EUROPA::Reservoir { + public: + NddlReservoir(const EUROPA::PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + bool open); + + NddlReservoir(const EUROPA::ObjectId parent, + const std::string& type, + const std::string& name, + bool open); + + virtual ~NddlReservoir(){} + + virtual void close(); + + virtual void constructor(const std::vector& args) { + Reservoir::constructor(args); + } + virtual void constructor(EUROPA::edouble ic, EUROPA::edouble ll_min, + EUROPA::edouble ll_max); + + virtual void constructor(EUROPA::edouble ic, EUROPA::edouble ll_min, + EUROPA::edouble ll_max, EUROPA::edouble p_max, + EUROPA::edouble c_max); + + virtual void constructor(EUROPA::edouble ic, EUROPA::edouble ll_min, + EUROPA::edouble ll_max, EUROPA::edouble pr_max, + EUROPA::edouble p_max, EUROPA::edouble cr_max, + EUROPA::edouble c_max); + + virtual void constructor(); + + void handleDefaults(bool autoClose = true); // default variable initialization + + EUROPA::ConstrainedVariableId initialCapacity; + EUROPA::ConstrainedVariableId levelLimitMin; + EUROPA::ConstrainedVariableId levelLimitMax; + EUROPA::ConstrainedVariableId productionRateMax; + EUROPA::ConstrainedVariableId productionMax; + EUROPA::ConstrainedVariableId consumptionRateMax; + EUROPA::ConstrainedVariableId consumptionMax; + + class produce : public EUROPA::ProducerToken { + public: + produce(const EUROPA::PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, bool close); + produce(const EUROPA::TokenId master, const std::string& predicateName, + const std::string& relation, bool close); + + /* Access to primitives of a token as public members. */ + EUROPA::StateVarId state; + EUROPA::ObjectVarId object; + EUROPA::TempVarId tStart; + EUROPA::TempVarId tEnd; + EUROPA::TempVarId tDuration; + EUROPA::TempVarId time; + + EUROPA::ConstrainedVariableId quantity; /*!< Add member specific for a resource */ virtual void close(); - virtual void constructor(edouble c, edouble ll_min); - virtual void constructor(edouble c, edouble ll_min, edouble cr_max); - virtual void constructor(edouble c, edouble ll_min, edouble c_max, edouble cr_max); - virtual void constructor(); + protected: + virtual void handleDefaults(bool autoClose = true); - void handleDefaults(bool autoClose = true); - - ConstrainedVariableId capacity; - ConstrainedVariableId levelLimitMin; - ConstrainedVariableId consumptionRateMax; - ConstrainedVariableId consumptionMax; + private: + //void commonInit(); }; - class NddlReservoir : public EUROPA::Reservoir { - public: - NddlReservoir(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - bool open); + class consume : public EUROPA::ConsumerToken { + public: + consume(const EUROPA::PlanDatabaseId planDatabase, + const std::string& predicateName, bool rejectable, bool isFact, bool close); + consume(const EUROPA::TokenId master, const std::string& predicateName, + const std::string& relation, bool close); - NddlReservoir(const ObjectId parent, - const LabelStr& type, - const LabelStr& name, - bool open); + /* Access to primitives of a token as public members. */ + EUROPA::StateVarId state; + EUROPA::ObjectVarId object; + EUROPA::TempVarId tStart; + EUROPA::TempVarId tEnd; + EUROPA::TempVarId tDuration; + EUROPA::TempVarId time; - virtual ~NddlReservoir(){} + EUROPA::ConstrainedVariableId quantity; /*!< Add member specific for a resource */ virtual void close(); - virtual void constructor(edouble ic, edouble ll_min, edouble ll_max); - - virtual void constructor(edouble ic, edouble ll_min, edouble ll_max, edouble p_max, edouble c_max); + protected: + virtual void handleDefaults(bool autoClose = true); - virtual void constructor(edouble ic, edouble ll_min, edouble ll_max, edouble pr_max, edouble p_max, edouble cr_max, edouble c_max); - - virtual void constructor(); - - void handleDefaults(bool autoClose = true); // default variable initialization - - ConstrainedVariableId initialCapacity; - ConstrainedVariableId levelLimitMin; - ConstrainedVariableId levelLimitMax; - ConstrainedVariableId productionRateMax; - ConstrainedVariableId productionMax; - ConstrainedVariableId consumptionRateMax; - ConstrainedVariableId consumptionMax; - - class produce : public EUROPA::ProducerToken { - public: - produce(const PlanDatabaseId& planDatabase, const LabelStr& predicateName, bool rejectable, bool isFact, bool close); - produce(const TokenId& master, const LabelStr& predicateName, const LabelStr& relation, bool close); - - /* Access to primitives of a token as public members. */ - StateVarId state; - ObjectVarId object; - TempVarId tStart; - TempVarId tEnd; - TempVarId tDuration; - TempVarId time; - - ConstrainedVariableId quantity; /*!< Add member specific for a resource */ - - virtual void close(); - - protected: - virtual void handleDefaults(bool autoClose = true); - - private: - //void commonInit(); - }; - - class consume : public EUROPA::ConsumerToken { - public: - consume(const PlanDatabaseId& planDatabase, const LabelStr& predicateName, bool rejectable, bool isFact, bool close); - consume(const TokenId& master, const LabelStr& predicateName, const LabelStr& relation, bool close); - - /* Access to primitives of a token as public members. */ - StateVarId state; - ObjectVarId object; - TempVarId tStart; - TempVarId tEnd; - TempVarId tDuration; - TempVarId time; - - ConstrainedVariableId quantity; /*!< Add member specific for a resource */ - - virtual void close(); - - protected: - virtual void handleDefaults(bool autoClose = true); - - private: - //void commonInit(); - }; - - protected: - private: + private: + //void commonInit(); }; + protected: + private: +}; + } // namespace NDDL #endif // NDDL_RESOURCE_HH diff --git a/src/PLASMA/Resource/component/Node.cc b/src/PLASMA/Resource/component/Node.cc index 49bd38082..b98b64e55 100644 --- a/src/PLASMA/Resource/component/Node.cc +++ b/src/PLASMA/Resource/component/Node.cc @@ -19,7 +19,9 @@ namespace EUROPA Node::Node( const NodeIdentity& identity ): m_Enabled( true ), m_Visit( -1 ), - m_Identity( identity ) + m_Identity( identity ), + m_InEdges(), + m_OutEdges() { } diff --git a/src/PLASMA/Resource/component/Node.hh b/src/PLASMA/Resource/component/Node.hh index 1d8af67f1..66e0f8945 100644 --- a/src/PLASMA/Resource/component/Node.hh +++ b/src/PLASMA/Resource/component/Node.hh @@ -14,7 +14,7 @@ namespace EUROPA { /** - * @brief + * @brief A node in the maximum flow graph. */ class Node { @@ -32,36 +32,24 @@ namespace EUROPA */ ~Node(); /** - * @brief + * @brief This node. */ inline const NodeIdentity& getIdentity() const; /** * @brief Returns true if the invoking node is enabled otherwise returns false. */ inline bool isEnabled() const; - /** - * @brief - */ + inline const EdgeList& getOutEdges() const; - /** - * @brief - */ + inline const EdgeList& getInEdges() const; - /** - * @brief - */ + inline void setDisabled(); - /** - * @brief - */ + inline void setEnabled(); - /** - * @brief - */ + inline int getVisit(); - /** - * @brief - */ + inline void setVisit( int v ); private: /** @@ -72,13 +60,9 @@ namespace EUROPA * @brief Adds \a edge to the ingoing edges of the invoking node. */ void addInEdge( Edge* edge ); - /** - * @brief - */ + void removeOutEdge( Edge* edge ); - /** - * @brief - */ + void removeInEdge( Edge* edge ); bool m_Enabled; @@ -88,9 +72,6 @@ namespace EUROPA EdgeList m_OutEdges; }; - /** - * @brief - */ std::ostream& operator<<( std::ostream& os, const Node& fn ) ; int Node::getVisit() { diff --git a/src/PLASMA/Resource/component/NodeIterator.hh b/src/PLASMA/Resource/component/NodeIterator.hh index 7da45eb4b..d64131202 100644 --- a/src/PLASMA/Resource/component/NodeIterator.hh +++ b/src/PLASMA/Resource/component/NodeIterator.hh @@ -13,15 +13,9 @@ namespace EUROPA { - /** - * @brief - */ class NodeIterator { public: - /** - * @brief - */ NodeIterator( const Graph& graph, bool mustBeEnabled = true ): m_Iterator( graph.m_Nodes.begin() ), m_End( graph.m_Nodes.end() ), @@ -33,17 +27,8 @@ namespace EUROPA ++m_Iterator; } } - /** - * @brief - */ inline bool ok() const; - /** - * @brief - */ - inline void operator++(); - /** - * @brief - */ + inline NodeIterator& operator++(); inline Node* operator*() const; private: NodeIdentity2Node::const_iterator m_Iterator; @@ -56,16 +41,16 @@ namespace EUROPA return m_Iterator != m_End; } - void NodeIterator::operator++() - { - ++m_Iterator; +NodeIterator& NodeIterator::operator++() { + ++m_Iterator; - if( m_Enabled ) - { - while( m_Iterator != m_End && !(*m_Iterator).second->isEnabled() ) - ++m_Iterator; - } - } + if( m_Enabled ) + { + while( m_Iterator != m_End && !(*m_Iterator).second->isEnabled() ) + ++m_Iterator; + } + return *this; +} Node* NodeIterator::operator*() const { diff --git a/src/PLASMA/Resource/component/OpenWorldFVDetector.cc b/src/PLASMA/Resource/component/OpenWorldFVDetector.cc index 950b79c28..985561a96 100644 --- a/src/PLASMA/Resource/component/OpenWorldFVDetector.cc +++ b/src/PLASMA/Resource/component/OpenWorldFVDetector.cc @@ -28,7 +28,7 @@ Resource::ProblemType OpenWorldFVDetector::getResourceLevelViolation(const Insta return retval; } -void OpenWorldFVDetector::getFDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const +void OpenWorldFVDetector::getFDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const { const std::pair& capacityBounds = m_res->getCapacityProfile()->getValue(inst->getTime()); @@ -39,7 +39,7 @@ void OpenWorldFVDetector::getFDLevelBounds(const InstantId& inst, edouble& lb, e ub = capacityBounds.second + usageUb; } -void OpenWorldFVDetector::getVDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const +void OpenWorldFVDetector::getVDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const { getDefaultLevelBounds(inst,lb,ub); ub += (m_maxCumulativeProduction - inst->getMinCumulativeProduction()); diff --git a/src/PLASMA/Resource/component/OpenWorldFVDetector.hh b/src/PLASMA/Resource/component/OpenWorldFVDetector.hh index 7d31c641e..8316fd396 100644 --- a/src/PLASMA/Resource/component/OpenWorldFVDetector.hh +++ b/src/PLASMA/Resource/component/OpenWorldFVDetector.hh @@ -1,5 +1,5 @@ -#ifndef _H_OpenWorldFVDetector -#define _H_OpenWorldFVDetector +#ifndef H_OpenWorldFVDetector +#define H_OpenWorldFVDetector #include "GenericFVDetector.hh" namespace EUROPA { @@ -9,8 +9,8 @@ namespace EUROPA { OpenWorldFVDetector(const ResourceId res); protected: virtual Resource::ProblemType getResourceLevelViolation(const InstantId inst) const; - virtual void getFDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const; // Level Bounds for FlawDetection - virtual void getVDLevelBounds(const InstantId& inst, edouble& lb, edouble& ub) const; // Level Bounds for ViolationDetection + virtual void getFDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const; // Level Bounds for FlawDetection + virtual void getVDLevelBounds(const InstantId inst, edouble& lb, edouble& ub) const; // Level Bounds for ViolationDetection }; } diff --git a/src/PLASMA/Resource/component/Reservoir.cc b/src/PLASMA/Resource/component/Reservoir.cc index 82b716091..6fbbfb852 100644 --- a/src/PLASMA/Resource/component/Reservoir.cc +++ b/src/PLASMA/Resource/component/Reservoir.cc @@ -10,68 +10,76 @@ #include "TokenVariable.hh" namespace EUROPA { - Reservoir::Reservoir(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, const LabelStr& detectorName, - const LabelStr& profileName, edouble initCapacityLb, edouble initCapacityUb, edouble lowerLimit, - edouble upperLimit, edouble maxInstProduction, edouble maxInstConsumption, edouble maxProduction, - edouble maxConsumption) : - Resource(planDatabase, type, name, detectorName, profileName, initCapacityLb, initCapacityUb, lowerLimit, upperLimit, - maxInstProduction, maxInstConsumption, maxProduction, maxConsumption) {} +Reservoir::Reservoir(const PlanDatabaseId planDatabase, const std::string& type, + const std::string& name, const std::string& detectorName, + const std::string& profileName, + edouble initCapacityLb, edouble initCapacityUb, + edouble lowerLimit, edouble upperLimit, + edouble maxInstProduction, edouble maxInstConsumption, + edouble maxProduction, edouble maxConsumption) : + Resource(planDatabase, type, name, detectorName, profileName, initCapacityLb, + initCapacityUb, lowerLimit, upperLimit, + maxInstProduction, maxInstConsumption, maxProduction, maxConsumption), + m_tokensToTransactions() {} - Reservoir::Reservoir(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open) : - Resource(planDatabase, type, name, open) {} +Reservoir::Reservoir(const PlanDatabaseId planDatabase, const std::string& type, + const std::string& name, bool open) : + Resource(planDatabase, type, name, open), m_tokensToTransactions() {} - Reservoir::Reservoir(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open) : - Resource(parent, type, localName, open) {} +Reservoir::Reservoir(const ObjectId parent, const std::string& type, + const std::string& localName, bool open) : + Resource(parent, type, localName, open), m_tokensToTransactions() {} - void Reservoir::createTransactions(const TokenId& tok) { + void Reservoir::createTransactions(const TokenId tok) { if(m_tokensToTransactions.find(tok) != m_tokensToTransactions.end()) { debugMsg("Reservoir:createTransactions", - "Token " << tok->getPredicateName().toString() << "(" << tok->getKey() << ") already has transactions."); + "Token " << tok->getPredicateName() << "(" << tok->getKey() << ") already has transactions."); return; } ReservoirTokenId t(tok); debugMsg("Reservoir:createTransactions", "Creating transactions for " << (t->isConsumer() ? "consumer " : "producer ") << "token " << - tok->getPredicateName().toString() << "(" << tok->getKey() << ")"); - TransactionId trans = (new Transaction(t->getTime(), t->getQuantity(), t->isConsumer()))->getId(); + tok->getPredicateName() << "(" << tok->getKey() << ")"); + TransactionId trans = + (new Transaction(t->getTime(), t->getQuantity(), t->isConsumer(), getId()))->getId(); m_transactionsToTokens.insert(std::pair(trans, tok)); m_tokensToTransactions.insert(std::pair(tok, trans)); } - void Reservoir::addToProfile(const TokenId& tok) { + void Reservoir::addToProfile(const TokenId tok) { checkError(m_tokensToTransactions.find(tok) != m_tokensToTransactions.end(), - "No transaction for " << tok->getPredicateName().toString() << "(" << tok->getKey() << ")"); + "No transaction for " << tok->getPredicateName() << "(" << tok->getKey() << ")"); TransactionId trans = m_tokensToTransactions.find(tok)->second; debugMsg("Reservoir:addToProfile", "For " << tok->toString() << " adding transaction " << trans->toString() << " to profile."); m_profile->addTransaction(trans); } - void Reservoir::removeTransactions(const TokenId& tok) { + void Reservoir::removeTransactions(const TokenId tok) { if(m_tokensToTransactions.find(tok) == m_tokensToTransactions.end()) return; TransactionId trans = m_tokensToTransactions.find(tok)->second; debugMsg("Reservoir:removeTransactions", "For " << tok->toString() << " deleting transaction " << trans->toString()); m_tokensToTransactions.erase(tok); m_transactionsToTokens.erase(trans); - delete (Transaction*) trans; + delete static_cast(trans); } - void Reservoir::removeFromProfile(const TokenId& tok) { + void Reservoir::removeFromProfile(const TokenId tok) { // checkError(m_tokensToTransactions.find(tok) != m_tokensToTransactions.end(), // "Token " << tok->getPredicateName().toString() << "(" << tok->getKey() << ") isn't in the profile."); if(m_tokensToTransactions.find(tok) == m_tokensToTransactions.end()) return; - debugMsg("Reservoir:removeFromProfile", toString() << " Removing token " << tok->getPredicateName().toString() << "(" << tok->getKey() << ")"); + debugMsg("Reservoir:removeFromProfile", toString() << " Removing token " << tok->getPredicateName() << "(" << tok->getKey() << ")"); TransactionId trans = m_tokensToTransactions.find(tok)->second; m_profile->removeTransaction(trans); Resource::removeFromProfile(tok); } - void Reservoir::getOrderingChoices(const TokenId& token, + void Reservoir::getOrderingChoices(const TokenId token, std::vector >& results, - unsigned int limit) { - checkError(m_tokensToTransactions.find(token) != m_tokensToTransactions.end(), "Token " << token->getPredicateName().toString() << + unsigned long limit) { + checkError(m_tokensToTransactions.find(token) != m_tokensToTransactions.end(), "Token " << token->getPredicateName() << "(" << token->getKey() << ") not in profile."); Resource::getOrderingChoices(token, results, limit); } diff --git a/src/PLASMA/Resource/component/Reservoir.hh b/src/PLASMA/Resource/component/Reservoir.hh index b37667b8a..21f043eec 100644 --- a/src/PLASMA/Resource/component/Reservoir.hh +++ b/src/PLASMA/Resource/component/Reservoir.hh @@ -1,5 +1,5 @@ -#ifndef _H_Reservoir -#define _H_Reservoir +#ifndef H_Reservoir +#define H_Reservoir #include "ResourceDefs.hh" #include "Resource.hh" @@ -8,45 +8,50 @@ namespace EUROPA { - class Reservoir : public Resource { - public: - /** - * @brief Constructor. This is primarily a convenience constructor for resource interactions outside of a model. - * @param planDatabase @see Object - * @param type @see Object - * @param name @see Object - * @param initCapacityLb The lower bound of the Resource's initial level. (For example, a battery may be only half charged initially.) - * @param initCapacityUb The upper bound of the Resource's initial level. (For example, a battery may be only half charged initially.) - * @param lowerLimit The lower capacity limit. (For example, a battery can't have less than no energy stored, or it might be considered unsafe to allow - * the capacity to get below 25%.) - * @param upperLimit The upper capacity limit. (For example, a battery has a maximum charge, or it might be unsafe to fill a beaker more than three-quarters full.) - * @param maxInstProduction The maximum amount of production possible at an instant. (For example, a power bus might only allow 2.5A to be drawn at one instant.) - * @param maxInstConsumption The maximum amount of consumption possible at an instant. (For example, a power bus might only allow 2.5A to be drawn at one instant.) - * @param maxProduction The maximum amount of production possible on this resource. - * @param maxConsumption The maximum amount of consumption possible on this resource. - */ - Reservoir(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, const LabelStr& detectorName, const LabelStr& profileName, - edouble initCapacityLb = 0, edouble initCapacityUb = 0, edouble lowerLimit = MINUS_INFINITY, - edouble upperLimit = PLUS_INFINITY, edouble maxInstProduction = PLUS_INFINITY, edouble maxInstConsumption = PLUS_INFINITY, - edouble maxProduction = PLUS_INFINITY, edouble maxConsumption = PLUS_INFINITY); +class Reservoir : public Resource { + public: + /** + * @brief Constructor. This is primarily a convenience constructor for resource interactions outside of a model. + * @param planDatabase see Object + * @param type see Object + * @param name see Object + * @param initCapacityLb The lower bound of the Resource's initial level. (For example, a battery may be only half charged initially.) + * @param initCapacityUb The upper bound of the Resource's initial level. (For example, a battery may be only half charged initially.) + * @param lowerLimit The lower capacity limit. (For example, a battery can't have less than no energy stored, or it might be considered unsafe to allow + * the capacity to get below 25%.) + * @param upperLimit The upper capacity limit. (For example, a battery has a maximum charge, or it might be unsafe to fill a beaker more than three-quarters full.) + * @param maxInstProduction The maximum amount of production possible at an instant. (For example, a power bus might only allow 2.5A to be drawn at one instant.) + * @param maxInstConsumption The maximum amount of consumption possible at an instant. (For example, a power bus might only allow 2.5A to be drawn at one instant.) + * @param maxProduction The maximum amount of production possible on this resource. + * @param maxConsumption The maximum amount of consumption possible on this resource. + */ + Reservoir(const PlanDatabaseId planDatabase, const std::string& type, + const std::string& name, const std::string& detectorName, + const std::string& profileName, + edouble initCapacityLb = 0, edouble initCapacityUb = 0, + edouble lowerLimit = MINUS_INFINITY, edouble upperLimit = PLUS_INFINITY, + edouble maxInstProduction = PLUS_INFINITY, + edouble maxInstConsumption = PLUS_INFINITY, + edouble maxProduction = PLUS_INFINITY, + edouble maxConsumption = PLUS_INFINITY); /** * @brief Constructor * @see Resource */ - Reservoir(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open); + Reservoir(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open); /** * @brief Constructor * @see Resource */ - Reservoir(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open); + Reservoir(const ObjectId parent, const std::string& type, const std::string& localName, bool open); //~Reservoir(); - void getOrderingChoices(const TokenId& token, + void getOrderingChoices(const TokenId token, std::vector >& results, - unsigned int limit = std::numeric_limits::max()); + unsigned long limit = std::numeric_limits::max()); // void getTokensToOrder(std::vector& results); @@ -56,10 +61,10 @@ namespace EUROPA { //void notifyFlawed(const InstantId inst); //void notifyNoLongerFlawed(const InstantId inst); //void notifyDeleted(const InstantId inst); - void addToProfile(const TokenId& tok); - void removeFromProfile(const TokenId& tok); - void createTransactions(const TokenId& tok); - void removeTransactions(const TokenId& tok); + void addToProfile(const TokenId tok); + void removeFromProfile(const TokenId tok); + void createTransactions(const TokenId tok); + void removeTransactions(const TokenId tok); std::map m_tokensToTransactions; }; diff --git a/src/PLASMA/Resource/component/Reusable.cc b/src/PLASMA/Resource/component/Reusable.cc index 1887da7dd..d31a7bede 100644 --- a/src/PLASMA/Resource/component/Reusable.cc +++ b/src/PLASMA/Resource/component/Reusable.cc @@ -11,80 +11,86 @@ namespace EUROPA { - Reusable::Reusable(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, const LabelStr& detectorName, const LabelStr& profileName, - edouble initCapacityLb, edouble initCapacityUb, edouble lowerLimit, edouble maxInstConsumption, - edouble maxConsumption) - :Resource(planDatabase, - type, - name, - detectorName, - profileName, - initCapacityLb, initCapacityUb, - lowerLimit, initCapacityUb, - maxInstConsumption, maxInstConsumption, - maxConsumption, maxConsumption) - { - } +Reusable::Reusable(const PlanDatabaseId planDatabase, const std::string& type, + const std::string& name, const std::string& detectorName, + const std::string& profileName, + edouble initCapacityLb, edouble initCapacityUb, edouble lowerLimit, + edouble maxInstConsumption, + edouble maxConsumption) + : Resource(planDatabase, + type, + name, + detectorName, + profileName, + initCapacityLb, initCapacityUb, + lowerLimit, initCapacityUb, + maxInstConsumption, maxInstConsumption, + maxConsumption, maxConsumption), + m_tokensToTransactions() +{ +} - Reusable::Reusable(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open) - : Resource(planDatabase, type, name, open) - { - } +Reusable::Reusable(const PlanDatabaseId planDatabase, const std::string& type, + const std::string& name, bool open) + : Resource(planDatabase, type, name, open), m_tokensToTransactions() +{ +} - Reusable::Reusable(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open) - : Resource(parent, type, localName, open) - { - } +Reusable::Reusable(const ObjectId parent, const std::string& type, + const std::string& localName, bool open) + : Resource(parent, type, localName, open), m_tokensToTransactions() +{ +} Reusable::~Reusable() { } - void Reusable::getOrderingChoices(const TokenId& token, - std::vector >& results, - unsigned int limit) { - checkError(m_tokensToTransactions.find(token) != m_tokensToTransactions.end(), "Token " << token->getPredicateName().toString() << - "(" << token->getKey() << ") not in profile for " << toString()); - Resource::getOrderingChoices(token, results, limit); - } +void Reusable::getOrderingChoices(const TokenId token, + std::vector >& results, + unsigned long limit) { + checkError(m_tokensToTransactions.find(token) != m_tokensToTransactions.end(), "Token " << token->getPredicateName() << + "(" << token->getKey() << ") not in profile for " << toString()); + Resource::getOrderingChoices(token, results, limit); +} - void Reusable::createTransactions(const TokenId& tok) { + void Reusable::createTransactions(const TokenId tok) { if(m_tokensToTransactions.find(tok) != m_tokensToTransactions.end()) { debugMsg("Reusable:createTransactions", - toString() << " Token " << tok->getPredicateName().toString() << "(" << tok->getKey() << ") already has transactions."); + toString() << " Token " << tok->getPredicateName() << "(" << tok->getKey() << ") already has transactions."); return; } ReusableTokenId t(tok); debugMsg("Reusable:createTransactions", - toString() << " Creating transactions for " << tok->getPredicateName().toString() << "(" << tok->getKey() << ")"); + toString() << " Creating transactions for " << tok->getPredicateName() << "(" << tok->getKey() << ")"); //here's the major difference between Reusable and Reservoir: always consume the quantity at the start //and produce it again at the end - TransactionId t1 = (new Transaction(t->start(), t->getQuantity(), true))->getId(); - TransactionId t2 = (new Transaction(t->end(), t->getQuantity(), false))->getId(); + TransactionId t1 = (new Transaction(t->start(), t->getQuantity(), true, getId()))->getId(); + TransactionId t2 = (new Transaction(t->end(), t->getQuantity(), false, getId()))->getId(); m_transactionsToTokens.insert(std::make_pair(t1, tok)); m_transactionsToTokens.insert(std::make_pair(t2, tok)); m_tokensToTransactions.insert(std::make_pair(tok, std::make_pair(t1, t2))); } - void Reusable::addToProfile(const TokenId& tok) { + void Reusable::addToProfile(const TokenId tok) { checkError(tok->isActive(), "Token " << tok->toString() << " is not active."); checkError(tok->getObject()->lastDomain().isSingleton(), "Token " << tok->toString() << " has a non-singleton object variable " << tok->getObject()->toLongString()); checkError(tok->getObject()->lastDomain().isMember(getKey()), toString() << " isn't in the object variable of " << tok->toString() << ": " << tok->getObject()->toLongString()); checkError(m_tokensToTransactions.find(tok) != m_tokensToTransactions.end(), - "No transaction for " << tok->getPredicateName().toString() << "(" << tok->getKey() << ")"); + "No transaction for " << tok->getPredicateName() << "(" << tok->getKey() << ")"); std::map >::const_iterator it = m_tokensToTransactions.find(tok); debugMsg("Reusable:addToProfile", - toString() << " Adding transactions for " << tok->getPredicateName().toString() << "(" << tok->getKey() << ") to the profile."); + toString() << " Adding transactions for " << tok->getPredicateName() << "(" << tok->getKey() << ") to the profile."); m_profile->addTransaction(it->second.first); m_profile->addTransaction(it->second.second); } - void Reusable::removeTransactions(const TokenId& tok) { + void Reusable::removeTransactions(const TokenId tok) { if(m_tokensToTransactions.find(tok) == m_tokensToTransactions.end()) return; debugMsg("Reusable:removeTransactions", toString() << " Removing transactions for " << tok->toString()); @@ -92,19 +98,19 @@ namespace EUROPA { m_tokensToTransactions.erase(tok); m_transactionsToTokens.erase(trans.first); m_transactionsToTokens.erase(trans.second); - delete (Transaction*) trans.first; - delete (Transaction*) trans.second; + delete static_cast(trans.first); + delete static_cast(trans.second); } - void Reusable::removeFromProfile(const TokenId& tok) { + void Reusable::removeFromProfile(const TokenId tok) { if(m_tokensToTransactions.find(tok) == m_tokensToTransactions.end()) { debugMsg("Reusable:removeFromProfile", - toString() << "Failed to find transactions for " << tok->getPredicateName().toString() << "(" << tok->getKey() << ")"); + toString() << "Failed to find transactions for " << tok->getPredicateName() << "(" << tok->getKey() << ")"); return; } debugMsg("Reusable:removeFromProfile", - toString() << " Removing token " << tok->getPredicateName().toString() << "(" << tok->getKey() << ")"); + toString() << " Removing token " << tok->getPredicateName() << "(" << tok->getKey() << ")"); std::pair trans = m_tokensToTransactions.find(tok)->second; debugMsg("Reusable:removeFromProfile", toString() << " Removing transaction for time " << trans.first->time()->toString() << " with quantity " << @@ -117,10 +123,10 @@ namespace EUROPA { Resource::removeFromProfile(tok); } - UnaryTimeline::UnaryTimeline(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open) + UnaryTimeline::UnaryTimeline(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open) : Reusable(planDatabase, type, name, open) {init(1, 1, 0, 1, PLUS_INFINITY, PLUS_INFINITY, PLUS_INFINITY, PLUS_INFINITY, "ClosedWorldFVDetector", "IncrementalFlowProfile");} - UnaryTimeline::UnaryTimeline(const ObjectId& parent, const LabelStr& type, const LabelStr& name, bool open) + UnaryTimeline::UnaryTimeline(const ObjectId parent, const std::string& type, const std::string& name, bool open) : Reusable(parent, type, name, open) {init(1, 1, 0, 1, PLUS_INFINITY, PLUS_INFINITY, PLUS_INFINITY, PLUS_INFINITY, "ClosedWorldFVDetector", "IncrementalFlowProfile");} @@ -128,47 +134,50 @@ namespace EUROPA { { } - CBReusable::CBReusable(const PlanDatabaseId& planDatabase, - const LabelStr& type, - const LabelStr& name, - const LabelStr& detectorName, - const LabelStr& profileName, - edouble initCapacityLb, - edouble initCapacityUb, - edouble lowerLimit, - edouble maxInstConsumption, - edouble maxConsumption) - : Resource(planDatabase, - type, - name, - detectorName, - profileName, - initCapacityLb, - initCapacityUb, - lowerLimit, - initCapacityUb, - maxInstConsumption, - maxInstConsumption, - maxConsumption, - maxConsumption) - { - } +CBReusable::CBReusable(const PlanDatabaseId planDatabase, + const std::string& type, + const std::string& name, + const std::string& detectorName, + const std::string& profileName, + edouble initCapacityLb, + edouble initCapacityUb, + edouble lowerLimit, + edouble maxInstConsumption, + edouble maxConsumption) + : Resource(planDatabase, + type, + name, + detectorName, + profileName, + initCapacityLb, + initCapacityUb, + lowerLimit, + initCapacityUb, + maxInstConsumption, + maxInstConsumption, + maxConsumption, + maxConsumption), + m_constraintsToTransactions() +{ +} - CBReusable::CBReusable(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open) - : Resource(planDatabase, type, name, open) - { - } +CBReusable::CBReusable(const PlanDatabaseId planDatabase, const std::string& type, + const std::string& name, bool open) + : Resource(planDatabase, type, name, open), m_constraintsToTransactions() +{ +} - CBReusable::CBReusable(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open) - : Resource(parent, type, localName, open) - { - } +CBReusable::CBReusable(const ObjectId parent, const std::string& type, + const std::string& localName, bool open) + : Resource(parent, type, localName, open), m_constraintsToTransactions() +{ +} CBReusable::~CBReusable() { } - void CBReusable::addToProfile(const ConstraintId& gc) + void CBReusable::addToProfile(const ConstraintId gc) { UsesId c = gc; if(m_constraintsToTransactions.find(c) != m_constraintsToTransactions.end()) { @@ -189,7 +198,7 @@ namespace EUROPA { debugMsg("CBReusable:constraints","Resource :" << toString() << " added constraint:" << c->toString()); } - void CBReusable::removeFromProfile(const ConstraintId& gc) + void CBReusable::removeFromProfile(const ConstraintId gc) { UsesId c = gc; @@ -208,7 +217,7 @@ namespace EUROPA { debugMsg("CBReusable:constraints","Resource :" << toString() << " removed constraint:" << c->toString()); } - void CBReusable::addToProfile(TransactionId& t) + void CBReusable::addToProfile(TransactionId t) { m_profile->addTransaction(t); // TODO: this is the way to add transactions to the resource, not clean because in this case there is no associated token @@ -216,7 +225,7 @@ namespace EUROPA { debugMsg("CBReusable:constraints", "Added transaction for time " << t->time()->toLongString() << " with quantity " << t->quantity()->toString()); } - void CBReusable::removeFromProfile(TransactionId& t) + void CBReusable::removeFromProfile(TransactionId t) { debugMsg("CBReusable:constraints", "Removing transaction " << t << " for time " << t->time()->toLongString() << " with quantity " << t->quantity()->toString()); m_profile->removeTransaction(t); @@ -224,33 +233,32 @@ namespace EUROPA { } // TODO: only needed for backwards compatibility with Resource API, rework hierarchy to fix this. - void CBReusable::addToProfile(const TokenId& tok) + void CBReusable::addToProfile(const TokenId tok) { debugMsg("CBReusable","Ignored addToProfile for Token:" << tok->toString()); } - void CBReusable::removeFromProfile(const TokenId& tok) + void CBReusable::removeFromProfile(const TokenId tok) { debugMsg("CBReusable","Ignored removeFromProfile for Token:" << tok->toString()); } - edouble getLb(ConstrainedVariableId v) - { - if (v->lastDomain().isSingleton()) - return v->lastDomain().getSingletonValue(); - - return v->lastDomain().getLowerBound(); - } +namespace { +edouble getLb(ConstrainedVariableId v) { + if (v->lastDomain().isSingleton()) + return v->lastDomain().getSingletonValue(); - edouble getUb(ConstrainedVariableId v) - { - if (v->lastDomain().isSingleton()) - return v->lastDomain().getSingletonValue(); + return v->lastDomain().getLowerBound(); +} - return v->lastDomain().getUpperBound(); - } +edouble getUb(ConstrainedVariableId v) { + if (v->lastDomain().isSingleton()) + return v->lastDomain().getSingletonValue(); + return v->lastDomain().getUpperBound(); +} +} - std::set CBReusable::getConstraintsForInstant(const InstantId& instant) + std::set CBReusable::getConstraintsForInstant(const InstantId instant) { std::set retval; @@ -332,26 +340,26 @@ namespace EUROPA { } } - Uses::Uses(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& ce, - const std::vector& scope) - : Constraint(name, propagatorName, ce, scope) - { - checkError(scope.size() == 4, "Uses constraint requires resource,qty,start,end"); +Uses::Uses(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId ce, + const std::vector& scope) + : Constraint(name, propagatorName, ce, scope), m_resource(), m_txns(), + m_violationProblems() { + checkError(scope.size() == 4, "Uses constraint requires resource,qty,start,end"); - m_txns.push_back((new Transaction(scope[Uses::START_VAR], scope[Uses::QTY_VAR], true, getId()))->getId()); - m_txns.push_back((new Transaction(scope[Uses::END_VAR], scope[Uses::QTY_VAR], false, getId()))->getId()); + m_txns.push_back((new Transaction(scope[Uses::START_VAR], scope[Uses::QTY_VAR], true, getId()))->getId()); + m_txns.push_back((new Transaction(scope[Uses::END_VAR], scope[Uses::QTY_VAR], false, getId()))->getId()); - if(scope[RESOURCE_VAR]->lastDomain().isSingleton()) { - m_resource = Entity::getTypedEntity(scope[RESOURCE_VAR]->lastDomain().getSingletonValue()); - check_error(m_resource.isValid()); - debugMsg("Uses:Uses", "Adding constraint " << toString() << " to resource-profile of resource " << m_resource->toString() ); - m_resource->addToProfile(getId()); - } + if(scope[RESOURCE_VAR]->lastDomain().isSingleton()) { + m_resource = Entity::getTypedEntity(scope[RESOURCE_VAR]->lastDomain().getSingletonValue()); + check_error(m_resource.isValid()); + debugMsg("Uses:Uses", "Adding constraint " << toString() << " to resource-profile of resource " << m_resource->toString() ); + m_resource->addToProfile(getId()); } +} - const TransactionId& Uses::getTransaction(int var) const + const TransactionId Uses::getTransaction(int var) const { if (var == Uses::START_VAR) return m_txns[0]; @@ -373,46 +381,45 @@ namespace EUROPA { // TODO: make sure Resource destructor doesn't get to these first for (unsigned int i=0;i(txn); } m_txns.clear(); Constraint::handleDiscard(); } - bool Uses::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType) - { - ConstrainedVariableId res = m_variables[RESOURCE_VAR]; - - // if this is a singleton message see if we can bind the resource - if(changeType == DomainListener::RESTRICT_TO_SINGLETON || - changeType == DomainListener::SET_TO_SINGLETON || - variable->lastDomain().isSingleton()) { - - if(m_resource.isNoId() && res->lastDomain().isSingleton()) { - m_resource = Entity::getTypedEntity(res->lastDomain().getSingletonValue()); - check_error(m_resource.isValid()); - m_resource->addToProfile(getId()); - debugMsg("Uses:Uses", "Added " << toString() << " to profile for resource " << m_resource->toString()); - } - } - // if this is a relax/reset message, see if we need to unbind the resource - else if((changeType == DomainListener::RESET || changeType == DomainListener::RELAXED) - && m_resource.isValid()) { +bool Uses::canIgnore(const ConstrainedVariableId variable, + unsigned int, + const DomainListener::ChangeType& changeType) { + ConstrainedVariableId res = m_variables[RESOURCE_VAR]; - if((variable->getKey() == res->getKey()) && !(res->lastDomain().isSingleton())) { - m_resource->removeFromProfile(getId()); - debugMsg("Uses:Uses", "Removed " << toString() << " from profile for resource " << m_resource->toString()); - m_resource = CBReusableId::noId(); - } + // if this is a singleton message see if we can bind the resource + if(changeType == DomainListener::RESTRICT_TO_SINGLETON || + changeType == DomainListener::SET_TO_SINGLETON || + variable->lastDomain().isSingleton()) { + + if(m_resource.isNoId() && res->lastDomain().isSingleton()) { + m_resource = Entity::getTypedEntity(res->lastDomain().getSingletonValue()); + check_error(m_resource.isValid()); + m_resource->addToProfile(getId()); + debugMsg("Uses:Uses", "Added " << toString() << " to profile for resource " << m_resource->toString()); } + } + // if this is a relax/reset message, see if we need to unbind the resource + else if((changeType == DomainListener::RESET || changeType == DomainListener::RELAXED) + && m_resource.isValid()) { - // Since we don't do bounds prop, always return true - return true; + if((variable->getKey() == res->getKey()) && !(res->lastDomain().isSingleton())) { + m_resource->removeFromProfile(getId()); + debugMsg("Uses:Uses", "Removed " << toString() << " from profile for resource " << m_resource->toString()); + m_resource = CBReusableId::noId(); + } } + // Since we don't do bounds prop, always return true + return true; +} + void Uses::handleExecute() { // TODO: not doing bounds prop for now, but we could @@ -425,7 +432,7 @@ namespace EUROPA { std::map::const_iterator it = m_violationProblems.begin(); for(;it != m_violationProblems.end();++it) { os << Resource::getProblemString(it->second) - << " for resource " << m_resource->getName().toString() + << " for resource " << m_resource->getName() << " at instant " << (it->first->getTime()); } @@ -468,13 +475,13 @@ namespace EUROPA { Constraint::notifyNoLongerViolated(); } - const LabelStr& Uses::CONSTRAINT_NAME() { - static const LabelStr sl_const("uses"); + const std::string& Uses::CONSTRAINT_NAME() { + static const std::string sl_const("uses"); return sl_const; } - const LabelStr& Uses::PROPAGATOR_NAME() { - static const LabelStr sl_const("Resource"); + const std::string& Uses::PROPAGATOR_NAME() { + static const std::string sl_const("Resource"); return sl_const; } diff --git a/src/PLASMA/Resource/component/Reusable.hh b/src/PLASMA/Resource/component/Reusable.hh index 86f773a4c..6481ca82d 100644 --- a/src/PLASMA/Resource/component/Reusable.hh +++ b/src/PLASMA/Resource/component/Reusable.hh @@ -1,5 +1,5 @@ -#ifndef _H_Reusable -#define _H_Reusable +#ifndef H_Reusable +#define H_Reusable #include "ResourceDefs.hh" #include "Resource.hh" @@ -10,23 +10,23 @@ namespace EUROPA { class Reusable : public Resource { public: //initial capacity is the upper limit, maxInstConsumption == maxInstProduction, maxConsumption == maxProduction - Reusable(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, const LabelStr& detectorName, const LabelStr& profileName, + Reusable(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, const std::string& detectorName, const std::string& profileName, edouble initCapacityLb = 0, edouble initCapacityUb = 0, edouble lowerLimit = MINUS_INFINITY, edouble maxInstConsumption = PLUS_INFINITY, edouble maxConsumption = PLUS_INFINITY); - Reusable(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open); - Reusable(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open); + Reusable(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open); + Reusable(const ObjectId parent, const std::string& type, const std::string& localName, bool open); virtual ~Reusable(); - virtual void getOrderingChoices(const TokenId& token, + virtual void getOrderingChoices(const TokenId token, std::vector >& results, - unsigned int limit = std::numeric_limits::max()); + unsigned long limit = std::numeric_limits::max()); protected: - void createTransactions(const TokenId& tok); - void removeTransactions(const TokenId& tok); - void addToProfile(const TokenId& tok); - void removeFromProfile(const TokenId& tok); + void createTransactions(const TokenId tok); + void removeTransactions(const TokenId tok); + void addToProfile(const TokenId tok); + void removeFromProfile(const TokenId tok); std::map > m_tokensToTransactions; }; @@ -35,8 +35,8 @@ namespace EUROPA { class UnaryTimeline : public Reusable { public: - UnaryTimeline(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open = false); - UnaryTimeline(const ObjectId& parent, const LabelStr& type, const LabelStr& name, bool open = false); + UnaryTimeline(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open = false); + UnaryTimeline(const ObjectId parent, const std::string& type, const std::string& name, bool open = false); virtual ~UnaryTimeline(); }; @@ -49,12 +49,12 @@ namespace EUROPA { class CBReusable : public Resource { public: //initial capacity is the upper limit, maxInstConsumption == maxInstProduction, maxConsumption == maxProduction - CBReusable(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, const LabelStr& detectorName, const LabelStr& profileName, + CBReusable(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, const std::string& detectorName, const std::string& profileName, edouble initCapacityLb = 0, edouble initCapacityUb = 0, edouble lowerLimit = MINUS_INFINITY, edouble maxInstConsumption = PLUS_INFINITY, edouble maxConsumption = PLUS_INFINITY); - CBReusable(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, bool open); - CBReusable(const ObjectId& parent, const LabelStr& type, const LabelStr& localName, bool open); + CBReusable(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, bool open); + CBReusable(const ObjectId parent, const std::string& type, const std::string& localName, bool open); virtual ~CBReusable(); virtual void notifyViolated(const InstantId inst, Resource::ProblemType problem); @@ -63,18 +63,18 @@ namespace EUROPA { virtual void notifyNoLongerFlawed(const InstantId inst); protected: - void addToProfile(const ConstraintId& c); - void removeFromProfile(const ConstraintId& c); - std::set getConstraintsForInstant(const InstantId& instant); + void addToProfile(const ConstraintId c); + void removeFromProfile(const ConstraintId c); + std::set getConstraintsForInstant(const InstantId instant); - void addToProfile(TransactionId& t); - void removeFromProfile(TransactionId& t); + void addToProfile(TransactionId t); + void removeFromProfile(TransactionId t); // TODO: only needed for backwards compatibility with Resource API, rework hierarchy to fix this. - void addToProfile(const TokenId& tok); - void removeFromProfile(const TokenId& tok); - void createTransactions(const TokenId& tok) {} - void removeTransactions(const TokenId& tok) {} + void addToProfile(const TokenId tok); + void removeFromProfile(const TokenId tok); + void createTransactions(const TokenId) {} + void removeTransactions(const TokenId) {} std::map > m_constraintsToTransactions; @@ -84,13 +84,13 @@ namespace EUROPA { class Uses : public Constraint { public: - Uses(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + Uses(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& scope); - static const LabelStr& CONSTRAINT_NAME(); - static const LabelStr& PROPAGATOR_NAME(); + static const std::string& CONSTRAINT_NAME(); + static const std::string& PROPAGATOR_NAME(); static const int RESOURCE_VAR = 0; static const int QTY_VAR = 1; @@ -99,7 +99,7 @@ namespace EUROPA { virtual std::string getViolationExpl() const; - const TransactionId& getTransaction(int var) const; + const TransactionId getTransaction(int var) const; CBReusableId getResource() const; @@ -119,9 +119,9 @@ namespace EUROPA { std::map m_violationProblems; // instant->problem map private: - virtual bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType); + virtual bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, + const DomainListener::ChangeType& changeType); virtual void handleExecute(); diff --git a/src/PLASMA/Resource/component/Solvers/ResourceMatching.cc b/src/PLASMA/Resource/component/Solvers/ResourceMatching.cc index db381d4ea..12c57bdf3 100644 --- a/src/PLASMA/Resource/component/Solvers/ResourceMatching.cc +++ b/src/PLASMA/Resource/component/Solvers/ResourceMatching.cc @@ -9,7 +9,7 @@ namespace EUROPA { namespace SOLVERS { template<> - void MatchingEngine::getMatches(const InstantId& inst, + void MatchingEngine::getMatches(const InstantId inst, std::vector& results) { m_cycleCount++; results = m_unfilteredRules; @@ -17,18 +17,18 @@ namespace EUROPA { } template<> - void MatchingEngine::getMatchesInternal(const InstantId& inst, + void MatchingEngine::getMatchesInternal(const InstantId inst, std::vector& results) { - const ResourceId& res = inst->getProfile()->getResource(); + const ResourceId res = inst->getProfile()->getResource(); debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for object types (" << - res->getType().toString() << ")"); - const SchemaId& schema = res->getPlanDatabase()->getSchema(); + res->getType() << ")"); + const SchemaId schema = res->getPlanDatabase()->getSchema(); trigger(schema->getAllObjectTypes(res->getType()), m_rulesByObjectType, results); } - void InstantMatchFinder::getMatches(const MatchingEngineId& engine, const EntityId& entity, + void InstantMatchFinder::getMatches(const MatchingEngineId engine, const EntityId entity, std::vector& results) { engine->getMatches(InstantId(entity), results); } diff --git a/src/PLASMA/Resource/component/Solvers/ResourceMatching.hh b/src/PLASMA/Resource/component/Solvers/ResourceMatching.hh index 08c6b47e1..6b1ddfa06 100644 --- a/src/PLASMA/Resource/component/Solvers/ResourceMatching.hh +++ b/src/PLASMA/Resource/component/Solvers/ResourceMatching.hh @@ -1,5 +1,5 @@ -#ifndef _H_ResourceMatching -#define _H_ResourceMatching +#ifndef H_ResourceMatching +#define H_ResourceMatching #include "MatchingEngine.hh" #include "ResourceDefs.hh" @@ -10,16 +10,16 @@ namespace EUROPA { * @brief Retrieves all relevant matching rules for the given instant. */ template<> - void MatchingEngine::getMatches(const InstantId& inst, + void MatchingEngine::getMatches(const InstantId inst, std::vector& results); template<> - void MatchingEngine::getMatchesInternal(const InstantId& inst, + void MatchingEngine::getMatchesInternal(const InstantId inst, std::vector& results); class InstantMatchFinder : public MatchFinder { public: - void getMatches(const MatchingEngineId& engine, const EntityId& entity, + void getMatches(const MatchingEngineId engine, const EntityId entity, std::vector& results); }; } diff --git a/src/PLASMA/Resource/component/Solvers/ResourceThreatDecisionPoint.cc b/src/PLASMA/Resource/component/Solvers/ResourceThreatDecisionPoint.cc index 35e765265..d8b6a091a 100644 --- a/src/PLASMA/Resource/component/Solvers/ResourceThreatDecisionPoint.cc +++ b/src/PLASMA/Resource/component/Solvers/ResourceThreatDecisionPoint.cc @@ -6,6 +6,9 @@ #include "FlowProfile.hh" #include "Constraint.hh" #include "DbClient.hh" +#include "tinyxml.h" + +#include namespace EUROPA { using namespace SOLVERS; @@ -21,7 +24,7 @@ namespace EUROPA { class ChoiceFilters { public: - ChoiceFilters() {} + ChoiceFilters() : m_filters() {} ~ChoiceFilters() { for(std::list::iterator it = m_filters.begin(); it != m_filters.end(); ++it) delete (*it); @@ -49,134 +52,153 @@ namespace EUROPA { std::list m_filters; }; - class DefaultChoiceFilter : public ChoiceFilter { - public: - DefaultChoiceFilter(Profile* profile, const LabelStr& explanation, const InstantId& inst) - : ChoiceFilter(), m_profile(profile), m_explanation(explanation), m_inst(inst) { +class DefaultChoiceFilter : public ChoiceFilter { +private: + DefaultChoiceFilter(const DefaultChoiceFilter&); + DefaultChoiceFilter& operator=(const DefaultChoiceFilter&); + public: + DefaultChoiceFilter(Profile* profile, const std::string& explanation, + const InstantId inst) + : ChoiceFilter(), m_profile(profile), m_explanation(explanation), m_inst(inst), + m_treatAsLowerFlaw(true) { + debugMsg("ResourceThreatDecisionPoint:filter", "Creating filter for " << inst->getTime() << " on " << inst->getProfile()->getResource()->toString()); + //if there are flaws at both levels + if(m_inst->hasLowerLevelFlaw() && m_inst->hasUpperLevelFlaw()) { + debugMsg("ResourceThreatDecisionPoint:filter", "Instant is flawed on both levels."); + // if we were chosen out of a lower level preference, behave like that + if(m_explanation == "lowerLevelFlaw" || m_explanation.find("Lower") != std::string::npos) { + debugMsg("ResourceThreatDecisionPoint:filter", "Treating as lower flaw because of " << m_explanation); m_treatAsLowerFlaw = true; - debugMsg("ResourceThreatDecisionPoint:filter", "Creating filter for " << inst->getTime() << " on " << inst->getProfile()->getResource()->toString()); - //if there are flaws at both levels - if(m_inst->hasLowerLevelFlaw() && m_inst->hasUpperLevelFlaw()) { - debugMsg("ResourceThreatDecisionPoint:filter", "Instant is flawed on both levels."); - // if we were chosen out of a lower level preference, behave like that - if(m_explanation == LabelStr("lowerLevelFlaw") || m_explanation.toString().find("Lower") != std::string::npos) { - debugMsg("ResourceThreatDecisionPoint:filter", "Treating as lower flaw because of " << m_explanation.toString()); - m_treatAsLowerFlaw = true; - } - // if we were chosen out of an upper level preference, behave like that - else if(m_explanation == LabelStr("upperLevelFlaw") || m_explanation.toString().find("Upper") != std::string::npos) { - debugMsg("ResourceThreatDecisionPoint:filter", "Treating as upper flaw because of " << m_explanation.toString()); - m_treatAsLowerFlaw = false; - } - // if we were chosen out of a magnitude preference - // pick level with greatest magnitude, treat as a flaw on that level - // if the level magnitude is equal, arbitrarily choose lower level - else { - m_treatAsLowerFlaw = m_inst->getLowerFlawMagnitude() >= m_inst->getUpperFlawMagnitude(); - debugMsg("ResourceThreatDecisionPoint:filter", "Treating as " << (m_treatAsLowerFlaw ? "lower" : "upper") << - " flaw because of magnitude. Lower: " << m_inst->getLowerFlawMagnitude() << " Upper: " << m_inst->getUpperFlawMagnitude()); - } - } - else { - m_treatAsLowerFlaw = m_inst->hasLowerLevelFlaw() && !m_inst->hasUpperLevelFlaw(); - debugMsg("ResourceThreatDecisionPoint:filter", "Instant is only flawed on the " << (m_treatAsLowerFlaw ? "lower" : "upper") << " level."); - } } - virtual bool operator()(const std::pair& p) const { - return true; + // if we were chosen out of an upper level preference, behave like that + else if(m_explanation == "upperLevelFlaw" || m_explanation.find("Upper") != std::string::npos) { + debugMsg("ResourceThreatDecisionPoint:filter", "Treating as upper flaw because of " << m_explanation); + m_treatAsLowerFlaw = false; } - virtual std::string toString() const {return "DefaultFilter";} - protected: - Profile* m_profile; - LabelStr m_explanation; - InstantId m_inst; - bool m_treatAsLowerFlaw; - }; - - class PredecessorNotContributingChoiceFilter : public DefaultChoiceFilter { - public: - PredecessorNotContributingChoiceFilter(Profile* profile, const LabelStr& explanation, const InstantId& inst) - : DefaultChoiceFilter(profile, explanation, inst) { - // For this ChoiceFilter, we need the profile to be a subclass of FlowProfile: - FlowProfile * fProfile = dynamic_cast ((Profile*) profile); - check_runtime_error(fProfile != 0, - "Cannot create PredecessorNotContributingChoiceFilter for profile not derived from FlowProfile " \ - " (choice of ResourceThreatHandler filter in PlannerConfig.xml probably conflicts with choice of profileType in NDDL)"); + // if we were chosen out of a magnitude preference + // pick level with greatest magnitude, treat as a flaw on that level + // if the level magnitude is equal, arbitrarily choose lower level + else { + m_treatAsLowerFlaw = m_inst->getLowerFlawMagnitude() >= m_inst->getUpperFlawMagnitude(); + debugMsg("ResourceThreatDecisionPoint:filter", "Treating as " << (m_treatAsLowerFlaw ? "lower" : "upper") << + " flaw because of magnitude. Lower: " << m_inst->getLowerFlawMagnitude() << " Upper: " << m_inst->getUpperFlawMagnitude()); } - - bool operator()(const std::pair& p) const { - InstantId inst = InstantId::noId(); - bool contributing = false; - - if(m_treatAsLowerFlaw) { - if(p.first->isConsumer()) { - debugMsg("ResourceThreatDecisionPoint:filter:predecessorNot", "Rejecting choice because flaw is lower level and predecessor is a consumer."); - return false; - } - contributing = ((FlowProfile*) m_profile)->getEarliestLowerLevelInstant(p.first, inst); - } - else { - if(!p.first->isConsumer()) { - debugMsg("ResourceThreatDecisionPoint:filter:predecesorNot", "Rejecting choice because flaw is upper level and predecessor is a producer."); - return false; - } - contributing = ((FlowProfile*) m_profile)->getEarliestUpperLevelInstant(p.first, inst); - } - checkError(contributing, "Should always have an instant for transaction " << p.first->toString()); - condDebugMsg(inst->getTime() <= m_inst->getTime(), "ResourceThreatDecisionPoint:filter:predecessorNot", - "Rejecting choice because predecessor is contributing at this instant."); - return inst->getTime() > m_inst->getTime(); + } + else { + m_treatAsLowerFlaw = m_inst->hasLowerLevelFlaw() && !m_inst->hasUpperLevelFlaw(); + debugMsg("ResourceThreatDecisionPoint:filter", "Instant is only flawed on the " << (m_treatAsLowerFlaw ? "lower" : "upper") << " level."); + } + } + virtual bool operator()(const std::pair&) const { + return true; + } + virtual std::string toString() const {return "DefaultFilter";} + protected: + Profile* m_profile; + std::string m_explanation; + InstantId m_inst; + bool m_treatAsLowerFlaw; +}; + +class PredecessorNotContributingChoiceFilter : public DefaultChoiceFilter { + public: + PredecessorNotContributingChoiceFilter(Profile* profile, const std::string& explanation, + const InstantId inst) + : DefaultChoiceFilter(profile, explanation, inst) { + // For this ChoiceFilter, we need the profile to be a subclass of FlowProfile: + FlowProfile * fProfile = boost::polymorphic_cast(profile); + checkRuntimeError(fProfile != 0, + "Cannot create PredecessorNotContributingChoiceFilter for " << + "profile not derived from FlowProfile (choice of " << + "ResourceThreatHandler filter in PlannerConfig.xml probably " << + "conflicts with choice of profileType in NDDL)"); + } + + bool operator()(const std::pair& p) const { + InstantId inst = InstantId::noId(); + bool contributing = false; + + if(m_treatAsLowerFlaw) { + if(p.first->isConsumer()) { + debugMsg("ResourceThreatDecisionPoint:filter:predecessorNot", + "Rejecting choice because flaw is lower level and predecessor is " << + "a consumer."); + return false; } - std::string toString() const {return "PredecessorNotContributingFilter";} - }; - - class SuccessorContributingChoiceFilter : public DefaultChoiceFilter { - public: - SuccessorContributingChoiceFilter(Profile* profile, const LabelStr& explanation, const InstantId& inst) - : DefaultChoiceFilter(profile, explanation, inst) { - // For this ChoiceFilter, we need the profile to be a subclass of FlowProfile: - FlowProfile * fProfile = dynamic_cast ((Profile*) profile); - check_runtime_error(fProfile != 0, - "Cannot create SuccessorContributingChoiceFilter for profile not derived from FlowProfile " \ - " (choice of ResourceThreatHandler filter in PlannerConfig.xml probably conflicts with choice of profileType in NDDL)"); + contributing = + (boost::polymorphic_cast(m_profile))->getEarliestLowerLevelInstant(p.first, inst); + } + else { + if(!p.first->isConsumer()) { + debugMsg("ResourceThreatDecisionPoint:filter:predecesorNot", + "Rejecting choice because flaw is upper level and predecessor is " << + "a producer."); + return false; } - - bool operator()(const std::pair& p) const { - InstantId inst = InstantId::noId(); - bool contributing = false; - - if(m_treatAsLowerFlaw) { - if(!p.second->isConsumer()) { - debugMsg("ResourceThreatDecisionPoint:filter:successor", "Rejecting choice because flaw is lower level and successor is a producer."); - return false; - } - contributing = ((FlowProfile*) m_profile)->getEarliestLowerLevelInstant(p.second, inst); - } - else { - if(p.second->isConsumer()) { - debugMsg("ResourceThreatDecisionPoint:filter:successor", "Rejecting choice because flaw is upper level and successor is a consumer."); - return false; - } - contributing = ((FlowProfile*) m_profile)->getEarliestUpperLevelInstant(p.second, inst); - } - checkError(contributing, "Should always have an instant for transaction " << p.second->toString()); - condDebugMsg(inst->getTime() > m_inst->getTime(), "ResourceThreatDecisionPoint:filter:successor", - "Rejecting choice because successor is not contributing at this instant."); - return inst->getTime() <= m_inst->getTime(); + contributing = + (boost::polymorphic_cast(m_profile))->getEarliestUpperLevelInstant(p.first, inst); + } + checkError(contributing, + "Should always have an instant for transaction " << + p.first->toString()); + condDebugMsg(inst->getTime() <= m_inst->getTime(), + "ResourceThreatDecisionPoint:filter:predecessorNot", + "Rejecting choice because predecessor is contributing at this instant."); + return inst->getTime() > m_inst->getTime(); + } + std::string toString() const {return "PredecessorNotContributingFilter";} +}; + +class SuccessorContributingChoiceFilter : public DefaultChoiceFilter { + public: + SuccessorContributingChoiceFilter(Profile* profile, const std::string& explanation, const InstantId inst) + : DefaultChoiceFilter(profile, explanation, inst) { + // For this ChoiceFilter, we need the profile to be a subclass of FlowProfile: + FlowProfile * fProfile = boost::polymorphic_cast(profile); + check_runtime_error(fProfile != 0, + "Cannot create SuccessorContributingChoiceFilter for profile not derived from FlowProfile " \ + " (choice of ResourceThreatHandler filter in PlannerConfig.xml probably conflicts with choice of profileType in NDDL)"); + } + + bool operator()(const std::pair& p) const { + InstantId inst = InstantId::noId(); + bool contributing = false; + + if(m_treatAsLowerFlaw) { + if(!p.second->isConsumer()) { + debugMsg("ResourceThreatDecisionPoint:filter:successor", "Rejecting choice because flaw is lower level and successor is a producer."); + return false; } - std::string toString() const {return "SuccessorContributingFilter";} - }; + contributing = + boost::polymorphic_cast(m_profile)->getEarliestLowerLevelInstant(p.second, inst); + } + else { + if(p.second->isConsumer()) { + debugMsg("ResourceThreatDecisionPoint:filter:successor", "Rejecting choice because flaw is upper level and successor is a consumer."); + return false; + } + contributing = + boost::polymorphic_cast(m_profile)->getEarliestUpperLevelInstant(p.second, inst); + } + checkError(contributing, "Should always have an instant for transaction " << p.second->toString()); + condDebugMsg(inst->getTime() > m_inst->getTime(), "ResourceThreatDecisionPoint:filter:successor", + "Rejecting choice because successor is not contributing at this instant."); + return inst->getTime() <= m_inst->getTime(); + } + std::string toString() const {return "SuccessorContributingFilter";} +}; class ChoiceComparator { public: virtual ~ChoiceComparator() {} - virtual bool operator()(const std::pair& p1, const std::pair& p2) const { + virtual bool operator()(const std::pair&, + const std::pair& ) const { check_error(ALWAYS_FAIL, "This used to be a pure virtual method."); return false; } virtual std::string toString() const { check_error(ALWAYS_FAIL, "This used to be a pure virtual method."); - return false; + return ""; } virtual ChoiceComparator* copy() const = 0; private: @@ -184,8 +206,8 @@ namespace EUROPA { class ChoiceOrder { public: - ChoiceOrder() {} - ChoiceOrder(const ChoiceOrder& other) { + ChoiceOrder() : m_cmps() {} + ChoiceOrder(const ChoiceOrder& other) : m_cmps() { debugMsg("ResourceThreatDecisionPoint:sort", "Copying the choice order."); condDebugMsg(other.m_cmps.empty(), "ResourceThreatDecisionPoint:sort", "Other order has no comparators."); for(std::list::const_iterator it = other.m_cmps.begin(); it != other.m_cmps.end(); ++it) { @@ -233,13 +255,16 @@ namespace EUROPA { class TransactionComparator { public: virtual ~TransactionComparator() {} - virtual bool operator()(const TransactionId& t1, const TransactionId& t2) const = 0; + virtual bool operator()(const TransactionId t1, const TransactionId t2) const = 0; virtual std::string toString() const = 0; virtual TransactionComparator* copy() const = 0; private: }; class SwitchComparator : public ChoiceComparator { + private: + SwitchComparator(const SwitchComparator&); + SwitchComparator& operator=(const SwitchComparator&); public: SwitchComparator(TransactionComparator* cmp, bool predecessor) : ChoiceComparator(), m_cmp(cmp), m_predecessor(predecessor) {} ~SwitchComparator(){delete m_cmp;} @@ -285,7 +310,7 @@ namespace EUROPA { class EarliestTransactionComparator : public TransactionComparator { public: - bool operator()(const TransactionId& t1, const TransactionId& t2) const { + bool operator()(const TransactionId t1, const TransactionId t2) const { return t1->time()->lastDomain().getLowerBound() < t2->time()->lastDomain().getLowerBound(); } std::string toString() const {return "earliest";} @@ -294,7 +319,7 @@ namespace EUROPA { class LatestTransactionComparator : public TransactionComparator { public: - bool operator()(const TransactionId& t1, const TransactionId& t2) const { + bool operator()(const TransactionId t1, const TransactionId t2) const { debugMsg("ResourceThreatDecisionPoint:sort:latest", "Comparing upper bounds of timepoints for " << t1->toString() << " and " << t2->toString()); return t1->time()->lastDomain().getUpperBound() > t2->time()->lastDomain().getUpperBound(); } @@ -304,7 +329,7 @@ namespace EUROPA { class LongestTransactionComparator : public TransactionComparator { public: - bool operator()(const TransactionId& t1, const TransactionId& t2) const { + bool operator()(const TransactionId t1, const TransactionId t2) const { return (t1->time()->lastDomain().getUpperBound() - t1->time()->lastDomain().getLowerBound()) > (t2->time()->lastDomain().getUpperBound() - t2->time()->lastDomain().getLowerBound()); @@ -315,7 +340,7 @@ namespace EUROPA { class ShortestTransactionComparator : public TransactionComparator { public: - bool operator()(const TransactionId& t1, const TransactionId& t2) const { + bool operator()(const TransactionId t1, const TransactionId t2) const { return (t1->time()->lastDomain().getUpperBound() - t1->time()->lastDomain().getLowerBound()) < (t2->time()->lastDomain().getUpperBound() - t2->time()->lastDomain().getLowerBound()); @@ -326,7 +351,7 @@ namespace EUROPA { class AscendingKeyTransactionComparator : public TransactionComparator { public: - bool operator()(const TransactionId& t1, const TransactionId& t2) const { + bool operator()(const TransactionId t1, const TransactionId t2) const { return t1->time()->getKey() < t2->time()->getKey(); } std::string toString() const {return "ascendingKey";} @@ -335,7 +360,7 @@ namespace EUROPA { class DescendingKeyTransactionComparator : public TransactionComparator { public: - bool operator()(const TransactionId& t1, const TransactionId& t2) const { + bool operator()(const TransactionId t1, const TransactionId t2) const { return t1->time()->getKey() > t2->time()->getKey(); } std::string toString() const {return "descendingKey";} @@ -343,7 +368,7 @@ namespace EUROPA { }; - bool ResourceThreatDecisionPoint::test(const EntityId& entity) { + bool ResourceThreatDecisionPoint::test(const EntityId entity) { return InstantId::convertable(entity); } @@ -376,10 +401,16 @@ namespace EUROPA { order="leastImpact" will order choices by last estimated temporal impact */ - ResourceThreatDecisionPoint::ResourceThreatDecisionPoint(const DbClientId& client, const InstantId& flawedInstant, const TiXmlElement& configData, const LabelStr& explanation) - : DecisionPoint(client, flawedInstant->getKey(), explanation), m_flawedInstant(flawedInstant), m_index(0) { - m_instTime = m_flawedInstant->getTime(); - m_resName = m_flawedInstant->getProfile()->getResource()->getName(); +ResourceThreatDecisionPoint::ResourceThreatDecisionPoint(const DbClientId client, + const InstantId flawedInstant, + const TiXmlElement& configData, + const std::string& explanation) + : DecisionPoint(client, flawedInstant->getKey(), explanation), + m_flawedInstant(flawedInstant), m_choices(), m_choiceCount(0), m_index(0), + m_constr(), m_instTime(flawedInstant->getTime()), + m_resName(m_flawedInstant->getProfile()->getResource()->getName()), + m_order(), m_filter(), m_constraintOrder(), m_constraintNames(), + m_constraintIt(m_constraintNames.end()) { //process the configuration data for ordering choices //store the filter, defaulting to "none" @@ -412,7 +443,7 @@ namespace EUROPA { ResourceThreatDecisionPoint::~ResourceThreatDecisionPoint() {} - void ResourceThreatDecisionPoint::createFilter(ChoiceFilters& filters, const std::string& filter, ProfileId& profile) { + void ResourceThreatDecisionPoint::createFilter(ChoiceFilters& filters, const std::string& filter, ProfileId profile) { checkError(filter == "none" || filter == "predecessorNot" || filter == "successor" || filter == "both", "Unknown filter attribute '" << filter << "'"); if(filter == "successor" || filter == "both") @@ -425,7 +456,7 @@ namespace EUROPA { std::string ResourceThreatDecisionPoint::toShortString() const { std::stringstream os; - os << "INS(" << m_instTime << ") on " << m_resName.toString(); + os << "INS(" << m_instTime << ") on " << m_resName; TransactionId predecessor = m_choices[m_index].first; TransactionId successor = m_choices[m_index].second; os << " {" << predecessor->toString() << " < " << successor->toString() << "}"; @@ -435,7 +466,7 @@ namespace EUROPA { std::string ResourceThreatDecisionPoint::toString() const { std::stringstream os; - os << "INSTANT=" << m_instTime << " on " << m_resName.toString() << " : "; + os << "INSTANT=" << m_instTime << " on " << m_resName << " : "; if (m_choiceCount == 0) { os << "NO CHOICES"; @@ -469,7 +500,7 @@ namespace EUROPA { //filter based on the configuration ChoiceFilters filter; - createFilter(filter, m_filter, const_cast(m_flawedInstant->getProfile())); + createFilter(filter, m_filter, static_cast(m_flawedInstant->getProfile())); //order based ont he configuration ChoiceOrder order; createOrder(order); @@ -510,14 +541,14 @@ namespace EUROPA { checkError(m_index < m_choiceCount, "Tried to execute past available choices:" << m_index << ">=" << m_choiceCount); TransactionId predecessor = m_choices[m_index].first; TransactionId successor = m_choices[m_index].second; - debugMsg("SolverDecisionPoint:handleExecute", "For " << m_instTime << " on " << m_resName.toString() << ", assigning " << - predecessor->toString() << " to be before " << successor->toString() << " because of " << getExplanation().toString() << "."); + debugMsg("SolverDecisionPoint:handleExecute", "For " << m_instTime << " on " << m_resName << ", assigning " << + predecessor->toString() << " to be before " << successor->toString() << " because of " << getExplanation() << "."); m_constr = m_client->createConstraint((*m_constraintIt).c_str(), makeScope(predecessor->time(), successor->time())); } void ResourceThreatDecisionPoint::handleUndo() { debugMsg("SolverDecisionPoint:handleUndo", "Retracting ordering decision on " << m_instTime << " on " << - m_resName.toString()); + m_resName); check_error(m_constr.isValid()); m_constr->discard(); m_constr = ConstraintId::noId(); diff --git a/src/PLASMA/Resource/component/Solvers/ResourceThreatDecisionPoint.hh b/src/PLASMA/Resource/component/Solvers/ResourceThreatDecisionPoint.hh index bf52ed24f..f00078c7e 100644 --- a/src/PLASMA/Resource/component/Solvers/ResourceThreatDecisionPoint.hh +++ b/src/PLASMA/Resource/component/Solvers/ResourceThreatDecisionPoint.hh @@ -1,5 +1,5 @@ -#ifndef _H_ResourceThreatDecisionPoint -#define _H_ResourceThreatDecisionPoint +#ifndef H_ResourceThreatDecisionPoint +#define H_ResourceThreatDecisionPoint #include "SolverDecisionPoint.hh" #include "ResourceDefs.hh" @@ -15,7 +15,7 @@ namespace EUROPA { class ResourceThreatDecisionPoint : public SOLVERS::DecisionPoint { public: - ResourceThreatDecisionPoint(const DbClientId& client, const InstantId& inst, const TiXmlElement& configData, const LabelStr& explanation = "unknown"); + ResourceThreatDecisionPoint(const DbClientId client, const InstantId inst, const TiXmlElement& configData, const std::string& explanation = "unknown"); virtual ~ResourceThreatDecisionPoint(); virtual std::string toString() const; virtual std::string toShortString() const; @@ -27,20 +27,20 @@ namespace EUROPA { virtual bool canUndo() const; virtual void handleExecute(); virtual void handleUndo(); - static bool test(const EntityId& entity); + static bool test(const EntityId entity); private: std::string toString(const std::pair& choice) const; - void createFilter(ChoiceFilters& filters, const std::string& filter, ProfileId& profile); + void createFilter(ChoiceFilters& filters, const std::string& filter, ProfileId profile); void createOrder(ChoiceOrder& order); protected: InstantId m_flawedInstant; std::vector > m_choices; - unsigned int m_choiceCount; - unsigned int m_index; + unsigned long m_choiceCount; + unsigned long m_index; ConstraintId m_constr; eint m_instTime; - LabelStr m_resName; + std::string m_resName; std::string m_order; std::string m_filter; std::string m_constraintOrder; diff --git a/src/PLASMA/Resource/component/Solvers/ResourceThreatManager.cc b/src/PLASMA/Resource/component/Solvers/ResourceThreatManager.cc index 343d00137..abea068ea 100644 --- a/src/PLASMA/Resource/component/Solvers/ResourceThreatManager.cc +++ b/src/PLASMA/Resource/component/Solvers/ResourceThreatManager.cc @@ -4,6 +4,7 @@ #include "Resource.hh" #include "PlanDatabase.hh" #include "Context.hh" +#include "tinyxml.h" #ifdef ABSOLUTE #undef ABSOLUTE @@ -18,18 +19,56 @@ namespace EUROPA { // class TimeComparator { // public: -// bool operator()(const InstantId& insta, const InstantId& instb) { +// bool operator()(const InstantId insta, const InstantId instb) { // return insta->getTime() < instb->getTime(); // } // }; // class FlawMagnitudeComparator { // public: -// bool operator()(const InstantId& insta, const InstantId& instb) { +// bool operator()(const InstantId insta, const InstantId instb) { // return insta-> // } // }; +namespace { +class ThreatIterator : public FlawIterator { + public: + ThreatIterator(ResourceThreatManager& manager) + : FlawIterator(manager), m_flawedInstants(), m_it(m_flawedInstants.end()) { + const ObjectSet& objs = manager.getPlanDatabase()->getObjects(); + for(ObjectSet::const_iterator it = objs.begin(); it != objs.end(); ++it) { + ObjectId obj(*it); + check_error(obj.isValid()); + debugMsg("ThreatIterator:ThreatIterator", "Checking to see if " << obj->toString() << " is a resource..."); + if(!ResourceId::convertable(obj)) + continue; + ResourceId res(obj); + std::vector temp; + debugMsg("ThreatIterator:ThreatIterator", "Resource! Getting flawed instants..."); + res->getFlawedInstants(temp); + m_flawedInstants.insert(m_flawedInstants.end(), temp.begin(), temp.end()); + } + debugMsg("ThreatIterator:ThreatIterator", "Got " << m_flawedInstants.size() << " total instants."); + m_it = m_flawedInstants.begin(); + advance(); + condDebugMsg(done(), "ThreatIterator:ThreatIterator", "Advanced to the end right away."); + } + protected: + private: + const EntityId nextCandidate() { + EntityId candidate; + if(m_it != m_flawedInstants.end()) { + candidate = *m_it; + ++m_it; + } + return candidate; + } + std::vector m_flawedInstants; + std::vector::iterator m_it; +}; +} + class InstantComparator { public: enum FlawDirection { @@ -39,7 +78,7 @@ namespace EUROPA { }; virtual ~InstantComparator() {} - virtual bool operator()(const InstantId& a, const InstantId& b) const = 0; + virtual bool operator()(const InstantId a, const InstantId b) const = 0; virtual std::string toString() const = 0; virtual InstantComparator* copy() const = 0; }; @@ -51,14 +90,14 @@ namespace EUROPA { m_cmps.clear(); } - DecisionOrder::DecisionOrder(const DecisionOrder& other) { - for(std::list::const_iterator it = other.m_cmps.begin(); it != other.m_cmps.end(); ++it) { - m_cmps.push_back((*it)->copy()); - } - } +DecisionOrder::DecisionOrder(const DecisionOrder& other) : m_cmps() { + for(std::list::const_iterator it = other.m_cmps.begin(); it != other.m_cmps.end(); ++it) { + m_cmps.push_back((*it)->copy()); + } +} //returns true if a is better than b - bool DecisionOrder::operator()(const InstantId& a, const InstantId& b, LabelStr& explanation) const { + bool DecisionOrder::operator()(const InstantId a, const InstantId b, std::string& explanation) const { check_error(!m_cmps.empty()); check_error(a.isValid() && b.isValid()); debugMsg("ResourceThreatManager:betterThan", "Comparing instant " << a->getTime() << " on " << a->getProfile()->getResource()->toString() << @@ -89,7 +128,7 @@ namespace EUROPA { class EarliestInstantComparator : public InstantComparator { public: - bool operator()(const InstantId& a, const InstantId& b) const { + bool operator()(const InstantId a, const InstantId b) const { return a->getTime() < b->getTime(); } std::string toString() const {return "earliest";} @@ -98,7 +137,7 @@ namespace EUROPA { class LatestInstantComparator : public InstantComparator { public: - bool operator()(const InstantId& a, const InstantId& b) const { + bool operator()(const InstantId a, const InstantId b) const { return a->getTime() > b->getTime(); } std::string toString() const {return "latest";} @@ -108,7 +147,7 @@ namespace EUROPA { class MostInstantComparator : public InstantComparator { public: MostInstantComparator(const FlawDirection& dir = ABSOLUTE) : InstantComparator(), m_dir(dir) {} - bool operator()(const InstantId& a, const InstantId& b) const { + bool operator()(const InstantId a, const InstantId b) const { if(m_dir == UPPER) { if(a->hasUpperLevelFlaw()) { if(b->hasUpperLevelFlaw()) { @@ -154,7 +193,7 @@ namespace EUROPA { class LeastInstantComparator : public InstantComparator { public: LeastInstantComparator(const FlawDirection& dir = ABSOLUTE) : InstantComparator(), m_dir(dir) {} - bool operator()(const InstantId& a, const InstantId& b) const { + bool operator()(const InstantId a, const InstantId b) const { if(m_dir == UPPER) { if(a->hasUpperLevelFlaw()) { if(b->hasUpperLevelFlaw()) { @@ -199,7 +238,7 @@ namespace EUROPA { class UpperInstantComparator : public InstantComparator { public: - bool operator()(const InstantId& a, const InstantId& b) const { + bool operator()(const InstantId a, const InstantId b) const { return a->hasUpperLevelFlaw() && !b->hasUpperLevelFlaw(); } std::string toString() const {return "upperLevelFlaw";} @@ -208,7 +247,7 @@ namespace EUROPA { class LowerInstantComparator : public InstantComparator { public: - bool operator()(const InstantId& a, const InstantId& b) const { + bool operator()(const InstantId a, const InstantId b) const { return a->hasLowerLevelFlaw() && !b->hasLowerLevelFlaw(); } std::string toString() const {return "lowerLevelFlaw";} @@ -216,8 +255,10 @@ namespace EUROPA { }; //at some point, this should take data about ordering choices by earliest/latest, most/least flawed, and most/least transactions - ResourceThreatManager::ResourceThreatManager(const TiXmlElement& configData) : FlawManager(configData), m_preferUpper(false), m_preferLower(false) { - std::string order = (configData.Attribute("order") == NULL ? "lower,most,earliest" : configData.Attribute("order")); +ResourceThreatManager::ResourceThreatManager(const TiXmlElement& configData) + : FlawManager(configData), m_preferUpper(false), m_preferLower(false), m_order() { + std::string order = (configData.Attribute("order") == NULL ? + "lower,most,earliest" : configData.Attribute("order")); std::string::size_type curPos = 0; InstantComparator::FlawDirection dir = InstantComparator::ABSOLUTE; while(curPos != std::string::npos) { @@ -255,12 +296,12 @@ namespace EUROPA { ResourceThreatManager::~ResourceThreatManager(){} //re-impelement this to delegate to FlawManager::staticMatch - bool ResourceThreatManager::staticMatch(const EntityId& entity) { + bool ResourceThreatManager::staticMatch(const EntityId entity) { return !InstantId::convertable(entity); } //there may be no dynamic information here - bool ResourceThreatManager::dynamicMatch(const EntityId& entity) { + bool ResourceThreatManager::dynamicMatch(const EntityId entity) { return staticMatch(entity); } @@ -268,7 +309,7 @@ namespace EUROPA { } //this should use data from the constructor - bool ResourceThreatManager::betterThan(const EntityId& a, const EntityId& b, LabelStr& explanation) { + bool ResourceThreatManager::betterThan(const EntityId a, const EntityId b, std::string& explanation) { check_error(InstantId::convertable(a) && InstantId::convertable(b)); InstantId instA(a); InstantId instB(b); @@ -276,7 +317,7 @@ namespace EUROPA { return m_order(a, b, explanation); } - std::string ResourceThreatManager::toString(const EntityId& entity) const { + std::string ResourceThreatManager::toString(const EntityId entity) const { check_error(InstantId::convertable(entity)); InstantId inst(entity); std::stringstream os; @@ -284,40 +325,10 @@ namespace EUROPA { return os.str(); } - class ThreatIterator : public FlawIterator { - public: - ThreatIterator(ResourceThreatManager& manager) : FlawIterator(manager) { - const ObjectSet& objs = manager.getPlanDatabase()->getObjects(); - for(ObjectSet::const_iterator it = objs.begin(); it != objs.end(); ++it) { - ObjectId obj(*it); - check_error(obj.isValid()); - debugMsg("ThreatIterator:ThreatIterator", "Checking to see if " << obj->toString() << " is a resource..."); - if(!ResourceId::convertable(obj)) - continue; - ResourceId res(obj); - std::vector temp; - debugMsg("ThreatIterator:ThreatIterator", "Resource! Getting flawed instants..."); - res->getFlawedInstants(temp); - m_flawedInstants.insert(m_flawedInstants.end(), temp.begin(), temp.end()); - } - debugMsg("ThreatIterator:ThreatIterator", "Got " << m_flawedInstants.size() << " total instants."); - m_it = m_flawedInstants.begin(); - advance(); - condDebugMsg(done(), "ThreatIterator:ThreatIterator", "Advanced to the end right away."); - } - protected: - private: - const EntityId nextCandidate() { - EntityId candidate; - if(m_it != m_flawedInstants.end()) { - candidate = *m_it; - ++m_it; - } - return candidate; - } - std::vector m_flawedInstants; - std::vector::iterator m_it; - }; +bool ResourceThreatManager::noMoreFlaws() { + return ThreatIterator(*this).done(); +} + IteratorId ResourceThreatManager::createIterator() { return (new ThreatIterator(*this))->getId(); diff --git a/src/PLASMA/Resource/component/Solvers/ResourceThreatManager.hh b/src/PLASMA/Resource/component/Solvers/ResourceThreatManager.hh index 89c1ae81d..f1ff58a08 100644 --- a/src/PLASMA/Resource/component/Solvers/ResourceThreatManager.hh +++ b/src/PLASMA/Resource/component/Solvers/ResourceThreatManager.hh @@ -1,5 +1,5 @@ -#ifndef _H_ResourceThreatManager -#define _H_ResourceThreatManager +#ifndef H_ResourceThreatManager +#define H_ResourceThreatManager #include "FlawManager.hh" #include "Instant.hh" @@ -9,10 +9,10 @@ namespace EUROPA { class DecisionOrder { public: - DecisionOrder() {} + DecisionOrder() : m_cmps() {} DecisionOrder(const DecisionOrder& other); ~DecisionOrder(); - bool operator()(const InstantId& a, const InstantId& b, LabelStr& explanation) const; + bool operator()(const InstantId a, const InstantId b, std::string& explanation) const; void addOrder(InstantComparator* cmp); private: std::list m_cmps; @@ -22,19 +22,20 @@ namespace EUROPA { public: ResourceThreatManager(const TiXmlElement& configData); virtual ~ResourceThreatManager(); - virtual std::string toString(const EntityId& entity) const; - virtual bool staticMatch(const EntityId& entity); - virtual bool dynamicMatch(const EntityId& entity); + virtual std::string toString(const EntityId entity) const; + virtual bool staticMatch(const EntityId entity); + virtual bool dynamicMatch(const EntityId entity); virtual void handleInitialize(); - virtual bool betterThan(const EntityId& a, const EntityId& b, LabelStr& explanation); + virtual bool betterThan(const EntityId a, const EntityId b, std::string& explanation); virtual IteratorId createIterator(); - virtual void notifyAdded(const ConstraintId& constraint){} - virtual void notifyRemoved(const ConstraintId& constraint) {} - virtual void notifyRemoved(const ConstrainedVariableId& var) {} - virtual void notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType){} - virtual void notifyAdded(const TokenId& token) {} - virtual void notifyRemoved(const TokenId& token) {} + virtual void notifyAdded(const ConstraintId){} + virtual void notifyRemoved(const ConstraintId) {} + virtual void notifyRemoved(const ConstrainedVariableId) {} + virtual void notifyChanged(const ConstrainedVariableId, const DomainListener::ChangeType&){} + virtual void notifyAdded(const TokenId) {} + virtual void notifyRemoved(const TokenId) {} + bool noMoreFlaws(); protected: private: diff --git a/src/PLASMA/Resource/component/TimetableProfile.cc b/src/PLASMA/Resource/component/TimetableProfile.cc index 18ebda238..ff3d93727 100644 --- a/src/PLASMA/Resource/component/TimetableProfile.cc +++ b/src/PLASMA/Resource/component/TimetableProfile.cc @@ -41,86 +41,86 @@ namespace EUROPA { m_maxPrevProduction = 0; } - void TimetableProfile::recomputeLevels( InstantId prev, InstantId inst) { - check_error(inst.isValid()); - - edouble maxInstantProduction(0), minInstantProduction(0), maxInstantConsumption(0), minInstantConsumption(0); - edouble maxCumulativeProduction(m_maxPrevProduction), minCumulativeProduction(m_minPrevProduction); - edouble maxCumulativeConsumption(m_maxPrevConsumption), minCumulativeConsumption(m_minPrevConsumption); - - const std::set& transactions(inst->getTransactions()); - debugMsg("TimetableProfile:recomputeLevels", "Transactions at " << inst->getTime() << ":"); - for(std::set::const_iterator it = transactions.begin(); it != transactions.end(); ++it) { - TransactionId trans = *it; - edouble lb, ub; - trans->quantity()->lastDomain().getBounds(lb, ub); - bool isConsumer = trans->isConsumer(); - debugMsg("TimetableProfile:recomputeLevels", "Time: [" << trans->time()->lastDomain().getLowerBound() << " " << - trans->time()->lastDomain().getUpperBound() << "] Quantity: " << (isConsumer ? "-" : "+") << - "[" << lb << " " << ub << "]"); - - //the minInstant values are 0 unless there is a transaction that cannot happen before or after this instant, so we have to add those - if(trans->time()->lastDomain().isSingleton()) { - if(isConsumer) - minInstantConsumption += lb; - else - minInstantProduction += lb; - } +void TimetableProfile::recomputeLevels( InstantId, InstantId inst) { + check_error(inst.isValid()); + + edouble maxInstantProduction(0), minInstantProduction(0), maxInstantConsumption(0), minInstantConsumption(0); + edouble maxCumulativeProduction(m_maxPrevProduction), minCumulativeProduction(m_minPrevProduction); + edouble maxCumulativeConsumption(m_maxPrevConsumption), minCumulativeConsumption(m_minPrevConsumption); + + const std::set& transactions(inst->getTransactions()); + debugMsg("TimetableProfile:recomputeLevels", "Transactions at " << inst->getTime() << ":"); + for(std::set::const_iterator it = transactions.begin(); it != transactions.end(); ++it) { + TransactionId trans = *it; + edouble lb, ub; + trans->quantity()->lastDomain().getBounds(lb, ub); + bool isConsumer = trans->isConsumer(); + debugMsg("TimetableProfile:recomputeLevels", "Time: [" << trans->time()->lastDomain().getLowerBound() << " " << + trans->time()->lastDomain().getUpperBound() << "] Quantity: " << (isConsumer ? "-" : "+") << + "[" << lb << " " << ub << "]"); + + //the minInstant values are 0 unless there is a transaction that cannot happen before or after this instant, so we have to add those + if(trans->time()->lastDomain().isSingleton()) { + if(isConsumer) + minInstantConsumption += lb; + else + minInstantProduction += lb; + } - //of course, in the upper case we consume and produce the most possible at this instant - if(isConsumer) - maxInstantConsumption += ub; - else - maxInstantProduction += ub; + //of course, in the upper case we consume and produce the most possible at this instant + if(isConsumer) + maxInstantConsumption += ub; + else + maxInstantProduction += ub; - //if the transaction just started, add producer to upper bounds and consumer to lower bounds - if(trans->time()->lastDomain().getLowerBound() == inst->getTime()) - handleTransactionStart(isConsumer, lb, ub); + //if the transaction just started, add producer to upper bounds and consumer to lower bounds + if(trans->time()->lastDomain().getLowerBound() == inst->getTime()) + handleTransactionStart(isConsumer, lb, ub); - //if the transaction just ended, add producer to lower bounds and consumer to upper bounds - if(trans->time()->lastDomain().getUpperBound() == inst->getTime()) { - handleTransactionEnd(isConsumer, lb, ub); - if(isConsumer) - minCumulativeConsumption += lb; - else - minCumulativeProduction += lb; - } + //if the transaction just ended, add producer to lower bounds and consumer to upper bounds + if(trans->time()->lastDomain().getUpperBound() == inst->getTime()) { + handleTransactionEnd(isConsumer, lb, ub); + if(isConsumer) + minCumulativeConsumption += lb; + else + minCumulativeProduction += lb; + } - } - maxCumulativeConsumption += maxInstantConsumption; - maxCumulativeProduction += maxInstantProduction; - - debugMsg("TimetableProfile:recompute", "Computed values for time " << inst->getTime() << ":" << std::endl << - " Lower level (min, max): (" << m_lowerLevelMin << ", " << m_lowerLevelMax << ")" << std::endl << - " Upper level (min, max): (" << m_upperLevelMin << ", " << m_upperLevelMax << ")" << std::endl << - " Instantaneous consumption (min, max): (" << minInstantConsumption << ", " << maxInstantConsumption << ")" << std::endl << - " Instantaneous production (min, max): (" << minInstantProduction << ", " << maxInstantProduction << ")" << std::endl << - " Cumulative consumption (min, max): (" << minCumulativeConsumption << ", " << maxCumulativeConsumption << ")" << std::endl << - " Cumulative production (min, max): (" << minCumulativeProduction << ", " << maxCumulativeProduction << ")" << std::endl); - inst->update(m_lowerLevelMin, m_lowerLevelMax, m_upperLevelMin, m_upperLevelMax, - minInstantConsumption, maxInstantConsumption, minInstantProduction, maxInstantProduction, - minCumulativeConsumption, maxCumulativeConsumption, minCumulativeProduction, maxCumulativeProduction, - m_minPrevConsumption, m_maxPrevConsumption, m_minPrevProduction, m_maxPrevProduction); - - //update the values for production and consumption that must have happened by the next transaction - for(std::set::const_iterator it = inst->getEndingTransactions().begin(); it != inst->getEndingTransactions().end(); ++it) { - TransactionId trans = *it; - check_error(trans.isValid()); - edouble lb, ub; - trans->quantity()->lastDomain().getBounds(lb, ub); - if(trans->isConsumer()) { - m_maxPrevConsumption += ub; - m_minPrevConsumption += lb; - } - else { - m_maxPrevProduction += ub; - m_minPrevProduction += lb; - } - } + } + maxCumulativeConsumption += maxInstantConsumption; + maxCumulativeProduction += maxInstantProduction; + + debugMsg("TimetableProfile:recompute", "Computed values for time " << inst->getTime() << ":" << std::endl << + " Lower level (min, max): (" << m_lowerLevelMin << ", " << m_lowerLevelMax << ")" << std::endl << + " Upper level (min, max): (" << m_upperLevelMin << ", " << m_upperLevelMax << ")" << std::endl << + " Instantaneous consumption (min, max): (" << minInstantConsumption << ", " << maxInstantConsumption << ")" << std::endl << + " Instantaneous production (min, max): (" << minInstantProduction << ", " << maxInstantProduction << ")" << std::endl << + " Cumulative consumption (min, max): (" << minCumulativeConsumption << ", " << maxCumulativeConsumption << ")" << std::endl << + " Cumulative production (min, max): (" << minCumulativeProduction << ", " << maxCumulativeProduction << ")" << std::endl); + inst->update(m_lowerLevelMin, m_lowerLevelMax, m_upperLevelMin, m_upperLevelMax, + minInstantConsumption, maxInstantConsumption, minInstantProduction, maxInstantProduction, + minCumulativeConsumption, maxCumulativeConsumption, minCumulativeProduction, maxCumulativeProduction, + m_minPrevConsumption, m_maxPrevConsumption, m_minPrevProduction, m_maxPrevProduction); + + //update the values for production and consumption that must have happened by the next transaction + for(std::set::const_iterator it = inst->getEndingTransactions().begin(); it != inst->getEndingTransactions().end(); ++it) { + TransactionId trans = *it; + check_error(trans.isValid()); + edouble lb, ub; + trans->quantity()->lastDomain().getBounds(lb, ub); + if(trans->isConsumer()) { + m_maxPrevConsumption += ub; + m_minPrevConsumption += lb; } + else { + m_maxPrevProduction += ub; + m_minPrevProduction += lb; + } + } +} - void TimetableProfile::getTransactionsToOrder(const InstantId& inst, std::vector& results) { + void TimetableProfile::getTransactionsToOrder(const InstantId inst, std::vector& results) { check_error(inst.isValid()); check_error(results.empty()); results.insert(results.end(), inst->getTransactions().begin(), inst->getTransactions().end()); diff --git a/src/PLASMA/Resource/component/TimetableProfile.hh b/src/PLASMA/Resource/component/TimetableProfile.hh index b9f3aea87..2216e0e96 100644 --- a/src/PLASMA/Resource/component/TimetableProfile.hh +++ b/src/PLASMA/Resource/component/TimetableProfile.hh @@ -1,5 +1,5 @@ -#ifndef _H_TimetableProfile -#define _H_TimetableProfile +#ifndef H_TimetableProfile +#define H_TimetableProfile #include "ResourceDefs.hh" #include "Profile.hh" @@ -11,7 +11,7 @@ namespace EUROPA { public: TimetableProfile(const PlanDatabaseId db, const FVDetectorId flawDetector); - void getTransactionsToOrder(const InstantId& inst, std::vector& results); + void getTransactionsToOrder(const InstantId inst, std::vector& results); protected: /** diff --git a/src/PLASMA/Resource/component/Types.hh b/src/PLASMA/Resource/component/Types.hh index bf353a4be..01139b76d 100644 --- a/src/PLASMA/Resource/component/Types.hh +++ b/src/PLASMA/Resource/component/Types.hh @@ -1,5 +1,5 @@ -#ifndef _TYPES_HEADER_FILE_ -#define _TYPES_HEADER_FILE_ +#ifndef TYPES_HEADER_FILE_ +#define TYPES_HEADER_FILE_ /** * @file Types.hh @@ -9,14 +9,15 @@ * @ingroup Resource */ -#ifdef _MSC_VER -# include -using std::map; -namespace hash_src = stdext; -#else -# include "hash_map.hh" -namespace hash_src = __gnu_cxx; -#endif //_MSC_VER +// #ifdef _MSC_VER +// # include +// using std::map; +// namespace hash_src = stdext; +// #elif __clang__ +// # include "hash_map.hh" +// namespace hash_src = __gnu_cxx; +// #endif //_MSC_VER +#include #include #include @@ -29,9 +30,9 @@ namespace hash_src = __gnu_cxx; #include "Instant.hh" #include "Transaction.hh" -//#define TRACE_GRAPH 1 +#define TRACE_GRAPH 0 -#ifdef TRACE_GRAPH +#if TRACE_GRAPH #define graphDebug( msg ) { \ std::stringstream sstr; \ @@ -61,50 +62,54 @@ namespace EUROPA typedef std::list< Edge* > EdgeList; typedef std::list< Node* > NodeList; - class NodeHash: - public std::unary_function +class NodeHash #ifdef _MSC_VER - , public hash_compare< Node * > + : public hash_compare< Node * > #endif //_MSC_VER +{ + public: + typedef Node* argument_type; + typedef size_t result_type; + size_t operator()(Node* n) const { - public: - size_t operator()(Node* n) const - { - hash_src::hash H; - return H( (long) n); - } - }; + boost::hash H; + return H( reinterpret_cast(n)); + } +}; - class EdgeHash: - public std::unary_function + class EdgeHash #ifdef _MSC_VER - , public hash_compare< Edge * > + : public hash_compare< Edge * > #endif //_MSC_VER { - public: + public: + typedef Edge* argument_type; + typedef size_t result_type; size_t operator()(Edge* n) const { - hash_src::hash H; - return H( (long) n ); + boost::hash H; + return H( reinterpret_cast(n) ); } }; - class TransactionIdHash: - public std::unary_function< TransactionId, size_t> + class TransactionIdHash #ifdef _MSC_VER - , public hash_compare< TransactionId > + : public hash_compare< TransactionId > #endif //_MSC_VER { - public: + public: + typedef TransactionId argument_type; + typedef size_t result_type; size_t operator()(TransactionId n) const { - hash_src::hash H; - return H( (long) ( (Transaction*) n ) ); + boost::hash H; + return H(reinterpret_cast(static_cast(n))); } }; +//TODO: Do we need to keep this MSC_VER branch? #ifdef _MSC_VER typedef map< Node*, bool > Node2Bool; typedef map< Node*, eint > Node2Int; @@ -114,14 +119,28 @@ namespace EUROPA typedef map< Edge*, edouble > Edge2DoubleMap; typedef map< TransactionId, InstantId > TransactionId2InstantId; #else -typedef hash_src::hash_map< Node*, bool, NodeHash > Node2Bool; -typedef hash_src::hash_map< Node*, eint, NodeHash > Node2Int; -typedef hash_src::hash_map< Node*, eint, NodeHash > Node2Long; -typedef hash_src::hash_map< Node*, edouble, NodeHash > Node2Double; +typedef boost::unordered_map< Node*, bool, NodeHash > Node2Bool; +typedef boost::unordered_map< Node*, eint, NodeHash > Node2Int; +typedef boost::unordered_map< Node*, eint, NodeHash > Node2Long; +typedef boost::unordered_map< Node*, edouble, NodeHash > Node2Double; -typedef hash_src::hash_map< Edge*, edouble, EdgeHash > Edge2DoubleMap; -typedef hash_src::hash_map< TransactionId, InstantId, TransactionIdHash > TransactionId2InstantId; +typedef boost::unordered_map< Edge*, edouble, EdgeHash > Edge2DoubleMap; +typedef boost::unordered_map< TransactionId, InstantId, TransactionIdHash > TransactionId2InstantId; #endif +/** + * @brief Indicates the ordering between two time variables associated with a transaction + */ +enum Order { + AFTER_OR_AT = 0, /*!< Indicates one transaction is strictly after or at the same time with another transaction. */ + BEFORE_OR_AT,/*!< Indicates one transaction is strictly before or at the same time with another transaction. */ + NOT_ORDERED,/*!< Indicates one transaction is not ordered with another transaction. */ + STRICTLY_AT,/*!< Indicates one transaction is strictly at the same time with another transaction. */ + UNKNOWN +}; +typedef std::pair TransactionIdTransactionIdPair; +typedef std::map< TransactionIdTransactionIdPair, Order > TransactionIdTransactionIdPair2Order; + + std::ostream& operator<<( std::ostream& os, const EdgeIdentity& fei ) ; diff --git a/src/PLASMA/Resource/test/rs-flow-test-module.cc b/src/PLASMA/Resource/test/rs-flow-test-module.cc index f6a447b56..25e638e34 100644 --- a/src/PLASMA/Resource/test/rs-flow-test-module.cc +++ b/src/PLASMA/Resource/test/rs-flow-test-module.cc @@ -10,6 +10,8 @@ #include "IncrementalFlowProfile.hh" #include "ProfilePropagator.hh" #include "ClosedWorldFVDetector.hh" +#include "BoostFlowProfile.hh" +#include "BoostFlowProfileGraph.hh" #include "Debug.hh" #include "Engine.hh" @@ -26,10 +28,12 @@ #include "STNTemporalAdvisor.hh" #include "Reusable.hh" #include "DurativeTokens.hh" +#include "TestUtils.hh" #include #include #include +#include using namespace EUROPA; @@ -45,8 +49,8 @@ class ResourceTestEngine : public EngineBase #define RESOURCE_DEFAULT_SETUP(ce, db, autoClose) \ ResourceTestEngine rte; \ - ConstraintEngine& ce = *((ConstraintEngine*)rte.getComponent("ConstraintEngine")); \ - PlanDatabase& db = *((PlanDatabase*)rte.getComponent("PlanDatabase")); \ + ConstraintEngine& ce = *boost::polymorphic_cast(rte.getComponent("ConstraintEngine")); \ + PlanDatabase& db = *boost::polymorphic_cast(rte.getComponent("PlanDatabase")); \ if (autoClose) \ db.close(); @@ -75,19 +79,27 @@ class DefaultSetupTest { class DummyDetector : public FVDetector { public: DummyDetector(const ResourceId res) : FVDetector(res) {}; - bool detect(const InstantId inst) {return false;} - void initialize(const InstantId inst) {} + bool detect(const InstantId ) {return false;} + void initialize(const InstantId ) {} void initialize() {} virtual PSResourceProfile* getFDLevelProfile() { return NULL; } virtual PSResourceProfile* getVDLevelProfile() { return NULL; } }; +// class BoostFlowProfile : public FlowProfile { +// public: +// BoostFlowProfile(const PlanDatabaseId db, const FVDetectorId flawDetector) +// : FlowProfile(db, flawDetector) { +// initializeGraphs(); +// } +// }; + class FlowProfileTest { public: - static bool test(){ + static bool flowProfileTest() { debugMsg("ResourceTest"," FlowProfile "); testAddAndRemove< EUROPA::FlowProfile> (); @@ -99,15 +111,43 @@ class FlowProfileTest testScenario5< EUROPA::FlowProfile>(); testScenario6< EUROPA::FlowProfile>(); testScenario7< EUROPA::FlowProfile>(); - testScenario8< EUROPA::FlowProfile>(); + // testScenario8< EUROPA::FlowProfile>(); testScenario9< EUROPA::FlowProfile>(); - //testScenario10< EUROPA::FlowProfile>(); - testScenario11< EUROPA::FlowProfile>(); - testScenario12< EUROPA::FlowProfile>(); - //testScenario13< EUROPA::FlowProfile>(); - //testScenario14< EUROPA::FlowProfile>(); - //testPaulBug(); + // testScenario10< EUROPA::FlowProfile>(); + // testScenario11< EUROPA::FlowProfile>(); + // testScenario12< EUROPA::FlowProfile>(); + // testScenario13< EUROPA::FlowProfile>(); + // testScenario14< EUROPA::FlowProfile>(); + testPaulBug(); + + return true; + } + + static bool boostFlowProfileTest() { + debugMsg("ResourceTest"," BoostFlowProfile "); + + testAddAndRemove (); + testScenario0< BoostFlowProfile>(); + testScenario1< BoostFlowProfile>(); + testScenario2< BoostFlowProfile>(); + testScenario3< BoostFlowProfile>(); + testScenario4< BoostFlowProfile>(); + testScenario5< BoostFlowProfile>(); + testScenario6< BoostFlowProfile>(); + testScenario7< BoostFlowProfile>(); + testScenario8< BoostFlowProfile>(); + testScenario9< BoostFlowProfile>(); + testScenario10(); + testScenario11(); + testScenario12(); + testScenario13(); + testScenario14(); + testPaulBug(); + return true; + + } + static bool incrementalFlowProfileTest() { debugMsg("ResourceTest"," IncrementalFlowProfile "); testAddAndRemove< EUROPA::IncrementalFlowProfile> (); @@ -127,8 +167,15 @@ class FlowProfileTest testScenario13< EUROPA::IncrementalFlowProfile>(); testScenario14< EUROPA::IncrementalFlowProfile>(); //testPaulBug(); + return true; + } - return true; + static bool test(){ + return + // flowProfileTest() && + boostFlowProfileTest() //&& + //incrementalFlowProfileTest() + ; } private: static bool verifyProfile( Profile& profile, int instances, eint times[], edouble lowerLevel[], edouble upperLevel[] ) { @@ -178,31 +225,52 @@ class FlowProfileTest return true; } - static void executeScenario0( Profile& profile, ConstraintEngine& ce ) { + static void executeScenario0( Profile& profile, ConstraintEngine& ) { // no transactions profile.recompute(); } static void executePaulBug(Profile& profile, ConstraintEngine& ce, int nrInstances, eint itimes[], edouble lowerLevels[], edouble upperLevels[] ) { - Variable t1(ce.getId(), IntervalIntDomain(10, PLUS_INFINITY), true, "T+"); - Variable t2(ce.getId(), IntervalIntDomain(120010, PLUS_INFINITY), true, "T-"); - Variable t3(ce.getId(), IntervalIntDomain(960000, PLUS_INFINITY), true, "t-"); - Variable t4(ce.getId(), IntervalIntDomain(961200, PLUS_INFINITY), true, "t+"); + /*! + * T+ precedes T- + * t- precedes t+ + * + * T+ <10-------(+1000)---------------------------------inf> + * T- | <120010--(-1000)---------------------------inf> + * t- | | <960000--------(-1)---------------inf> + * t+ | | | <961200--------(+1)-------inf> + * | | | | | + * | | | | | + * 1000 1000 1000 1000 0 + * 0 0 -1 -1 0 + * + */ + + Variable t1(ce.getId(), IntervalIntDomain(10, PLUS_INFINITY), + false, true, "T+"); + Variable t2(ce.getId(), IntervalIntDomain(120010, PLUS_INFINITY), + false, true, "T-"); + Variable t3(ce.getId(), IntervalIntDomain(960000, PLUS_INFINITY), + false, true, "t-"); + Variable t4(ce.getId(), IntervalIntDomain(961200, PLUS_INFINITY), + false, true, "t+"); - Variable q1(ce.getId(), IntervalDomain(1000), true, "qT+"); - Variable q2(ce.getId(), IntervalDomain(-1000), true, "qT-"); - Variable q3(ce.getId(), IntervalDomain(-1), true, "qt-"); - Variable q4(ce.getId(), IntervalDomain(1), true, "qt-"); + Variable q1(ce.getId(), IntervalDomain(1000), false, true, "qT+"); + Variable q2(ce.getId(), IntervalDomain(1000), false, true, "qT-"); + Variable q3(ce.getId(), IntervalDomain(1), false, true, "qt-"); + Variable q4(ce.getId(), IntervalDomain(1), false, true, "qt+"); - LessThanEqualConstraint c0(LabelStr("precedes"), LabelStr("Temporal"), ce.getId() , makeScope(t1.getId(), t2.getId())); - LessThanEqualConstraint c1(LabelStr("precedes"), LabelStr("Temporal"), ce.getId() , makeScope(t3.getId(), t4.getId())); + LessThanEqualConstraint c0("precedes", "Temporal", ce.getId(), + makeScope(t1.getId(), t2.getId())); + LessThanEqualConstraint c1("precedes", "Temporal", ce.getId(), + makeScope(t3.getId(), t4.getId())); ce.propagate(); - Transaction trans1(t1.getId(), q1.getId(), false); - Transaction trans2(t2.getId(), q2.getId(), true); - Transaction trans3(t3.getId(), q3.getId(), true); - Transaction trans4(t4.getId(), q4.getId(), false); + Transaction trans1(t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2(t2.getId(), q2.getId(), true, EntityId::noId()); + Transaction trans3(t3.getId(), q3.getId(), true, EntityId::noId()); + Transaction trans4(t4.getId(), q4.getId(), false, EntityId::noId()); profile.addTransaction( trans1.getId() ); profile.addTransaction( trans2.getId() ); @@ -233,20 +301,20 @@ class FlowProfileTest * */ - Variable t1( ce.getId(), IntervalIntDomain( 0, 10), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain(10, 15), true, "t2" ); - Variable t3( ce.getId(), IntervalIntDomain( 5, 15), true, "t3" ); - Variable t4( ce.getId(), IntervalIntDomain( 5, 15), true, "t4" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain(10, 15), false, true, "t2" ); + Variable t3( ce.getId(), IntervalIntDomain( 5, 15), false, true, "t3" ); + Variable t4( ce.getId(), IntervalIntDomain( 5, 15), false, true, "t4" ); - Variable q1( ce.getId(), IntervalDomain(1, 1), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 1), true, "q2" ); - Variable q3( ce.getId(), IntervalDomain(1, 1), true, "q3" ); - Variable q4( ce.getId(), IntervalDomain(1, 1), true, "q4" ); + Variable q1( ce.getId(), IntervalDomain(1, 1), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 1), false, true, "q2" ); + Variable q3( ce.getId(), IntervalDomain(1, 1), false, true, "q3" ); + Variable q4( ce.getId(), IntervalDomain(1, 1), false, true, "q4" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); - Transaction trans3( t3.getId(), q3.getId(), true); - Transaction trans4( t4.getId(), q4.getId(), false); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); + Transaction trans3( t3.getId(), q3.getId(), true, EntityId::noId()); + Transaction trans4( t4.getId(), q4.getId(), false, EntityId::noId()); profile.addTransaction( trans1.getId() ); profile.addTransaction( trans2.getId() ); @@ -262,14 +330,14 @@ class FlowProfileTest static void executeScenario2( Profile& profile, ConstraintEngine& ce, int nrInstances, eint itimes[], edouble lowerLevels[], edouble upperLevels[] ) { - Variable t1( ce.getId(), IntervalIntDomain( 0, 10), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( 0, 10), true, "t2" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t2" ); - Variable q1( ce.getId(), IntervalDomain(1, 1), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 1), true, "q2" ); + Variable q1( ce.getId(), IntervalDomain(1, 1), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 1), false, true, "q2" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); profile.addTransaction( trans1.getId() ); profile.addTransaction( trans2.getId() ); @@ -282,17 +350,17 @@ class FlowProfileTest } static void executeScenario3( Profile& profile, ConstraintEngine& ce, int nrInstances, eint itimes[], edouble lowerLevels[], edouble upperLevels[] ) { - Variable t1( ce.getId(), IntervalIntDomain( 0, 10), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( 10, 10), true, "t2" ); - Variable t3( ce.getId(), IntervalIntDomain( 10, 20), true, "t3" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( 10, 10), false, true, "t2" ); + Variable t3( ce.getId(), IntervalIntDomain( 10, 20), false, true, "t3" ); - Variable q1( ce.getId(), IntervalDomain(1, 2), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 2), true, "q2" ); - Variable q3( ce.getId(), IntervalDomain(1, 2), true, "q3" ); + Variable q1( ce.getId(), IntervalDomain(1, 2), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 2), false, true, "q2" ); + Variable q3( ce.getId(), IntervalDomain(1, 2), false, true, "q3" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); - Transaction trans3( t3.getId(), q3.getId(), false ); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); + Transaction trans3( t3.getId(), q3.getId(), false , EntityId::noId()); profile.addTransaction( trans1.getId() ); profile.addTransaction( trans2.getId() ); @@ -306,17 +374,17 @@ class FlowProfileTest } static void executeScenario4( Profile& profile, ConstraintEngine& ce, int nrInstances, eint itimes[], edouble lowerLevels[], edouble upperLevels[] ) { - Variable t1( ce.getId(), IntervalIntDomain( 0, 5), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( 10, 15), true, "t2" ); - Variable t3( ce.getId(), IntervalIntDomain( 20, 25), true, "t3" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 5), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( 10, 15), false, true, "t2" ); + Variable t3( ce.getId(), IntervalIntDomain( 20, 25), false, true, "t3" ); - Variable q1( ce.getId(), IntervalDomain(1, 2), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 2), true, "q2" ); - Variable q3( ce.getId(), IntervalDomain(1, 2), true, "q3" ); + Variable q1( ce.getId(), IntervalDomain(1, 2), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 2), false, true, "q2" ); + Variable q3( ce.getId(), IntervalDomain(1, 2), false, true, "q3" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); - Transaction trans3( t3.getId(), q3.getId(), false ); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); + Transaction trans3( t3.getId(), q3.getId(), false , EntityId::noId()); profile.addTransaction( trans1.getId() ); profile.addTransaction( trans2.getId() ); @@ -331,17 +399,17 @@ class FlowProfileTest static void executeScenario5( Profile& profile, ConstraintEngine& ce, int nrInstances, eint itimes[], edouble lowerLevels[], edouble upperLevels[] ) { - Variable t1( ce.getId(), IntervalIntDomain( 0, 10), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( 0, 10), true, "t2" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t2" ); - Variable q1( ce.getId(), IntervalDomain(1, 1), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 1), true, "q2" ); + Variable q1( ce.getId(), IntervalDomain(1, 1), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 1), false, true, "q2" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); - EqualConstraint c0(LabelStr("concurrent"), LabelStr("Temporal"), ce.getId() , makeScope(t1.getId(), t2.getId())); + EqualConstraint c0("concurrent", "Temporal", ce.getId() , makeScope(t1.getId(), t2.getId())); ce.propagate(); @@ -377,20 +445,20 @@ class FlowProfileTest edouble lowerLevels[nrInstances] = {-4,-2}; edouble upperLevels[nrInstances] = {4,2}; - Variable t1( ce.getId(), IntervalIntDomain( 0, 100), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( 0, 100), true, "t2" ); - Variable t3( ce.getId(), IntervalIntDomain( 0, 100), true, "t3" ); - Variable t4( ce.getId(), IntervalIntDomain( 0, 100), true, "t4" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 100), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( 0, 100), false, true, "t2" ); + Variable t3( ce.getId(), IntervalIntDomain( 0, 100), false, true, "t3" ); + Variable t4( ce.getId(), IntervalIntDomain( 0, 100), false, true, "t4" ); - Variable q1( ce.getId(), IntervalDomain(1, 2), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 2), true, "q2" ); - Variable q3( ce.getId(), IntervalDomain(1, 2), true, "q3" ); - Variable q4( ce.getId(), IntervalDomain(1, 2), true, "q4" ); + Variable q1( ce.getId(), IntervalDomain(1, 2), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 2), false, true, "q2" ); + Variable q3( ce.getId(), IntervalDomain(1, 2), false, true, "q3" ); + Variable q4( ce.getId(), IntervalDomain(1, 2), false, true, "q4" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); - Transaction trans3( t3.getId(), q3.getId(), false); - Transaction trans4( t4.getId(), q4.getId(), true ); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); + Transaction trans3( t3.getId(), q3.getId(), false, EntityId::noId()); + Transaction trans4( t4.getId(), q4.getId(), true , EntityId::noId()); profile.addTransaction( trans1.getId() ); profile.addTransaction( trans2.getId() ); @@ -513,7 +581,8 @@ class FlowProfileTest */ debugMsg("ResourceTest"," Case 5"); - EqualConstraint c0(LabelStr("concurrent"), LabelStr("Temporal"), ce.getId() , makeScope( t3.getId(), t4.getId())); + EqualConstraint c0("concurrent", "Temporal", ce.getId() , + makeScope( t3.getId(), t4.getId())); ce.propagate(); @@ -533,16 +602,16 @@ class FlowProfileTest } static void executeScenario7( Profile& profile, ConstraintEngine& ce, int nrInstances, eint itimes[], edouble lowerLevels[], edouble upperLevels[] ) { - Variable t1( ce.getId(), IntervalIntDomain( 0, 10), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( 0, 10), true, "t2" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t2" ); - Variable q1( ce.getId(), IntervalDomain(2, 2), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 2), true, "q2" ); + Variable q1( ce.getId(), IntervalDomain(2, 2), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 2), false, true, "q2" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); - EqualConstraint c0(LabelStr("concurrent"), LabelStr("Temporal"), ce.getId() , makeScope(t1.getId(), t2.getId())); + EqualConstraint c0("concurrent", "Temporal", ce.getId() , makeScope(t1.getId(), t2.getId())); ce.propagate(); @@ -557,16 +626,16 @@ class FlowProfileTest } static void executeScenario8( Profile& profile, ConstraintEngine& ce, int nrInstances, eint itimes[], edouble lowerLevels[], edouble upperLevels[] ) { - Variable t1( ce.getId(), IntervalIntDomain( 0, 10), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( 0, 10), true, "t2" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t2" ); - Variable q1( ce.getId(), IntervalDomain(1, 2), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(2, 2), true, "q2" ); + Variable q1( ce.getId(), IntervalDomain(1, 2), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(2, 2), false, true, "q2" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); - EqualConstraint c0(LabelStr("concurrent"), LabelStr("Temporal"), ce.getId() , makeScope(t1.getId(), t2.getId())); + EqualConstraint c0("concurrent", "Temporal", ce.getId() , makeScope(t1.getId(), t2.getId())); ce.propagate(); @@ -582,20 +651,20 @@ class FlowProfileTest static void executeScenario9( Profile& profile, ConstraintEngine& ce, int nrInstances, eint itimes[], edouble lowerLevels[], edouble upperLevels[] ) { - Variable t1( ce.getId(), IntervalIntDomain( 1, 3), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain(10, 12), true, "t2" ); - Variable t3( ce.getId(), IntervalIntDomain( 9, 9), true, "t3" ); - Variable t4( ce.getId(), IntervalIntDomain( 11, 11), true, "t4" ); + Variable t1( ce.getId(), IntervalIntDomain( 1, 3), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain(10, 12), false, true, "t2" ); + Variable t3( ce.getId(), IntervalIntDomain( 9, 9), false, true, "t3" ); + Variable t4( ce.getId(), IntervalIntDomain( 11, 11), false, true, "t4" ); - Variable q1( ce.getId(), IntervalDomain(1, 1), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 1), true, "q2" ); - Variable q3( ce.getId(), IntervalDomain(1, 1), true, "q3" ); - Variable q4( ce.getId(), IntervalDomain(1, 1), true, "q4" ); + Variable q1( ce.getId(), IntervalDomain(1, 1), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 1), false, true, "q2" ); + Variable q3( ce.getId(), IntervalDomain(1, 1), false, true, "q3" ); + Variable q4( ce.getId(), IntervalDomain(1, 1), false, true, "q4" ); - Transaction trans1( t1.getId(), q1.getId(), true); - Transaction trans2( t2.getId(), q2.getId(), false ); - Transaction trans3( t3.getId(), q3.getId(), true); - Transaction trans4( t4.getId(), q4.getId(), false ); + Transaction trans1( t1.getId(), q1.getId(), true, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), false , EntityId::noId()); + Transaction trans3( t3.getId(), q3.getId(), true, EntityId::noId()); + Transaction trans4( t4.getId(), q4.getId(), false , EntityId::noId()); profile.addTransaction( trans1.getId() ); profile.addTransaction( trans2.getId() ); @@ -627,38 +696,38 @@ class FlowProfileTest * */ - Variable t1( ce.getId(), IntervalIntDomain(0,0), true, "t1" ); - Variable q1( ce.getId(), IntervalDomain(3, 3), true, "q1" ); - Transaction trans1( t1.getId(), q1.getId(), true); + Variable t1( ce.getId(), IntervalIntDomain(0,0), false, true, "t1" ); + Variable q1( ce.getId(), IntervalDomain(3, 3), false, true, "q1" ); + Transaction trans1( t1.getId(), q1.getId(), true, EntityId::noId()); - Variable t2( ce.getId(), IntervalIntDomain(10, 10), true, "t2" ); - Variable q2( ce.getId(), IntervalDomain(3, 3), true, "q2" ); - Transaction trans2( t2.getId(), q2.getId(), false ); + Variable t2( ce.getId(), IntervalIntDomain(10, 10), false, true, "t2" ); + Variable q2( ce.getId(), IntervalDomain(3, 3), false, true, "q2" ); + Transaction trans2( t2.getId(), q2.getId(), false , EntityId::noId()); - LessThanEqualConstraint c0(LabelStr("precedes"), LabelStr("Temporal"), ce.getId() , makeScope(t1.getId(), t2.getId())); + LessThanEqualConstraint c0("precedes", "Temporal", ce.getId() , makeScope(t1.getId(), t2.getId())); - Variable t3( ce.getId(), IntervalIntDomain(10, 10), true, "t3" ); - Variable q3( ce.getId(), IntervalDomain(2, 2), true, "q3" ); - Transaction trans3( t3.getId(), q3.getId(), true); + Variable t3( ce.getId(), IntervalIntDomain(10, 10), false, true, "t3" ); + Variable q3( ce.getId(), IntervalDomain(2, 2), false, true, "q3" ); + Transaction trans3( t3.getId(), q3.getId(), true, EntityId::noId()); - Variable t4( ce.getId(), IntervalIntDomain(100, 100), true, "t4" ); - Variable q4( ce.getId(), IntervalDomain(2, 2), true, "q4" ); - Transaction trans4( t4.getId(), q4.getId(), false ); + Variable t4( ce.getId(), IntervalIntDomain(100, 100), false, true, "t4" ); + Variable q4( ce.getId(), IntervalDomain(2, 2), false, true, "q4" ); + Transaction trans4( t4.getId(), q4.getId(), false , EntityId::noId()); - LessThanEqualConstraint c1(LabelStr("precedes"), LabelStr("Temporal"), ce.getId() , makeScope(t3.getId(), t4.getId())); + LessThanEqualConstraint c1("precedes", "Temporal", ce.getId() , makeScope(t3.getId(), t4.getId())); - Variable t5( ce.getId(), IntervalIntDomain(11, 100), true, "t5" ); - Variable q5( ce.getId(), IntervalDomain(3, 3), true, "q5" ); - Transaction trans5( t5.getId(), q5.getId(), true); + Variable t5( ce.getId(), IntervalIntDomain(11, 100), false, true, "t5" ); + Variable q5( ce.getId(), IntervalDomain(3, 3), false, true, "q5" ); + Transaction trans5( t5.getId(), q5.getId(), true, EntityId::noId()); - Variable t6( ce.getId(), IntervalIntDomain(12, 100), true, "t6" ); - Variable q6( ce.getId(), IntervalDomain(3, 3), true, "q6" ); - Transaction trans6( t6.getId(), q6.getId(), false ); + Variable t6( ce.getId(), IntervalIntDomain(12, 100), false, true, "t6" ); + Variable q6( ce.getId(), IntervalDomain(3, 3), false, true, "q6" ); + Transaction trans6( t6.getId(), q6.getId(), false , EntityId::noId()); - LessThanEqualConstraint c2(LabelStr("precedes"), LabelStr("Temporal"), ce.getId() , makeScope(t5.getId(), t6.getId())); + LessThanEqualConstraint c2("precedes", "Temporal", ce.getId() , makeScope(t5.getId(), t6.getId())); - LessThanEqualConstraint c3(LabelStr("precedes"), LabelStr("Temporal"), ce.getId() , makeScope(t2.getId(), t3.getId())); - LessThanEqualConstraint c4(LabelStr("precedes"), LabelStr("Temporal"), ce.getId() , makeScope(t2.getId(), t5.getId())); + LessThanEqualConstraint c3("precedes", "Temporal", ce.getId() , makeScope(t2.getId(), t3.getId())); + LessThanEqualConstraint c4("precedes", "Temporal", ce.getId() , makeScope(t2.getId(), t5.getId())); ce.propagate(); @@ -689,17 +758,21 @@ class FlowProfileTest * */ - Variable t1( ce.getId(), IntervalIntDomain( MINUS_INFINITY, PLUS_INFINITY ), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( MINUS_INFINITY, PLUS_INFINITY ), true, "t2" ); + Variable t1( ce.getId(), + IntervalIntDomain( MINUS_INFINITY, PLUS_INFINITY ), + false, true, "t1" ); + Variable t2( ce.getId(), + IntervalIntDomain( MINUS_INFINITY, PLUS_INFINITY ), + false, true, "t2" ); - Variable q1( ce.getId(), IntervalDomain(0, PLUS_INFINITY), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(0, PLUS_INFINITY), true, "q2" ); + Variable q1( ce.getId(), IntervalDomain(0, PLUS_INFINITY), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(0, PLUS_INFINITY), false, true, "q2" ); - Transaction trans1( t1.getId(), q1.getId(), true); - Transaction trans2( t2.getId(), q2.getId(), false ); + Transaction trans1( t1.getId(), q1.getId(), true, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), false , EntityId::noId()); - LessThanEqualConstraint c1(LabelStr("precedes"), LabelStr("Temporal"), ce.getId() , makeScope(t1.getId(), t2.getId())); + LessThanEqualConstraint c1("precedes", "Temporal", ce.getId() , makeScope(t1.getId(), t2.getId())); ce.propagate(); @@ -726,19 +799,19 @@ class FlowProfileTest * */ - Variable t1( ce.getId(), IntervalIntDomain( MINUS_INFINITY, PLUS_INFINITY ), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( MINUS_INFINITY, PLUS_INFINITY ), true, "t2" ); + Variable t1( ce.getId(), IntervalIntDomain( MINUS_INFINITY, PLUS_INFINITY ), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( MINUS_INFINITY, PLUS_INFINITY ), false, true, "t2" ); - Variable q1( ce.getId(), IntervalDomain(0, PLUS_INFINITY), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(0, PLUS_INFINITY), true, "q2" ); + Variable q1( ce.getId(), IntervalDomain(0, PLUS_INFINITY), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(0, PLUS_INFINITY), false, true, "q2" ); - Transaction trans1( t1.getId(), q1.getId(), true); - Transaction trans2( t2.getId(), q2.getId(), false ); + Transaction trans1( t1.getId(), q1.getId(), true, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), false , EntityId::noId()); - Variable distance( ce.getId(), IntervalIntDomain( 1, PLUS_INFINITY ), true, "distance" ); - AddEqualConstraint c1(LabelStr("temporalDistance"), LabelStr("Temporal"), ce.getId() , makeScope(t1.getId(), distance.getId(), t2.getId())); + Variable distance( ce.getId(), IntervalIntDomain( 1, PLUS_INFINITY ), false, true, "distance" ); + AddEqualConstraint c1("temporalDistance", "Temporal", ce.getId() , makeScope(t1.getId(), distance.getId(), t2.getId())); ce.propagate(); @@ -797,21 +870,21 @@ class FlowProfileTest * */ - Variable t1( ce.getId(), IntervalIntDomain( 0, 9 ), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain( 1,10 ), true, "t2" ); - Variable t3( ce.getId(), IntervalIntDomain( 0, 0 ), true, "t3" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 9 ), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain( 1,10 ), false, true, "t2" ); + Variable t3( ce.getId(), IntervalIntDomain( 0, 0 ), false, true, "t3" ); - Variable q1( ce.getId(), IntervalDomain(3, 3), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(3, 3), true, "q2" ); - Variable q3( ce.getId(), IntervalDomain(3, 3), true, "q3" ); + Variable q1( ce.getId(), IntervalDomain(3, 3), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(3, 3), false, true, "q2" ); + Variable q3( ce.getId(), IntervalDomain(3, 3), false, true, "q3" ); - Transaction trans1( t1.getId(), q1.getId(), true); - Transaction trans2( t2.getId(), q2.getId(), false ); - Transaction trans3( t3.getId(), q3.getId(), true ); + Transaction trans1( t1.getId(), q1.getId(), true, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), false , EntityId::noId()); + Transaction trans3( t3.getId(), q3.getId(), true , EntityId::noId()); - Variable distance( ce.getId(), IntervalIntDomain( 1, PLUS_INFINITY ), true, "distance" ); - AddEqualConstraint c1(LabelStr("temporalDistance"), LabelStr("Temporal"), ce.getId() , makeScope(t1.getId(), distance.getId(), t2.getId())); + Variable distance( ce.getId(), IntervalIntDomain( 1, PLUS_INFINITY ), false, true, "distance" ); + AddEqualConstraint c1("temporalDistance", "Temporal", ce.getId() , makeScope(t1.getId(), distance.getId(), t2.getId())); ce.propagate(); @@ -838,9 +911,9 @@ class FlowProfileTest debugMsg("ResourceTest"," Case 1"); - Variable t1( ce.getId(), IntervalIntDomain( 0, 10 ), true, "t1" ); - Variable q1( ce.getId(), IntervalDomain(3, 3), true, "q1" ); - Transaction trans1( t1.getId(), q1.getId(), true); + Variable t1( ce.getId(), IntervalIntDomain( 0, 10 ), false, true, "t1" ); + Variable q1( ce.getId(), IntervalDomain(3, 3), false, true, "q1" ); + Transaction trans1( t1.getId(), q1.getId(), true, EntityId::noId()); profile.addTransaction( trans1.getId() ); @@ -870,9 +943,9 @@ class FlowProfileTest */ debugMsg("ResourceTest"," Case 2"); - Variable t2( ce.getId(), IntervalIntDomain( 5, 15 ), true, "t2" ); - Variable q2( ce.getId(), IntervalDomain(3, 3), true, "q2" ); - Transaction trans2( t2.getId(), q2.getId(), true ); + Variable t2( ce.getId(), IntervalIntDomain( 5, 15 ), false, true, "t2" ); + Variable q2( ce.getId(), IntervalDomain(3, 3), false, true, "q2" ); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); profile.addTransaction( trans2.getId() ); @@ -905,9 +978,9 @@ class FlowProfileTest debugMsg("ResourceTest"," Case 3"); - Variable t3( ce.getId(), IntervalIntDomain( 20, 25 ), true, "t3" ); - Variable q3( ce.getId(), IntervalDomain(3, 3), true, "q3" ); - Transaction trans3( t3.getId(), q3.getId(), true ); + Variable t3( ce.getId(), IntervalIntDomain( 20, 25 ), false, true, "t3" ); + Variable q3( ce.getId(), IntervalDomain(3, 3), false, true, "q3" ); + Transaction trans3( t3.getId(), q3.getId(), true , EntityId::noId()); profile.addTransaction( trans3.getId() ); @@ -940,9 +1013,9 @@ class FlowProfileTest debugMsg("ResourceTest"," Case 4"); - Variable t4( ce.getId(), IntervalIntDomain(-10, 0 ), true, "t4" ); - Variable q4( ce.getId(), IntervalDomain(3, 3), true, "q4" ); - Transaction trans4( t4.getId(), q4.getId(), true ); + Variable t4( ce.getId(), IntervalIntDomain(-10, 0 ), false, true, "t4" ); + Variable q4( ce.getId(), IntervalDomain(3, 3), false, true, "q4" ); + Transaction trans4( t4.getId(), q4.getId(), true , EntityId::noId()); profile.addTransaction( trans4.getId() ); @@ -984,20 +1057,20 @@ class FlowProfileTest DummyDetector detector(ResourceId::noId()); Profile profile(db.getId(), detector.getId()); - Variable t1( ce.getId(), IntervalIntDomain( 0, 10), true, "t1" ); - Variable t2( ce.getId(), IntervalIntDomain(10, 15), true, "t2" ); - Variable t3( ce.getId(), IntervalIntDomain( 5, 15), true, "t3" ); - Variable t4( ce.getId(), IntervalIntDomain( 5, 15), true, "t4" ); + Variable t1( ce.getId(), IntervalIntDomain( 0, 10), false, true, "t1" ); + Variable t2( ce.getId(), IntervalIntDomain(10, 15), false, true, "t2" ); + Variable t3( ce.getId(), IntervalIntDomain( 5, 15), false, true, "t3" ); + Variable t4( ce.getId(), IntervalIntDomain( 5, 15), false, true, "t4" ); - Variable q1( ce.getId(), IntervalDomain(1, 2), true, "q1" ); - Variable q2( ce.getId(), IntervalDomain(1, 1), true, "q2" ); - Variable q3( ce.getId(), IntervalDomain(1, 1), true, "q3" ); - Variable q4( ce.getId(), IntervalDomain(1, 1), true, "q4" ); + Variable q1( ce.getId(), IntervalDomain(1, 2), false, true, "q1" ); + Variable q2( ce.getId(), IntervalDomain(1, 1), false, true, "q2" ); + Variable q3( ce.getId(), IntervalDomain(1, 1), false, true, "q3" ); + Variable q4( ce.getId(), IntervalDomain(1, 1), false, true, "q4" ); - Transaction trans1( t1.getId(), q1.getId(), false); - Transaction trans2( t2.getId(), q2.getId(), true ); - Transaction trans3( t3.getId(), q3.getId(), true); - Transaction trans4( t4.getId(), q4.getId(), false); + Transaction trans1( t1.getId(), q1.getId(), false, EntityId::noId()); + Transaction trans2( t2.getId(), q2.getId(), true , EntityId::noId()); + Transaction trans3( t3.getId(), q3.getId(), true, EntityId::noId()); + Transaction trans4( t4.getId(), q4.getId(), false, EntityId::noId()); profile.addTransaction( trans1.getId() ); profile.addTransaction( trans2.getId() ); @@ -1442,27 +1515,32 @@ class FVDetectorTest { static bool testReusableDetector() { RESOURCE_DEFAULT_SETUP(ce, db, false); - Reusable res(db.getId(), LabelStr("Reusable"), LabelStr("res1"), LabelStr("ClosedWorldFVDetector"), LabelStr("IncrementalFlowProfile"), - 1, 1, 0); + Reusable res(db.getId(), "Reusable", "res1", + "ClosedWorldFVDetector", "IncrementalFlowProfile", + 1, 1, 0); //create a token that violates the limit (i.e. consumes 2) - ReusableToken tok1(db.getId(), LabelStr("Reusable.uses"), IntervalIntDomain(1), IntervalIntDomain(10), - IntervalIntDomain(9), IntervalDomain(2)); + ReusableToken tok1(db.getId(), "Reusable.uses", + IntervalIntDomain(1), IntervalIntDomain(10), + IntervalIntDomain(9), IntervalDomain(2)); CPPUNIT_ASSERT(!ce.propagate()); tok1.discard(false); //create a token that doesn't - ReusableToken tok2(db.getId(), LabelStr("Reusable.uses"), IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), IntervalIntDomain(9), + ReusableToken tok2(db.getId(), "Reusable.uses", + IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), + IntervalIntDomain(9), IntervalDomain(1)); CPPUNIT_ASSERT(ce.propagate()); - //create a token that doesn't, but must start during the previous token, causing a violation - ReusableToken tok3(db.getId(), LabelStr("Reusable.uses"), IntervalIntDomain(9), IntervalIntDomain(11), IntervalIntDomain(2), + //create a token that doesn't, but must start during the previous token, causing a violation + ReusableToken tok3(db.getId(), "Reusable.uses", IntervalIntDomain(9), + IntervalIntDomain(11), IntervalIntDomain(2), IntervalDomain(1)); CPPUNIT_ASSERT(!ce.propagate()); tok3.discard(false); CPPUNIT_ASSERT(ce.propagate()); //create a token that doesn't, and may start afterwards, creating a flaw - ReusableToken tok4(db.getId(), LabelStr("Reusable.uses"), IntervalIntDomain(10, 13), IntervalIntDomain(15, 18), IntervalIntDomain(5), + ReusableToken tok4(db.getId(), "Reusable.uses", IntervalIntDomain(10, 13), IntervalIntDomain(15, 18), IntervalIntDomain(5), IntervalDomain(1)); CPPUNIT_ASSERT(ce.propagate()); CPPUNIT_ASSERT(db.hasOrderingChoice(tok4.getId())); diff --git a/src/PLASMA/Resource/test/rs-flow-test-module.hh b/src/PLASMA/Resource/test/rs-flow-test-module.hh index 029dc38e1..232804b53 100644 --- a/src/PLASMA/Resource/test/rs-flow-test-module.hh +++ b/src/PLASMA/Resource/test/rs-flow-test-module.hh @@ -7,9 +7,9 @@ class FlowProfileModuleTests : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(FlowProfileModuleTests); - CPPUNIT_TEST(defaultSetupTests); + // CPPUNIT_TEST(defaultSetupTests); CPPUNIT_TEST(flowProfileTests); - CPPUNIT_TEST(FVDetectorTests); + // CPPUNIT_TEST(FVDetectorTests); CPPUNIT_TEST_SUITE_END(); public: diff --git a/src/PLASMA/Resource/test/rs-test-module.cc b/src/PLASMA/Resource/test/rs-test-module.cc index 16bd05781..d1349c3ac 100644 --- a/src/PLASMA/Resource/test/rs-test-module.cc +++ b/src/PLASMA/Resource/test/rs-test-module.cc @@ -26,6 +26,7 @@ #include "Debug.hh" #include "ThreatDecisionPoint.hh" +#include "Context.hh" #include "Profile.hh" #include "FlowProfile.hh" #include "IncrementalFlowProfile.hh" @@ -37,6 +38,8 @@ #include "ResourceThreatManager.hh" #include "ProfilePropagator.hh" #include "ResourceMatching.hh" +#include "tinyxml.h" +#include "TestUtils.hh" #include "Engine.hh" #include "ModuleConstraintEngine.hh" @@ -51,6 +54,9 @@ #include #include +#include +#include + using namespace EUROPA; class ResourceTestEngine : public EngineBase @@ -67,7 +73,7 @@ ResourceTestEngine::ResourceTestEngine() { createModules(); doStart(); - Schema* schema = (Schema*)getComponent("Schema"); + Schema* schema = boost::polymorphic_cast(getComponent("Schema")); schema->addObjectType("Resource"); } @@ -97,10 +103,12 @@ const double productionMax = 40; const double consumptionRateMax = -8; const double consumptionMax = -50; +#include + #define RESOURCE_DEFAULT_SETUP(ce, db, autoClose) \ ResourceTestEngine rte; \ - ConstraintEngine& ce = *((ConstraintEngine*)rte.getComponent("ConstraintEngine")); \ - PlanDatabase& db = *((PlanDatabase*)rte.getComponent("PlanDatabase")); \ + ConstraintEngine& ce = *boost::polymorphic_cast(rte.getComponent("ConstraintEngine")); \ + PlanDatabase& db = *boost::polymorphic_cast(rte.getComponent("PlanDatabase")); \ if (autoClose) \ db.close(); @@ -134,7 +142,7 @@ class DummyProfile : public Profile { InstantId getInstant(const int time) { return getGreatestInstant(time)->second; } - void getTransactionsToOrder(const InstantId& inst, std::vector& results) { + void getTransactionsToOrder(const InstantId inst, std::vector& results) { check_error(inst.isValid()); check_error(results.empty()); results.insert(results.end(), inst->getTransactions().begin(), inst->getTransactions().end()); @@ -142,19 +150,19 @@ class DummyProfile : public Profile { int gotNotified(){return m_receivedNotification;} void resetNotified(){m_receivedNotification = 0;} private: - void handleTemporalConstraintAdded(const TransactionId predecessor, int preArgIndex, - const TransactionId successor, int sucArgIndex) { + void handleTemporalConstraintAdded(const TransactionId predecessor, unsigned int preArgIndex, + const TransactionId successor, unsigned int sucArgIndex) { Profile::handleTemporalConstraintAdded(predecessor, preArgIndex, successor, sucArgIndex); m_receivedNotification++; } - void handleTemporalConstraintRemoved(const TransactionId predecessor, int preArgIndex, - const TransactionId successor, int sucArgIndex) { + void handleTemporalConstraintRemoved(const TransactionId predecessor, unsigned int preArgIndex, + const TransactionId successor, unsigned int sucArgIndex) { Profile::handleTemporalConstraintRemoved(predecessor, preArgIndex, successor, sucArgIndex); m_receivedNotification++; } - void initRecompute(InstantId inst){} + void initRecompute(InstantId ){} void initRecompute(){} - void recomputeLevels(InstantId prev, InstantId inst) { + void recomputeLevels(InstantId, InstantId) { } int m_receivedNotification; }; @@ -162,22 +170,21 @@ class DummyProfile : public Profile { class DummyDetector : public FVDetector { public: DummyDetector(const ResourceId res) : FVDetector(res) {}; - bool detect(const InstantId inst) {return false;} - void initialize(const InstantId inst) {} + bool detect(const InstantId ) {return false;} + void initialize(const InstantId ) {} void initialize() {} virtual PSResourceProfile* getFDLevelProfile() { return NULL; } virtual PSResourceProfile* getVDLevelProfile() { return NULL; } }; - class DummyResource : public Resource { public: - DummyResource(const PlanDatabaseId& planDatabase, const LabelStr& type, const LabelStr& name, + DummyResource(const PlanDatabaseId planDatabase, const std::string& type, const std::string& name, edouble initCapacityLb = 0, edouble initCapacityUb = 0, edouble lowerLimit = MINUS_INFINITY, edouble upperLimit = PLUS_INFINITY, edouble maxInstProduction = PLUS_INFINITY, edouble maxInstConsumption = PLUS_INFINITY, edouble maxProduction = PLUS_INFINITY, edouble maxConsumption = PLUS_INFINITY) - : Resource(planDatabase, type, name, LabelStr("OpenWorldFVDetector"), LabelStr("TimetableProfile"), initCapacityLb, initCapacityUb, + : Resource(planDatabase, type, name, "OpenWorldFVDetector", "TimetableProfile", initCapacityLb, initCapacityUb, lowerLimit, upperLimit, maxInstProduction, maxInstConsumption, maxProduction, maxConsumption) {} @@ -189,23 +196,43 @@ class DummyResource : public Resource { m_profile->removeTransaction(trans); // m_profile->recompute(); } - void addToProfile(const TokenId& token) {} - void removeFromProfile(const TokenId& token) {} - void createTransactions(const TokenId& token) {} - void removeTransactions(const TokenId& token) {} + void addToProfile(const TokenId ) {} + void removeFromProfile(const TokenId) {} + void createTransactions(const TokenId) {} + void removeTransactions(const TokenId ) {} private: - void notifyViolated(const InstantId inst) { + void notifyViolated(const InstantId inst, ProblemType ) { TransactionId trans = *(inst->getTransactions().begin()); const_cast(trans->time()->lastDomain()).empty(); } //no implementation. no tests for flaw detection - void notifyFlawed(const InstantId inst) { + void notifyFlawed(const InstantId ) { } - void notifyDeleted(const InstantId inst) {} - void notifyNoLongerFlawed(const InstantId inst){} + void notifyDeleted(const InstantId ) {} + void notifyNoLongerFlawed(const InstantId ){} +}; + +class BareTransactionDeleter { + public: + BareTransactionDeleter(Profile& profile) : m_profile(&profile), m_res(NULL) {} + BareTransactionDeleter(DummyResource& res) : m_profile(NULL), m_res(&res) {} + void operator()(Transaction* t) { + if(m_profile != NULL) { + m_profile->removeTransaction(t->getId()); + } + if(m_res != NULL) { + m_res->removeTransaction(t->getId()); + } + delete t; + } + private: + Profile* m_profile; + DummyResource* m_res; }; + +typedef boost::shared_ptr TransactionPtr; /** add tests for getClosedTransactions and getPendingTransactions! */ @@ -246,7 +273,7 @@ class ProfileTest { ++it; ++retval; } - CPPUNIT_ASSERT((unsigned) retval == times.size()); + CPPUNIT_ASSERT(static_cast(retval) == times.size()); return true; } @@ -293,6 +320,7 @@ class ProfileTest { RESOURCE_DEFAULT_SETUP(ce, db, true); DummyDetector detector(ResourceId::noId()); DummyProfile profile(db.getId(), detector.getId()); + BareTransactionDeleter deleter(profile); Variable t1(ce.getId(), IntervalIntDomain(0, 0)); Variable t2(ce.getId(), IntervalIntDomain(10, 10)); @@ -303,23 +331,23 @@ class ProfileTest { std::set times; - Transaction trans1(t1.getId(), quantity.getId(), false); - Transaction trans2(t2.getId(), quantity.getId(), false); //distinct cases - Transaction trans3(t3.getId(), quantity.getId(), false); //overlap on left side. both trans1 and trans2 should appear at time 0 - Transaction trans4(t4.getId(), quantity.getId(), false); //overlap in the middle. should have trans3 and trans4 at time 1 and only trans4 at time 4 - Transaction trans5(t5.getId(), quantity.getId(), false); //overlap on right side. both trans 4 and trans5 should appear at time 4 + TransactionPtr trans1(new Transaction(t1.getId(), quantity.getId(), false, EntityId::noId()), deleter); + TransactionPtr trans2(new Transaction(t2.getId(), quantity.getId(), false, EntityId::noId()), deleter); //distinct cases + TransactionPtr trans3(new Transaction(t3.getId(), quantity.getId(), false, EntityId::noId()), deleter); //overlap on left side. both trans1 and trans2 should appear at time 0 + TransactionPtr trans4(new Transaction(t4.getId(), quantity.getId(), false, EntityId::noId()), deleter); //overlap in the middle. should have trans3 and trans4 at time 1 and only trans4 at time 4 + TransactionPtr trans5(new Transaction(t5.getId(), quantity.getId(), false, EntityId::noId()), deleter); //overlap on right side. both trans 4 and trans5 should appear at time 4 - profile.addTransaction(trans1.getId()); + profile.addTransaction(trans1->getId()); times.insert(0); ProfileIterator prof1(profile.getId()); CPPUNIT_ASSERT(checkTimes(times, prof1)); - profile.addTransaction(trans2.getId()); + profile.addTransaction(trans2->getId()); times.insert(10); ProfileIterator prof2(profile.getId()); CPPUNIT_ASSERT(checkTimes(times, prof2)); - profile.addTransaction(trans3.getId()); + profile.addTransaction(trans3->getId()); times.insert(3); ProfileIterator prof3(profile.getId()); CPPUNIT_ASSERT(checkTimes(times, prof3)); @@ -327,7 +355,7 @@ class ProfileTest { CPPUNIT_ASSERT(!oCheck1.done()); CPPUNIT_ASSERT(oCheck1.getInstant()->getTransactions().size() == 2); - profile.addTransaction(trans4.getId()); + profile.addTransaction(trans4->getId()); times.insert(1); times.insert(4); ProfileIterator prof4(profile.getId()); @@ -336,7 +364,7 @@ class ProfileTest { CPPUNIT_ASSERT(!oCheck2.done()); CPPUNIT_ASSERT(oCheck2.getInstant()->getTransactions().size() == 2); - profile.addTransaction(trans5.getId()); + profile.addTransaction(trans5->getId()); times.insert(6); ProfileIterator prof5(profile.getId()); CPPUNIT_ASSERT(checkTimes(times, prof5)); @@ -344,7 +372,7 @@ class ProfileTest { CPPUNIT_ASSERT(!oCheck3.done()); CPPUNIT_ASSERT(oCheck3.getInstant()->getTransactions().size() == 2); - profile.removeTransaction(trans4.getId()); + profile.removeTransaction(trans4->getId()); times.erase(1); ProfileIterator prof6(profile.getId()); CPPUNIT_ASSERT(checkTimes(times, prof6)); @@ -353,16 +381,16 @@ class ProfileTest { ProfileIterator oCheck5(profile.getId(), 4, 4); CPPUNIT_ASSERT(oCheck5.getInstant()->getTransactions().size() == 1); - profile.removeTransaction(trans1.getId()); - profile.removeTransaction(trans2.getId()); + profile.removeTransaction(trans1->getId()); + profile.removeTransaction(trans2->getId()); times.erase(10); ProfileIterator prof7(profile.getId()); CPPUNIT_ASSERT(checkTimes(times, prof7)); ProfileIterator oCheck6(profile.getId(), 0, 0); CPPUNIT_ASSERT(oCheck6.getInstant()->getTransactions().size() == 1); - profile.removeTransaction(trans3.getId()); - profile.removeTransaction(trans5.getId()); + profile.removeTransaction(trans3->getId()); + profile.removeTransaction(trans5->getId()); ProfileIterator prof8(profile.getId()); CPPUNIT_ASSERT(prof8.done()); @@ -374,6 +402,7 @@ class ProfileTest { RESOURCE_DEFAULT_SETUP(ce, db, true); DummyDetector detector(ResourceId::noId()); DummyProfile profile(db.getId(), detector.getId()); + BareTransactionDeleter deleter(profile); Variable t1(ce.getId(), IntervalIntDomain(0, 0)); Variable t2(ce.getId(), IntervalIntDomain(10, 10)); @@ -387,17 +416,17 @@ class ProfileTest { times.insert(3); times.insert(4); times.insert(6); times.insert(10); - Transaction trans1(t1.getId(), quantity.getId(), false); - Transaction trans2(t2.getId(), quantity.getId(), false); - Transaction trans3(t3.getId(), quantity.getId(), false); - Transaction trans4(t4.getId(), quantity.getId(), false); - Transaction trans5(t5.getId(), quantity.getId(), false); + TransactionPtr trans1(new Transaction(t1.getId(), quantity.getId(), false, EntityId::noId()), deleter); + TransactionPtr trans2(new Transaction(t2.getId(), quantity.getId(), false, EntityId::noId()), deleter); + TransactionPtr trans3(new Transaction(t3.getId(), quantity.getId(), false, EntityId::noId()), deleter); + TransactionPtr trans4(new Transaction(t4.getId(), quantity.getId(), false, EntityId::noId()), deleter); + TransactionPtr trans5(new Transaction(t5.getId(), quantity.getId(), false, EntityId::noId()), deleter); - profile.addTransaction(trans1.getId()); - profile.addTransaction(trans2.getId()); - profile.addTransaction(trans3.getId()); - profile.addTransaction(trans4.getId()); - profile.addTransaction(trans5.getId()); + profile.addTransaction(trans1->getId()); + profile.addTransaction(trans2->getId()); + profile.addTransaction(trans3->getId()); + profile.addTransaction(trans4->getId()); + profile.addTransaction(trans5->getId()); ProfileIterator baseTest(profile.getId()); CPPUNIT_ASSERT(checkTimes(times, baseTest)); @@ -409,9 +438,10 @@ class ProfileTest { ProfileIterator prof1(profile.getId()); CPPUNIT_ASSERT(checkTimes(times, prof1)); ProfileIterator oCheck1(profile.getId(), 2, 2); - CPPUNIT_ASSERT(oCheck1.getInstant()->getTransactions().size() == 2); - CPPUNIT_ASSERT(oCheck1.getInstant()->getTransactions().find(trans3.getId()) != oCheck1.getInstant()->getTransactions().end()); - CPPUNIT_ASSERT(oCheck1.getInstant()->getTransactions().find(trans4.getId()) != oCheck1.getInstant()->getTransactions().end()); + const InstantId inst(oCheck1.getInstant()); + CPPUNIT_ASSERT(inst->getTransactions().size() == 2); + CPPUNIT_ASSERT(inst->getTransactions().find(trans3->getId()) != inst->getTransactions().end()); + CPPUNIT_ASSERT(inst->getTransactions().find(trans4->getId()) != inst->getTransactions().end()); ProfileIterator oCheck1_1(profile.getId(), 3, 3); CPPUNIT_ASSERT(oCheck1_1.done()); @@ -449,44 +479,45 @@ class ProfileTest { DummyDetector detector(ResourceId::noId()); TimetableProfile r(db.getId(), detector.getId()); + BareTransactionDeleter deleter(r); // Variable t0(ce.getId(), IntervalIntDomain(MINUS_INFINITY, MINUS_INFINITY)); // Variable q0(ce.getId(), IntervalDomain(0, 0)); -// Transaction trans0(t0.getId(), q0.getId(), false); -// r.addTransaction(trans0.getId()); +// TransactionPtr trans0(new Transaction(t0.getId(), q0.getId(), false, EntityId::noId()), deleter); +// r.addTransaction(trans0->getId()); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 0); Variable t1(ce.getId(), IntervalIntDomain(0, HORIZON_END)); Variable q1(ce.getId(), IntervalDomain(45, 45)); - Transaction trans1(t1.getId(), q1.getId(), false); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); CPPUNIT_ASSERT(ce.propagate()); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*1)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 1000 * 45); Variable t2(ce.getId(), IntervalIntDomain(1, HORIZON_END)); Variable q2(ce.getId(), IntervalDomain(35, 35)); - Transaction trans2(t2.getId(), q2.getId(), false); - r.addTransaction(trans2.getId()); + TransactionPtr trans2(new Transaction(t2.getId(), q2.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans2->getId()); CPPUNIT_ASSERT(ce.propagate()); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*2)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1*45 + 80*999)); Variable t3(ce.getId(), IntervalIntDomain(2, HORIZON_END)); Variable q3(ce.getId(), IntervalDomain(20, 20)); - Transaction trans3(t3.getId(), q3.getId(), false); - r.addTransaction(trans3.getId()); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans3->getId()); CPPUNIT_ASSERT(ce.propagate()); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*3 + 4*3)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1*45 + 1*80 + 998*100)); - trans2.time()->restrictBaseDomain(IntervalIntDomain(1, trans2.time()->lastDomain().getUpperBound())); + trans2->time()->restrictBaseDomain(IntervalIntDomain(1, trans2->time()->lastDomain().getUpperBound())); CPPUNIT_ASSERT(ce.propagate()); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*3 + 4*3)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1*45 + 1*80 + 998*100)); - trans2.time()->restrictBaseDomain(IntervalIntDomain(2, trans2.time()->lastDomain().getUpperBound())); + trans2->time()->restrictBaseDomain(IntervalIntDomain(2, trans2->time()->lastDomain().getUpperBound())); CPPUNIT_ASSERT(ce.propagate()); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*3 + 3*3)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (2*45 + 998*100)); @@ -502,68 +533,69 @@ class ProfileTest { DummyDetector detector(ResourceId::noId()); TimetableProfile r(db.getId(), detector.getId()); + BareTransactionDeleter deleter(r); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == 0); Variable t1(ce.getId(), IntervalIntDomain(4, 6)); Variable q1(ce.getId(), IntervalDomain(0, PLUS_INFINITY)); - Transaction trans1(t1.getId(), q1.getId(), false); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*1)); Variable t2(ce.getId(), IntervalIntDomain(-4, 10)); Variable q2(ce.getId(), IntervalDomain(0, PLUS_INFINITY)); - Transaction trans2(t2.getId(), q2.getId(), false); - r.addTransaction(trans2.getId()); + TransactionPtr trans2(new Transaction(t2.getId(), q2.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans2->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*2 + 3*2 + 4*1)); Variable t3(ce.getId(), IntervalIntDomain(1, 3)); Variable q3(ce.getId(), IntervalDomain(0, PLUS_INFINITY)); - Transaction trans3(t3.getId(), q3.getId(), false); - r.addTransaction(trans3.getId()); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans3->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*2 +3*2 + 4*2 + 5*2 + 6*1)); Variable t4(ce.getId(), IntervalIntDomain(1, 2)); Variable q4(ce.getId(), IntervalDomain(0, PLUS_INFINITY)); - Transaction trans4(t4.getId(), q4.getId(), false); - r.addTransaction(trans4.getId()); + TransactionPtr trans4(new Transaction(t4.getId(), q4.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans4->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*3 + 3*3 + 4*2 + 5*2 + 6*2 + 7*1)); Variable t5(ce.getId(), IntervalIntDomain(3, 7)); Variable q5(ce.getId(), IntervalDomain(0, PLUS_INFINITY)); - Transaction trans5(t5.getId(), q5.getId(), false); - r.addTransaction(trans5.getId()); + TransactionPtr trans5(new Transaction(t5.getId(), q5.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans5->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*3 + 3*3 + 4*3 + 5*3 + 6*3 + 7*2 + 8*1)); Variable t6(ce.getId(), IntervalIntDomain(4, 7)); Variable q6(ce.getId(), IntervalDomain(0, PLUS_INFINITY)); - Transaction trans6(t6.getId(), q6.getId(), false); - r.addTransaction(trans6.getId()); + TransactionPtr trans6(new Transaction(t6.getId(), q6.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans6->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*3 + 3*3 + 4*3 + 5*4 + 6*4 + 7*3 + 8*1)); // Insert for a singleton value Variable t7(ce.getId(), IntervalIntDomain(5, 5)); Variable q7(ce.getId(), IntervalDomain(0, PLUS_INFINITY)); - Transaction trans7(t7.getId(), q7.getId(), false); - r.addTransaction(trans7.getId()); + TransactionPtr trans7(new Transaction(t7.getId(), q7.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans7->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*3 + 3*3 + 4*3 + 5*4 + 6*5 + 7*4 + 8*3 + 9*1)); // Now free them and check the retractions are working correctly - r.removeTransaction(trans7.getId()); + r.removeTransaction(trans7->getId()); CPPUNIT_ASSERT(ce.propagate()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*3 + 3*3 + 4*3 + 5*4 + 6*4 + 7*3 + 8*1)); - r.removeTransaction(trans6.getId()); + r.removeTransaction(trans6->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*3 + 3*3 + 4*3 + 5*3 + 6*3 + 7*2 + 8*1)); - r.removeTransaction(trans5.getId()); + r.removeTransaction(trans5->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*3 + 3*3 + 4*2 + 5*2 + 6*2 + 7*1)); - r.removeTransaction(trans4.getId()); + r.removeTransaction(trans4->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*2 +3*2 + 4*2 + 5*2 + 6*1)); - r.removeTransaction(trans3.getId()); + r.removeTransaction(trans3->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*2 + 3*2 + 4*1)); - r.removeTransaction(trans2.getId()); + r.removeTransaction(trans2->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == (1*1 + 2*1)); - r.removeTransaction(trans1.getId()); + r.removeTransaction(trans1->getId()); CPPUNIT_ASSERT(ce.propagate() && checkSum(r.getId()) == 0); RESOURCE_DEFAULT_TEARDOWN(); @@ -576,59 +608,60 @@ class ProfileTest { DummyDetector detector(ResourceId::noId()); TimetableProfile r(db.getId(), detector.getId()); + BareTransactionDeleter deleter(r); Variable t1(ce.getId(), IntervalIntDomain(0, 1)); Variable q1(ce.getId(), IntervalDomain(1, 1)); - Transaction trans1(t1.getId(), q1.getId(), false); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); ce.propagate(); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*1)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 1); Variable t2(ce.getId(), IntervalIntDomain(1, 3)); Variable q2(ce.getId(), IntervalDomain(4, 4)); - Transaction trans2(t2.getId(), q2.getId(), true); - r.addTransaction(trans2.getId()); + TransactionPtr trans2(new Transaction(t2.getId(), q2.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans2->getId()); ce.propagate(); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*1)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1 + 4*2)); Variable t3(ce.getId(), IntervalIntDomain(2, 4)); Variable q3(ce.getId(), IntervalDomain(8, 8)); - Transaction trans3(t3.getId(), q3.getId(), false); - r.addTransaction(trans3.getId()); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans3->getId()); ce.propagate(); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*2 + 4*2 + 5*1)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1*1 + 4*1 + 12*1 + 8*1)); Variable t4(ce.getId(), IntervalIntDomain(3, 6)); Variable q4(ce.getId(), IntervalDomain(2, 2)); - Transaction trans4(t4.getId(), q4.getId(), false); - r.addTransaction(trans4.getId()); + TransactionPtr trans4(new Transaction(t4.getId(), q4.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans4->getId()); ce.propagate(); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*2 + 4*3 + 5*2 + 6*1)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1*1 + 4*1 + 12*1 + 10*1 + 2*2)); Variable t5(ce.getId(), IntervalIntDomain(2, 10)); Variable q5(ce.getId(), IntervalDomain(6, 6)); - Transaction trans5(t5.getId(), q5.getId(), true); - r.addTransaction(trans5.getId()); + TransactionPtr trans5(new Transaction(t5.getId(), q5.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans5->getId()); ce.propagate(); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*3 + 4*4 + 5*3 + 6*2 + 7*1)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1*1 + 4*1 + 18*1 + 16*1 + 8*2 + 6*4)); Variable t6(ce.getId(), IntervalIntDomain(6, 8)); Variable q6(ce.getId(), IntervalDomain(3, 3)); - Transaction trans6(t6.getId(), q6.getId(), false); - r.addTransaction(trans6.getId()); + TransactionPtr trans6(new Transaction(t6.getId(), q6.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans6->getId()); ce.propagate(); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*3 + 4*4 + 5*3 + 6*3 + 7*2 + 8*1)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1*1 + 4*1 + 18*1 + 16*1 + 8*2 + 9*2 + 6*2)); Variable t7(ce.getId(), IntervalIntDomain(7, 8)); Variable q7(ce.getId(), IntervalDomain(4, 4)); - Transaction trans7(t7.getId(), q7.getId(), true); - r.addTransaction(trans7.getId()); + TransactionPtr trans7(new Transaction(t7.getId(), q7.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans7->getId()); ce.propagate(); CPPUNIT_ASSERT(checkSum(r.getId()) == (1*1 + 2*2 + 3*3 + 4*4 + 5*3 + 6*3 + +7* 3 + 8*3 + 9*1)); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == (1*1 + 4*1 + 18*1 + 16*1 + 8*2 + 9*1 + 13*1 + 6*2)); @@ -643,21 +676,22 @@ class ProfileTest { DummyDetector detector(ResourceId::noId()); TimetableProfile r(db.getId(), detector.getId()); + BareTransactionDeleter deleter(r); Variable t1(ce.getId(), IntervalIntDomain(0, 10)); Variable q1(ce.getId(), IntervalDomain(10, 10)); - Transaction trans1(t1.getId(), q1.getId(), false); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); ce.propagate(); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 10*10); - trans1.time()->restrictBaseDomain(IntervalIntDomain(1, trans1.time()->lastDomain().getUpperBound())); + trans1->time()->restrictBaseDomain(IntervalIntDomain(1, trans1->time()->lastDomain().getUpperBound())); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 10*9); - trans1.time()->restrictBaseDomain(IntervalIntDomain(trans1.time()->lastDomain().getLowerBound(), eint(8))); + trans1->time()->restrictBaseDomain(IntervalIntDomain(trans1->time()->lastDomain().getLowerBound(), eint(8))); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 10*7); - trans1.time()->restrictBaseDomain(IntervalIntDomain(trans1.time()->lastDomain().getLowerBound(), eint(6))); + trans1->time()->restrictBaseDomain(IntervalIntDomain(trans1->time()->lastDomain().getLowerBound(), eint(6))); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 10*5); RESOURCE_DEFAULT_TEARDOWN(); @@ -670,21 +704,21 @@ class ProfileTest { DummyDetector detector(ResourceId::noId()); TimetableProfile r(db.getId(), detector.getId()); - + BareTransactionDeleter deleter(r); // Test producer Variable t1(ce.getId(), IntervalIntDomain(0, 10)); Variable q1(ce.getId(), IntervalDomain(5, 10)); - Transaction trans1(t1.getId(), q1.getId(), false); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); ce.propagate(); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 10*10); // Test consumer Variable t3(ce.getId(), IntervalIntDomain(1, 5)); Variable q3(ce.getId(), IntervalDomain(1, 4)); - Transaction trans3(t3.getId(), q3.getId(), true); - r.addTransaction(trans3.getId()); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans3->getId()); ce.propagate(); CPPUNIT_ASSERT(checkLevelArea(r.getId()) == 10*1 + 14*4 + 13*5);//+ 14*3 + 21*1 + 20*3 + 20*2); @@ -696,60 +730,61 @@ class ProfileTest { { RESOURCE_DEFAULT_SETUP(ce,db,false); - DummyResource r(db.getId(), LabelStr("Resource"), LabelStr("r1"), initialCapacity, initialCapacity, limitMin, limitMax, + DummyResource r(db.getId(), "Resource", "r1", initialCapacity, initialCapacity, limitMin, limitMax, productionRateMax, -(consumptionRateMax), productionMax, -(consumptionMax)); + BareTransactionDeleter deleter(r); db.close(); Variable t1(ce.getId(), IntervalIntDomain(0, 1)); Variable q1(ce.getId(), IntervalDomain(productionRateMax, productionRateMax + 1)); - Transaction trans1(t1.getId(), q1.getId(), false); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); ce.propagate(); Variable t3(ce.getId(), IntervalIntDomain(0, 1)); Variable q3(ce.getId(), IntervalDomain(1, 1)); - Transaction trans3(t3.getId(), q3.getId(), false); - r.addTransaction(trans3.getId()); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans3->getId()); // no violation because of temporal flexibility CPPUNIT_ASSERT(ce.propagate()); - trans1.time()->restrictBaseDomain(IntervalIntDomain(1, trans1.time()->lastDomain().getUpperBound())); - trans3.time()->restrictBaseDomain(IntervalIntDomain(1, trans3.time()->lastDomain().getUpperBound())); + trans1->time()->restrictBaseDomain(IntervalIntDomain(1, trans1->time()->lastDomain().getUpperBound())); + trans3->time()->restrictBaseDomain(IntervalIntDomain(1, trans3->time()->lastDomain().getUpperBound())); CPPUNIT_ASSERT(!ce.propagate()); //r->getResourceViolations(violations); //CPPUNIT_ASSERT(violations.size() == 1); //CPPUNIT_ASSERT(violations.front()->getType() == ResourceViolation::ProductionRateExceeded); - r.removeTransaction(trans3.getId()); - r.removeTransaction(trans1.getId()); + r.removeTransaction(trans3->getId()); + r.removeTransaction(trans1->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t2(ce.getId(), IntervalIntDomain(0, 1)); Variable q2(ce.getId(), IntervalDomain(-(consumptionRateMax), -(consumptionRateMax - 1))); - Transaction trans2(t2.getId(), q2.getId(), true); - r.addTransaction(trans2.getId()); + TransactionPtr trans2(new Transaction(t2.getId(), q2.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans2->getId()); ce.propagate(); Variable t4(ce.getId(), IntervalIntDomain(0, 1)); Variable q4(ce.getId(), IntervalDomain(1, 1)); - Transaction trans4(t4.getId(), q4.getId(), true); - r.addTransaction(trans4.getId()); + TransactionPtr trans4(new Transaction(t4.getId(), q4.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans4->getId()); // no violation because of temporal flexibility CPPUNIT_ASSERT(ce.propagate()); - trans2.time()->restrictBaseDomain(IntervalIntDomain(1, trans2.time()->lastDomain().getUpperBound())); - trans4.time()->restrictBaseDomain(IntervalIntDomain(1, trans4.time()->lastDomain().getUpperBound())); + trans2->time()->restrictBaseDomain(IntervalIntDomain(1, trans2->time()->lastDomain().getUpperBound())); + trans4->time()->restrictBaseDomain(IntervalIntDomain(1, trans4->time()->lastDomain().getUpperBound())); CPPUNIT_ASSERT(!ce.propagate()); //violations.clear(); //r->getResourceViolations(violations); //CPPUNIT_ASSERT(violations.size() == 1); //CPPUNIT_ASSERT(violations.front()->getType() == ResourceViolation::ConsumptionRateExceeded); - r.removeTransaction(trans4.getId()); - r.removeTransaction(trans2.getId()); + r.removeTransaction(trans4->getId()); + r.removeTransaction(trans2->getId()); CPPUNIT_ASSERT(ce.propagate()); RESOURCE_DEFAULT_TEARDOWN(); @@ -762,47 +797,48 @@ class ProfileTest { RESOURCE_DEFAULT_SETUP(ce,db,false); - DummyResource r(db.getId(), LabelStr("Resource"), LabelStr("r1"), initialCapacity, initialCapacity, limitMin, limitMax, + DummyResource r(db.getId(), "Resource", "r1", initialCapacity, initialCapacity, limitMin, limitMax, productionRateMax, -(consumptionRateMax), productionMax, -(consumptionMax)); + BareTransactionDeleter deleter(r); db.close(); // Test that a violation is detected when the excess in the level cannot be overcome by remaining // production Variable t1(ce.getId(), IntervalIntDomain(2, 2)); Variable q1(ce.getId(), IntervalDomain(8, 8)); - Transaction trans1(t1.getId(), q1.getId(), true); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t2(ce.getId(), IntervalIntDomain(3, 3)); Variable q2(ce.getId(), IntervalDomain(8, 8)); - Transaction trans2(t2.getId(), q2.getId(), true); - r.addTransaction(trans2.getId()); + TransactionPtr trans2(new Transaction(t2.getId(), q2.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans2->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t3(ce.getId(), IntervalIntDomain(4, 4)); Variable q3(ce.getId(), IntervalDomain(8, 8)); - Transaction trans3(t3.getId(), q3.getId(), true); - r.addTransaction(trans3.getId()); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans3->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t4(ce.getId(), IntervalIntDomain(5, 5)); Variable q4(ce.getId(), IntervalDomain(8, 8)); - Transaction trans4(t4.getId(), q4.getId(), true); - r.addTransaction(trans4.getId()); + TransactionPtr trans4(new Transaction(t4.getId(), q4.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans4->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t5(ce.getId(), IntervalIntDomain(6, 6)); Variable q5(ce.getId(), IntervalDomain(8, 8)); - Transaction trans5(t5.getId(), q5.getId(), true); - r.addTransaction(trans5.getId()); + TransactionPtr trans5(new Transaction(t5.getId(), q5.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans5->getId()); CPPUNIT_ASSERT(ce.propagate()); // This will push it over the edge Variable t6(ce.getId(), IntervalIntDomain(10, 10)); Variable q6(ce.getId(), IntervalDomain(8, 8)); - Transaction trans6(t6.getId(), q6.getId(), true); - r.addTransaction(trans6.getId()); + TransactionPtr trans6(new Transaction(t6.getId(), q6.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans6->getId()); CPPUNIT_ASSERT(!ce.propagate()); CPPUNIT_ASSERT(checkLevelArea(r.getProfile()) == 0); @@ -819,53 +855,54 @@ class ProfileTest { RESOURCE_DEFAULT_SETUP(ce,db,false); - DummyResource r(db.getId(), LabelStr("Resource"), LabelStr("r1"), initialCapacity, initialCapacity, limitMin, limitMax, + DummyResource r(db.getId(), "Resource", "r1", initialCapacity, initialCapacity, limitMin, limitMax, PLUS_INFINITY, -(consumptionMax), PLUS_INFINITY, -(consumptionMax)); + BareTransactionDeleter deleter(r); db.close(); // Test that a violation is detected when the excess in the level cannot be overcome by remaining // production Variable t1(ce.getId(), IntervalIntDomain(2, 2)); Variable q1(ce.getId(), IntervalDomain(8, 8)); - Transaction trans1(t1.getId(), q1.getId(), true); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t2(ce.getId(), IntervalIntDomain(3, 3)); Variable q2(ce.getId(), IntervalDomain(8, 8)); - Transaction trans2(t2.getId(), q2.getId(), true); - r.addTransaction(trans2.getId()); + TransactionPtr trans2(new Transaction(t2.getId(), q2.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans2->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t3(ce.getId(), IntervalIntDomain(4, 4)); Variable q3(ce.getId(), IntervalDomain(8, 8)); - Transaction trans3(t3.getId(), q3.getId(), true); - r.addTransaction(trans3.getId()); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans3->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t4(ce.getId(), IntervalIntDomain(5, 5)); Variable q4(ce.getId(), IntervalDomain(8, 8)); - Transaction trans4(t4.getId(), q4.getId(), true); - r.addTransaction(trans4.getId()); + TransactionPtr trans4(new Transaction(t4.getId(), q4.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans4->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t5(ce.getId(), IntervalIntDomain(6, 6)); Variable q5(ce.getId(), IntervalDomain(8, 8)); - Transaction trans5(t5.getId(), q5.getId(), true); - r.addTransaction(trans5.getId()); + TransactionPtr trans5(new Transaction(t5.getId(), q5.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans5->getId()); CPPUNIT_ASSERT(ce.propagate()); Variable t6(ce.getId(), IntervalIntDomain(8, 8)); Variable q6(ce.getId(), IntervalDomain(8, 8)); - Transaction trans6(t6.getId(), q6.getId(), true); - r.addTransaction(trans6.getId()); + TransactionPtr trans6(new Transaction(t6.getId(), q6.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans6->getId()); CPPUNIT_ASSERT(ce.propagate()); // This will push it over the edge Variable t7(ce.getId(), IntervalIntDomain(10, 10)); Variable q7(ce.getId(), IntervalDomain(8, 8)); - Transaction trans7(t7.getId(), q7.getId(), true); - r.addTransaction(trans7.getId()); + TransactionPtr trans7(new Transaction(t7.getId(), q7.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans7->getId()); CPPUNIT_ASSERT(!ce.propagate()); CPPUNIT_ASSERT(checkLevelArea(r.getProfile()) == 0); @@ -881,7 +918,7 @@ class ProfileTest { { // Define input constrains for the resource spec RESOURCE_DEFAULT_SETUP(ce,db,false); - DummyResource r(db.getId(), LabelStr("Resource"), LabelStr("r1"), initialCapacity + 1, initialCapacity + 1, limitMin, limitMax, + DummyResource r(db.getId(), "Resource", "r1", initialCapacity + 1, initialCapacity + 1, limitMin, limitMax, productionRateMax, -(consumptionRateMax), productionMax + 100, -(consumptionMax)); db.close(); @@ -893,7 +930,7 @@ class ProfileTest { for (int i = 0; i < 11; i++){ ConstrainedVariableId time = (new Variable(ce.getId(), IntervalIntDomain(i, i)))->getId(); ConstrainedVariableId quantity = (new Variable(ce.getId(), IntervalDomain(productionRateMax, productionRateMax)))->getId(); - TransactionId t = (new Transaction(time, quantity, false))->getId(); + TransactionId t = (new Transaction(time, quantity, false, EntityId::noId()))->getId(); r.addTransaction(t); transactions.push_back(t); vars.push_back(quantity); @@ -914,10 +951,12 @@ class ProfileTest { // CPPUNIT_ASSERT(violations.size() == 1); // CPPUNIT_ASSERT(violations.front()->getType() == ResourceViolation::LevelTooHigh); - for(std::list::iterator it = transactions.begin(); it != transactions.end(); ++it) - delete (Transaction*) (*it); + for(std::list::iterator it = transactions.begin(); it != transactions.end(); ++it) { + r.removeTransaction(*it); + delete static_cast(*it); + } for(std::list::iterator it = vars.begin(); it != vars.end(); ++it) - delete (ConstrainedVariable*) (*it); + delete static_cast(*it); RESOURCE_DEFAULT_TEARDOWN(); return(true); @@ -927,7 +966,7 @@ class ProfileTest { { RESOURCE_DEFAULT_SETUP(ce,db,false); - DummyResource r(db.getId(), LabelStr("Resource"), LabelStr("r1"), initialCapacity, initialCapacity, limitMin, limitMax, + DummyResource r(db.getId(), "Resource", "r1", initialCapacity, initialCapacity, limitMin, limitMax, productionRateMax, -(consumptionRateMax), productionMax, -(consumptionMax)); db.close(); @@ -938,7 +977,7 @@ class ProfileTest { for (int i = 0; i < 11; i++){ ConstrainedVariableId time = (new Variable(ce.getId(), IntervalIntDomain(i, i)))->getId(); ConstrainedVariableId quantity = (new Variable(ce.getId(), IntervalDomain(productionRateMax, productionRateMax)))->getId(); - TransactionId t = (new Transaction(time, quantity, false))->getId(); + TransactionId t = (new Transaction(time, quantity, false, EntityId::noId()))->getId(); r.addTransaction(t); //r->constrain(t); transactions.push_back(t); @@ -948,7 +987,7 @@ class ProfileTest { for (int i = 0; i < 11; i++){ ConstrainedVariableId time = (new Variable(ce.getId(), IntervalIntDomain(i, i)))->getId(); ConstrainedVariableId quantity = (new Variable(ce.getId(), IntervalDomain(productionRateMax, productionRateMax)))->getId(); - TransactionId t = (new Transaction(time, quantity, true))->getId(); + TransactionId t = (new Transaction(time, quantity, true, EntityId::noId()))->getId(); r.addTransaction(t); //r->constrain(t); transactions.push_back(t); @@ -964,10 +1003,12 @@ class ProfileTest { // r->getResourceViolations(violations); // CPPUNIT_ASSERT(violations.size() > 0); - for(std::list::iterator it = transactions.begin(); it != transactions.end(); ++it) - delete (Transaction*) (*it); + for(std::list::iterator it = transactions.begin(); it != transactions.end(); ++it) { + r.removeTransaction(*it); + delete static_cast(*it); + } for(std::list::iterator it = variables.begin(); it != variables.end(); ++it) - delete (ConstrainedVariable*) (*it); + delete static_cast(*it); RESOURCE_DEFAULT_TEARDOWN(); return(true); } @@ -988,8 +1029,9 @@ class ProfileTest { // Define input constrains for the resource spec RESOURCE_DEFAULT_SETUP(ce,db,false); - DummyResource r(db.getId(), LabelStr("Resource"), LabelStr("r1"), initialCapacity, initialCapacity, limitMin, limitMax, + DummyResource r(db.getId(), "Resource", "r1", initialCapacity, initialCapacity, limitMin, limitMax, productionRateMax, -(consumptionRateMax), 5, -(consumptionMax)); + BareTransactionDeleter deleter(r); db.close(); IntervalDomain result; @@ -1000,8 +1042,8 @@ class ProfileTest { // Test that a flaw is signalled when there is a possibility to violate limits Variable t1(ce.getId(), IntervalIntDomain(5, 5)); Variable q1(ce.getId(), IntervalDomain(5, 5)); - Transaction trans1(t1.getId(), q1.getId(), false); - r.addTransaction(trans1.getId()); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), false, EntityId::noId()), deleter); + r.addTransaction(trans1->getId()); // Have a single transaction, test before, at and after. getLevel(r, 0, result); @@ -1013,13 +1055,13 @@ class ProfileTest { Variable t2(ce.getId(), IntervalIntDomain(0, 7)); Variable q2(ce.getId(), IntervalDomain(5, 5)); - Transaction trans2(t2.getId(), q2.getId(), true); - r.addTransaction(trans2.getId()); + TransactionPtr trans2(new Transaction(t2.getId(), q2.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans2->getId()); Variable t3(ce.getId(), IntervalIntDomain(2, 10)); Variable q3(ce.getId(), IntervalDomain(5, 5)); - Transaction trans3(t3.getId(), q3.getId(), true); - r.addTransaction(trans3.getId()); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), true, EntityId::noId()), deleter); + r.addTransaction(trans3->getId()); // Confirm that we can query in the middle getLevel(r, 6, result); @@ -1040,25 +1082,26 @@ class ProfileTest { RESOURCE_DEFAULT_SETUP(ce, db, false); DummyDetector detector(ResourceId::noId()); DummyProfile profile(db.getId(), detector.getId()); + BareTransactionDeleter deleter(profile); - Variable t1(ce.getId(), IntervalIntDomain(0, 10), true, "t1"); - Variable t2(ce.getId(), IntervalIntDomain(10, 15), true, "t2"); - Variable t3(ce.getId(), IntervalIntDomain(5, 15), true, "t3"); - Variable t4(ce.getId(), IntervalIntDomain(5, 15), true, "t1"); - Variable q1(ce.getId(), IntervalDomain(1, 1), true, "q1"); - Variable q2(ce.getId(), IntervalDomain(1, 1), true, "q2"); - Variable q3(ce.getId(), IntervalDomain(1, 1), true, "q3"); - Variable q4(ce.getId(), IntervalDomain(1, 1), true, "q4"); + Variable t1(ce.getId(), IntervalIntDomain(0, 10), false, true, "t1"); + Variable t2(ce.getId(), IntervalIntDomain(10, 15), false, true, "t2"); + Variable t3(ce.getId(), IntervalIntDomain(5, 15), false, true, "t3"); + Variable t4(ce.getId(), IntervalIntDomain(5, 15), false, true, "t1"); + Variable q1(ce.getId(), IntervalDomain(1, 1), false, true, "q1"); + Variable q2(ce.getId(), IntervalDomain(1, 1), false, true, "q2"); + Variable q3(ce.getId(), IntervalDomain(1, 1), false, true, "q3"); + Variable q4(ce.getId(), IntervalDomain(1, 1), false, true, "q4"); - Transaction trans1(t1.getId(), q1.getId(), false); - Transaction trans2(t2.getId(), q2.getId(), true); - Transaction trans3(t3.getId(), q3.getId(), true); - Transaction trans4(t4.getId(), q4.getId(), false); + TransactionPtr trans1(new Transaction(t1.getId(), q1.getId(), false, EntityId::noId()), deleter); + TransactionPtr trans2(new Transaction(t2.getId(), q2.getId(), true, EntityId::noId()), deleter); + TransactionPtr trans3(new Transaction(t3.getId(), q3.getId(), true, EntityId::noId()), deleter); + TransactionPtr trans4(new Transaction(t4.getId(), q4.getId(), false, EntityId::noId()), deleter); - profile.addTransaction(trans1.getId()); - profile.addTransaction(trans2.getId()); - profile.addTransaction(trans3.getId()); - profile.addTransaction(trans4.getId()); + profile.addTransaction(trans1->getId()); + profile.addTransaction(trans2->getId()); + profile.addTransaction(trans3->getId()); + profile.addTransaction(trans4->getId()); InstantId inst = profile.getInstant(0); @@ -1067,14 +1110,14 @@ class ProfileTest { for(std::set::const_iterator it = inst->getTransactions().begin(); it != inst->getTransactions().end(); ++it) { CPPUNIT_ASSERT((*it).isValid()); - CPPUNIT_ASSERT((*it) == trans1.getId()); + CPPUNIT_ASSERT((*it) == trans1->getId()); } //for time 5 std::set trans; - trans.insert(trans1.getId()); - trans.insert(trans3.getId()); - trans.insert(trans4.getId()); + trans.insert(trans1->getId()); + trans.insert(trans3->getId()); + trans.insert(trans4->getId()); inst = profile.getInstant(5); CPPUNIT_ASSERT(inst.isValid()); @@ -1088,10 +1131,10 @@ class ProfileTest { CPPUNIT_ASSERT(trans.empty()); //for time 10 - trans.insert(trans1.getId()); - trans.insert(trans2.getId()); - trans.insert(trans3.getId()); - trans.insert(trans4.getId()); + trans.insert(trans1->getId()); + trans.insert(trans2->getId()); + trans.insert(trans3->getId()); + trans.insert(trans4->getId()); inst = profile.getInstant(10); CPPUNIT_ASSERT(inst.isValid()); @@ -1105,9 +1148,9 @@ class ProfileTest { CPPUNIT_ASSERT(trans.empty()); //for time 15 - trans.insert(trans2.getId()); - trans.insert(trans3.getId()); - trans.insert(trans4.getId()); + trans.insert(trans2->getId()); + trans.insert(trans3->getId()); + trans.insert(trans4->getId()); inst = profile.getInstant(15); CPPUNIT_ASSERT(inst.isValid()); @@ -1130,6 +1173,8 @@ class ResourceTest { public: static bool test() { EUROPA_runTest(testReservoir); + EUROPA_runTest(testFlowReservoirWithConsumptionParameterSpecification); + EUROPA_runTest(testIncrementalFlowProfileIssue71); EUROPA_runTest(testReusable); EUROPA_runTest(testReservoirRemove); EUROPA_runTest(testDanglingTransaction); @@ -1137,15 +1182,111 @@ class ResourceTest { } private: + static bool testIncrementalFlowProfileIssue71() { + RESOURCE_DEFAULT_SETUP(ce, db, false); + Reservoir res1(db.getId(), "Reservoir", "Battery1", + "ClosedWorldFVDetector", "IncrementalFlowProfile", + 0, 0, 0, 1000); + ProducerToken p1(db.getId(), "Reservoir.produce", + IntervalIntDomain(10, PLUS_INFINITY), + IntervalDomain(1000.0)); + ConsumerToken c1(db.getId(), "Reservoir.consume", + // IntervalIntDomain(120010, PLUS_INFINITY), + IntervalIntDomain(), + IntervalDomain(1000.0)); + ConsumerToken c2(db.getId(), "Reservoir.consume", + IntervalIntDomain(960000, PLUS_INFINITY), + IntervalDomain(1.0)); + ProducerToken p2(db.getId(), "Reservoir.produce", + // IntervalIntDomain(961200, PLUS_INFINITY), + IntervalIntDomain(), + IntervalDomain(1.0)); + + + ConstrainedVariableId d1 = + db.getClient()->createVariable("int", IntervalIntDomain(120000), "d1"); + db.getClient()->createConstraint("temporalDistance", + makeScope(p1.getTime(), d1, c1.getTime())); + + ConstrainedVariableId d2 = + db.getClient()->createVariable("int", IntervalIntDomain(1200), "d2"); + db.getClient()->createConstraint("temporalDistance", + makeScope(c2.getTime(), d2, p2.getTime())); + + CPPUNIT_ASSERT(ce.propagate()); + + std::vector instants; + res1.getFlawedInstants(instants); + CPPUNIT_ASSERT(instants.size() == 2); + CPPUNIT_ASSERT(instants[0]->getTime() == 960000); + CPPUNIT_ASSERT(instants[1]->getTime() == 961200); + return true; + } + + static bool testFlowReservoirWithConsumptionParameterSpecification() { + RESOURCE_DEFAULT_SETUP(ce, db, false); + Reservoir res1(db.getId(), "Reservoir", "Battery1", + "OpenWorldFVDetector", "IncrementalFlowProfile", + 0, 0, 0, 1000); + + ConsumerToken c1(db.getId(), "Reservoir.consume", + IntervalIntDomain(10), + IntervalDomain(5, 10)); + ConsumerToken c2(db.getId(), "Reservoir.consume", + IntervalIntDomain(20), + IntervalDomain(5, 10)); + res1.constrain(c1.getId(), c1.getId()); + res1.constrain(c1.getId(), c2.getId()); + CPPUNIT_ASSERT(ce.propagate()); + ProfileIterator it1(res1.getProfile()); + CPPUNIT_ASSERT(!it1.done()); + CPPUNIT_ASSERT(it1.getTime() == 10); + CPPUNIT_ASSERT(it1.getUpperBound() == -5.0); + CPPUNIT_ASSERT(it1.getLowerBound() == -10.0); + CPPUNIT_ASSERT(it1.next()); + CPPUNIT_ASSERT(it1.getTime() == 20); + CPPUNIT_ASSERT(it1.getUpperBound() == -10.0); + CPPUNIT_ASSERT(it1.getLowerBound() == -20.0); + + c1.getQuantity()->specify(5.0); + CPPUNIT_ASSERT(ce.propagate()); + ProfileIterator it2(res1.getProfile()); + CPPUNIT_ASSERT(!it2.done()); + CPPUNIT_ASSERT(it2.getTime() == 10); + CPPUNIT_ASSERT(it2.getUpperBound() == -5.0); + CPPUNIT_ASSERT(it2.getLowerBound() == -5.0); + CPPUNIT_ASSERT(it2.next()); + CPPUNIT_ASSERT(it2.getTime() == 20); + CPPUNIT_ASSERT(it2.getUpperBound() == -10.0); + CPPUNIT_ASSERT(it2.getLowerBound() == -15.0); + + c1.getQuantity()->specify(7.0); + CPPUNIT_ASSERT(ce.propagate()); + ProfileIterator it3(res1.getProfile()); + CPPUNIT_ASSERT(!it3.done()); + CPPUNIT_ASSERT(it3.getTime() == 10); + CPPUNIT_ASSERT(it3.getUpperBound() == -7.0); + CPPUNIT_ASSERT(it3.getLowerBound() == -7.0); + CPPUNIT_ASSERT(it3.next()); + CPPUNIT_ASSERT(it3.getTime() == 20); + CPPUNIT_ASSERT(it3.getUpperBound() == -12.0); + CPPUNIT_ASSERT(it3.getLowerBound() == -17.0); + + return true; + } + static bool testReservoir() { RESOURCE_DEFAULT_SETUP(ce, db, false); - Reservoir res1(db.getId(), LabelStr("Reservoir"), LabelStr("Battery1"), LabelStr("OpenWorldFVDetector"), LabelStr("TimetableProfile"), - 10, 10, 0, 1000); - Reservoir res2(db.getId(), LabelStr("Reservoir"), LabelStr("Battery2"), LabelStr("OpenWorldFVDetector"), LabelStr("TimetableProfile"), - 10, 10, 0, 1000); + Reservoir res1(db.getId(), "Reservoir", "Battery1", + "OpenWorldFVDetector", "TimetableProfile", + 10, 10, 0, 1000); + Reservoir res2(db.getId(), "Reservoir", "Battery2", + "OpenWorldFVDetector", "TimetableProfile", + 10, 10, 0, 1000); - ConsumerToken consumer(db.getId(), LabelStr("Reservoir.consume"), IntervalIntDomain(10), + ConsumerToken consumer(db.getId(), "Reservoir.consume", + IntervalIntDomain(10), IntervalDomain(5)); ProfileIterator it1(res1.getProfile()); @@ -1166,7 +1307,7 @@ class ResourceTest { ProfileIterator it6(res2.getProfile()); CPPUNIT_ASSERT(it6.done()); - ConsumerToken throwaway(db.getId(), LabelStr("Reservoir.consume"), IntervalIntDomain(10), + ConsumerToken throwaway(db.getId(), "Reservoir.consume", IntervalIntDomain(10), IntervalDomain(5)); res1.constrain(throwaway.getId(), throwaway.getId()); @@ -1180,14 +1321,14 @@ class ResourceTest { static bool testReservoirRemove() { RESOURCE_DEFAULT_SETUP(ce, db, false); //setup two reservoirs - Reservoir res1(db.getId(), LabelStr("Reservoir"), LabelStr("Battery1"), LabelStr("OpenWorldFVDetector"), LabelStr("TimetableProfile"), + Reservoir res1(db.getId(), "Reservoir", "Battery1", "OpenWorldFVDetector", "TimetableProfile", 10, 10, 0, 1000, 0, 5); - Reservoir res2(db.getId(), LabelStr("Reservoir"), LabelStr("Battery2"), LabelStr("OpenWorldFVDetector"), LabelStr("TimetableProfile"), + Reservoir res2(db.getId(), "Reservoir", "Battery2", "OpenWorldFVDetector", "TimetableProfile", 10, 10, 0, 1000); //create a flaw - ConsumerToken c1(db.getId(), LabelStr("Reservoir.consume"), IntervalIntDomain(0, 10), IntervalDomain(3, 5)); - ConsumerToken c2(db.getId(), LabelStr("Reservoir.consume"), IntervalIntDomain(0, 10), IntervalDomain(3, 5)); + ConsumerToken c1(db.getId(), "Reservoir.consume", IntervalIntDomain(0, 10), IntervalDomain(3, 5)); + ConsumerToken c2(db.getId(), "Reservoir.consume", IntervalIntDomain(0, 10), IntervalDomain(3, 5)); c1.getObject()->specify(res1.getKey()); c2.getObject()->specify(res1.getKey()); @@ -1213,9 +1354,9 @@ class ResourceTest { ce.getId(); // Only point of this is to remove a compile-time warning (unused-variable) - Reusable res(db.getId(), LabelStr("Reusable"), LabelStr("Foo"), LabelStr("OpenWorldFVDetector"), LabelStr("TimetableProfile")); + Reusable res(db.getId(), "Reusable", "Foo", "OpenWorldFVDetector", "TimetableProfile"); - ReusableToken use(db.getId(), LabelStr("Reusable.uses"), IntervalIntDomain(0, 5), IntervalIntDomain(10, 15), IntervalIntDomain(1, PLUS_INFINITY), + ReusableToken use(db.getId(), "Reusable.uses", IntervalIntDomain(0, 5), IntervalIntDomain(10, 15), IntervalIntDomain(1, PLUS_INFINITY), IntervalDomain(10)); //should create two transactions and four instants @@ -1247,7 +1388,7 @@ class ResourceTest { } CPPUNIT_ASSERT(instCount == 2); - ReusableToken throwaway(db.getId(), LabelStr("Reusable.uses"), IntervalIntDomain(50), IntervalIntDomain(51), IntervalIntDomain(1), IntervalDomain(1)); + ReusableToken throwaway(db.getId(), "Reusable.uses", IntervalIntDomain(50), IntervalIntDomain(51), IntervalIntDomain(1), IntervalDomain(1)); throwaway.discard(false); RESOURCE_DEFAULT_TEARDOWN(); @@ -1255,7 +1396,7 @@ class ResourceTest { } static bool testDanglingTransaction() { - RESOURCE_DEFAULT_SETUP(ce, db, false); + RESOURCE_DEFAULT_SETUP(unused(ce), db, false); rte.getConfig()->setProperty("nddl.includePath", ".:../component/NDDL"); rte.executeScript("nddl", "missing-transaction.nddl", true); @@ -1288,7 +1429,7 @@ class ResourceTest { //get the slave that can go on Foo instances TokenId fooSlave = master->getSlave(1); CPPUNIT_ASSERT(fooSlave.isValid()); - CPPUNIT_ASSERT(fooSlave->getName().toString() == "Foo.foo"); + CPPUNIT_ASSERT(fooSlave->getName() == "Foo.foo"); //get the slave that can go on Battery instances TokenId battSlave = master->getSlave(0); @@ -1322,8 +1463,8 @@ class ResourceTest { class ConstraintNameListener : public ConstrainedVariableListener { public: - ConstraintNameListener(const ConstrainedVariableId& var) : ConstrainedVariableListener(var), m_constraintName("NO_CONSTRAINT") {} - void notifyConstraintAdded(const ConstraintId& constr, int argIndex) { + ConstraintNameListener(const ConstrainedVariableId var) : ConstrainedVariableListener(var), m_constraintName("NO_CONSTRAINT") {} + void notifyConstraintAdded(const ConstraintId constr, unsigned int) { m_constraintName = constr->getName(); } ~ConstraintNameListener() @@ -1331,446 +1472,497 @@ class ConstraintNameListener : public ConstrainedVariableListener { } - const LabelStr& getName() {return m_constraintName;} + const std::string& getName() {return m_constraintName;} private: - LabelStr m_constraintName; + std::string m_constraintName; }; // Test that used to be in Solvers/test/solvers-test-module.cc class ResourceSolverTest { -public: - static bool test() { - EUROPA_runTest(testResourceDecisionPoint); - EUROPA_runTest(testResourceThreatDecisionPoint); - EUROPA_runTest(testResourceThreatManager); - return true; - } -private: + public: + static bool test() { + EUROPA_runTest(testResourceDecisionPoint); + EUROPA_runTest(testResourceThreatDecisionPoint); + EUROPA_runTest(testResourceThreatManager); + EUROPA_runTest(testResourceThreatManagerNoMoreFlaws); + return true; + } + private: - // TBS: This tested a previous version of ResourceThreatDecisionPoint (basically a glorified ThreatDecisionPoint, which we now test here), so - // there's not much value in this test anymore. - static bool testResourceDecisionPoint() { + // TBS: This tested a previous version of ResourceThreatDecisionPoint (basically a glorified ThreatDecisionPoint, which we now test here), so + // there's not much value in this test anymore. + static bool testResourceDecisionPoint() { - RESOURCE_DEFAULT_SETUP(ceObj, dbObj, false); + RESOURCE_DEFAULT_SETUP(ceObj, dbObj, false); - PlanDatabaseId db = dbObj.getId(); - ConstraintEngineId ce = ceObj.getId(); - DbClientId client = db->getClient(); + PlanDatabaseId db = dbObj.getId(); + ConstraintEngineId ce = ceObj.getId(); + DbClientId client = db->getClient(); - Reusable reusable(db, "Reusable", "myReusable", "ClosedWorldFVDetector", "IncrementalFlowProfile", 2, 2, 0); + Reusable reusable(db, "Reusable", "myReusable", "ClosedWorldFVDetector", "IncrementalFlowProfile", 2, 2, 0); - ReusableToken tok1(db, "Reusable.uses", IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); + ReusableToken tok1(db, "Reusable.uses", IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); - ReusableToken tok2(db, "Reusable.uses", IntervalIntDomain(11, 13), IntervalIntDomain(15, 17), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); + ReusableToken tok2(db, "Reusable.uses", IntervalIntDomain(11, 13), IntervalIntDomain(15, 17), IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); - ReusableToken tok3(db, "Reusable.uses", IntervalIntDomain(11, 16), IntervalIntDomain(18, 19), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); + ReusableToken tok3(db, "Reusable.uses", IntervalIntDomain(11, 16), IntervalIntDomain(18, 19), IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); - CPPUNIT_ASSERT(ce->propagate()); - CPPUNIT_ASSERT(reusable.hasTokensToOrder()); - TiXmlElement dummy(""); - SOLVERS::ThreatDecisionPoint dp1(client, tok1.getId(), dummy); + CPPUNIT_ASSERT(ce->propagate()); + CPPUNIT_ASSERT(reusable.hasTokensToOrder()); + TiXmlElement dummy(""); + SOLVERS::ThreatDecisionPoint dp1(client, tok1.getId(), dummy); - dp1.initialize(); + dp1.initialize(); - SOLVERS::ThreatDecisionPoint dp2(client, tok2.getId(), dummy); - dp2.initialize(); + SOLVERS::ThreatDecisionPoint dp2(client, tok2.getId(), dummy); + dp2.initialize(); - SOLVERS::ThreatDecisionPoint dp3(client, tok3.getId(), dummy); - dp3.initialize(); + SOLVERS::ThreatDecisionPoint dp3(client, tok3.getId(), dummy); + dp3.initialize(); - RESOURCE_DEFAULT_TEARDOWN(); - return true; - } + RESOURCE_DEFAULT_TEARDOWN(); + return true; + } - static bool testResourceThreatDecisionPoint() { - - RESOURCE_DEFAULT_SETUP(ceObj, dbObj, false); - - PlanDatabaseId db = dbObj.getId(); - ConstraintEngineId ce = ceObj.getId(); - DbClientId client = db->getClient(); - - Reusable reusable(db, "Reusable", "myReusable", "ClosedWorldFVDetector", "IncrementalFlowProfile", 1, 1, 0); - - ReusableToken tok1(db, "Reusable.uses", IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); - - ReusableToken tok2(db, "Reusable.uses", IntervalIntDomain(11, 13), IntervalIntDomain(15, 17), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); - - ReusableToken tok3(db, "Reusable.uses", IntervalIntDomain(11, 16), IntervalIntDomain(18, 19), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); - - CPPUNIT_ASSERT(ce->propagate()); - - CPPUNIT_ASSERT(reusable.hasTokensToOrder()); - std::vector flawedInstants; - reusable.getFlawedInstants(flawedInstants); - CPPUNIT_ASSERT(flawedInstants.size() == 5); - CPPUNIT_ASSERT(flawedInstants[0]->getTime() == 11); - - TiXmlElement dummy(""); - ResourceThreatDecisionPoint dp1(client, flawedInstants[0], dummy); - - dp1.initialize(); - - CPPUNIT_ASSERT(dp1.getChoices().size() == 8); - - std::string noFilter = ""; - TiXmlElement* noFilterXml = initXml(noFilter); - ResourceThreatDecisionPoint dp2(client, flawedInstants[0], *noFilterXml); - dp2.initialize(); - CPPUNIT_ASSERT(dp2.getChoices().size() == 8); - - std::string predFilter = ""; - TiXmlElement* predFilterXml = initXml(predFilter); - ResourceThreatDecisionPoint dp3(client, flawedInstants[0], *predFilterXml); - dp3.initialize(); - CPPUNIT_ASSERT(dp3.getChoices().size() == 3); - CPPUNIT_ASSERT(dp3.getChoices()[0].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp3.getChoices()[0].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp3.getChoices()[1].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp3.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp3.getChoices()[2].first->time() == tok2.end()); - CPPUNIT_ASSERT(dp3.getChoices()[2].second->time() == tok3.start()); - - std::string sucFilter = ""; - TiXmlElement* sucFilterXml = initXml(sucFilter); - ResourceThreatDecisionPoint dp4(client, flawedInstants[0], *sucFilterXml); - dp4.initialize(); - CPPUNIT_ASSERT(dp4.getChoices().size() == 5); - CPPUNIT_ASSERT(dp4.getChoices()[0].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp4.getChoices()[0].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp4.getChoices()[1].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp4.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp4.getChoices()[2].first->time() == tok2.start()); - CPPUNIT_ASSERT(dp4.getChoices()[2].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp4.getChoices()[3].first->time() == tok2.end()); - CPPUNIT_ASSERT(dp4.getChoices()[3].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp4.getChoices()[4].first->time() == tok3.start()); - CPPUNIT_ASSERT(dp4.getChoices()[4].second->time() == tok2.start()); - - std::string bothFilter = ""; - TiXmlElement* bothFilterXml = initXml(bothFilter); - ResourceThreatDecisionPoint dp5(client, flawedInstants[0], *bothFilterXml); - dp5.initialize(); - CPPUNIT_ASSERT(dp5.getChoices().size() == 3); - CPPUNIT_ASSERT(dp5.getChoices()[0].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp5.getChoices()[0].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp5.getChoices()[1].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp5.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp5.getChoices()[2].first->time() == tok2.end()); - CPPUNIT_ASSERT(dp5.getChoices()[2].second->time() == tok3.start()); - - //the combination of ascendingKeyPredecessor and ascendingKeySuccessor have already been tested by now - - std::string earliestPred = ""; - TiXmlElement* earliestPredXml = initXml(earliestPred); - ResourceThreatDecisionPoint dp6(client, flawedInstants[0], *earliestPredXml); - dp6.initialize(); - CPPUNIT_ASSERT(dp6.getChoices().size() == 3); - CPPUNIT_ASSERT(dp6.getChoices()[0].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp6.getChoices()[0].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp6.getChoices()[1].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp6.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp6.getChoices()[2].first->time() == tok2.end()); - CPPUNIT_ASSERT(dp6.getChoices()[2].second->time() == tok3.start()); - - std::string latestPred = ""; - TiXmlElement* latestPredXml = initXml(latestPred); - ResourceThreatDecisionPoint dp7(client, flawedInstants[0], *latestPredXml); - dp7.initialize(); - CPPUNIT_ASSERT(dp7.getChoices().size() == 3); - CPPUNIT_ASSERT(dp7.getChoices()[0].first->time() == tok2.end()); - CPPUNIT_ASSERT(dp7.getChoices()[0].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp7.getChoices()[1].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp7.getChoices()[1].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp7.getChoices()[2].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp7.getChoices()[2].second->time() == tok3.start()); - - - std::string longestPred = ""; - TiXmlElement* longestPredXml = initXml(longestPred); - ResourceThreatDecisionPoint dp8(client, flawedInstants[0], *longestPredXml); - dp8.initialize(); - CPPUNIT_ASSERT(dp8.getChoices().size() == 5); - CPPUNIT_ASSERT(dp8.getChoices()[0].first->time() == tok3.start()); - - - std::string shortestPred = ""; - TiXmlElement* shortestPredXml = initXml(shortestPred); - ResourceThreatDecisionPoint dp9(client, flawedInstants[0], *shortestPredXml); - dp9.initialize(); - CPPUNIT_ASSERT(dp9.getChoices().size() == 3); - CPPUNIT_ASSERT(dp9.getChoices()[0].first->time() == tok2.start() || - dp9.getChoices()[0].first->time() == tok1.end()); - - std::string descendingKeyPred = ""; - TiXmlElement* descendingKeyPredXml = initXml(descendingKeyPred); - ResourceThreatDecisionPoint dp10(client, flawedInstants[0], *descendingKeyPredXml); - dp10.initialize(); - CPPUNIT_ASSERT(dp10.getChoices().size() == 3); - CPPUNIT_ASSERT(dp10.getChoices()[0].first->time() == tok2.end()); - CPPUNIT_ASSERT(dp10.getChoices()[1].first->time() == tok1.end()); - - - std::string earliestSucc = ""; - TiXmlElement* earliestSuccXml = initXml(earliestSucc); - ResourceThreatDecisionPoint dp11(client, flawedInstants[0], *earliestSuccXml); - dp11.initialize(); - CPPUNIT_ASSERT(dp11.getChoices().size() == 3); - CPPUNIT_ASSERT(dp11.getChoices()[0].second->time() == tok2.start() || - dp11.getChoices()[0].second->time() == tok3.start()); - - std::string latestSucc = ""; - TiXmlElement* latestSuccXml = initXml(latestSucc); - ResourceThreatDecisionPoint dp12(client, flawedInstants[0], *latestSuccXml); - dp12.initialize(); - CPPUNIT_ASSERT(dp12.getChoices().size() == 3); - CPPUNIT_ASSERT(dp12.getChoices()[0].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp12.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp12.getChoices()[2].second->time() == tok2.start()); - - - std::string longestSucc = ""; - TiXmlElement* longestSuccXml = initXml(longestSucc); - ResourceThreatDecisionPoint dp13(client, flawedInstants[0], *longestSuccXml); - dp13.initialize(); - CPPUNIT_ASSERT(dp13.getChoices().size() == 3); - CPPUNIT_ASSERT(dp13.getChoices()[0].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp13.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp13.getChoices()[2].second->time() == tok2.start()); - - std::string shortestSucc = ""; - TiXmlElement* shortestSuccXml = initXml(shortestSucc); - ResourceThreatDecisionPoint dp14(client, flawedInstants[0], *shortestSuccXml); - dp14.initialize(); - CPPUNIT_ASSERT(dp14.getChoices().size() == 3); - CPPUNIT_ASSERT(dp14.getChoices()[0].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp14.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp14.getChoices()[2].second->time() == tok3.start()); - - std::string descendingKeySucc = ""; - TiXmlElement* descendingKeySuccXml = initXml(descendingKeySucc); - ResourceThreatDecisionPoint dp15(client, flawedInstants[0], *descendingKeySuccXml); - dp15.initialize(); - CPPUNIT_ASSERT(dp15.getChoices().size() == 3); - CPPUNIT_ASSERT(dp15.getChoices()[0].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp15.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp15.getChoices()[2].second->time() == tok2.start()); - - - std::string ascendingKeySucc = ""; - TiXmlElement* ascendingKeySuccXml = initXml(ascendingKeySucc); - ResourceThreatDecisionPoint dp16(client, flawedInstants[0], *ascendingKeySuccXml); - dp16.initialize(); - CPPUNIT_ASSERT(dp16.getChoices().size() == 3); - CPPUNIT_ASSERT(dp16.getChoices()[0].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp16.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp16.getChoices()[2].second->time() == tok3.start()); - - - std::string leastImpact = ""; - TiXmlElement* leastImpactXml = initXml(leastImpact); - ResourceThreatDecisionPoint dp17(client, flawedInstants[0], *leastImpactXml); - dp17.initialize(); - CPPUNIT_ASSERT(dp17.getChoices().size() == 5); - CPPUNIT_ASSERT(dp17.getChoices()[0].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp17.getChoices()[0].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp17.getChoices()[1].first->time() == tok1.end()); - CPPUNIT_ASSERT(dp17.getChoices()[1].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp17.getChoices()[2].first->time() == tok2.start()); - CPPUNIT_ASSERT(dp17.getChoices()[2].second->time() == tok3.start()); - CPPUNIT_ASSERT(dp17.getChoices()[3].first->time() == tok3.start()); - CPPUNIT_ASSERT(dp17.getChoices()[3].second->time() == tok2.start()); - CPPUNIT_ASSERT(dp17.getChoices()[4].first->time() == tok2.end()); - CPPUNIT_ASSERT(dp17.getChoices()[4].second->time() == tok3.start()); - - std::string precedesOnly = ""; - TiXmlElement* precedesOnlyXml = initXml(precedesOnly); - ResourceThreatDecisionPoint dp18(client, flawedInstants[0], *precedesOnlyXml); - dp18.initialize(); - ConstraintNameListener* nameListener = new ConstraintNameListener(dp18.getChoices()[0].first->time()); - dp18.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("precedes")); - dp18.undo(); - delete (ConstrainedVariableListener*) nameListener; - ce->propagate(); - nameListener = new ConstraintNameListener(dp18.getChoices()[1].first->time()); - dp18.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("precedes")); - dp18.undo(); - ce->propagate(); - delete (ConstrainedVariableListener*) nameListener; - - std::string concurrentOnly = ""; - TiXmlElement* concurrentOnlyXml = initXml(concurrentOnly); - ResourceThreatDecisionPoint dp19(client, flawedInstants[0], *concurrentOnlyXml); - dp19.initialize(); - nameListener = new ConstraintNameListener(dp19.getChoices()[0].first->time()); - dp19.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("concurrent")); - dp19.undo(); - delete (ConstrainedVariableListener*) nameListener; - ce->propagate(); - nameListener = new ConstraintNameListener(dp19.getChoices()[1].first->time()); - dp19.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("concurrent")); - dp19.undo(); - ce->propagate(); - delete (ConstrainedVariableListener*) nameListener; - - //pair first has already been implicitly tested and constraint first is necessary to make this easy anyway, so it'll get tested as well. - - std::string precedesFirst = ""; - TiXmlElement* precedesFirstXml = initXml(precedesFirst); - ResourceThreatDecisionPoint dp20(client, flawedInstants[0], *precedesFirstXml); - dp20.initialize(); - nameListener = new ConstraintNameListener(dp20.getChoices()[0].first->time()); - dp20.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("precedes")); - dp20.undo(); - ce->propagate(); - dp20.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("concurrent")); - dp20.undo(); - ce->propagate(); - delete (ConstrainedVariableListener*) nameListener; - //step once more to test creating a constraint on the next choice - nameListener = new ConstraintNameListener(dp20.getChoices()[1].first->time()); - dp20.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("precedes")); - dp20.undo(); - ce->propagate(); - delete nameListener; - - std::string concurrentFirst = ""; - TiXmlElement* concurrentFirstXml = initXml(concurrentFirst); - ResourceThreatDecisionPoint dp21(client, flawedInstants[0], *concurrentFirstXml); - dp21.initialize(); - nameListener = new ConstraintNameListener(dp21.getChoices()[0].first->time()); - dp21.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("concurrent")); - dp21.undo(); - ce->propagate(); - dp21.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("precedes")); - dp21.undo(); - ce->propagate(); - delete (ConstrainedVariableListener*) nameListener; - //step once more to test creating a constraint on the next choice - nameListener = new ConstraintNameListener(dp21.getChoices()[1].first->time()); - dp21.execute(); - ce->propagate(); - CPPUNIT_ASSERT(nameListener->getName() == LabelStr("concurrent")); - dp21.undo(); - ce->propagate(); - delete nameListener; - - delete concurrentFirstXml; - delete precedesFirstXml; - delete concurrentOnlyXml; - delete precedesOnlyXml; - delete leastImpactXml; - delete ascendingKeySuccXml; - delete descendingKeySuccXml; - delete shortestSuccXml; - delete longestSuccXml; - delete latestSuccXml; - delete earliestSuccXml; - delete descendingKeyPredXml; - delete shortestPredXml; - delete longestPredXml; - delete latestPredXml; - delete earliestPredXml; - delete bothFilterXml; - delete sucFilterXml; - delete predFilterXml; - delete noFilterXml; - - return true; - } + static bool testResourceThreatDecisionPoint() { + + RESOURCE_DEFAULT_SETUP(ceObj, dbObj, false); + + PlanDatabaseId db = dbObj.getId(); + ConstraintEngineId ce = ceObj.getId(); + DbClientId client = db->getClient(); + + Reusable reusable(db, "Reusable", "myReusable", "ClosedWorldFVDetector", + "IncrementalFlowProfile", 1, 1, 0); + + ReusableToken tok1(db, "Reusable.uses", + IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), + IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + + ReusableToken tok2(db, "Reusable.uses", + IntervalIntDomain(11, 13), IntervalIntDomain(15, 17), + IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + + ReusableToken tok3(db, "Reusable.uses", + IntervalIntDomain(11, 16), IntervalIntDomain(18, 19), + IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + + CPPUNIT_ASSERT(ce->propagate()); + + CPPUNIT_ASSERT(reusable.hasTokensToOrder()); + std::vector flawedInstants; + reusable.getFlawedInstants(flawedInstants); + CPPUNIT_ASSERT(flawedInstants.size() == 5); + CPPUNIT_ASSERT(flawedInstants[0]->getTime() == 11); + + TiXmlElement dummy(""); + ResourceThreatDecisionPoint dp1(client, flawedInstants[0], dummy); + + dp1.initialize(); + + CPPUNIT_ASSERT(dp1.getChoices().size() == 8); + + std::string noFilter = ""; + TiXmlElement* noFilterXml = initXml(noFilter); + ResourceThreatDecisionPoint dp2(client, flawedInstants[0], *noFilterXml); + dp2.initialize(); + CPPUNIT_ASSERT(dp2.getChoices().size() == 8); + + std::string predFilter = ""; + TiXmlElement* predFilterXml = initXml(predFilter); + ResourceThreatDecisionPoint dp3(client, flawedInstants[0], *predFilterXml); + dp3.initialize(); + CPPUNIT_ASSERT(dp3.getChoices().size() == 3); + CPPUNIT_ASSERT(dp3.getChoices()[0].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp3.getChoices()[0].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp3.getChoices()[1].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp3.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp3.getChoices()[2].first->time() == tok2.end()); + CPPUNIT_ASSERT(dp3.getChoices()[2].second->time() == tok3.start()); + + std::string sucFilter = ""; + TiXmlElement* sucFilterXml = initXml(sucFilter); + ResourceThreatDecisionPoint dp4(client, flawedInstants[0], *sucFilterXml); + dp4.initialize(); + CPPUNIT_ASSERT(dp4.getChoices().size() == 5); + CPPUNIT_ASSERT(dp4.getChoices()[0].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp4.getChoices()[0].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp4.getChoices()[1].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp4.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp4.getChoices()[2].first->time() == tok2.start()); + CPPUNIT_ASSERT(dp4.getChoices()[2].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp4.getChoices()[3].first->time() == tok2.end()); + CPPUNIT_ASSERT(dp4.getChoices()[3].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp4.getChoices()[4].first->time() == tok3.start()); + CPPUNIT_ASSERT(dp4.getChoices()[4].second->time() == tok2.start()); + + std::string bothFilter = ""; + TiXmlElement* bothFilterXml = initXml(bothFilter); + ResourceThreatDecisionPoint dp5(client, flawedInstants[0], *bothFilterXml); + dp5.initialize(); + CPPUNIT_ASSERT(dp5.getChoices().size() == 3); + CPPUNIT_ASSERT(dp5.getChoices()[0].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp5.getChoices()[0].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp5.getChoices()[1].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp5.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp5.getChoices()[2].first->time() == tok2.end()); + CPPUNIT_ASSERT(dp5.getChoices()[2].second->time() == tok3.start()); + + //the combination of ascendingKeyPredecessor and ascendingKeySuccessor have already been tested by now + + std::string earliestPred = ""; + TiXmlElement* earliestPredXml = initXml(earliestPred); + ResourceThreatDecisionPoint dp6(client, flawedInstants[0], *earliestPredXml); + dp6.initialize(); + CPPUNIT_ASSERT(dp6.getChoices().size() == 3); + CPPUNIT_ASSERT(dp6.getChoices()[0].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp6.getChoices()[0].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp6.getChoices()[1].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp6.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp6.getChoices()[2].first->time() == tok2.end()); + CPPUNIT_ASSERT(dp6.getChoices()[2].second->time() == tok3.start()); + + std::string latestPred = ""; + TiXmlElement* latestPredXml = initXml(latestPred); + ResourceThreatDecisionPoint dp7(client, flawedInstants[0], *latestPredXml); + dp7.initialize(); + CPPUNIT_ASSERT(dp7.getChoices().size() == 3); + CPPUNIT_ASSERT(dp7.getChoices()[0].first->time() == tok2.end()); + CPPUNIT_ASSERT(dp7.getChoices()[0].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp7.getChoices()[1].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp7.getChoices()[1].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp7.getChoices()[2].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp7.getChoices()[2].second->time() == tok3.start()); + + + std::string longestPred = ""; + TiXmlElement* longestPredXml = initXml(longestPred); + ResourceThreatDecisionPoint dp8(client, flawedInstants[0], *longestPredXml); + dp8.initialize(); + CPPUNIT_ASSERT(dp8.getChoices().size() == 5); + CPPUNIT_ASSERT(dp8.getChoices()[0].first->time() == tok3.start()); + + + std::string shortestPred = ""; + TiXmlElement* shortestPredXml = initXml(shortestPred); + ResourceThreatDecisionPoint dp9(client, flawedInstants[0], *shortestPredXml); + dp9.initialize(); + CPPUNIT_ASSERT(dp9.getChoices().size() == 3); + CPPUNIT_ASSERT(dp9.getChoices()[0].first->time() == tok2.start() || + dp9.getChoices()[0].first->time() == tok1.end()); + + std::string descendingKeyPred = ""; + TiXmlElement* descendingKeyPredXml = initXml(descendingKeyPred); + ResourceThreatDecisionPoint dp10(client, flawedInstants[0], *descendingKeyPredXml); + dp10.initialize(); + CPPUNIT_ASSERT(dp10.getChoices().size() == 3); + CPPUNIT_ASSERT(dp10.getChoices()[0].first->time() == tok2.end()); + CPPUNIT_ASSERT(dp10.getChoices()[1].first->time() == tok1.end()); + + + std::string earliestSucc = ""; + TiXmlElement* earliestSuccXml = initXml(earliestSucc); + ResourceThreatDecisionPoint dp11(client, flawedInstants[0], *earliestSuccXml); + dp11.initialize(); + CPPUNIT_ASSERT(dp11.getChoices().size() == 3); + CPPUNIT_ASSERT(dp11.getChoices()[0].second->time() == tok2.start() || + dp11.getChoices()[0].second->time() == tok3.start()); + + std::string latestSucc = ""; + TiXmlElement* latestSuccXml = initXml(latestSucc); + ResourceThreatDecisionPoint dp12(client, flawedInstants[0], *latestSuccXml); + dp12.initialize(); + CPPUNIT_ASSERT(dp12.getChoices().size() == 3); + CPPUNIT_ASSERT(dp12.getChoices()[0].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp12.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp12.getChoices()[2].second->time() == tok2.start()); + + + std::string longestSucc = ""; + TiXmlElement* longestSuccXml = initXml(longestSucc); + ResourceThreatDecisionPoint dp13(client, flawedInstants[0], *longestSuccXml); + dp13.initialize(); + CPPUNIT_ASSERT(dp13.getChoices().size() == 3); + CPPUNIT_ASSERT(dp13.getChoices()[0].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp13.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp13.getChoices()[2].second->time() == tok2.start()); + + std::string shortestSucc = ""; + TiXmlElement* shortestSuccXml = initXml(shortestSucc); + ResourceThreatDecisionPoint dp14(client, flawedInstants[0], *shortestSuccXml); + dp14.initialize(); + CPPUNIT_ASSERT(dp14.getChoices().size() == 3); + CPPUNIT_ASSERT(dp14.getChoices()[0].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp14.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp14.getChoices()[2].second->time() == tok3.start()); + + std::string descendingKeySucc = ""; + TiXmlElement* descendingKeySuccXml = initXml(descendingKeySucc); + ResourceThreatDecisionPoint dp15(client, flawedInstants[0], *descendingKeySuccXml); + dp15.initialize(); + CPPUNIT_ASSERT(dp15.getChoices().size() == 3); + CPPUNIT_ASSERT(dp15.getChoices()[0].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp15.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp15.getChoices()[2].second->time() == tok2.start()); + + + std::string ascendingKeySucc = ""; + TiXmlElement* ascendingKeySuccXml = initXml(ascendingKeySucc); + ResourceThreatDecisionPoint dp16(client, flawedInstants[0], *ascendingKeySuccXml); + dp16.initialize(); + CPPUNIT_ASSERT(dp16.getChoices().size() == 3); + CPPUNIT_ASSERT(dp16.getChoices()[0].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp16.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp16.getChoices()[2].second->time() == tok3.start()); + + + std::string leastImpact = ""; + TiXmlElement* leastImpactXml = initXml(leastImpact); + ResourceThreatDecisionPoint dp17(client, flawedInstants[0], *leastImpactXml); + dp17.initialize(); + CPPUNIT_ASSERT(dp17.getChoices().size() == 5); + CPPUNIT_ASSERT(dp17.getChoices()[0].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp17.getChoices()[0].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp17.getChoices()[1].first->time() == tok1.end()); + CPPUNIT_ASSERT(dp17.getChoices()[1].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp17.getChoices()[2].first->time() == tok2.start()); + CPPUNIT_ASSERT(dp17.getChoices()[2].second->time() == tok3.start()); + CPPUNIT_ASSERT(dp17.getChoices()[3].first->time() == tok3.start()); + CPPUNIT_ASSERT(dp17.getChoices()[3].second->time() == tok2.start()); + CPPUNIT_ASSERT(dp17.getChoices()[4].first->time() == tok2.end()); + CPPUNIT_ASSERT(dp17.getChoices()[4].second->time() == tok3.start()); + + std::string precedesOnly = ""; + TiXmlElement* precedesOnlyXml = initXml(precedesOnly); + ResourceThreatDecisionPoint dp18(client, flawedInstants[0], *precedesOnlyXml); + dp18.initialize(); + ConstraintNameListener* nameListener = new ConstraintNameListener(dp18.getChoices()[0].first->time()); + dp18.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "precedes"); + dp18.undo(); + delete nameListener; + ce->propagate(); + nameListener = new ConstraintNameListener(dp18.getChoices()[1].first->time()); + dp18.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "precedes"); + dp18.undo(); + ce->propagate(); + delete nameListener; + + std::string concurrentOnly = ""; + TiXmlElement* concurrentOnlyXml = initXml(concurrentOnly); + ResourceThreatDecisionPoint dp19(client, flawedInstants[0], *concurrentOnlyXml); + dp19.initialize(); + nameListener = new ConstraintNameListener(dp19.getChoices()[0].first->time()); + dp19.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "concurrent"); + dp19.undo(); + delete nameListener; + ce->propagate(); + nameListener = new ConstraintNameListener(dp19.getChoices()[1].first->time()); + dp19.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "concurrent"); + dp19.undo(); + ce->propagate(); + delete nameListener; + + //pair first has already been implicitly tested and constraint first is necessary to make this easy anyway, so it'll get tested as well. + + std::string precedesFirst = ""; + TiXmlElement* precedesFirstXml = initXml(precedesFirst); + ResourceThreatDecisionPoint dp20(client, flawedInstants[0], *precedesFirstXml); + dp20.initialize(); + nameListener = new ConstraintNameListener(dp20.getChoices()[0].first->time()); + dp20.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "precedes"); + dp20.undo(); + ce->propagate(); + dp20.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "concurrent"); + dp20.undo(); + ce->propagate(); + delete nameListener; + //step once more to test creating a constraint on the next choice + nameListener = new ConstraintNameListener(dp20.getChoices()[1].first->time()); + dp20.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "precedes"); + dp20.undo(); + ce->propagate(); + delete nameListener; + + std::string concurrentFirst = ""; + TiXmlElement* concurrentFirstXml = initXml(concurrentFirst); + ResourceThreatDecisionPoint dp21(client, flawedInstants[0], *concurrentFirstXml); + dp21.initialize(); + nameListener = new ConstraintNameListener(dp21.getChoices()[0].first->time()); + dp21.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "concurrent"); + dp21.undo(); + ce->propagate(); + dp21.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "precedes"); + dp21.undo(); + ce->propagate(); + delete nameListener; + //step once more to test creating a constraint on the next choice + nameListener = new ConstraintNameListener(dp21.getChoices()[1].first->time()); + dp21.execute(); + ce->propagate(); + CPPUNIT_ASSERT(nameListener->getName() == "concurrent"); + dp21.undo(); + ce->propagate(); + delete nameListener; + + delete concurrentFirstXml; + delete precedesFirstXml; + delete concurrentOnlyXml; + delete precedesOnlyXml; + delete leastImpactXml; + delete ascendingKeySuccXml; + delete descendingKeySuccXml; + delete shortestSuccXml; + delete longestSuccXml; + delete latestSuccXml; + delete earliestSuccXml; + delete descendingKeyPredXml; + delete shortestPredXml; + delete longestPredXml; + delete latestPredXml; + delete earliestPredXml; + delete bothFilterXml; + delete sucFilterXml; + delete predFilterXml; + delete noFilterXml; + return true; + } - static bool testResourceThreatManager() { - - RESOURCE_DEFAULT_SETUP(ceObj, dbObj, false); - - PlanDatabaseId db = dbObj.getId(); - ConstraintEngineId ce = ceObj.getId(); - DbClientId client = db->getClient(); - - Reusable reusable(db, "Reusable", "myReusable", "ClosedWorldFVDetector", "IncrementalFlowProfile", 1, 1, 0); - - ReusableToken tok1(db, "Reusable.uses", IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); - - ReusableToken tok2(db, "Reusable.uses", IntervalIntDomain(11, 13), IntervalIntDomain(15, 17), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); - - ReusableToken tok3(db, "Reusable.uses", IntervalIntDomain(11, 16), IntervalIntDomain(18, 19), IntervalIntDomain(1, PLUS_INFINITY), - IntervalDomain(1.0, 1.0), "myReusable"); - - CPPUNIT_ASSERT(ce->propagate()); - - std::vector instants; - reusable.getFlawedInstants(instants); - - LabelStr explanation; - std::string earliest = ""; - TiXmlElement* earliestXml = initXml(earliest); - ResourceThreatManager earliestManager(*earliestXml); - earliestManager.initialize(*earliestXml, db, SOLVERS::ContextId::noId(), SOLVERS::FlawManagerId::noId()); - CPPUNIT_ASSERT(earliestManager.betterThan(instants[0], instants[1], explanation)); //these are identical except for the time - CPPUNIT_ASSERT(earliestManager.betterThan(instants[1], instants[2], explanation)); //these have different levels - CPPUNIT_ASSERT(!earliestManager.betterThan(instants[0], instants[0], explanation)); - - std::string latest = ""; - TiXmlElement* latestXml = initXml(latest); - ResourceThreatManager latestManager(*latestXml); - latestManager.initialize(*latestXml, db, SOLVERS::ContextId::noId(), SOLVERS::FlawManagerId::noId()); - CPPUNIT_ASSERT(latestManager.betterThan(instants[3], instants[2], explanation)); - CPPUNIT_ASSERT(latestManager.betterThan(instants[2], instants[1], explanation)); - CPPUNIT_ASSERT(!latestManager.betterThan(instants[0], instants[0], explanation)); - - std::string most = ""; - TiXmlElement* mostXml = initXml(most); - ResourceThreatManager mostManager(*mostXml); - mostManager.initialize(*mostXml, db, SOLVERS::ContextId::noId(), SOLVERS::FlawManagerId::noId()); - CPPUNIT_ASSERT(mostManager.betterThan(instants[0], instants[1], explanation)); - CPPUNIT_ASSERT(!mostManager.betterThan(instants[1], instants[0], explanation)); - CPPUNIT_ASSERT(!mostManager.betterThan(instants[1], instants[2], explanation)); - CPPUNIT_ASSERT(!mostManager.betterThan(instants[3], instants[4], explanation)); - - std::string least = ""; - TiXmlElement* leastXml = initXml(least); - ResourceThreatManager leastManager(*leastXml); - leastManager.initialize(*leastXml, db, SOLVERS::ContextId::noId(), SOLVERS::FlawManagerId::noId()); - CPPUNIT_ASSERT(!leastManager.betterThan(instants[0], instants[1], explanation)); - CPPUNIT_ASSERT(leastManager.betterThan(instants[1], instants[0], explanation)); - CPPUNIT_ASSERT(!leastManager.betterThan(instants[3], instants[4], explanation)); - CPPUNIT_ASSERT(!leastManager.betterThan(instants[4], instants[3], explanation)); - - //can't test upper/lower with reusables - delete leastXml; - delete mostXml; - delete latestXml; - delete earliestXml; - return true; - } + + static bool testResourceThreatManager() { + + RESOURCE_DEFAULT_SETUP(ceObj, dbObj, false); + + PlanDatabaseId db = dbObj.getId(); + ConstraintEngineId ce = ceObj.getId(); + + Reusable reusable(db, "Reusable", "myReusable", "ClosedWorldFVDetector", "IncrementalFlowProfile", 1, 1, 0); + + ReusableToken tok1(db, "Reusable.uses", IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + + ReusableToken tok2(db, "Reusable.uses", IntervalIntDomain(11, 13), IntervalIntDomain(15, 17), IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + + ReusableToken tok3(db, "Reusable.uses", IntervalIntDomain(11, 16), IntervalIntDomain(18, 19), IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + + CPPUNIT_ASSERT(ce->propagate()); + + std::vector instants; + reusable.getFlawedInstants(instants); + + std::string explanation; + std::string earliest = ""; + TiXmlElement* earliestXml = initXml(earliest); + ResourceThreatManager earliestManager(*earliestXml); + SOLVERS::Context ctx("foo"); + earliestManager.initialize(*earliestXml, db, ctx.getId(), SOLVERS::FlawManagerId::noId()); + CPPUNIT_ASSERT(earliestManager.betterThan(instants[0], instants[1], explanation)); //these are identical except for the time + CPPUNIT_ASSERT(earliestManager.betterThan(instants[1], instants[2], explanation)); //these have different levels + CPPUNIT_ASSERT(!earliestManager.betterThan(instants[0], instants[0], explanation)); + + std::string latest = ""; + TiXmlElement* latestXml = initXml(latest); + ResourceThreatManager latestManager(*latestXml); + latestManager.initialize(*latestXml, db, ctx.getId(), SOLVERS::FlawManagerId::noId()); + CPPUNIT_ASSERT(latestManager.betterThan(instants[3], instants[2], explanation)); + CPPUNIT_ASSERT(latestManager.betterThan(instants[2], instants[1], explanation)); + CPPUNIT_ASSERT(!latestManager.betterThan(instants[0], instants[0], explanation)); + + std::string most = ""; + TiXmlElement* mostXml = initXml(most); + ResourceThreatManager mostManager(*mostXml); + mostManager.initialize(*mostXml, db, ctx.getId(), SOLVERS::FlawManagerId::noId()); + CPPUNIT_ASSERT(mostManager.betterThan(instants[0], instants[1], explanation)); + CPPUNIT_ASSERT(!mostManager.betterThan(instants[1], instants[0], explanation)); + CPPUNIT_ASSERT(!mostManager.betterThan(instants[1], instants[2], explanation)); + CPPUNIT_ASSERT(!mostManager.betterThan(instants[3], instants[4], explanation)); + + std::string least = ""; + TiXmlElement* leastXml = initXml(least); + ResourceThreatManager leastManager(*leastXml); + leastManager.initialize(*leastXml, db, ctx.getId(), SOLVERS::FlawManagerId::noId()); + CPPUNIT_ASSERT(!leastManager.betterThan(instants[0], instants[1], explanation)); + CPPUNIT_ASSERT(leastManager.betterThan(instants[1], instants[0], explanation)); + CPPUNIT_ASSERT(!leastManager.betterThan(instants[3], instants[4], explanation)); + CPPUNIT_ASSERT(!leastManager.betterThan(instants[4], instants[3], explanation)); + + //can't test upper/lower with reusables + delete leastXml; + delete mostXml; + delete latestXml; + delete earliestXml; + return true; + } + + static bool testResourceThreatManagerNoMoreFlaws() { + RESOURCE_DEFAULT_SETUP(ceObj, dbObj, false); + + PlanDatabaseId db = dbObj.getId(); + ConstraintEngineId ce = ceObj.getId(); + DbClientId client = db->getClient(); + + Reusable reusable(db, "Reusable", "myReusable", "ClosedWorldFVDetector", "IncrementalFlowProfile", 1, 1, 0); + + ReusableToken tok1(db, "Reusable.uses", + IntervalIntDomain(1, 3), IntervalIntDomain(10, 12), + IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + + ReusableToken tok2(db, "Reusable.uses", + IntervalIntDomain(11, 13), IntervalIntDomain(15, 17), + IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + CPPUNIT_ASSERT(ce->propagate()); + + + std::string earliest = ""; + TiXmlElement* earliestXml = initXml(earliest); + ResourceThreatManager earliestManager(*earliestXml); + SOLVERS::Context ctx("foo"); + earliestManager.initialize(*earliestXml, db, ctx.getId(), SOLVERS::FlawManagerId::noId()); + + CPPUNIT_ASSERT(!earliestManager.noMoreFlaws()); + client->constrain(reusable.getId(), tok1.getId(), tok2.getId()); + CPPUNIT_ASSERT(ce->propagate()); + CPPUNIT_ASSERT(earliestManager.noMoreFlaws()); + + ReusableToken tok3(db, "Reusable.uses", + IntervalIntDomain(16, 18), IntervalIntDomain(20, 30), + IntervalIntDomain(1, PLUS_INFINITY), + IntervalDomain(1.0, 1.0), "myReusable"); + CPPUNIT_ASSERT(ce->propagate()); + + CPPUNIT_ASSERT(!earliestManager.noMoreFlaws()); + delete earliestXml; + return true; + } }; void ResourceModuleTests::cppSetup(void) diff --git a/src/PLASMA/RulesEngine/CMakeLists.txt b/src/PLASMA/RulesEngine/CMakeLists.txt index 878f54752..558de6f74 100644 --- a/src/PLASMA/RulesEngine/CMakeLists.txt +++ b/src/PLASMA/RulesEngine/CMakeLists.txt @@ -1,5 +1,6 @@ include(EuropaModule) set(internal_dependencies PlanDatabase ConstraintEngine Utils TinyXml) +# set(internal_dependencies PlanDatabase) set(root_sources ModuleRulesEngine.cc) set(base_sources ProxyVariableRelation.cc Rule.cc RuleInstance.cc RuleVariableListener.cc RulesEngine.cc RulesEngineListener.cc) set(component_sources "") diff --git a/src/PLASMA/RulesEngine/ModuleRulesEngine.cc b/src/PLASMA/RulesEngine/ModuleRulesEngine.cc index c3c3ff542..8844ea605 100644 --- a/src/PLASMA/RulesEngine/ModuleRulesEngine.cc +++ b/src/PLASMA/RulesEngine/ModuleRulesEngine.cc @@ -7,6 +7,9 @@ #include "RuleVariableListener.hh" #include "Constraints.hh" #include "Propagators.hh" +#include "CESchema.hh" + +#include namespace EUROPA { @@ -27,30 +30,29 @@ namespace EUROPA { { } - void ModuleRulesEngine::initialize(EngineId engine) - { - PlanDatabase* pdb = (PlanDatabase*)engine->getComponent("PlanDatabase"); - RuleSchema* rs = new RuleSchema(); - engine->addComponent("RuleSchema",rs); - RulesEngine* re = new RulesEngine(rs->getId(),pdb->getId()); - engine->addComponent("RulesEngine",re); - - // Allocate an instance of Default Propagator to handle rule related constraint propagation. - // Will be cleaned up automatically by the ConstraintEngine - new DefaultPropagator("RulesEngine", pdb->getConstraintEngine(), SYSTEM_PRIORITY); - - CESchema* ces = (CESchema*)engine->getComponent("CESchema"); - REGISTER_SYSTEM_CONSTRAINT(ces,ProxyVariableRelation, "proxyRelation", "Default"); - REGISTER_SYSTEM_CONSTRAINT(ces,RuleVariableListener, RuleVariableListener::CONSTRAINT_NAME(),"Default"); - REGISTER_SYSTEM_CONSTRAINT(ces,LockConstraint, "filterLock", "RulesEngine"); - } - - void ModuleRulesEngine::uninitialize(EngineId engine) - { - RulesEngine* re = (RulesEngine*)engine->removeComponent("RulesEngine"); - delete re; +void ModuleRulesEngine::initialize(EngineId engine) { + PlanDatabase* pdb = + boost::polymorphic_cast(engine->getComponent("PlanDatabase")); + RuleSchema* rs = new RuleSchema(); + engine->addComponent("RuleSchema",rs); + RulesEngine* re = new RulesEngine(rs->getId(),pdb->getId()); + engine->addComponent("RulesEngine",re); + + // Allocate an instance of Default Propagator to handle rule related constraint propagation. + // Will be cleaned up automatically by the ConstraintEngine + new DefaultPropagator("RulesEngine", pdb->getConstraintEngine(), SYSTEM_PRIORITY); + + CESchema* ces = boost::polymorphic_cast(engine->getComponent("CESchema")); + REGISTER_SYSTEM_CONSTRAINT(ces,ProxyVariableRelation, "proxyRelation", "Default"); + REGISTER_SYSTEM_CONSTRAINT(ces,RuleVariableListener, RuleVariableListener::CONSTRAINT_NAME(),"Default"); + REGISTER_SYSTEM_CONSTRAINT(ces,LockConstraint, "filterLock", "RulesEngine"); +} - RuleSchema* rs = (RuleSchema*)engine->removeComponent("RuleSchema"); - delete rs; - } +void ModuleRulesEngine::uninitialize(EngineId engine) { + RulesEngine* re = boost::polymorphic_cast(engine->removeComponent("RulesEngine")); + delete re; + + RuleSchema* rs = boost::polymorphic_cast(engine->removeComponent("RuleSchema")); + delete rs; +} } diff --git a/src/PLASMA/RulesEngine/ModuleRulesEngine.hh b/src/PLASMA/RulesEngine/ModuleRulesEngine.hh index e56f8a635..418a46eae 100644 --- a/src/PLASMA/RulesEngine/ModuleRulesEngine.hh +++ b/src/PLASMA/RulesEngine/ModuleRulesEngine.hh @@ -1,6 +1,6 @@ -#ifndef _H_ModuleRulesEngine -#define _H_ModuleRulesEngine +#ifndef H_ModuleRulesEngine +#define H_ModuleRulesEngine #include "Module.hh" @@ -29,4 +29,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_ModuleRulesEngine */ +#endif /* #ifndef H_ModuleRulesEngine */ diff --git a/src/PLASMA/RulesEngine/RulesEngineDefs.hh b/src/PLASMA/RulesEngine/RulesEngineDefs.hh index 93719910a..8e4087ac7 100644 --- a/src/PLASMA/RulesEngine/RulesEngineDefs.hh +++ b/src/PLASMA/RulesEngine/RulesEngineDefs.hh @@ -1,5 +1,5 @@ -#ifndef _H_RulesEngineDefs -#define _H_RulesEngineDefs +#ifndef H_RulesEngineDefs +#define H_RulesEngineDefs #include "PlanDatabaseDefs.hh" diff --git a/src/PLASMA/RulesEngine/base/ProxyVariableRelation.cc b/src/PLASMA/RulesEngine/base/ProxyVariableRelation.cc index fc6fc55af..31e01c8ae 100644 --- a/src/PLASMA/RulesEngine/base/ProxyVariableRelation.cc +++ b/src/PLASMA/RulesEngine/base/ProxyVariableRelation.cc @@ -3,24 +3,30 @@ namespace EUROPA { - ProxyVariableRelation::ProxyVariableRelation(const ConstrainedVariableId& objectVar, - const ConstrainedVariableId& proxyVar, + ProxyVariableRelation::ProxyVariableRelation(const ConstrainedVariableId objectVar, + const ConstrainedVariableId proxyVar, const std::vector& path) : Constraint("proxyRelation", "Default", objectVar->getConstraintEngine(), makeScope(objectVar, proxyVar)), m_objectDomain(static_cast(getCurrentDomain(objectVar))), m_proxyDomain(static_cast(getCurrentDomain(proxyVar))), m_path(path), - m_sourceConstraintKey(0){ + m_autoSpecified(false), + m_sourceConstraintKey(0), + m_sourceConstraint() { checkError(getScope().size() == ARG_COUNT, toString()); } - ProxyVariableRelation::ProxyVariableRelation(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + ProxyVariableRelation::ProxyVariableRelation(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables), m_objectDomain(static_cast(getCurrentDomain(variables[0]))), - m_proxyDomain(static_cast(getCurrentDomain(variables[1]))){ + m_proxyDomain(static_cast(getCurrentDomain(variables[1]))), + m_path(), + m_autoSpecified(false), + m_sourceConstraintKey(), + m_sourceConstraint() { checkError(getScope().size() == ARG_COUNT, toString()); } @@ -65,8 +71,8 @@ namespace EUROPA { } - bool ProxyVariableRelation::canIgnore(const ConstrainedVariableId& variable, - int argIndex, + bool ProxyVariableRelation::canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType){ // If the object variable is specified to a singleton, and the proxy variable can be specified, then // we will force the proxy to be set to the field value of the given object @@ -104,11 +110,12 @@ namespace EUROPA { return false; } - void ProxyVariableRelation::setSource(const ConstraintId& sourceConstraint){ - checkError(sourceConstraint->getName() == LabelStr("proxyRelation"), sourceConstraint->toString()); - checkError(m_path.empty(), "Should be empty when setting up the source from " << sourceConstraint->toString()); - m_sourceConstraint = sourceConstraint; - } +void ProxyVariableRelation::setSource(const ConstraintId sourceConstraint) { + checkError(sourceConstraint->getName() == "proxyRelation", + sourceConstraint->toString()); + checkError(m_path.empty(), "Should be empty when setting up the source from " << sourceConstraint->toString()); + m_sourceConstraint = sourceConstraint; +} /** * In the lifetime of a constraint, this should only be called at most once. It is used to lazily copy a source path under conditions @@ -119,7 +126,8 @@ namespace EUROPA { */ void ProxyVariableRelation::updatePathFromSource(){ if(m_sourceConstraint.isId() && m_sourceConstraintKey != m_sourceConstraint->getKey()){ - ProxyVariableRelation* proxyConstraint = (ProxyVariableRelation*) m_sourceConstraint; + ProxyVariableRelation* proxyConstraint = + id_cast(m_sourceConstraint); m_path = proxyConstraint->m_path; m_sourceConstraint = ConstraintId::noId(); } diff --git a/src/PLASMA/RulesEngine/base/ProxyVariableRelation.hh b/src/PLASMA/RulesEngine/base/ProxyVariableRelation.hh index 231981c4e..e974d9f7a 100644 --- a/src/PLASMA/RulesEngine/base/ProxyVariableRelation.hh +++ b/src/PLASMA/RulesEngine/base/ProxyVariableRelation.hh @@ -16,16 +16,16 @@ namespace EUROPA { /** * @brief Constructor used for initial allocation */ - ProxyVariableRelation(const ConstrainedVariableId& objectVar, - const ConstrainedVariableId& proxyVar, + ProxyVariableRelation(const ConstrainedVariableId objectVar, + const ConstrainedVariableId proxyVar, const std::vector& path); /** * @brief Standard constructor to support copying */ - ProxyVariableRelation(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + ProxyVariableRelation(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); private: @@ -35,14 +35,14 @@ namespace EUROPA { /** * @brief Used to only track set and reset events. Will not be subject to propagation */ - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); /** * @brief Required to support copying. Will assign the source constraint id, triggering a path update. */ - void setSource(const ConstraintId& sourceConstraint); + void setSource(const ConstraintId sourceConstraint); /** * @brief Used to handle lazy copy if we migrate a constraint diff --git a/src/PLASMA/RulesEngine/base/Rule.cc b/src/PLASMA/RulesEngine/base/Rule.cc index 80ae3797e..adfea132d 100644 --- a/src/PLASMA/RulesEngine/base/Rule.cc +++ b/src/PLASMA/RulesEngine/base/Rule.cc @@ -8,10 +8,8 @@ namespace EUROPA { - RuleSchema::RuleSchema() - : m_id(this) - { - } +RuleSchema::RuleSchema() + : m_id(this), m_rulesByName() {} RuleSchema::~RuleSchema() { @@ -19,59 +17,50 @@ namespace EUROPA { m_id.remove(); } - const RuleSchemaId& RuleSchema::getId() const {return m_id;} - - void RuleSchema::registerRule(const RuleId& rule) - { - m_rulesByName.insert(std::make_pair(rule->getName().getKey(), rule->getId())); - } + const RuleSchemaId RuleSchema::getId() const {return m_id;} - void RuleSchema::getRules(const PlanDatabaseId& pdb, const LabelStr& name, std::vector& results) - { - const SchemaId& schema = pdb->getSchema(); +void RuleSchema::registerRule(const RuleId rule) { + m_rulesByName.insert(std::make_pair(rule->getName(), rule->getId())); +} - // If the predicate is defined on the parent class, then - // call this function recursively. do it first since predicates for super-classes should be executed first - if(schema->hasParent(name)) - getRules(pdb,schema->getParent(name), results); +void RuleSchema::getRules(const PlanDatabaseId pdb, const std::string& name, + std::vector& results) { + const SchemaId schema = pdb->getSchema(); - std::multimap::const_iterator it = m_rulesByName.find(name.getKey()); - while(it != m_rulesByName.end()){ - RuleId rule = it->second; - check_error(rule.isValid()); + // If the predicate is defined on the parent class, then + // call this function recursively. do it first since predicates for super-classes should be executed first + if(schema->hasParent(name)) + getRules(pdb,schema->getParent(name), results); - if(rule->getName() != name) - break; + std::multimap::const_iterator it = m_rulesByName.find(name); + while(it != m_rulesByName.end()){ + RuleId rule = it->second; + check_error(rule.isValid()); - results.push_back(rule); - ++it; - } - } + if(rule->getName() != name) + break; - const std::multimap& RuleSchema::getRules() - { - return m_rulesByName; - } + results.push_back(rule); + ++it; + } +} - void RuleSchema::purgeAll() - { - std::multimap& rules = m_rulesByName; - for(std::multimap::const_iterator it = rules.begin(); it != rules.end(); ++it){ - RuleId rule = it->second; - delete (Rule*) rule; - } +const std::multimap& RuleSchema::getRules() { + return m_rulesByName; +} - rules.clear(); - } +void RuleSchema::purgeAll() { + cleanup(m_rulesByName); +} - Rule::Rule(const LabelStr& name) + Rule::Rule(const std::string& name) : m_id(this) , m_name(name) , m_source("noSrc") { } - Rule::Rule(const LabelStr &name, const LabelStr &source) + Rule::Rule(const std::string &name, const std::string &source) : m_id(this) , m_name(name) , m_source(source) @@ -84,11 +73,11 @@ namespace EUROPA { m_id.remove(); } - const RuleId& Rule::getId() const {return m_id;} + const RuleId Rule::getId() const {return m_id;} - const LabelStr& Rule::getName() const {return m_name;} + const std::string& Rule::getName() const {return m_name;} - const LabelStr& Rule::getSource() const {return m_source;} + const std::string& Rule::getSource() const {return m_source;} std::string Rule::toString() const { diff --git a/src/PLASMA/RulesEngine/base/Rule.hh b/src/PLASMA/RulesEngine/base/Rule.hh index 5d4e52f69..c29e0195c 100644 --- a/src/PLASMA/RulesEngine/base/Rule.hh +++ b/src/PLASMA/RulesEngine/base/Rule.hh @@ -1,5 +1,5 @@ -#ifndef _H_Rule -#define _H_Rule +#ifndef H_Rule +#define H_Rule /** @@ -11,7 +11,6 @@ */ #include "RulesEngineDefs.hh" -#include "LabelStr.hh" #include "Engine.hh" #include #include @@ -31,17 +30,17 @@ namespace EUROPA { /** * @brief Accessor */ - const RuleSchemaId& getId() const; + const RuleSchemaId getId() const; - void registerRule(const RuleId& rule); + void registerRule(const RuleId rule); /** * @brief Retrieve all registered rules for the given predicate. This will include rules * defined in ancestors of the current predicate also. */ - void getRules(const PlanDatabaseId& pdb, const LabelStr& predicate, std::vector& results); + void getRules(const PlanDatabaseId pdb, const std::string& predicate, std::vector& results); - const std::multimap& getRules(); + const std::multimap& getRules(); /** * @brief Delete all rules stored. @@ -50,7 +49,7 @@ namespace EUROPA { protected: RuleSchemaId m_id; /*!< Id for reference */ - std::multimap m_rulesByName; + std::multimap m_rulesByName; }; /** @@ -66,18 +65,18 @@ namespace EUROPA { /** * @brief Accessor */ - const RuleId& getId() const; + const RuleId getId() const; /** * @brief Accessor * @return The predicate for which this rule applies. */ - const LabelStr& getName() const; + const std::string& getName() const; - const LabelStr& getSource() const; + const std::string& getSource() const; - virtual RuleInstanceId createInstance(const TokenId& token, - const PlanDatabaseId& planDb, + virtual RuleInstanceId createInstance(const TokenId token, + const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const = 0; virtual std::string toString() const; @@ -87,12 +86,12 @@ namespace EUROPA { * @brief Constructor. * @param name A unique name for the rule. */ - Rule(const LabelStr& name); - Rule(const LabelStr& name, const LabelStr &src); + Rule(const std::string& name); + Rule(const std::string& name, const std::string &src); RuleId m_id; /*!< Id for reference */ - const LabelStr m_name; /*! Unique name for the rule */ - const LabelStr m_source; + const std::string m_name; /*! Unique name for the rule */ + const std::string m_source; }; } diff --git a/src/PLASMA/RulesEngine/base/RuleInstance.cc b/src/PLASMA/RulesEngine/base/RuleInstance.cc index 8e36fcff7..04bd0a379 100644 --- a/src/PLASMA/RulesEngine/base/RuleInstance.cc +++ b/src/PLASMA/RulesEngine/base/RuleInstance.cc @@ -13,70 +13,120 @@ #include "Domains.hh" #include +#include namespace EUROPA { - RuleInstance::RuleInstance(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb) - : m_id(this), m_rule(rule), m_token(token), m_planDb(planDb), m_rulesEngine(), m_guardDomain(0), m_isExecuted(false), m_isPositive(true){ - check_error(rule.isValid(), "Parent must be a valid rule id."); - check_error(isValid()); - commonInit(); - } +RuleInstance::RuleInstance(const RuleId rule, const TokenId token, + const PlanDatabaseId planDb) + : m_id(this), m_rule(rule), m_token(token), m_planDb(planDb), m_rulesEngine(), + m_parent(), m_guards(), + m_guardDomain(0), m_guardListener(), m_isExecuted(false), m_isPositive(true), + m_constraints(), m_childRules(), m_variables(), m_slaves(), + m_variablesByName(), m_slavesByName(), + m_constraintsByName() { + check_error(rule.isValid(), "Parent must be a valid rule id."); + check_error(isValid()); + commonInit(); +} - RuleInstance::RuleInstance(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb, - const std::vector& guards) - : m_id(this), m_rule(rule), m_token(token), m_planDb(planDb), m_rulesEngine(), m_guardDomain(0), m_isExecuted(false), m_isPositive(true){ - check_error(isValid()); - setGuard(guards); - commonInit(); - } +RuleInstance::RuleInstance(const RuleId rule, const TokenId token, + const PlanDatabaseId planDb, + const std::vector& guards) + : m_id(this), m_rule(rule), m_token(token), m_planDb(planDb), m_rulesEngine(), + m_parent(), m_guards(), + m_guardDomain(0), m_guardListener(), m_isExecuted(false), m_isPositive(true), + m_constraints(), m_childRules(), m_variables(), m_slaves(), m_variablesByName(), + m_slavesByName(), m_constraintsByName() { + check_error(isValid()); + setGuard(guards); + commonInit(); +} - RuleInstance::RuleInstance(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb, - const ConstrainedVariableId& guard, const Domain& domain) - : m_id(this), m_rule(rule), m_token(token), m_planDb(planDb), m_rulesEngine(), m_guardDomain(0), m_isExecuted(false), m_isPositive(true){ - check_error(isValid()); - setGuard(guard, domain); - commonInit(); - } +RuleInstance::RuleInstance(const RuleId rule, const TokenId token, + const PlanDatabaseId planDb, + const ConstrainedVariableId guard, const Domain& domain) + : m_id(this), m_rule(rule), m_token(token), m_planDb(planDb), m_rulesEngine(), + m_parent(), m_guards(), + m_guardDomain(0), m_guardListener(), m_isExecuted(false), m_isPositive(true), + m_constraints(), m_childRules(), m_variables(), m_slaves(), m_variablesByName(), + m_slavesByName(), m_constraintsByName() { + check_error(isValid()); + setGuard(guard, domain); + commonInit(); +} - /** - * @brief Constructor refers to parent for tokens, and variables that are accessible in its scope. - */ - RuleInstance::RuleInstance(const RuleInstanceId& parent, const std::vector& guards) +/** + * @brief Constructor refers to parent for tokens, and variables that are accessible in its scope. + */ +RuleInstance::RuleInstance(const RuleInstanceId parent, + const std::vector& guards) : m_id(this), m_rule(parent->getRule()), m_token(parent->getToken()), - m_planDb(parent->getPlanDatabase()),m_rulesEngine() , m_parent(parent), m_guardDomain(0), m_isExecuted(false), m_isPositive(true){ - check_error(isValid()); - setGuard(guards); - } + m_planDb(parent->getPlanDatabase()),m_rulesEngine() , m_parent(parent), + m_guards(), m_guardDomain(0), m_guardListener(), m_isExecuted(false), + m_isPositive(true), m_constraints(), m_childRules(), m_variables(), m_slaves(), + m_variablesByName(), m_slavesByName(), m_constraintsByName() { + check_error(isValid()); + setGuard(guards); +} - /** - * @brief Constructor refers to parent for tokens, and variables that are accessible in its scope. - */ - RuleInstance::RuleInstance(const RuleInstanceId& parent, const std::vector& guards, const bool positive) +/** + * @brief Constructor refers to parent for tokens, and variables that are accessible in its scope. + */ +RuleInstance::RuleInstance(const RuleInstanceId parent, + const std::vector& guards, + const bool positive) : m_id(this), m_rule(parent->getRule()), m_token(parent->getToken()), - m_planDb(parent->getPlanDatabase()),m_rulesEngine() , m_parent(parent), m_guardDomain(0), m_isExecuted(false), m_isPositive(positive){ - check_error(isValid()); - setGuard(guards); - } + m_planDb(parent->getPlanDatabase()), m_rulesEngine(), m_parent(parent), + m_guards(), m_guardDomain(0), m_guardListener(), m_isExecuted(false), + m_isPositive(positive), m_constraints(), m_childRules(), m_variables(), + m_slaves(), m_variablesByName(), m_slavesByName(), m_constraintsByName() { + check_error(isValid()); + setGuard(guards); +} - /** - * @brief Constructor refers to parent for tokens, and variables that are accessible in its scope. - */ - RuleInstance::RuleInstance(const RuleInstanceId& parent, const ConstrainedVariableId& guard, const Domain& domain) +/** + * @brief Constructor refers to parent for tokens, and variables that are accessible in its scope. + */ +RuleInstance::RuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId guard, const Domain& domain) : m_id(this), m_rule(parent->getRule()), m_token(parent->getToken()), - m_planDb(parent->getPlanDatabase()), m_rulesEngine(), m_parent(parent), m_guardDomain(0), m_isExecuted(false), m_isPositive(true){ - check_error(isValid()); - setGuard(guard, domain); - } + m_planDb(parent->getPlanDatabase()), m_rulesEngine(), m_parent(parent), + m_guards(), m_guardDomain(0), m_guardListener(), m_isExecuted(false), + m_isPositive(true), m_constraints(), m_childRules(), m_variables(), m_slaves(), + m_variablesByName(), m_slavesByName(), m_constraintsByName() { + check_error(isValid()); + setGuard(guard, domain); +} /** * @brief Constructor refers to parent for tokens, and variables that are accessible in its scope. */ - RuleInstance::RuleInstance(const RuleInstanceId& parent, const ConstrainedVariableId& guard, const Domain& domain, const bool positive) +RuleInstance::RuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId guard, + const Domain& domain, const bool positive) : m_id(this), m_rule(parent->getRule()), m_token(parent->getToken()), - m_planDb(parent->getPlanDatabase()), m_rulesEngine(), m_parent(parent), m_guardDomain(0), m_isExecuted(false), m_isPositive(positive){ - check_error(isValid()); - setGuard(guard, domain); - } + m_planDb(parent->getPlanDatabase()), m_rulesEngine(), m_parent(parent), + m_guards(), m_guardDomain(0), m_guardListener(), m_isExecuted(false), + m_isPositive(positive), m_constraints(), m_childRules(), m_variables(), + m_slaves(), m_variablesByName(), m_slavesByName(), m_constraintsByName() { + check_error(isValid()); + setGuard(guard, domain); +} + +RuleInstance::RuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId guard, + const Domain& domain, const bool positive, + const std::vector& guardComponents) + : m_id(this), m_rule(parent->getRule()), m_token(parent->getToken()), + m_planDb(parent->getPlanDatabase()), m_rulesEngine(), m_parent(parent), + m_guards(), m_guardDomain(0), m_guardListener(), m_isExecuted(false), + m_isPositive(positive), m_constraints(), m_childRules(), m_variables(), + m_slaves(), m_variablesByName(), m_slavesByName(), m_constraintsByName() { + check_error(isValid()); + setGuard(guard, domain, guardComponents); +} + + /** * @brief Clean up all the allocated elements @@ -112,13 +162,13 @@ namespace EUROPA { Entity::handleDiscard(); } - const RuleInstanceId& RuleInstance::getId() const{return m_id;} + const RuleInstanceId RuleInstance::getId() const{return m_id;} - const RuleId& RuleInstance::getRule() const {return m_rule;} + const RuleId RuleInstance::getRule() const {return m_rule;} - const PlanDatabaseId& RuleInstance::getPlanDatabase() const {return m_planDb;} + const PlanDatabaseId RuleInstance::getPlanDatabase() const {return m_planDb;} - const TokenId& RuleInstance::getToken() const {return m_token;} + const TokenId RuleInstance::getToken() const {return m_token;} const std::vector RuleInstance::getSlaves() const {return std::vector(m_slaves);} @@ -154,11 +204,21 @@ namespace EUROPA { */ bool RuleInstance::test(const std::vector& guards) const { checkError(m_rule.isValid(), m_rule); - debugMsg("RuleInstance:test", "Testing rule " << toString() << " for " << m_rule->getName().toString() << " from " << m_rule->getSource().toString()); + debugMsg("RuleInstance:test", + "Testing rule " << toString() << " for " << m_rule->getName() << + " from " << m_rule->getSource()); + if(m_guardDomain != 0) { // Case of explicit guard on a single variable debugMsg("RuleInstance:test", "Case of explicit guard on a single variable"); - checkError(guards.size() == 1, "Explicit guard on one variable only"); + // checkError(guards.size() == 1, "Explicit guard on one variable only"); bool result = false; + //+ 1 here because the first variable may be the one created implicitly for some + //testEQ or similar constraint and therefore may not be available to the planner + for(std::vector::const_iterator it = guards.begin() + 1; + it != guards.end(); ++it) { + if(!((*it)->isSpecified() || (*it)->baseDomain().isSingleton())) + return false; + } if(guards[0]->lastDomain().isSingleton()) { result = (m_guardDomain->isMember(guards[0]->lastDomain().getSingletonValue()) == m_isPositive); } @@ -185,7 +245,7 @@ namespace EUROPA { debugMsg("RuleInstance:test", "checking " << counter << " argument:" << guard->toString()); - if(!guard->lastDomain().isSingleton()){ + if(!(guard->isSpecified() || guard->baseDomain().isSingleton())){ debugMsg("RuleInstance:test", "argument " << counter << " is not specified " << guard->baseDomain().toString()); return false; } @@ -221,85 +281,85 @@ namespace EUROPA { /** * Delete any allocated elements due to firing, and reset status */ - void RuleInstance::undo(){ - check_error(isExecuted(), "Cannot undo a rule if not already executed."); - - // Clear child rules before destroying local entities. This is the reverse order of allocation - discardAll(m_childRules); - - if(!Entity::isPurging()){ - m_rulesEngine->notifyUndone(getId()); - // Clear slave lookups - m_slavesByName.clear(); - - // Clear variable lookups - may include token variables so we have to be careful - for(std::vector::const_iterator it = m_variables.begin(); it != m_variables.end(); ++it){ - ConstrainedVariableId var = *it; - checkError(var.isValid(), var); - edouble key = var->getName().getKey(); - m_variablesByName.erase(key); - } +void RuleInstance::undo() { + check_error(isExecuted(), "Cannot undo a rule if not already executed."); - // Copy collection to avoid iterator changing due to call back - std::vector constraints = m_constraints; - for(std::vector::const_iterator it = constraints.begin(); it != constraints.end(); ++it){ - ConstraintId constraint = *it; - checkError(constraint.isValid(), constraint); - - // Only discard constraints that are connected to the master since the master may persist after the rule has cleaned up - // but the constraints should not. If it is not connected to the master then it applies to local variables or slave variables. - // if a full roll-back of the rule occurs, slaves and local variables will be deleted, causing a delete of the attendant constraints. - // In the event that a slave persists, as cann occur when the master is removed through termination, then the constraints among - // remaining slaves should also be retained - if(connectedToToken(constraint, m_token)){ - debugMsg("RuleInstance:undo", "Removing connected constraint " << constraint->toLongString()); - constraint->discard(); - } - else // If we are not removing the constraint, we must remove the dependency on it - constraint->removeDependent(this); + // Clear child rules before destroying local entities. This is the reverse order of allocation + discardAll(m_childRules); + + if(!Entity::isPurging()){ + m_rulesEngine->notifyUndone(getId()); + // Clear slave lookups + m_slavesByName.clear(); + + // Clear variable lookups - may include token variables so we have to be careful + for(std::vector::const_iterator it = m_variables.begin(); it != m_variables.end(); ++it){ + ConstrainedVariableId var = *it; + checkError(var.isValid(), var); + m_variablesByName.erase(var->getName()); + } + + // Copy collection to avoid iterator changing due to call back + std::vector constraints = m_constraints; + for(std::vector::const_iterator it = constraints.begin(); it != constraints.end(); ++it){ + ConstraintId constr = *it; + checkError(constr.isValid(), constr); + + // Only discard constraints that are connected to the master since the master may persist after the rule has cleaned up + // but the constraints should not. If it is not connected to the master then it applies to local variables or slave variables. + // if a full roll-back of the rule occurs, slaves and local variables will be deleted, causing a delete of the attendant constraints. + // In the event that a slave persists, as cann occur when the master is removed through termination, then the constraints among + // remaining slaves should also be retained + if(connectedToToken(constr, m_token)){ + debugMsg("RuleInstance:undo", + "Removing connected constraint " << constr->toLongString()); + constr->discard(); } + else // If we are not removing the constraint, we must remove the dependency on it + constr->removeDependent(this); + } - m_constraints.clear(); + m_constraints.clear(); - // Clean up slaves if not already de-allocated. Copy collection to avoid call back changing the set of - // slaves - debugMsg("RuleInstance:undo", "Processing slaves"); - std::vector slaves = m_slaves; - for(std::vector::const_iterator it = slaves.begin(); it != slaves.end(); ++it){ - TokenId slave = *it; - checkError(slave.isValid(), slave); - TokenId master = slave->master(); - checkError(master.isNoId() || master == m_token, master); + // Clean up slaves if not already de-allocated. Copy collection to avoid call back changing the set of + // slaves + debugMsg("RuleInstance:undo", "Processing slaves"); + std::vector slaves = m_slaves; + for(std::vector::const_iterator it = slaves.begin(); it != slaves.end(); ++it){ + TokenId slave = *it; + checkError(slave.isValid(), slave); + TokenId master = slave->master(); + checkError(master.isNoId() || master == m_token, master); - // Remove the dependent since the slave MAY NOT GO AWAY - slave->removeDependent(this); + // Remove the dependent since the slave MAY NOT GO AWAY + slave->removeDependent(this); - if(master.isId()) - slave->removeMaster(m_token); - } + if(master.isId()) + slave->removeMaster(m_token); + } - m_slaves.clear(); + m_slaves.clear(); - // Cleanup local variables - debugMsg("RuleInstance:undo", "Cleaning up local variables"); + // Cleanup local variables + debugMsg("RuleInstance:undo", "Cleaning up local variables"); - for(std::vector::const_iterator it = m_variables.begin(); - it != m_variables.end(); - ++it){ - ConstrainedVariableId var = *it; - checkError(var.isValid(), var); - debugMsg("RuleInstance:undo", "Removing " << var->toLongString()); - getToken()->removeLocalVariable(var); + for(std::vector::const_iterator it = m_variables.begin(); + it != m_variables.end(); + ++it){ + ConstrainedVariableId var = *it; + checkError(var.isValid(), var); + debugMsg("RuleInstance:undo", "Removing " << var->toLongString()); + getToken()->removeLocalVariable(var); - if(var->parent() == m_id) - var->discard(); + if(var->parent() == m_id) + var->discard(); - checkError(var.isValid(), var << " should still be va;id after a discard."); - } - m_variables.clear(); - m_isExecuted = false; + checkError(var.isValid(), var << " should still be valid after a discard."); } + m_variables.clear(); + m_isExecuted = false; } +} void RuleInstance::setGuard(const std::vector& guards){ check_error(m_guards.empty()); @@ -309,65 +369,81 @@ namespace EUROPA { debugMsg("RuleInstance:setGuard", "Added guard: " << m_guardListener->toLongString()); } - void RuleInstance::setGuard(const ConstrainedVariableId& guard, const Domain& domain){ + void RuleInstance::setGuard(const ConstrainedVariableId guard, const Domain& domain){ check_error(m_guards.empty()); check_error(guard.isValid()); m_guards.push_back(guard); check_error(Domain::canBeCompared(guard->baseDomain(), domain), - "Failed attempt to compare " + guard->baseDomain().getTypeName().toString() + - " with " + domain.getTypeName().toString()); + "Failed attempt to compare " + guard->baseDomain().getTypeName() + + " with " + domain.getTypeName()); m_guardDomain = domain.copy(); m_guardListener = (new RuleVariableListener(m_planDb->getConstraintEngine(), m_id, m_guards))->getId(); m_guardListener->addDependent(this); debugMsg("RuleInstance:setGuard", "Added guard: " << m_guardListener->toLongString()); } - TokenId RuleInstance::addSlave(Token* slave){ - m_slaves.push_back(slave->getId()); - slave->addDependent((Entity*) this); - return slave->getId(); - } - - ConstrainedVariableId RuleInstance::addVariable( const Domain& baseDomain, - bool canBeSpecified, - const LabelStr& name){ - // If there is already a name-value pair for retrieving a variable by name, - // we erase it. Though we do not erase the actual variable stored in the list since it still - // has to be cleaned up when the rule instance is undone. This is done reluctantly, since it - // is based on assumptions that there will be no child rules. This is all required to support the - // looping construct used to implement the 'foreach' semantics. Therefore, we overwrite the old - // value with the new value. - if(!getVariable(name).isNoId()) { - m_variablesByName.erase(name.getKey()); - - // Also erase all variables that may be derived from the variable we're removing - std::string prefix = name.toString()+"."; - std::map::iterator it = m_variablesByName.begin(); - while (it != m_variablesByName.end()) { - edouble varLabel = it->first; - std::string varName = LabelStr(varLabel).toString(); - ++it; - if (varName.find(prefix)==0) - m_variablesByName.erase(varLabel); - } - } +void RuleInstance::setGuard(const ConstrainedVariableId guard, const Domain& domain, + const std::vector& guardComponents){ + check_error(m_guards.empty()); + check_error(guard.isValid()); + m_guards.push_back(guard); + m_guards.insert(m_guards.end(), guardComponents.begin(), guardComponents.end()); + checkError(Domain::canBeCompared(guard->baseDomain(), domain), + "Failed attempt to compare " << + guard->baseDomain().getTypeName() << " with " << + domain.getTypeName()); + m_guardDomain = domain.copy(); + m_guardListener = (new RuleVariableListener(m_planDb->getConstraintEngine(), m_id, + m_guards))->getId(); + m_guardListener->addDependent(this); + debugMsg("RuleInstance:setGuard", "Added guard: " << m_guardListener->toLongString()); +} - ConstrainedVariableId localVariable = (new Variable(m_planDb->getConstraintEngine(), - baseDomain, - false, // TODO: Maybe true? - canBeSpecified, - name, - m_id))->getId(); - // Only allowed add a variable for an executed rule instance - check_error(isExecuted()); +TokenId RuleInstance::addSlave(Token* slave){ + m_slaves.push_back(slave->getId()); + slave->addDependent(this); + return slave->getId(); +} - m_variables.push_back(localVariable); - addVariable(localVariable, name); - return localVariable; +ConstrainedVariableId RuleInstance::addVariable( const Domain& baseDomain, + bool canBeSpecified, + const std::string& name){ + // If there is already a name-value pair for retrieving a variable by name, + // we erase it. Though we do not erase the actual variable stored in the list since it still + // has to be cleaned up when the rule instance is undone. This is done reluctantly, since it + // is based on assumptions that there will be no child rules. This is all required to support the + // looping construct used to implement the 'foreach' semantics. Therefore, we overwrite the old + // value with the new value. + if(!getVariable(name).isNoId()) { + m_variablesByName.erase(name); + + // Also erase all variables that may be derived from the variable we're removing + std::string prefix = name + "."; + std::map::iterator it = m_variablesByName.begin(); + while (it != m_variablesByName.end()) { + std::string varName = it->first; + ++it; + if (varName.find(prefix)==0) + m_variablesByName.erase(varName); + } } - void RuleInstance::addVariable(const ConstrainedVariableId& var, const LabelStr& name){ - check_error(var.isValid(), "Tried to add invalid variable " + name.toString()); + ConstrainedVariableId localVariable = (new Variable(m_planDb->getConstraintEngine(), + baseDomain, + false, // TODO: Maybe true? + canBeSpecified, + name, + m_id))->getId(); + // Only allowed add a variable for an executed rule instance + check_error(isExecuted()); + + m_variables.push_back(localVariable); + addVariable(localVariable, name); + return localVariable; +} + + void RuleInstance::addVariable(const ConstrainedVariableId var, const std::string& name){ + check_error(var.isValid(), "Tried to add invalid variable " + name); m_variablesByName.insert(std::make_pair(name, var)); getToken()->addLocalVariable(var); } @@ -376,18 +452,22 @@ namespace EUROPA { * This is going to be slow as we iterate over a load of variables and do string manipulate in them. Could optimize * if this seems a problem. */ - void RuleInstance::clearLoopVar(const LabelStr& loopVarName){ - std::map::iterator it = m_variablesByName.begin(); - while (it != m_variablesByName.end()){ - const LabelStr& name = it->first; - const ConstrainedVariableId& var = it->second; - // If we get a match straight away, remove the entry. - if(var->parent() == getId() && (name == loopVarName || (name.countElements(".") > 0 && loopVarName == name.getElement(0, ".")))) - m_variablesByName.erase(it++); - else - ++it; - } +void RuleInstance::clearLoopVar(const std::string& loopVarName){ + std::map::iterator it = m_variablesByName.begin(); + while (it != m_variablesByName.end()){ + const std::string& name = it->first; + const ConstrainedVariableId var = it->second; + // If we get a match straight away, remove the entry. + if(var->parent() == getId() && + (name == loopVarName || + //(name.countElements(".") > 0 && loopVarName == name.getElement(0, ".")) + (name.find('.') != std::string::npos && loopVarName == name.substr(0, name.find('.'))) + )) + m_variablesByName.erase(it++); + else + ++it; } +} std::string RuleInstance::makeImplicitVariableName(){ std::stringstream sstr; @@ -398,30 +478,32 @@ namespace EUROPA { /** * @see addVariable */ - TokenId RuleInstance::addSlave(Token* slave, const LabelStr& name){ + TokenId RuleInstance::addSlave(Token* slave, const std::string& name){ // As with adding variables, we have to handle case of re-use of name when executing the inner // loop of 'foreach' - m_slavesByName.erase(name.getKey()); + m_slavesByName.erase(name); - m_slavesByName.insert(std::make_pair(name.getKey(), slave->getId())); + m_slavesByName.insert(std::make_pair(name, slave->getId())); return addSlave(slave); } - void RuleInstance::addConstraint(const LabelStr& name, const std::vector& scope){ - ConstraintId constraint = getPlanDatabase()->getConstraintEngine()->createConstraint(name, - scope); - addConstraint(constraint); - } +void RuleInstance::addConstraint(const std::string& name, const std::vector& scope){ + ConstraintId constr = + getPlanDatabase()->getConstraintEngine()->createConstraint(name, + scope); + addConstraint(constr); +} - void RuleInstance::addConstraint(const ConstraintId& constraint){ - m_constraints.push_back(constraint); - const LabelStr& name = constraint->getName(); - m_constraintsByName.erase(name.getKey()); - m_constraintsByName.insert(std::make_pair(name.getKey(), constraint)); - constraint->addDependent((Entity*) this); - debugMsg("RuleInstance:addConstraint", "added constraint:" << constraint->toString()); - } +void RuleInstance::addConstraint(const ConstraintId constr){ + m_constraints.push_back(constr); + const std::string& name = constr->getName(); + m_constraintsByName.erase(name); + m_constraintsByName.insert(std::make_pair(name, constr)); + constr->addDependent(this); + debugMsg("RuleInstance:addConstraint", + "added constraint:" << constr->toString()); +} void RuleInstance::addChildRule(RuleInstance* instance){ m_childRules.push_back(instance->getId()); @@ -432,90 +514,92 @@ namespace EUROPA { check_error(m_rule.isValid()); check_error(m_token.isValid()); check_error(m_token->isActive(), - m_token->getPredicateName().toString() + " is not active"); + m_token->getPredicateName() + " is not active"); check_error(m_planDb->getSchema()->isA(m_token->getPredicateName(), m_rule->getName()), - "Cannot have rule " + m_rule->getName().toString() + - " on predicate " + m_token->getPredicateName().toString()); + "Cannot have rule " + m_rule->getName() + + " on predicate " + m_token->getPredicateName()); return true; } - ConstrainedVariableId RuleInstance::getVariable(const LabelStr& name) const{ - std::map::const_iterator it = m_variablesByName.find(name.getKey()); - if(it != m_variablesByName.end()) - return it->second; - else if (!m_parent.isNoId()) - return m_parent->getVariable(name); - else if(getPlanDatabase()->isGlobalVariable(name)) - return getPlanDatabase()->getGlobalVariable(name); - else - return ConstrainedVariableId::noId(); - } - - TokenId RuleInstance::getSlave(const LabelStr& name) const{ - static const LabelStr sl_this("this"); - // Special handling for 'this' - if(name == sl_this) - return m_token; +ConstrainedVariableId RuleInstance::getVariable(const std::string& name) const { + std::map::const_iterator it = + m_variablesByName.find(name); + if(it != m_variablesByName.end()) + return it->second; + else if (!m_parent.isNoId()) + return m_parent->getVariable(name); + else if(getPlanDatabase()->isGlobalVariable(name)) + return getPlanDatabase()->getGlobalVariable(name); + else + return ConstrainedVariableId::noId(); +} - std::map::const_iterator it = m_slavesByName.find(name.getKey()); - if(it != m_slavesByName.end()) - return it->second; - else if (!m_parent.isNoId()) - return m_parent->getSlave(name); - else - return TokenId::noId(); - } +TokenId RuleInstance::getSlave(const std::string& name) const { + static const std::string sl_this("this"); + // Special handling for 'this' + if(name == sl_this) + return m_token; + + std::map::const_iterator it = m_slavesByName.find(name); + if(it != m_slavesByName.end()) + return it->second; + else if (!m_parent.isNoId()) + return m_parent->getSlave(name); + else + return TokenId::noId(); +} - ConstraintId RuleInstance::getConstraint(const LabelStr& name) const{ - std::map::const_iterator it = m_constraintsByName.find(name.getKey()); - if(it != m_constraintsByName.end()) - return it->second; - else if (!m_parent.isNoId()) - return m_parent->getConstraint(name); - else - return ConstraintId::noId(); - } +ConstraintId RuleInstance::getConstraint(const std::string& name) const { + std::map::const_iterator it = m_constraintsByName.find(name); + if(it != m_constraintsByName.end()) + return it->second; + else if (!m_parent.isNoId()) + return m_parent->getConstraint(name); + else + return ConstraintId::noId(); +} ConstraintId RuleInstance::constraint(const std::string& name) const{ - return getConstraint(LabelStr(name)); + return getConstraint(name); } - void RuleInstance::commonInit(){ - const std::vector& vars = m_token->getVariables(); - for(std::vector::const_iterator it = vars.begin(); it != vars.end(); ++it){ - ConstrainedVariableId var = *it; - m_variablesByName.insert(std::make_pair(var->getName().getKey(), var)); - } +void RuleInstance::commonInit() { + const std::vector& vars = m_token->getVariables(); + for(std::vector::const_iterator it = vars.begin(); it != vars.end(); ++it){ + ConstrainedVariableId var = *it; + m_variablesByName.insert(std::make_pair(var->getName(), var)); } +} - std::vector RuleInstance::getVariables(const std::string& delimitedVars) const{ - std::vector scope; - LabelStr strScope(delimitedVars); - unsigned int size = strScope.countElements(":"); - for(unsigned int i=0; i < size; i++){ - LabelStr strVar = strScope.getElement(i, ":"); - ConstrainedVariableId var; - - // It is possible that the label is of the form "predicate.member" in which case we - // must obtain the token from current scope and then getthe variable from there. - if(strVar.countElements(".") == 1) - var = getVariable(strVar); - else { - LabelStr slaveName = strVar.getElement(0, "."); - LabelStr varName = strVar.getElement(1, "."); - TokenId slave = getSlave(slaveName); - check_error(slave.isValid()); - var = slave->getVariable(varName); - } - check_error(var.isValid()); - scope.push_back(var); +std::vector RuleInstance::getVariables(const std::string& delimitedVars) const{ + std::vector scope; + std::vector strScope; + boost::split(strScope, delimitedVars, boost::is_any_of(":")); + for(std::vector::const_iterator it = strScope.begin(); it != strScope.end(); + ++it) { + const std::string& strVar = *it; + ConstrainedVariableId var; + std::string::size_type dot = strVar.find("."); + // It is possible that the label is of the form "predicate.member" in which case we + // must obtain the token from current scope and then getthe variable from there. + if(dot == std::string::npos) + var = getVariable(strVar); + else { + std::string slaveName = strVar.substr(0, dot); + std::string varName = strVar.substr(dot + 1); + TokenId slave = getSlave(slaveName); + check_error(slave.isValid()); + var = slave->getVariable(varName); } - - return scope; + check_error(var.isValid()); + scope.push_back(var); } + return scope; +} + ConstrainedVariableId RuleInstance::varFromObject(const std::string& objectString, const std::string& varString, bool canBeSpecified){ @@ -527,89 +611,92 @@ namespace EUROPA { return retVar; } - ConstrainedVariableId RuleInstance::varFromObject(const ConstrainedVariableId& obj, - const std::string& varString, - const std::string& fullName, - bool canBeSpecified){ - std::vector names; - tokenize(varString, names, std::string(Schema::getDelimiter())); - unsigned int varindex = 0; - - // First we compute the position index, and get the type of the last variable. This will then - // be used to populate the base domain of the proxy variable by iteration over the base domain. - - // Initialize with any object in the domain - ObjectId iObj = Entity::getTypedEntity(obj->lastDomain().getLowerBound()); - std::vector path; /*!< Push indexes as they are found */ - - // Traverse the object structure using the names in each case. Store indexes as we go to build a path - for (; varindex < names.size()-1; ++varindex) { - ConstrainedVariableId iVar = iObj->getVariable(LabelStr(iObj->getName().toString() + "." + names[varindex])); - path.push_back(iVar->getIndex()); - checkError(iVar->lastDomain().isSingleton(), iVar->toString() + ", " + iObj->getName().toString() + "." + names[varindex]); - iObj = Entity::getTypedEntity(iVar->lastDomain().getSingletonValue()); - } +ConstrainedVariableId RuleInstance::varFromObject(const ConstrainedVariableId obj, + const std::string& varString, + const std::string& fullName, + bool canBeSpecified){ + std::vector names; + boost::split(names, varString, boost::is_any_of(".")); - // Finally, handle the terminal point - the field variable itself - std::string field_name = iObj->getName().toString() + "." + names[varindex]; - ConstrainedVariableId fieldVar = iObj->getVariable(LabelStr(field_name)); - checkError(fieldVar.isValid(), "No variable named '" << field_name << "' in " << iObj->getName().toString()); - path.push_back(fieldVar->getIndex()); + unsigned int varindex = 0; - // Get the field type for the resulting domain. - const bool isOpen = fieldVar->baseDomain().isOpen(); - const bool isBool = fieldVar->baseDomain().isBool(); + // First we compute the position index, and get the type of the last variable. This will then + // be used to populate the base domain of the proxy variable by iteration over the base domain. - // At this point, the index is complete, and we know the type. We can allocate and populate the domain - const ObjectDomain& objectDomain = static_cast(obj->baseDomain()); + // Initialize with any object in the domain + ObjectId iObj = Entity::getTypedEntity(obj->lastDomain().getLowerBound()); + std::vector path; /*!< Push indexes as they are found */ - // Iterate over each object. For each, obtain the variable using the path, and store its value - const std::list objects = objectDomain.makeObjectList(); + // Traverse the object structure using the names in each case. Store indexes as we go to build a path + for (; varindex < names.size()-1; ++varindex) { + ConstrainedVariableId iVar = iObj->getVariable(iObj->getName() + "." + names[varindex]); + path.push_back(static_cast(iVar->getIndex())); + checkError(iVar->lastDomain().isSingleton(), iVar->toString() + ", " + iObj->getName() + "." + names[varindex]); + iObj = Entity::getTypedEntity(iVar->lastDomain().getSingletonValue()); + } - EnumeratedDomain proxyBaseDomain(fieldVar->baseDomain().getDataType()); + // Finally, handle the terminal point - the field variable itself + std::string field_name = iObj->getName() + "." + names[varindex]; + ConstrainedVariableId fieldVar = iObj->getVariable(field_name); + checkError(fieldVar.isValid(), "No variable named '" << field_name << "' in " << iObj->getName()); + path.push_back(static_cast(fieldVar->getIndex())); - std::list values; - for(std::list::const_iterator it = objects.begin(); it != objects.end(); ++it){ - ObjectId object = *it; - ConstrainedVariableId fieldVar = object->getVariable(path); - checkError(fieldVar->lastDomain().isSingleton(), fieldVar->toString() + " : " + fieldVar->lastDomain().toString() + " is not a singleton."); - edouble value = fieldVar->lastDomain().getSingletonValue(); - proxyBaseDomain.insert(value); - debugMsg("RuleInstance:varFromObject", "Adding value from " << fieldVar->toString()); - } + // Get the field type for the resulting domain. + const bool isOpen = fieldVar->baseDomain().isOpen(); + const bool isBool = fieldVar->baseDomain().isBool(); - // Allocate the proxy variable - ConstrainedVariableId proxyVariable; + // At this point, the index is complete, and we know the type. We can allocate and populate the domain + const ObjectDomain& objectDomain = static_cast(obj->baseDomain()); - // If it is a boolean, allocate a bool domain instead of the enumerated domain - if(isBool){ - BoolDomain boolDomain(fieldVar->baseDomain().getDataType()); - edouble lb = proxyBaseDomain.getLowerBound(); - edouble ub = proxyBaseDomain.getUpperBound(); + // Iterate over each object. For each, obtain the variable using the path, and store its value + const std::list objects = objectDomain.makeObjectList(); - // If a singleton, set as such - if(lb == ub) - boolDomain.set(ub); + EnumeratedDomain proxyBaseDomain(fieldVar->baseDomain().getDataType()); - proxyVariable = addVariable(boolDomain, canBeSpecified, fullName); - } - else { - // Close if necessary - if(!isOpen) - proxyBaseDomain.close(); + std::list values; + for(std::list::const_iterator it = objects.begin(); it != objects.end(); ++it){ + ObjectId object = *it; + ConstrainedVariableId objectFieldVar = object->getVariable(path); + checkError(objectFieldVar->lastDomain().isSingleton(), + objectFieldVar->toString() << " : " << + objectFieldVar->lastDomain().toString() << " is not a singleton."); + edouble value = objectFieldVar->lastDomain().getSingletonValue(); + proxyBaseDomain.insert(value); + debugMsg("RuleInstance:varFromObject", "Adding value from " << objectFieldVar->toString()); + } - proxyVariable = addVariable(proxyBaseDomain, canBeSpecified, fullName); - } + // Allocate the proxy variable + ConstrainedVariableId proxyVariable; - // Post the new constraint - ConstraintId proxyVariableRelation = (new ProxyVariableRelation(obj, proxyVariable, path))->getId(); - addConstraint(proxyVariableRelation); + // If it is a boolean, allocate a bool domain instead of the enumerated domain + if(isBool){ + BoolDomain boolDomain(fieldVar->baseDomain().getDataType()); + edouble lb = proxyBaseDomain.getLowerBound(); + edouble ub = proxyBaseDomain.getUpperBound(); - // Return the new variable - return proxyVariable; + // If a singleton, set as such + if(lb == ub) + boolDomain.set(ub); + + proxyVariable = addVariable(boolDomain, canBeSpecified, fullName); + } + else { + // Close if necessary + if(!isOpen) + proxyBaseDomain.close(); + + proxyVariable = addVariable(proxyBaseDomain, canBeSpecified, fullName); } - ConstrainedVariableId RuleInstance::varfromtok(const TokenId& token, const std::string varstring) { + // Post the new constraint + ConstraintId proxyVariableRelation = (new ProxyVariableRelation(obj, proxyVariable, path))->getId(); + addConstraint(proxyVariableRelation); + + // Return the new variable + return proxyVariable; +} + + ConstrainedVariableId RuleInstance::varfromtok(const TokenId token, const std::string varstring) { std::string local_name = varstring.substr(0, varstring.find(Schema::getDelimiter())); checkError(token.isValid(), "Cannot get variable : " << varstring << " from token with id " << token); ConstrainedVariableId retVar; @@ -628,101 +715,102 @@ namespace EUROPA { return retVar; // } - void RuleInstance::notifyDiscarded(const Entity* entity){ +void RuleInstance::notifyDiscarded(const Entity* entity){ - checkError(dynamic_cast(entity) != 0 || dynamic_cast(entity), - "Must be a constraint or a token: " << entity->getKey()); + checkError(dynamic_cast(entity) != 0 || dynamic_cast(entity), + "Must be a constraint or a token: " << entity->getKey()); - // Is it a slave? If so, reference to it - if(dynamic_cast(entity) == 0){ - for(std::vector::iterator it = m_slaves.begin(); it != m_slaves.end(); ++it){ - TokenId token = *it; - checkError(token.isValid(), token); - if(token->getKey() == entity->getKey()){ - m_slaves.erase(it); - return; - } + // Is it a slave? If so, reference to it + if(dynamic_cast(entity) == 0){ + for(std::vector::iterator it = m_slaves.begin(); it != m_slaves.end(); ++it){ + TokenId token = *it; + checkError(token.isValid(), token); + if(token->getKey() == entity->getKey()){ + m_slaves.erase(it); + return; } - - return; - } - - // Is it the guard listener - if(m_guardListener.isId() && entity->getKey() == m_guardListener->getKey()){ - m_guardListener = ConstraintId::noId(); - m_guards.clear(); - return; } - // If neither of the above, it must be a regular constraint - for(std::vector::iterator it = m_constraints.begin(); it != m_constraints.end(); ++it){ - ConstraintId constraint = *it; - checkError(constraint.isValid(), constraint); - if(constraint->getKey() == entity->getKey()){ - m_constraints.erase(it); - return; - } - } + return; } - bool RuleInstance::connectedToToken(const ConstraintId& constraint, const TokenId& token) const{ - // If the constrant is actually a rule variable listener then it is part of the context of the rule instance - // and thus part of the context of the token - if(RuleVariableListenerId::convertable(constraint)) - return true; + // Is it the guard listener + if(m_guardListener.isId() && entity->getKey() == m_guardListener->getKey()){ + m_guardListener = ConstraintId::noId(); + m_guards.clear(); + return; + } - for(std::vector::const_iterator it = constraint->getScope().begin(); - it != constraint->getScope().end(); ++it){ - ConstrainedVariableId var = *it; - EntityId parent = var->parent(); - if(parent == token || parent == m_id) - return true; + // If neither of the above, it must be a regular constraint + for(std::vector::iterator it = m_constraints.begin(); it != m_constraints.end(); ++it){ + ConstraintId constr = *it; + checkError(constr.isValid(), constr); + if(constr->getKey() == entity->getKey()){ + m_constraints.erase(it); + return; } + } +} - return false; +bool RuleInstance::connectedToToken(const ConstraintId constr, + const TokenId token) const { + // If the constrant is actually a rule variable listener then it is part of the context of the rule instance + // and thus part of the context of the token + if(RuleVariableListenerId::convertable(constr)) + return true; + + for(std::vector::const_iterator it = constr->getScope().begin(); + it != constr->getScope().end(); ++it){ + ConstrainedVariableId var = *it; + EntityId parent = var->parent(); + if(parent == token || parent == m_id) + return true; } - std::string RuleInstance::ruleExecutionContext() const { - static const std::string TAB_DELIMITER(" "); - std::stringstream ss; + return false; +} + +std::string RuleInstance::ruleExecutionContext() const { + static const std::string TAB_DELIMITER(" "); + std::stringstream ss; - // What is the token - ss << "[" << getToken()->getKey() << "]Rule fired on master token: " << + // What is the token + ss << "[" << getToken()->getKey() << "]Rule fired on master token: " << getToken()->toString() << ". The rule instance context is given below:" << std::endl << std::endl; - // What rule - ss << "Rule: " << getRule()->toString() << std::endl << std::endl; + // What rule + ss << "Rule: " << getRule()->toString() << std::endl << std::endl; - // What guards are involved - if(m_guards.empty()) - ss << "No Guards" << std::endl; - else { - ss << "Guards:" << std::endl; + // What guards are involved + if(m_guards.empty()) + ss << "No Guards" << std::endl; + else { + ss << "Guards:" << std::endl; - for(std::vector::const_iterator it = m_guards.begin(); it != m_guards.end(); ++it){ - ConstrainedVariableId guard = *it; - ss << TAB_DELIMITER << guard->getName().toString() << " == " << guard->lastDomain().toString() << std::endl; - } + for(std::vector::const_iterator it = m_guards.begin(); it != m_guards.end(); ++it){ + ConstrainedVariableId guard = *it; + ss << TAB_DELIMITER << guard->getName() << " == " << guard->lastDomain().toString() << std::endl; } + } - ss << std::endl; + ss << std::endl; - // What slaves are created - if(m_slaves.empty()) - ss << "No Slaves" << std::endl; - else { - ss << "Slaves: " << std::endl; - for(std::map::const_iterator it = m_slavesByName.begin(); it != m_slavesByName.end(); ++it){ - LabelStr name = (LabelStr) it->first; - TokenId token = it->second; - ss << TAB_DELIMITER << name.toString() << "==" << token->toString() << std::endl; - } + // What slaves are created + if(m_slaves.empty()) + ss << "No Slaves" << std::endl; + else { + ss << "Slaves: " << std::endl; + for(std::map::const_iterator it = m_slavesByName.begin(); it != m_slavesByName.end(); ++it){ + std::string name(it->first); + TokenId token = it->second; + ss << TAB_DELIMITER << name << "==" << token->toString() << std::endl; } - - ss << "++++++++++++++++++x+++++++"; - return ss.str(); } + ss << "++++++++++++++++++x+++++++"; + return ss.str(); +} + bool RuleInstance::hasEmptyGuard() const { if(m_guards.empty()) return false; @@ -732,4 +820,5 @@ namespace EUROPA { return true; return false; } + } diff --git a/src/PLASMA/RulesEngine/base/RuleInstance.hh b/src/PLASMA/RulesEngine/base/RuleInstance.hh index 036c3ea6b..228f7aea1 100644 --- a/src/PLASMA/RulesEngine/base/RuleInstance.hh +++ b/src/PLASMA/RulesEngine/base/RuleInstance.hh @@ -1,5 +1,5 @@ -#ifndef _H_RuleInstance -#define _H_RuleInstance +#ifndef H_RuleInstance +#define H_RuleInstance /** * @file RuleInstance.hh @@ -28,14 +28,13 @@ namespace EUROPA{ /** * @brief Constructor to construct an unguarded root rule context */ - RuleInstance(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb); + RuleInstance(const RuleId rule, const TokenId token, const PlanDatabaseId planDb); /** * @brief Constructor to construct a guarded root rule context where the guard is triggered * whenever the guard variable is set to a singleton. - * @param guard The variable which will be evaluated. trigger rule when set to any singleton value. */ - RuleInstance(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb, + RuleInstance(const RuleId rule, const TokenId token, const PlanDatabaseId planDb, const std::vector& guards); /** @@ -44,18 +43,21 @@ namespace EUROPA{ * @param guard The variable which will be evaluated * @param domain Fired when domain.isMember(guard.singletonValue) */ - RuleInstance(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb, - const ConstrainedVariableId& guard, const Domain& domain); + RuleInstance(const RuleId rule, const TokenId token, const PlanDatabaseId planDb, + const ConstrainedVariableId guard, const Domain& domain); /** * @brief Constructor to construct a rule instance from a parent. Must have a guard! */ - RuleInstance(const RuleInstanceId& parent, const std::vector& guards); + RuleInstance(const RuleInstanceId parent, + const std::vector& guards); /** * @brief Constructor to construct a rule instance from a parent. Must have a guard! */ - RuleInstance(const RuleInstanceId& parent, const std::vector& guards, const bool positive); + RuleInstance(const RuleInstanceId parent, + const std::vector& guards, + const bool positive); /** * @brief Constructor to construct a rule instance from a parent. Must have a guard! @@ -63,8 +65,8 @@ namespace EUROPA{ * @param guard The variable which will be evaluated * @param domain Fired when domain.isMember(guard.singletonValue) */ - RuleInstance(const RuleInstanceId& parent, - const ConstrainedVariableId& guard, const Domain& domain); + RuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId guard, const Domain& domain); /** * @brief Constructor to construct a rule instance from a parent. Must have a guard! @@ -73,8 +75,15 @@ namespace EUROPA{ * @param domain Fired when domain.isMember(guard.singletonValue) ^ !positive * @param positive Flag to indicate whether the test is positive or not. */ - RuleInstance(const RuleInstanceId& parent, - const ConstrainedVariableId& guard, const Domain& domain, const bool positive); + RuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId guard, const Domain& domain, + const bool positive); + + RuleInstance(const RuleInstanceId parent, + const ConstrainedVariableId var, + const Domain& domain, + const bool positive, + const std::vector& guardComponents); /** * Destructor @@ -84,24 +93,24 @@ namespace EUROPA{ /** * @brief Id Accessor */ - const RuleInstanceId& getId() const; + const RuleInstanceId getId() const; /** * @brief Accessor for the model rule governing evaluation and execution * @return An Id that must be valid. */ - const RuleId& getRule() const; + const RuleId getRule() const; /** * @brief Accessor for PlanDatabase */ - const PlanDatabaseId& getPlanDatabase() const; + const PlanDatabaseId getPlanDatabase() const; /** * @brief Accessor * @return The token to which the rule context applies. It must be ACTIVE. */ - const TokenId& getToken() const; + const TokenId getToken() const; /** * @brief Accessor @@ -114,9 +123,9 @@ namespace EUROPA{ void setRulesEngine(const RulesEngineId &rulesEngine); - ConstrainedVariableId getVariable(const LabelStr& name) const; - TokenId getSlave(const LabelStr& name) const; - ConstraintId getConstraint(const LabelStr& name) const; + ConstrainedVariableId getVariable(const std::string& name) const; + TokenId getSlave(const std::string& name) const; + ConstraintId getConstraint(const std::string& name) const; /************** Call-backs from the rule variable listener **************/ @@ -128,7 +137,7 @@ namespace EUROPA{ /** * @brief Tests if the condition, if there is one, is satisfied. - * @param The guard variables to evaluate against + * @param guards The guard variables to evaluate against */ bool test(const std::vector& guards) const; @@ -168,7 +177,7 @@ namespace EUROPA{ const std::vector &getChildRules(void) const {return m_childRules;} - void addConstraint(const ConstraintId& constraint); + void addConstraint(const ConstraintId constraint); bool hasEmptyGuard() const; @@ -186,8 +195,8 @@ namespace EUROPA{ /*!< Helper methods */ TokenId addSlave(Token* slave); - TokenId addSlave(Token* slave, const LabelStr& name); - ConstrainedVariableId varfromtok(const TokenId& tok, const std::string varstring) ; + TokenId addSlave(Token* slave, const std::string& name); + ConstrainedVariableId varfromtok(const TokenId tok, const std::string varstring) ; /** * @brief Obtains a variable which represents the set of all values for an object field. May retrieve @@ -208,7 +217,7 @@ namespace EUROPA{ * @param fullName The full name used for resolution. Should always contain varString. * @param canBeSpecified Indicate if the allocated variable should be specifiable. */ - ConstrainedVariableId varFromObject(const ConstrainedVariableId& object, + ConstrainedVariableId varFromObject(const ConstrainedVariableId object, const std::string& varString, const std::string& fullName, bool canBeSpecified = false); @@ -219,15 +228,15 @@ namespace EUROPA{ * @param var The variable to be added to scope. * @param name The name of the variable to use for lookup */ - void addVariable(const ConstrainedVariableId& var, const LabelStr& name); + void addVariable(const ConstrainedVariableId var, const std::string& name); ConstrainedVariableId addVariable( const Domain& baseDomain, bool canBeSpecified, - const LabelStr& name); + const std::string& name); - void addConstraint(const LabelStr& name, const std::vector& scope); + void addConstraint(const std::string& name, const std::vector& scope); void addChildRule(RuleInstance* instance); - void clearLoopVar(const LabelStr& loopVarName); + void clearLoopVar(const std::string& loopVarName); std::string makeImplicitVariableName(); ConstraintId constraint(const std::string& name) const; @@ -235,11 +244,13 @@ namespace EUROPA{ RuleInstanceId m_id; const RuleId m_rule; const TokenId m_token; - const PlanDatabaseId& m_planDb; + const PlanDatabaseId m_planDb; RulesEngineId m_rulesEngine; RuleInstanceId m_parent; private: + RuleInstance(const RuleInstance&); + RuleInstance& operator=(const RuleInstance&); /** * @brief Invoked by derived classes to set the guard variable where the test criteria will be that * the specified domain of the guard is a singleton. Private since should onle be called from constructor. @@ -251,7 +262,11 @@ namespace EUROPA{ * the specified domain of the guard is a singleton, and equals the given value. Private since should * only be called from constructor. */ - void setGuard(const ConstrainedVariableId& guard, const Domain& domain); + void setGuard(const ConstrainedVariableId guard, const Domain& domain); + + void setGuard(const ConstrainedVariableId guad, const Domain& domain, + const std::vector& guardComponents); + /** @@ -266,7 +281,7 @@ namespace EUROPA{ * @brief Test of a constraint is connected to a given token. This is true if any variable in the scope * of the constraint belongs to the token. */ - bool connectedToToken(const ConstraintId& constraint, const TokenId& token) const; + bool connectedToToken(const ConstraintId constraint, const TokenId token) const; /** ANALYSIS ROUTINES FOR DEBUGGING **/ std::string ruleExecutionContext() const; @@ -280,11 +295,11 @@ namespace EUROPA{ bool m_isPositive; /*!< If this is false, the rule's guard is on a negative test. */ std::vector m_constraints; /*!< Constraints introduced through rule execution */ std::vector m_childRules; /*!< Child rules introduced through rule execution */ - std::vector m_variables; /*< Local variables introduced through rule execution */ - std::vector m_slaves; /*< Slaves introduced through rule execution */ - std::map m_variablesByName; /*!< Context lookup */ - std::map m_slavesByName; /*!< Context lookup */ - std::map m_constraintsByName; /*!< Context lookup */ + std::vector m_variables; /*!< Local variables introduced through rule execution */ + std::vector m_slaves; /*!< Slaves introduced through rule execution */ + std::map m_variablesByName; /*!< Context lookup */ + std::map m_slavesByName; /*!< Context lookup */ + std::map m_constraintsByName; /*!< Context lookup */ }; } #endif diff --git a/src/PLASMA/RulesEngine/base/RuleVariableListener.cc b/src/PLASMA/RulesEngine/base/RuleVariableListener.cc index 66e15c222..436996e56 100644 --- a/src/PLASMA/RulesEngine/base/RuleVariableListener.cc +++ b/src/PLASMA/RulesEngine/base/RuleVariableListener.cc @@ -3,34 +3,34 @@ #include "DomainListener.hh" #include "ConstrainedVariable.hh" #include "ConstraintType.hh" -#include "LabelStr.hh" #include "Rule.hh" namespace EUROPA { - RuleVariableListener::RuleVariableListener(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& scope) - : Constraint(name, propagatorName, constraintEngine, scope){} +RuleVariableListener::RuleVariableListener(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& scope) + : Constraint(name, propagatorName, constraintEngine, scope), m_ruleInstance(), + m_sourceConstraint() {} - RuleVariableListener::RuleVariableListener(const ConstraintEngineId& constraintEngine, - const RuleInstanceId& ruleInstance, - const std::vector& scope) +RuleVariableListener::RuleVariableListener(const ConstraintEngineId constraintEngine, + const RuleInstanceId ruleInstance, + const std::vector& scope) : Constraint(CONSTRAINT_NAME(), PROPAGATOR_NAME(), constraintEngine, scope), - m_ruleInstance(ruleInstance){ - check_error(! m_ruleInstance->isExecuted(), - "A Rule Instance should never be already executed when we construct the constraint!"); + m_ruleInstance(ruleInstance), m_sourceConstraint() { + check_error(! m_ruleInstance->isExecuted(), + "A Rule Instance should never be already executed when we construct the constraint!"); - // Add rule variable listener as a dependent of the rule instance to receive discard notifications - m_ruleInstance->addDependent(this); - } + // Add rule variable listener as a dependent of the rule instance to receive discard notifications + m_ruleInstance->addDependent(this); +} /** * @see Mergemento::merge */ - void RuleVariableListener::setSource(const ConstraintId& sourceConstraint){ + void RuleVariableListener::setSource(const ConstraintId sourceConstraint){ check_error(sourceConstraint.isValid()); checkError(sourceConstraint->getName() == getName(), @@ -44,27 +44,27 @@ namespace EUROPA { * so that rule execution is not subject to the vagaries of propagtion timing * @return true */ - bool RuleVariableListener::canIgnore(const ConstrainedVariableId& variable, - int argIndex, - const DomainListener::ChangeType& changeType){ - checkError(getRuleInstance().isValid(), getKey() << " has lost its rule instance:" << getRuleInstance()); +bool RuleVariableListener::canIgnore(const ConstrainedVariableId, + unsigned int, + const DomainListener::ChangeType&){ + checkError(getRuleInstance().isValid(), getKey() << " has lost its rule instance:" << getRuleInstance()); - if(getRuleInstance().isNoId()) - return true; + if(getRuleInstance().isNoId()) + return true; - debugMsg("RuleVariableListener:canIgnore", - "Checking canIgnore for guard listener for rule " << getRuleInstance()->getRule()->getName().toString() << - " from source " << (m_sourceConstraint.isId() ? m_sourceConstraint->getName().toString() : "NULL")); + debugMsg("RuleVariableListener:canIgnore", + "Checking canIgnore for guard listener for rule " << getRuleInstance()->getRule()->getName() << + " from source " << (m_sourceConstraint.isId() ? m_sourceConstraint->getName() : "NULL")); - return false; - } + return false; +} - const RuleInstanceId& RuleVariableListener::getRuleInstance() { + const RuleInstanceId RuleVariableListener::getRuleInstance() { if(m_ruleInstance.isNoId()){ checkError(m_sourceConstraint.isValid(), "Must be able to get this from a source constraint."); // Now obtain the rule instance from the source - RuleVariableListener* source = (RuleVariableListener*) m_sourceConstraint; + RuleVariableListener* source = id_cast(m_sourceConstraint); m_ruleInstance = source->getRuleInstance(); checkError(m_ruleInstance.isNoId() || m_ruleInstance.isValid(), m_sourceConstraint->toString()); @@ -111,7 +111,7 @@ namespace EUROPA { * @brief If the base class test passes, then we need to see if there is any more information contained in the rule that * has not been applied. This will be the case if the rule has not fired yet and the test indicates it could. */ - bool RuleVariableListener::testIsRedundant(const ConstrainedVariableId& var) const{ + bool RuleVariableListener::testIsRedundant(const ConstrainedVariableId var) const{ return Constraint::testIsRedundant(var) && (m_ruleInstance.isNoId() || m_ruleInstance->isExecuted() || !m_ruleInstance->test(getScope())); } } diff --git a/src/PLASMA/RulesEngine/base/RuleVariableListener.hh b/src/PLASMA/RulesEngine/base/RuleVariableListener.hh index f4ebe9f41..6b0f7d064 100644 --- a/src/PLASMA/RulesEngine/base/RuleVariableListener.hh +++ b/src/PLASMA/RulesEngine/base/RuleVariableListener.hh @@ -1,5 +1,5 @@ -#ifndef _H_RuleVariableListener -#define _H_RuleVariableListener +#ifndef H_RuleVariableListener +#define H_RuleVariableListener #include "RulesEngineDefs.hh" #include "Constraint.hh" @@ -20,31 +20,31 @@ namespace EUROPA * @brief Standard constraint constructor must be provided to facilitate * creation of a copy during merging. */ - RuleVariableListener(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + RuleVariableListener(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables); /** * @brief Implement this method to allow ruleInstance data to be extracted and copied */ - void setSource(const ConstraintId& sourceConstraint); + void setSource(const ConstraintId sourceConstraint); - const RuleInstanceId& getRuleInstance(); + const RuleInstanceId getRuleInstance(); /** * @brief Standard constraint name */ - static const LabelStr& CONSTRAINT_NAME(){ - static const LabelStr sl_const("RuleVariableListener"); + static const std::string& CONSTRAINT_NAME(){ + static const std::string sl_const("RuleVariableListener"); return sl_const; } /** * @brief Standard propagator */ - static const LabelStr& PROPAGATOR_NAME(){ - static const LabelStr sl_const("RulesEngine"); + static const std::string& PROPAGATOR_NAME(){ + static const std::string sl_const("RulesEngine"); return sl_const; } @@ -63,7 +63,7 @@ namespace EUROPA /** * @brief Over-ride base class test */ - virtual bool testIsRedundant(const ConstrainedVariableId& var = ConstrainedVariableId::noId()) const; + virtual bool testIsRedundant(const ConstrainedVariableId var = ConstrainedVariableId::noId()) const; friend class RuleInstance; @@ -71,12 +71,12 @@ namespace EUROPA * @brief Constructor used internally by the RuleInstance class when allocating * the listener. */ - RuleVariableListener(const ConstraintEngineId& constraintEngine, - const RuleInstanceId& ruleInstance, + RuleVariableListener(const ConstraintEngineId constraintEngine, + const RuleInstanceId ruleInstance, const std::vector& scope); - bool canIgnore(const ConstrainedVariableId& variable, - int argIndex, + bool canIgnore(const ConstrainedVariableId variable, + unsigned int argIndex, const DomainListener::ChangeType& changeType); void handleExecute(); diff --git a/src/PLASMA/RulesEngine/base/RulesEngine.cc b/src/PLASMA/RulesEngine/base/RulesEngine.cc index 104042cd7..f61615a95 100644 --- a/src/PLASMA/RulesEngine/base/RulesEngine.cc +++ b/src/PLASMA/RulesEngine/base/RulesEngine.cc @@ -20,17 +20,17 @@ namespace EUROPA{ private: friend class RulesEngine; - DbRuleEngineConnector(const PlanDatabaseId& planDatabase, const RulesEngineId& rulesEngine) + DbRuleEngineConnector(const PlanDatabaseId planDatabase, const RulesEngineId rulesEngine) : PlanDatabaseListener(planDatabase), m_rulesEngine(rulesEngine){} - void notifyActivated(const TokenId& token){m_rulesEngine->notifyActivated(token);} - void notifyDeactivated(const TokenId& token){m_rulesEngine->notifyDeactivated(token);} - void notifyTerminated(const TokenId& token){m_rulesEngine->notifyDeactivated(token);} + void notifyActivated(const TokenId token){m_rulesEngine->notifyActivated(token);} + void notifyDeactivated(const TokenId token){m_rulesEngine->notifyDeactivated(token);} + void notifyTerminated(const TokenId token){m_rulesEngine->notifyDeactivated(token);} const RulesEngineId m_rulesEngine; }; class RulesEngineCallback : public PostPropagationCallback { public: - RulesEngineCallback(const ConstraintEngineId& ce, const RulesEngineId& re) : PostPropagationCallback(ce), m_re(re) {} + RulesEngineCallback(const ConstraintEngineId ce, const RulesEngineId re) : PostPropagationCallback(ce), m_re(re) {} bool operator()() { if(m_re->hasWork()) { @@ -43,10 +43,16 @@ namespace EUROPA{ RulesEngineId m_re; }; - RulesEngine::RulesEngine(const RuleSchemaId& schema, const PlanDatabaseId& planDatabase) + RulesEngine::RulesEngine(const RuleSchemaId schema, const PlanDatabaseId planDatabase) : m_id(this) , m_schema(schema) , m_planDb(planDatabase) + , m_planDbListener() + , m_callback() + , m_ruleInstancesByToken() + , m_listeners() + , m_ruleInstancesToExecute() + , m_ruleInstancesToUndo() , m_deleted(false) , m_executing(false) { @@ -55,30 +61,30 @@ namespace EUROPA{ check_error(m_planDb->getTokens().empty()); } - RulesEngine::~RulesEngine(){ - check_error(m_planDbListener.isValid()); +RulesEngine::~RulesEngine(){ + check_error(m_planDbListener.isValid()); - // If we are not purging, then events should have propagated removal of all rule instances - check_error(Entity::isPurging() || m_ruleInstancesByToken.empty()); + // If we are not purging, then events should have propagated removal of all rule instances + check_error(Entity::isPurging() || m_ruleInstancesByToken.empty()); - m_deleted = true; - // Thus, only if we are in purge mode will we directly remove rule instances - for(std::multimap::const_iterator it=m_ruleInstancesByToken.begin();it!=m_ruleInstancesByToken.end();++it){ - RuleInstanceId ruleInstance = it->second; - check_error(ruleInstance.isValid()); - ruleInstance->discard(); - } - - delete (PlanDatabaseListener*) m_planDbListener; // removes itself from the plan database set of listeners - delete (PostPropagationCallback*) m_callback; - m_id.remove(); + m_deleted = true; + // Thus, only if we are in purge mode will we directly remove rule instances + for(std::multimap::const_iterator it=m_ruleInstancesByToken.begin();it!=m_ruleInstancesByToken.end();++it){ + RuleInstanceId ruleInstance = it->second; + check_error(ruleInstance.isValid()); + ruleInstance->discard(); } - const RulesEngineId& RulesEngine::getId() const{return m_id;} + delete static_cast(m_planDbListener); // removes itself from the plan database set of listeners + delete static_cast(m_callback); + m_id.remove(); +} + + const RulesEngineId RulesEngine::getId() const{return m_id;} - const PlanDatabaseId& RulesEngine::getPlanDatabase() const {return m_planDb;} + const PlanDatabaseId RulesEngine::getPlanDatabase() const {return m_planDb;} - const RuleSchemaId& RulesEngine::getRuleSchema() const { return m_schema; } + const RuleSchemaId RulesEngine::getRuleSchema() const { return m_schema; } std::set RulesEngine::getRuleInstances() const{ @@ -88,7 +94,7 @@ namespace EUROPA{ return ruleInstances; } - void RulesEngine::getRuleInstances(const TokenId& token,std::set& results) const{ + void RulesEngine::getRuleInstances(const TokenId token,std::set& results) const{ check_error(token.isValid()); std::multimap::const_iterator it = m_ruleInstancesByToken.find(token->getKey()); while(it!=m_ruleInstancesByToken.end() && it->first == token->getKey()){ @@ -115,7 +121,7 @@ namespace EUROPA{ } } - void RulesEngine::notifyActivated(const TokenId& token){ + void RulesEngine::notifyActivated(const TokenId token){ check_error(token.isValid()); check_error(token->isActive()); check_error(m_ruleInstancesByToken.find(token->getKey()) == m_ruleInstancesByToken.end()); @@ -131,16 +137,16 @@ namespace EUROPA{ } } - void RulesEngine::notifyDeactivated(const TokenId& token){ + void RulesEngine::notifyDeactivated(const TokenId token){ check_error(!Entity::isPurging()); cleanupRuleInstances(token); } - void RulesEngine::notifyTerminated(const TokenId& token){ + void RulesEngine::notifyTerminated(const TokenId token){ cleanupRuleInstances(token); } - void RulesEngine::cleanupRuleInstances(const TokenId& token){ + void RulesEngine::cleanupRuleInstances(const TokenId token){ check_error(token.isValid()); std::multimap::iterator it = m_ruleInstancesByToken.find(token->getKey()); @@ -153,7 +159,7 @@ namespace EUROPA{ } - bool RulesEngine::hasPendingRuleInstances(const TokenId& token) const { + bool RulesEngine::hasPendingRuleInstances(const TokenId token) const { check_error(token.isValid()); std::multimap::const_iterator it = m_ruleInstancesByToken.find(token->getKey()); while(it!=m_ruleInstancesByToken.end() && it->first == token->getKey()){ @@ -166,7 +172,7 @@ namespace EUROPA{ return false; } - bool RulesEngine::isPending(const RuleInstanceId& r) const { + bool RulesEngine::isPending(const RuleInstanceId r) const { // Try r directly if(!r->isExecuted() && !r->willNotFire()){ debugMsg("RulesEngine:isPending", "Found pending rule:" << r->getKey() << " for " << r->getToken()->toString()); @@ -196,12 +202,12 @@ namespace EUROPA{ m_listeners.erase(listener); } - void RulesEngine::scheduleForExecution(const RuleInstanceId& r) { + void RulesEngine::scheduleForExecution(const RuleInstanceId r) { debugMsg("RulesEngine:scheduleForExecution", "Scheduling rule " << r->toString()); m_ruleInstancesToExecute.push_back(r); } - void RulesEngine::scheduleForUndoing(const RuleInstanceId& r) { + void RulesEngine::scheduleForUndoing(const RuleInstanceId r) { debugMsg("RulesEngine:scheduleForUndoing", "Scheduling rule " << r->toString()); m_ruleInstancesToUndo.push_back(r); } diff --git a/src/PLASMA/RulesEngine/base/RulesEngine.hh b/src/PLASMA/RulesEngine/base/RulesEngine.hh index baff9300a..06294b1ff 100644 --- a/src/PLASMA/RulesEngine/base/RulesEngine.hh +++ b/src/PLASMA/RulesEngine/base/RulesEngine.hh @@ -1,5 +1,5 @@ -#ifndef _H_RulesEngine -#define _H_RulesEngine +#ifndef H_RulesEngine +#define H_RulesEngine /** * @file RulesEngine.hh @@ -24,22 +24,22 @@ namespace EUROPA { */ class RulesEngine : public EngineComponent { public: - RulesEngine(const RuleSchemaId& schema, const PlanDatabaseId& planDatabase); + RulesEngine(const RuleSchemaId schema, const PlanDatabaseId planDatabase); ~RulesEngine(); - const RulesEngineId& getId() const; + const RulesEngineId getId() const; - const PlanDatabaseId& getPlanDatabase() const; + const PlanDatabaseId getPlanDatabase() const; - void notifyActivated(const TokenId& token); - void notifyDeactivated(const TokenId& token); - void notifyTerminated(const TokenId& token); + void notifyActivated(const TokenId token); + void notifyDeactivated(const TokenId token); + void notifyTerminated(const TokenId token); std::set getRuleInstances() const; - void getRuleInstances(const TokenId& token,std::set& results) const; - bool hasPendingRuleInstances(const TokenId& token) const; + void getRuleInstances(const TokenId token,std::set& results) const; + bool hasPendingRuleInstances(const TokenId token) const; - const RuleSchemaId& getRuleSchema() const; + const RuleSchemaId getRuleSchema() const; private: friend class RulesEngineListener; @@ -50,10 +50,10 @@ namespace EUROPA { void remove(const RulesEngineListenerId &listener); void notifyExecuted(const RuleInstanceId &rule); void notifyUndone(const RuleInstanceId &rule); - void cleanupRuleInstances(const TokenId& token); - bool isPending(const RuleInstanceId& r) const; - void scheduleForExecution(const RuleInstanceId& r); - void scheduleForUndoing(const RuleInstanceId& r); + void cleanupRuleInstances(const TokenId token); + bool isPending(const RuleInstanceId r) const; + void scheduleForExecution(const RuleInstanceId r); + void scheduleForUndoing(const RuleInstanceId r); bool doRules(); bool hasWork() const; diff --git a/src/PLASMA/RulesEngine/base/RulesEngineListener.cc b/src/PLASMA/RulesEngine/base/RulesEngineListener.cc index bc35e272e..54be085b2 100644 --- a/src/PLASMA/RulesEngine/base/RulesEngineListener.cc +++ b/src/PLASMA/RulesEngine/base/RulesEngineListener.cc @@ -20,4 +20,8 @@ namespace EUROPA { const RulesEngineListenerId &RulesEngineListener::getId() const { return m_id; } + +void RulesEngineListener::notifyExecuted(const RuleInstanceId &){} +void RulesEngineListener::notifyUndone(const RuleInstanceId &){} + } diff --git a/src/PLASMA/RulesEngine/base/RulesEngineListener.hh b/src/PLASMA/RulesEngine/base/RulesEngineListener.hh index 43ea91f4c..59f1f791b 100644 --- a/src/PLASMA/RulesEngine/base/RulesEngineListener.hh +++ b/src/PLASMA/RulesEngine/base/RulesEngineListener.hh @@ -1,5 +1,5 @@ -#ifndef _H_RulesEngineListener -#define _H_RulesEngineListener +#ifndef H_RulesEngineListener +#define H_RulesEngineListener #include "RulesEngineDefs.hh" @@ -7,8 +7,8 @@ namespace EUROPA { class RulesEngineListener { public: virtual ~RulesEngineListener(); - virtual void notifyExecuted(const RuleInstanceId &rule){} - virtual void notifyUndone(const RuleInstanceId &rule){} + virtual void notifyExecuted(const RuleInstanceId &rule); + virtual void notifyUndone(const RuleInstanceId &rule); const RulesEngineListenerId &getId() const; protected: diff --git a/src/PLASMA/RulesEngine/test/TestRule.cc b/src/PLASMA/RulesEngine/test/TestRule.cc index 8fb0af30d..2096655c3 100644 --- a/src/PLASMA/RulesEngine/test/TestRule.cc +++ b/src/PLASMA/RulesEngine/test/TestRule.cc @@ -16,7 +16,7 @@ namespace EUROPA { */ class TestRule_Root: public RuleInstance{ public: - TestRule_Root(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb) + TestRule_Root(const RuleId rule, const TokenId token, const PlanDatabaseId planDb) : RuleInstance(rule, token, planDb, makeScope(token->getObject())){} void handleExecute(); }; @@ -26,7 +26,7 @@ namespace EUROPA { */ class TestRule_0: public RuleInstance{ public: - TestRule_0(const RuleInstanceId& parentInstance, const ConstrainedVariableId& guard) + TestRule_0(const RuleInstanceId parentInstance, const ConstrainedVariableId guard) : RuleInstance(parentInstance, makeScope(guard)), m_localGuard(guard){} void handleExecute(); @@ -37,7 +37,7 @@ namespace EUROPA { TestRule::TestRule(const LabelStr& name, const IntervalIntDomain& guardBaseDomain) : Rule(name), m_guardBaseDomain(guardBaseDomain){} - RuleInstanceId TestRule::createInstance(const TokenId& token, const PlanDatabaseId& planDb, + RuleInstanceId TestRule::createInstance(const TokenId token, const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const{ RuleInstanceId rootInstance = (new TestRule_Root(m_id, token, planDb))->getId(); rootInstance->setRulesEngine(rulesEngine); diff --git a/src/PLASMA/RulesEngine/test/TestRule.hh b/src/PLASMA/RulesEngine/test/TestRule.hh index f4180e891..ddd35f71a 100644 --- a/src/PLASMA/RulesEngine/test/TestRule.hh +++ b/src/PLASMA/RulesEngine/test/TestRule.hh @@ -1,5 +1,5 @@ -#ifndef _H_TestRule -#define _H_TestRule +#ifndef H_TestRule +#define H_TestRule #include "Rule.hh" #include "Domains.hh" @@ -21,7 +21,7 @@ namespace EUROPA { */ class TestRule: public Rule { public: - RuleInstanceId createInstance(const TokenId& token, const PlanDatabaseId& planDb, + RuleInstanceId createInstance(const TokenId token, const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const; TestRule(const LabelStr& name, const IntervalIntDomain& guardBaseDomain = IntervalIntDomain(1,1)); const IntervalIntDomain& getGuardBaseDomain() const {return m_guardBaseDomain;} diff --git a/src/PLASMA/RulesEngine/test/module-tests.cc b/src/PLASMA/RulesEngine/test/module-tests.cc index 1ac9a8b86..6a059a0ff 100644 --- a/src/PLASMA/RulesEngine/test/module-tests.cc +++ b/src/PLASMA/RulesEngine/test/module-tests.cc @@ -5,7 +5,7 @@ using namespace EUROPA; CPPUNIT_TEST_SUITE_REGISTRATION( RulesEngineModuleTests ); -int main( int argc, char **argv) +int main( int, char **) { // Init data types so that id counts don't fail VoidDT::instance(); diff --git a/src/PLASMA/RulesEngine/test/re-test-module.cc b/src/PLASMA/RulesEngine/test/re-test-module.cc index 394b9568d..c971b3941 100644 --- a/src/PLASMA/RulesEngine/test/re-test-module.cc +++ b/src/PLASMA/RulesEngine/test/re-test-module.cc @@ -15,6 +15,8 @@ #include "Propagators.hh" #include "ProxyVariableRelation.hh" #include "Constraint.hh" +#include "CESchema.hh" +#include "TestUtils.hh" #include "Constraints.hh" #include "ModuleConstraintEngine.hh" @@ -23,17 +25,18 @@ #include #include +#include using namespace EUROPA; class SimpleSubGoal: public Rule { public: SimpleSubGoal() - : Rule(LabelStr("AllObjects.Predicate")) + : Rule("AllObjects.Predicate") { } - RuleInstanceId createInstance(const TokenId& token, const PlanDatabaseId& planDb, + RuleInstanceId createInstance(const TokenId token, const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const{ RuleInstanceId rootInstance = (new RootInstance(m_id, token, planDb))->getId(); std::vector vars = rootInstance->getVariables("start:end:duration:object:state"); @@ -47,12 +50,12 @@ class SimpleSubGoal: public Rule { private: class RootInstance: public RuleInstance{ public: - RootInstance(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb) - : RuleInstance(rule, token, planDb) {} + RootInstance(const RuleId rule, const TokenId token, const PlanDatabaseId planDb) + : RuleInstance(rule, token, planDb), m_onlySlave() {} void handleExecute(){ - m_onlySlave = addSlave(new IntervalToken(m_token, "met_by", LabelStr("AllObjects.Predicate"))); - addConstraint(LabelStr("eq"), makeScope(m_token->end(), m_onlySlave->start())); + m_onlySlave = addSlave(new IntervalToken(m_token, "met_by", "AllObjects.Predicate")); + addConstraint("eq", makeScope(m_token->end(), m_onlySlave->start())); } TokenId m_onlySlave; @@ -77,88 +80,88 @@ class SimpleSubGoal: public Rule { class NestedGuards_0: public Rule { public: NestedGuards_0(); - RuleInstanceId createInstance(const TokenId& token, const PlanDatabaseId& planDb, + RuleInstanceId createInstance(const TokenId token, const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const; }; class NestedGuards_0_Root: public RuleInstance{ public: - NestedGuards_0_Root(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb); + NestedGuards_0_Root(const RuleId rule, const TokenId token, const PlanDatabaseId planDb); void handleExecute(); TokenId m_onlySlave; }; class NestedGuards_0_0: public RuleInstance{ public: - NestedGuards_0_0(const RuleInstanceId& parentInstance, const ConstrainedVariableId& guard, const Domain& domain); + NestedGuards_0_0(const RuleInstanceId parentInstance, const ConstrainedVariableId guard, const Domain& domain); void handleExecute(); TokenId m_onlySlave; }; class NestedGuards_0_1: public RuleInstance{ public: - NestedGuards_0_1(const RuleInstanceId& parentInstance, const std::vector& guards); + NestedGuards_0_1(const RuleInstanceId parentInstance, const std::vector& guards); void handleExecute(); TokenId m_onlySlave; }; NestedGuards_0::NestedGuards_0() - : Rule(LabelStr("AllObjects.Predicate")) + : Rule("AllObjects.Predicate") { } -RuleInstanceId NestedGuards_0::createInstance(const TokenId& token, const PlanDatabaseId& planDb, +RuleInstanceId NestedGuards_0::createInstance(const TokenId token, const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const{ RuleInstanceId rootInstance = (new NestedGuards_0_Root(m_id, token, planDb))->getId(); rootInstance->setRulesEngine(rulesEngine); return rootInstance; } -NestedGuards_0_Root::NestedGuards_0_Root(const RuleId& rule, const TokenId& token, - const PlanDatabaseId& planDb) - : RuleInstance(rule, token, planDb, makeScope(token->getObject())) {} +NestedGuards_0_Root::NestedGuards_0_Root(const RuleId rule, const TokenId token, + const PlanDatabaseId planDb) + : RuleInstance(rule, token, planDb, makeScope(token->getObject())), m_onlySlave() {} void NestedGuards_0_Root::handleExecute(){ - m_onlySlave = addSlave(new IntervalToken(m_token, "met_by", LabelStr("AllObjects.Predicate"))); - addConstraint(LabelStr("eq"), makeScope(m_token->end(), m_onlySlave->start())); + m_onlySlave = addSlave(new IntervalToken(m_token, "met_by", "AllObjects.Predicate")); + addConstraint("eq", makeScope(m_token->end(), m_onlySlave->start())); addChildRule(new NestedGuards_0_0(m_id, m_token->start(), IntervalIntDomain(8, 12))); /*!< Add child context with guards - start == 10 */ addChildRule(new NestedGuards_0_1(m_id, makeScope(m_onlySlave->getObject()))); /*!< Add child context with guards - object set to singleton */ } -NestedGuards_0_0::NestedGuards_0_0(const RuleInstanceId& parentInstance, const ConstrainedVariableId& guard, const Domain& domain) - : RuleInstance(parentInstance, guard, domain){} +NestedGuards_0_0::NestedGuards_0_0(const RuleInstanceId parentInstance, const ConstrainedVariableId guard, const Domain& domain) + : RuleInstance(parentInstance, guard, domain), m_onlySlave() {} void NestedGuards_0_0::handleExecute(){ - m_onlySlave = addSlave(new IntervalToken(m_token, "met_by", LabelStr("AllObjects.Predicate"))); - addConstraint(LabelStr("eq"), makeScope(m_token->start(), m_onlySlave->end())); // Place before + m_onlySlave = addSlave(new IntervalToken(m_token, "met_by", "AllObjects.Predicate")); + addConstraint("eq", makeScope(m_token->start(), m_onlySlave->end())); // Place before } -NestedGuards_0_1::NestedGuards_0_1(const RuleInstanceId& parentInstance, const std::vector& guards) - : RuleInstance(parentInstance, guards){} +NestedGuards_0_1::NestedGuards_0_1(const RuleInstanceId parentInstance, const std::vector& guards) + : RuleInstance(parentInstance, guards), m_onlySlave() {} void NestedGuards_0_1::handleExecute(){ - m_onlySlave = addSlave(new IntervalToken(m_token, "met_by", LabelStr("AllObjects.Predicate"))); - addConstraint(LabelStr("eq"), makeScope(m_token->start(), m_onlySlave->end())); // Place before + m_onlySlave = addSlave(new IntervalToken(m_token, "met_by", "AllObjects.Predicate")); + addConstraint("eq", makeScope(m_token->start(), m_onlySlave->end())); // Place before } class LocalVariableGuard_0: public Rule { public: LocalVariableGuard_0(); - RuleInstanceId createInstance(const TokenId& token, const PlanDatabaseId& planDb, + RuleInstanceId createInstance(const TokenId token, const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const; }; class LocalVariableGuard_0_Root: public RuleInstance{ public: - LocalVariableGuard_0_Root(const RuleId& rule, const TokenId& token, const PlanDatabaseId& planDb); + LocalVariableGuard_0_Root(const RuleId rule, const TokenId token, const PlanDatabaseId planDb); void handleExecute(); - static const ConstrainedVariableId& getGuard() {return s_guard;} + static const ConstrainedVariableId getGuard() {return s_guard;} static ConstrainedVariableId s_guard; }; class LocalVariableGuard_0_0: public RuleInstance{ public: - LocalVariableGuard_0_0(const RuleInstanceId& parentInstance, const ConstrainedVariableId& guard, const Domain& domain) + LocalVariableGuard_0_0(const RuleInstanceId parentInstance, const ConstrainedVariableId guard, const Domain& domain) : RuleInstance(parentInstance, guard, domain){} void handleExecute(); }; @@ -166,20 +169,20 @@ class LocalVariableGuard_0_0: public RuleInstance{ ConstrainedVariableId LocalVariableGuard_0_Root::s_guard; LocalVariableGuard_0::LocalVariableGuard_0() - : Rule(LabelStr("AllObjects.Predicate")) + : Rule("AllObjects.Predicate") { } -RuleInstanceId LocalVariableGuard_0::createInstance(const TokenId& token, - const PlanDatabaseId& planDb, +RuleInstanceId LocalVariableGuard_0::createInstance(const TokenId token, + const PlanDatabaseId planDb, const RulesEngineId &rulesEngine) const{ RuleInstanceId rootInstance = (new LocalVariableGuard_0_Root(m_id, token, planDb))->getId(); rootInstance->setRulesEngine(rulesEngine); return rootInstance; } -LocalVariableGuard_0_Root::LocalVariableGuard_0_Root(const RuleId& rule, const TokenId& token, - const PlanDatabaseId& planDb) +LocalVariableGuard_0_Root::LocalVariableGuard_0_Root(const RuleId rule, const TokenId token, + const PlanDatabaseId planDb) : RuleInstance(rule, token, planDb){} void LocalVariableGuard_0_Root::handleExecute(){ @@ -191,7 +194,7 @@ void LocalVariableGuard_0_Root::handleExecute(){ baseDomain.insert(LabelStr("D")); baseDomain.insert(LabelStr("E")); baseDomain.close(); - ConstrainedVariableId guard = addVariable(baseDomain, true, LabelStr("b")); + ConstrainedVariableId guard = addVariable(baseDomain, true, "b"); s_guard = guard; // To allow it to be set // Now allocate the guard domain. @@ -205,7 +208,7 @@ void LocalVariableGuard_0_Root::handleExecute(){ } void LocalVariableGuard_0_0::handleExecute(){ - addSlave(new IntervalToken(m_token, "any", LabelStr("AllObjects.Predicate"))); + addSlave(new IntervalToken(m_token, "any", "AllObjects.Predicate")); } class RETestEngine : public EngineBase @@ -214,10 +217,10 @@ class RETestEngine : public EngineBase RETestEngine(); virtual ~RETestEngine(); - const ConstraintEngineId& getConstraintEngine() const; - const SchemaId& getSchema() const; - const PlanDatabaseId& getPlanDatabase() const; - const RulesEngineId& getRulesEngine() const; + const ConstraintEngineId getConstraintEngine() const; + const SchemaId getSchema() const; + const PlanDatabaseId getPlanDatabase() const; + const RulesEngineId getRulesEngine() const; protected: void createModules(); @@ -242,12 +245,12 @@ RETestEngine::RETestEngine() sch->registerObjectType(ot->getId()); - Object* objectPtr = new Object(getPlanDatabase(), "AllObjects", LabelStr("defaultObj")); + Object* objectPtr = new Object(getPlanDatabase(), "AllObjects", "defaultObj"); assert(objectPtr != 0); Object& object = *objectPtr; assert(objectPtr->getId() == object.getId()); - CESchema* ces = (CESchema*)getComponent("CESchema"); + CESchema* ces = boost::polymorphic_cast(getComponent("CESchema")); REGISTER_SYSTEM_CONSTRAINT(ces,EqualConstraint, "concurrent", "Default"); REGISTER_SYSTEM_CONSTRAINT(ces,LessThanEqualConstraint, "precedes", "Default"); REGISTER_SYSTEM_CONSTRAINT(ces,AddEqualConstraint, "temporaldistance", "Default"); @@ -259,24 +262,20 @@ RETestEngine::~RETestEngine() doShutdown(); } -const ConstraintEngineId& RETestEngine::getConstraintEngine() const -{ - return ((ConstraintEngine*)getComponent("ConstraintEngine"))->getId(); +const ConstraintEngineId RETestEngine::getConstraintEngine() const { + return boost::polymorphic_cast(getComponent("ConstraintEngine"))->getId(); } -const SchemaId& RETestEngine::getSchema() const -{ - return ((Schema*)getComponent("Schema"))->getId(); +const SchemaId RETestEngine::getSchema() const { + return boost::polymorphic_cast(getComponent("Schema"))->getId(); } -const PlanDatabaseId& RETestEngine::getPlanDatabase() const -{ - return ((PlanDatabase*)getComponent("PlanDatabase"))->getId(); +const PlanDatabaseId RETestEngine::getPlanDatabase() const { + return boost::polymorphic_cast(getComponent("PlanDatabase"))->getId(); } -const RulesEngineId& RETestEngine::getRulesEngine() const -{ - return ((RulesEngine*)getComponent("RulesEngine"))->getId(); +const RulesEngineId RETestEngine::getRulesEngine() const { + return boost::polymorphic_cast(getComponent("RulesEngine"))->getId(); } void RETestEngine::createModules() @@ -287,10 +286,12 @@ void RETestEngine::createModules() addModule((new ModuleRulesEngine())->getId()); } +namespace { ConstraintEngineId ce; SchemaId schema; PlanDatabaseId db; RulesEngineId re; +} #define RE_DEFAULT_SETUP(ce, db, autoClose) \ RETestEngine testEngine; \ @@ -326,7 +327,7 @@ class RulesEngineTest { // Create a token of an expected type IntervalToken t0(db, - LabelStr("AllObjects.Predicate"), + "AllObjects.Predicate", true, false, IntervalIntDomain(0, 1000), @@ -347,15 +348,15 @@ class RulesEngineTest { static bool testNestedGuards(){ RE_DEFAULT_SETUP(ce, db, false); - Object o1(db, LabelStr("AllObjects"), LabelStr("o1")); - Object o2(db, LabelStr("AllObjects"), LabelStr("o2")); + Object o1(db, "AllObjects", "o1"); + Object o2(db, "AllObjects", "o2"); db->close(); re->getRuleSchema()->registerRule((new NestedGuards_0())->getId()); // Create a token of an expected type IntervalToken t0(db, - LabelStr("AllObjects.Predicate"), + "AllObjects.Predicate", true, false, IntervalIntDomain(0, 10), @@ -397,15 +398,15 @@ class RulesEngineTest { static bool testNestedGuardsConstraint(){ RE_DEFAULT_SETUP(ce, db, false); - Object o1(db, LabelStr("AllObjects"), LabelStr("o1")); - Object o2(db, LabelStr("AllObjects"), LabelStr("o2")); + Object o1(db, "AllObjects", "o1"); + Object o2(db, "AllObjects", "o2"); db->close(); re->getRuleSchema()->registerRule((new NestedGuards_0())->getId()); // Create a token of an expected type IntervalToken t0(db, - LabelStr("AllObjects.Predicate"), + "AllObjects.Predicate", true, false, IntervalIntDomain(0, 10), @@ -472,7 +473,7 @@ class RulesEngineTest { re->getRuleSchema()->registerRule((new LocalVariableGuard_0())->getId()); IntervalToken t0(db, - LabelStr("AllObjects.Predicate"), + "AllObjects.Predicate", true, false, IntervalIntDomain(0, 1000), @@ -505,10 +506,10 @@ class RulesEngineTest { RE_DEFAULT_SETUP(ce, db, false); db->close(); - re->getRuleSchema()->registerRule((new TestRule(LabelStr("AllObjects.Predicate")))->getId()); + re->getRuleSchema()->registerRule((new TestRule("AllObjects.Predicate"))->getId()); IntervalToken t0(db, - LabelStr("AllObjects.Predicate"), + "AllObjects.Predicate", true, false, IntervalIntDomain(0, 1000), @@ -533,7 +534,7 @@ class RulesEngineTest { db->close(); RuleSchema rs; - rs.registerRule((new TestRule(LabelStr("AllObjects.Predicate")))->getId()); + rs.registerRule((new TestRule("AllObjects.Predicate"))->getId()); rs.purgeAll(); RE_DEFAULT_TEARDOWN(); @@ -550,7 +551,7 @@ class RulesEngineTest { { // Create a token of an expected type IntervalToken t0(db, - LabelStr("AllObjects.Predicate"), + "AllObjects.Predicate", true, false, IntervalIntDomain(0, 1000), @@ -566,7 +567,7 @@ class RulesEngineTest { CPPUNIT_ASSERT(t0.end()->getDerivedDomain() == slaveToken->start()->getDerivedDomain()); t0.commit(); - delete (Token*) slaveToken; + delete static_cast(slaveToken); Entity::garbageCollect(); } @@ -576,7 +577,7 @@ class RulesEngineTest { { // Create a token of an expected type IntervalToken t0(db, - LabelStr("AllObjects.Predicate"), + "AllObjects.Predicate", true, false, IntervalIntDomain(0, 1000), @@ -596,7 +597,7 @@ class RulesEngineTest { } Entity::garbageCollect(); - delete (Token*) slaveToken; + delete static_cast(slaveToken); } RE_DEFAULT_TEARDOWN(); diff --git a/src/PLASMA/Solvers/CMakeLists.txt b/src/PLASMA/Solvers/CMakeLists.txt index 4a8945792..37a577ac3 100644 --- a/src/PLASMA/Solvers/CMakeLists.txt +++ b/src/PLASMA/Solvers/CMakeLists.txt @@ -1,7 +1,8 @@ include(EuropaModule) set(internal_dependencies NDDL RulesEngine TemporalNetwork PlanDatabase ConstraintEngine Utils TinyXml) +# set(internal_dependencies NDDL RulesEngine TemporalNetwork PlanDatabase) set(root_sources ModuleSolvers.cc) -set(base_sources ComponentFactory.cc Context.cc FlawFilter.cc FlawHandler.cc FlawManager.cc MatchingEngine.cc MatchingRule.cc Solver.cc SolverDecisionPoint.cc SolverUtils.cc) +set(base_sources ComponentFactory.cc Context.cc FlawFilter.cc FlawHandler.cc FlawManager.cc MatchingEngine.cc MatchingRule.cc Solver.cc SolverDecisionPoint.cc SolverUtils.cc SearchListener.cc) set(component_sources Filters.cc HSTSDecisionPoints.cc OpenConditionDecisionPoint.cc OpenConditionManager.cc PSSolversImpl.cc ThreatDecisionPoint.cc ThreatManager.cc UnboundVariableDecisionPoint.cc UnboundVariableManager.cc ValueSource.cc) set(test_sources module-tests.cc solvers-test-module.cc) diff --git a/src/PLASMA/Solvers/ModuleSolvers.cc b/src/PLASMA/Solvers/ModuleSolvers.cc index aab642e8d..fc0e0de7b 100644 --- a/src/PLASMA/Solvers/ModuleSolvers.cc +++ b/src/PLASMA/Solvers/ModuleSolvers.cc @@ -14,6 +14,9 @@ #include "UnboundVariableManager.hh" #include "RulesEngine.hh" #include "PSSolversImpl.hh" +#include "CESchema.hh" + +#include // TODO: is this necessary? #ifdef near @@ -42,68 +45,74 @@ namespace EUROPA { { } - void ModuleSolvers::initialize(EngineId engine) - { - ConstraintEngine* ce = (ConstraintEngine*)engine->getComponent("ConstraintEngine"); - PlanDatabase* pdb = (PlanDatabase*)engine->getComponent("PlanDatabase"); - PSSolverManager* sm = new PSSolverManagerImpl(pdb->getId()); - engine->addComponent("PSSolverManager",sm); - - REGISTER_SYSTEM_CONSTRAINT(ce->getCESchema(),SOLVERS::FlawHandler::VariableListener,SOLVERS::FlawHandler::VariableListener::CONSTRAINT_NAME(),SOLVERS::FlawHandler::VariableListener::PROPAGATOR_NAME()); - - EUROPA::SOLVERS::ComponentFactoryMgr* cfm = new EUROPA::SOLVERS::ComponentFactoryMgr(); - engine->addComponent("ComponentFactoryMgr",cfm); - REGISTER_COMPONENT_FACTORY(cfm,SOLVERS::FlawFilter, FlawFilter); - - REGISTER_FLAW_MANAGER(cfm,SOLVERS::UnboundVariableManager, UnboundVariableManager); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::MinValue, StandardVariableHandler); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::MinValue, Min); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::MaxValue, Max); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::HSTS::ValueEnum, ValEnum); - - REGISTER_FLAW_MANAGER(cfm,SOLVERS::OpenConditionManager, OpenConditionManager); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::SupportedOCDecisionPoint, StandardOpenConditionHandler); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::OpenConditionDecisionPoint, BasicOpenConditionHandler); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::SupportedOCDecisionPoint, SupportedOpenConditionHandler); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::HSTS::OpenConditionDecisionPoint, HSTSOpenConditionDecisionPoint); - - REGISTER_FLAW_MANAGER(cfm,SOLVERS::ThreatManager, ThreatManager); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::ThreatDecisionPoint, StandardThreatHandler); - REGISTER_FLAW_HANDLER(cfm,SOLVERS::HSTS::ThreatDecisionPoint, HSTSThreatDecisionPoint); - - REGISTER_FLAW_FILTER(cfm,SOLVERS::GuardFilter, GuardFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::NotGuardFilter, NotGuardFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::ParameterFilter, ParameterFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::LocalVariableFilter, LocalVariableFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::SingletonFilter, Singleton); - REGISTER_FLAW_FILTER(cfm,SOLVERS::InfiniteDynamicFilter, InfiniteDynamicFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::HorizonFilter, HorizonFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::HorizonVariableFilter, HorizonVariableFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::MasterMustBeAssignedFilter, MasterMustBeInsertedFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::TokenMustBeAssignedFilter, TokenMustBeAssignedFilter); - REGISTER_FLAW_FILTER(cfm,SOLVERS::TokenMustBeAssignedFilter, ParentMustBeInsertedFilter); - - REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::EarlyTokenComparator, early); - REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::LateTokenComparator, late); - REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::NearTokenComparator, near); - REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::FarTokenComparator, far); - REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::AscendingKeyTokenComparator, ascendingKey); - - EUROPA::SOLVERS::MatchFinderMgr* mfm = new EUROPA::SOLVERS::MatchFinderMgr(); - engine->addComponent("MatchFinderMgr",mfm); - REGISTER_MATCH_FINDER(mfm,SOLVERS::VariableMatchFinder,ConstrainedVariable::entityTypeName()); - REGISTER_MATCH_FINDER(mfm,SOLVERS::TokenMatchFinder,Token::entityTypeName()); - } +void ModuleSolvers::initialize(EngineId engine) { + ConstraintEngine* ce = + boost::polymorphic_cast(engine->getComponent("ConstraintEngine")); + + PlanDatabase* pdb = + boost::polymorphic_cast(engine->getComponent("PlanDatabase")); + + PSSolverManager* sm = new PSSolverManagerImpl(pdb->getId()); + engine->addComponent("PSSolverManager",sm); + + REGISTER_SYSTEM_CONSTRAINT(ce->getCESchema(),SOLVERS::FlawHandler::VariableListener,SOLVERS::FlawHandler::VariableListener::CONSTRAINT_NAME(),SOLVERS::FlawHandler::VariableListener::PROPAGATOR_NAME()); + + EUROPA::SOLVERS::ComponentFactoryMgr* cfm = new EUROPA::SOLVERS::ComponentFactoryMgr(); + engine->addComponent("ComponentFactoryMgr",cfm); + REGISTER_COMPONENT_FACTORY(cfm,SOLVERS::FlawFilter, FlawFilter); + + REGISTER_FLAW_MANAGER(cfm,SOLVERS::UnboundVariableManager, UnboundVariableManager); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::MinValue, StandardVariableHandler); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::MinValue, Min); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::MaxValue, Max); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::RandomValue, Random); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::HSTS::ValueEnum, ValEnum); + + REGISTER_FLAW_MANAGER(cfm,SOLVERS::OpenConditionManager, OpenConditionManager); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::SupportedOCDecisionPoint, StandardOpenConditionHandler); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::OpenConditionDecisionPoint, BasicOpenConditionHandler); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::SupportedOCDecisionPoint, SupportedOpenConditionHandler); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::HSTS::OpenConditionDecisionPoint, HSTSOpenConditionDecisionPoint); + + REGISTER_FLAW_MANAGER(cfm,SOLVERS::ThreatManager, ThreatManager); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::ThreatDecisionPoint, StandardThreatHandler); + REGISTER_FLAW_HANDLER(cfm,SOLVERS::HSTS::ThreatDecisionPoint, HSTSThreatDecisionPoint); + + REGISTER_FLAW_FILTER(cfm,SOLVERS::GuardFilter, GuardFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::NotGuardFilter, NotGuardFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::ParameterFilter, ParameterFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::LocalVariableFilter, LocalVariableFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::SingletonFilter, Singleton); + REGISTER_FLAW_FILTER(cfm,SOLVERS::InfiniteDynamicFilter, InfiniteDynamicFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::HorizonFilter, HorizonFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::HorizonVariableFilter, HorizonVariableFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::MasterMustBeAssignedFilter, MasterMustBeInsertedFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::TokenMustBeAssignedFilter, TokenMustBeAssignedFilter); + REGISTER_FLAW_FILTER(cfm,SOLVERS::TokenMustBeAssignedFilter, ParentMustBeInsertedFilter); + + REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::EarlyTokenComparator, early); + REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::LateTokenComparator, late); + REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::NearTokenComparator, near); + REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::FarTokenComparator, far); + REGISTER_TOKEN_SORTER(cfm,SOLVERS::HSTS::AscendingKeyTokenComparator, ascendingKey); + + EUROPA::SOLVERS::MatchFinderMgr* mfm = new EUROPA::SOLVERS::MatchFinderMgr(); + engine->addComponent("MatchFinderMgr",mfm); + REGISTER_MATCH_FINDER(mfm,SOLVERS::VariableMatchFinder,ConstrainedVariable::entityTypeName()); + REGISTER_MATCH_FINDER(mfm,SOLVERS::TokenMatchFinder,Token::entityTypeName()); +} - void ModuleSolvers::uninitialize(EngineId engine) - { - EUROPA::SOLVERS::MatchFinderMgr* mfm = (EUROPA::SOLVERS::MatchFinderMgr*)engine->removeComponent("MatchFinderMgr"); - delete mfm; +void ModuleSolvers::uninitialize(EngineId engine) { + EUROPA::SOLVERS::MatchFinderMgr* mfm = + boost::polymorphic_cast(engine->removeComponent("MatchFinderMgr")); + delete mfm; - EUROPA::SOLVERS::ComponentFactoryMgr* cfm = (EUROPA::SOLVERS::ComponentFactoryMgr*)engine->removeComponent("ComponentFactoryMgr"); - delete cfm; + EUROPA::SOLVERS::ComponentFactoryMgr* cfm = + boost::polymorphic_cast(engine->removeComponent("ComponentFactoryMgr")); + delete cfm; - PSSolverManager* sm = (PSSolverManager*)engine->removeComponent("PSSolverManager"); - delete sm; - } + PSSolverManager* sm = + boost::polymorphic_cast(engine->removeComponent("PSSolverManager")); + delete sm; +} } diff --git a/src/PLASMA/Solvers/ModuleSolvers.hh b/src/PLASMA/Solvers/ModuleSolvers.hh index d07940369..bbb63e11f 100644 --- a/src/PLASMA/Solvers/ModuleSolvers.hh +++ b/src/PLASMA/Solvers/ModuleSolvers.hh @@ -1,6 +1,6 @@ -#ifndef _H_ModuleSolvers -#define _H_ModuleSolvers +#ifndef H_ModuleSolvers +#define H_ModuleSolvers #include "Module.hh" @@ -29,4 +29,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_ModuleSolvers */ +#endif /* #ifndef H_ModuleSolvers */ diff --git a/src/PLASMA/Solvers/PSSolvers.hh b/src/PLASMA/Solvers/PSSolvers.hh index 5d19ec886..bba38120b 100644 --- a/src/PLASMA/Solvers/PSSolvers.hh +++ b/src/PLASMA/Solvers/PSSolvers.hh @@ -1,8 +1,8 @@ -#ifndef _H_PSSolvers -#define _H_PSSolvers +#ifndef H_PSSolvers +#define H_PSSolvers #include "Engine.hh" -#include "PSUtils.hh" +#include "PSList.hh" #include namespace EUROPA @@ -17,37 +17,36 @@ namespace EUROPA virtual PSSolver* createSolver(const std::string& configurationFile) = 0; }; - class PSSolver - { - public: - virtual ~PSSolver() {} - - virtual void step() = 0; - virtual void solve(int maxSteps,int maxDepth) = 0; - virtual bool backjump(unsigned int stepCount) = 0; - virtual void reset() = 0; - virtual void reset(unsigned int depth) = 0; - virtual void destroy() = 0; +class PSSolver { + public: + virtual ~PSSolver() {} + + virtual void step() = 0; + virtual bool solve(int maxSteps,int maxDepth) = 0; + virtual bool backjump(unsigned int stepCount) = 0; + virtual void reset() = 0; + virtual void reset(unsigned int depth) = 0; + virtual void destroy() = 0; - virtual int getStepCount() = 0; - virtual int getDepth() = 0; - virtual int getOpenDecisionCnt() = 0; + virtual int getStepCount() = 0; + virtual int getDepth() = 0; + virtual int getOpenDecisionCnt() = 0; - virtual bool isExhausted() = 0; - virtual bool isTimedOut() = 0; - virtual bool isConstraintConsistent() = 0; - virtual bool hasFlaws() = 0; + virtual bool isExhausted() = 0; + virtual bool isTimedOut() = 0; + virtual bool isConstraintConsistent() = 0; + virtual bool hasFlaws() = 0; - virtual PSList getFlaws() = 0; - virtual std::string getLastExecutedDecision() = 0; + virtual PSList getFlaws() = 0; + virtual std::string getLastExecutedDecision() = 0; - // TODO: should horizon start and end be part of configuration? - virtual const std::string& getConfigFilename() = 0; - virtual eint::basis_type getHorizonStart() = 0; - virtual eint::basis_type getHorizonEnd() = 0; + // TODO: should horizon start and end be part of configuration? + virtual const std::string& getConfigFilename() = 0; + virtual eint::basis_type getHorizonStart() = 0; + virtual eint::basis_type getHorizonEnd() = 0; - virtual void configure(eint::basis_type horizonStart, eint::basis_type horizonEnd) = 0; - }; + virtual void configure(eint::basis_type horizonStart, eint::basis_type horizonEnd) = 0; +}; } diff --git a/src/PLASMA/Solvers/SolverDefs.hh b/src/PLASMA/Solvers/SolverDefs.hh index 0010e0657..368cf9380 100644 --- a/src/PLASMA/Solvers/SolverDefs.hh +++ b/src/PLASMA/Solvers/SolverDefs.hh @@ -45,7 +45,7 @@ namespace EUROPA { /** * @brief Used to store guard entry data - var name and expected value to match on. */ - typedef std::pair GuardEntry; + typedef std::pair GuardEntry; static Priority & worstCasePriority() { static Priority sl_worstCasePriority(99999); @@ -57,11 +57,11 @@ namespace EUROPA { return sl_bestCasePriority; } - inline const Priority getBestCasePriority() { + inline Priority getBestCasePriority() { return bestCasePriority(); } - inline const Priority getWorstCasePriority() { + inline Priority getWorstCasePriority() { return worstCasePriority(); } diff --git a/src/PLASMA/Solvers/base/ComponentFactory.cc b/src/PLASMA/Solvers/base/ComponentFactory.cc index eb340d59e..69bd7a08b 100644 --- a/src/PLASMA/Solvers/base/ComponentFactory.cc +++ b/src/PLASMA/Solvers/base/ComponentFactory.cc @@ -10,39 +10,32 @@ */ namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - Component::Component() - : m_id(this) - { - } +Component::Component() : m_id(this), m_name() {} - Component::Component(const TiXmlElement& configData) - : m_id(this) - { - } +Component::Component(const TiXmlElement&) : m_id(this), m_name() {} - Component::~Component() - { - m_id.remove(); - } +Component::~Component() { + m_id.remove(); +} + +ComponentId Component::getId() {return m_id;} - ComponentId& Component::getId() {return m_id;} +const ComponentId Component::getId() const {return m_id;} - const ComponentId& Component::getId() const {return m_id;} +const std::string& Component::getName() const { + return m_name; +} - const LabelStr& Component::getName() const { - return m_name; - } +void Component::setName(const std::string& name){ + m_name = name; +} - void Component::setName(const LabelStr& name){ - m_name = name; - } +ComponentId ComponentFactoryMgr::createComponentInstance(const TiXmlElement& configData) { + std::string name = extractData(configData, "component"); + return FactoryMgr::createInstance(name,ComponentArgs(configData)); +} - ComponentId ComponentFactoryMgr::createInstance(const TiXmlElement& configData) - { - LabelStr name = extractData(configData, "component"); - return FactoryMgr::createInstance(name,ComponentArgs(configData)); - } - } +} } diff --git a/src/PLASMA/Solvers/base/ComponentFactory.hh b/src/PLASMA/Solvers/base/ComponentFactory.hh index 005f1a481..d1fae0ce6 100644 --- a/src/PLASMA/Solvers/base/ComponentFactory.hh +++ b/src/PLASMA/Solvers/base/ComponentFactory.hh @@ -27,14 +27,14 @@ namespace EUROPA { class Component : public FactoryObj { public: virtual ~Component(); - ComponentId& getId(); - const ComponentId& getId() const; - const LabelStr& getName() const; - void setName(const LabelStr& name); + ComponentId getId(); + const ComponentId getId() const; + const std::string& getName() const; + void setName(const std::string& name); protected: ComponentId m_id; - LabelStr m_name; + std::string m_name; Component(const TiXmlElement& configData); Component(); @@ -49,10 +49,10 @@ namespace EUROPA { /** * @brief Defines a base class for factories that take xml configuration data. */ - class ComponentFactoryMgr : public FactoryMgr { - public: - virtual ComponentId createInstance(const TiXmlElement& configData); - }; + class ComponentFactoryMgr : public FactoryMgr { + public: + virtual ComponentId createComponentInstance(const TiXmlElement& configData); + }; /** * @brief Provides concrete allocation using a template. @@ -61,13 +61,13 @@ namespace EUROPA { class ComponentFactory: public Factory { public: - ComponentFactory(const LabelStr& name) : Factory(name) {} + ComponentFactory(const std::string& name) : Factory(name) {} - virtual EUROPA::FactoryObjId& createInstance(const EUROPA::FactoryArgs& fa) { - const ComponentArgs& args = (const ComponentArgs&)fa; + virtual EUROPA::FactoryObjId createInstance(const EUROPA::FactoryArgs& fa) { + const ComponentArgs& args = dynamic_cast(fa); ComponentType* ct = new ComponentType(args.configData); ct->setName(getName()); - return (EUROPA::FactoryObjId&)(ct->getId()); + return static_cast(ct->getId()); } }; diff --git a/src/PLASMA/Solvers/base/Context.cc b/src/PLASMA/Solvers/base/Context.cc index d7ce9292c..f67c0b327 100644 --- a/src/PLASMA/Solvers/base/Context.cc +++ b/src/PLASMA/Solvers/base/Context.cc @@ -2,22 +2,22 @@ #include "Error.hh" namespace EUROPA { - namespace SOLVERS { - Context::Context(const LabelStr& name) : m_id(this), m_name(name) {} +namespace SOLVERS { +Context::Context(const std::string& name) : m_id(this), m_name(name), m_map() {} Context::~Context() { m_id.remove(); } - double Context::get(const LabelStr& key) const { - std::map::const_iterator it = m_map.find(key); - checkError(it != m_map.end(), "Error: '" << key.toString() << "' not in context '" << m_name.toString() << "'"); + double Context::get(const std::string& key) const { + std::map::const_iterator it = m_map.find(key); + checkError(it != m_map.end(), "Error: '" << key << "' not in context '" << m_name << "'"); return it->second; } - void Context::remove(const LabelStr& key) { - std::map::const_iterator it = m_map.find(key); - checkError(it != m_map.end(), "Error: '" << key.toString() << "' not in context '" << m_name.toString() << "'"); + void Context::remove(const std::string& key) { + std::map::const_iterator it = m_map.find(key); + checkError(it != m_map.end(), "Error: '" << key << "' not in context '" << m_name << "'"); m_map.erase(key); } } diff --git a/src/PLASMA/Solvers/base/Context.hh b/src/PLASMA/Solvers/base/Context.hh index 740103fc2..876ff9f58 100644 --- a/src/PLASMA/Solvers/base/Context.hh +++ b/src/PLASMA/Solvers/base/Context.hh @@ -1,26 +1,25 @@ -#ifndef _H_Context -#define _H_Context +#ifndef H_Context +#define H_Context #include "SolverDefs.hh" -#include "LabelStr.hh" namespace EUROPA { namespace SOLVERS { class Context { public: - Context(const LabelStr& name); + Context(const std::string& name); ~Context(); - double get(const LabelStr& key) const; - void remove(const LabelStr& key); - void put(const LabelStr& key, const double value) {m_map[key] = value;} - const LabelStr& getName() const {return m_name;} + double get(const std::string& key) const; + void remove(const std::string& key); + void put(const std::string& key, const double value) {m_map[key] = value;} + const std::string& getName() const {return m_name;} ContextId getId() const {return m_id;} protected: private: ContextId m_id; - const LabelStr m_name; - std::map m_map; + const std::string m_name; + std::map m_map; }; } } diff --git a/src/PLASMA/Solvers/base/FlawFilter.cc b/src/PLASMA/Solvers/base/FlawFilter.cc index 6243326eb..d26b8bcd0 100644 --- a/src/PLASMA/Solvers/base/FlawFilter.cc +++ b/src/PLASMA/Solvers/base/FlawFilter.cc @@ -5,13 +5,13 @@ #include "FlawFilter.hh" namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - FlawFilter::FlawFilter(const TiXmlElement& configData, bool isDynamic) - : MatchingRule(configData), m_isDynamic(isDynamic) {} +FlawFilter::FlawFilter(const TiXmlElement& configData, bool _isDynamic) + : MatchingRule(configData), m_isDynamic(_isDynamic), m_context() {} - bool FlawFilter::isDynamic() const {return m_isDynamic;} +bool FlawFilter::isDynamic() const {return m_isDynamic;} - bool FlawFilter::test(const EntityId& entity) {return true;} - } +bool FlawFilter::test(const EntityId) {return true;} +} } diff --git a/src/PLASMA/Solvers/base/FlawFilter.hh b/src/PLASMA/Solvers/base/FlawFilter.hh index ec6513157..266c90e1f 100644 --- a/src/PLASMA/Solvers/base/FlawFilter.hh +++ b/src/PLASMA/Solvers/base/FlawFilter.hh @@ -8,28 +8,28 @@ #include "MatchingRule.hh" namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - class FlawFilter: public MatchingRule { - public: - FlawFilter(const TiXmlElement& configData, bool isDynamic = false); +class FlawFilter: public MatchingRule { + public: + FlawFilter(const TiXmlElement& configData, bool isDynamic = false); - /** - * @brief Tests if the filter is dynamically changing and may need to be re-evaluated. - */ - bool isDynamic() const; + /** + * @brief Tests if the filter is dynamically changing and may need to be re-evaluated. + */ + bool isDynamic() const; - virtual bool test(const EntityId& entity); + virtual bool test(const EntityId entity); - ContextId getContext() const {return m_context;} - void setContext(ContextId& ctx) {m_context = ctx;} + // ContextId getContext() const {return m_context;} + // void setContext(ContextId ctx) {m_context = ctx;} - private: - const bool m_isDynamic; - ContextId m_context; - }; + private: + const bool m_isDynamic; + ContextId m_context; +}; - } +} } #define REGISTER_FLAW_FILTER(MGR,CLASS, NAME) REGISTER_COMPONENT_FACTORY(MGR,CLASS, NAME) diff --git a/src/PLASMA/Solvers/base/FlawHandler.cc b/src/PLASMA/Solvers/base/FlawHandler.cc index 3f8d943f4..6da0c4ba4 100644 --- a/src/PLASMA/Solvers/base/FlawHandler.cc +++ b/src/PLASMA/Solvers/base/FlawHandler.cc @@ -13,19 +13,21 @@ #include "PlanDatabase.hh" #include "Utils.hh" #include "XMLUtils.hh" +#include "tinyxml.h" #include namespace EUROPA { - namespace SOLVERS { - - - TiXmlElement* FlawHandler::s_element = NULL; - - FlawHandler::FlawHandler(const TiXmlElement& configData): - MatchingRule(static_cast(*(makeConfigData(configData)))), - m_configData(s_element), - m_guards(readGuards(configData, false)), - m_masterGuards(readGuards(configData, true)){ +namespace SOLVERS { + +FlawHandler::FlawHandler(const TiXmlElement& configData): + MatchingRule(configData), + m_configData(makeConfigData(configData)), + m_priority(0), + m_weight(0), + m_guards(readGuards(configData, false)), + m_masterGuards(readGuards(configData, true)), + m_db(), + m_maxChoices(0){ // Establish the priority const char* priorityStr = m_configData->Attribute("priority"); @@ -38,8 +40,6 @@ namespace EUROPA { const char* maxChoicesStr = m_configData->Attribute("maxChoices"); m_maxChoices = static_cast(atof(maxChoicesStr)); - checkError(m_maxChoices >= 0, maxChoicesStr << " must be positive"); - // The base uses a number that exceeds the max absolute value priority allowed. // It also multiplies by a minimum of 1 to ensure that 0 guards are handled as low weights. // Note also that we make it 2 so that defaul t compatibility heuristics @@ -47,9 +47,14 @@ namespace EUROPA { refreshWeight(); } - void FlawHandler::refreshWeight() { - m_weight = std::abs(m_priority - (2+staticFilterCount() + customStaticFilterCount() + m_guards.size() + m_masterGuards.size()) * WEIGHT_BASE()); - } +void FlawHandler::refreshWeight() { + m_weight = + std::abs(m_priority - + (2.0 + staticFilterCount() + customStaticFilterCount() + + static_cast(m_guards.size()) + + static_cast(m_masterGuards.size())) * + WEIGHT_BASE()); +} /** * @brief Process the input element to pull defaults from the parent @@ -58,33 +63,35 @@ namespace EUROPA { checkError(strcmp(configData.Value(), "FlawHandler") == 0, "Invalid Tag of " << configData.Value()); checkError(configData.Parent() != NULL, "Must have a parent to get the default properties."); - s_element = static_cast(configData.Clone()); - TiXmlElement* parent = (TiXmlElement*) configData.Parent(); + TiXmlElement* element = static_cast(configData.Clone()); + TiXmlElement* parent = static_cast(configData.Parent()); - if(s_element->Attribute("priority") == NULL){ + if(element->Attribute("priority") == NULL){ if(parent->Attribute("defaultPriority") != NULL) - s_element->SetAttribute("priority", parent->Attribute("defaultPriority")); + element->SetAttribute("priority", parent->Attribute("defaultPriority")); else - s_element->SetAttribute("priority", "99999"); + element->SetAttribute("priority", "99999"); } - if(s_element->Attribute("maxChoices") == NULL){ + if(element->Attribute("maxChoices") == NULL){ // Set a default of 0 which implies no cut to be applied - s_element->SetAttribute("maxChoices", "0"); + element->SetAttribute("maxChoices", "0"); } - return s_element; + return element; } FlawHandler::~FlawHandler(){ delete m_configData; } - Priority FlawHandler::getPriority(const EntityId&) { return m_priority;} + Priority FlawHandler::getPriority(const EntityId) { return m_priority;} double FlawHandler::getWeight() const {return m_weight;} - unsigned int FlawHandler::getMaxChoices() const {return m_maxChoices;} + unsigned int FlawHandler::getMaxChoices() const {return m_maxChoices;} + + bool FlawHandler::customStaticMatch(const EntityId) const {return true;} std::string FlawHandler::toString() const{ std::stringstream sstr; @@ -119,8 +126,8 @@ namespace EUROPA { std::string FlawHandler::toString(const GuardEntry& entry){ std::stringstream sstr; - LabelStr varName = entry.first; - sstr << varName.toString() << " == "; + std::string varName = entry.first; + sstr << varName << " == "; if(LabelStr::isString(entry.second)) sstr << LabelStr(entry.second).toString(); @@ -132,8 +139,8 @@ namespace EUROPA { return sstr.str(); } - edouble FlawHandler::convertValueIfNecessary(const PlanDatabaseId& db, - const ConstrainedVariableId& guardVar, + edouble FlawHandler::convertValueIfNecessary(const PlanDatabaseId db, + const ConstrainedVariableId guardVar, const edouble& testValue){ // Convert if an object variable. Make it the object id. if(db->getSchema()->isObjectType(guardVar->baseDomain().getTypeName())){ @@ -182,7 +189,7 @@ namespace EUROPA { else { LabelStr lblStr(data); // Cast to a double - value = (edouble) lblStr; + value = lblStr.getKey(); } } @@ -196,7 +203,7 @@ namespace EUROPA { return sl_noGuards; } - bool FlawHandler::makeConstraintScope(const EntityId& entity, std::vector& scope) const { + bool FlawHandler::makeConstraintScope(const EntityId entity, std::vector& scope) const { checkError(hasGuards(), "Should not call unless there are guards on the handler."); TokenId token = getTokenFromEntity(entity); @@ -208,7 +215,7 @@ namespace EUROPA { if(!m_guards.empty()){ for (std::vector< GuardEntry >::const_iterator it = m_guards.begin(); it != m_guards.end(); ++it){ const GuardEntry& entry = *it; - const LabelStr& guardName = entry.first; + const std::string& guardName = entry.first; ConstrainedVariableId guard = token->getVariable(guardName); // If it does not have the required variable, return false @@ -228,7 +235,7 @@ namespace EUROPA { for (std::vector< GuardEntry >::const_iterator it = m_masterGuards.begin(); it != m_masterGuards.end(); ++it){ const GuardEntry& entry = *it; - const LabelStr& guardName = entry.first; + const std::string& guardName = entry.first; ConstrainedVariableId guard = master->getVariable(guardName); // If it does not have the required variable, return false @@ -267,11 +274,11 @@ namespace EUROPA { } /* Have to convert if it is an object variable */ - bool FlawHandler::matches(const ConstrainedVariableId& guardVar, const edouble& testValue){ + bool FlawHandler::matches(const ConstrainedVariableId guardVar, const edouble& testValue){ if(!guardVar->lastDomain().isSingleton()) return false; - const PlanDatabaseId& pdb = getPlanDatabase(guardVar); + const PlanDatabaseId pdb = getPlanDatabase(guardVar); edouble convertedValue = convertValueIfNecessary(pdb, guardVar, testValue); condDebugMsg(pdb->getSchema()->isObjectType(guardVar->baseDomain().getTypeName()),"FlawHandler:matches", @@ -284,7 +291,7 @@ namespace EUROPA { return guardVar->lastDomain().getSingletonValue() == convertedValue; } - const PlanDatabaseId& FlawHandler::getPlanDatabase(const ConstrainedVariableId& tokenVar){ + const PlanDatabaseId FlawHandler::getPlanDatabase(const ConstrainedVariableId tokenVar){ if(m_db.isNoId()){ checkError(tokenVar->parent().isId() && TokenId::convertable(tokenVar->parent()), tokenVar->toString() << " should have a parent token."); @@ -295,7 +302,7 @@ namespace EUROPA { return m_db; } - TokenId FlawHandler::getTokenFromEntity(const EntityId& entity){ + TokenId FlawHandler::getTokenFromEntity(const EntityId entity){ if(TokenId::convertable(entity)) return entity; @@ -314,16 +321,17 @@ namespace EUROPA { /** FlawHandler::VariableListener **/ - FlawHandler::VariableListener::VariableListener(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables) - : Constraint(name, propagatorName, constraintEngine, variables), m_isApplied(false) {} - - FlawHandler::VariableListener::VariableListener(const ConstraintEngineId& ce, - const EntityId& target, - const FlawManagerId& flawManager, - const FlawHandlerId& flawHandler, +FlawHandler::VariableListener::VariableListener(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables) + : Constraint(name, propagatorName, constraintEngine, variables), + m_target(), m_flawManager(), m_flawHandler(), m_isApplied(false) {} + + FlawHandler::VariableListener::VariableListener(const ConstraintEngineId ce, + const EntityId target, + const FlawManagerId flawManager, + const FlawHandlerId flawHandler, const std::vector& scope) : Constraint(CONSTRAINT_NAME(), PROPAGATOR_NAME(), ce, scope), m_target(target), m_flawManager(flawManager), m_flawHandler(flawHandler), m_isApplied(false) {} diff --git a/src/PLASMA/Solvers/base/FlawHandler.hh b/src/PLASMA/Solvers/base/FlawHandler.hh index 2d4119ff2..ed68c787d 100644 --- a/src/PLASMA/Solvers/base/FlawHandler.hh +++ b/src/PLASMA/Solvers/base/FlawHandler.hh @@ -22,192 +22,193 @@ namespace EUROPA { * data so that it can be accessed during actual decision point allocation. * @see DecisionPoint */ - class FlawHandler: public MatchingRule { - public: - virtual ~FlawHandler(); + class FlawHandler: public MatchingRule { + public: + virtual ~FlawHandler(); - /** - * @brief Main factory method - */ - virtual DecisionPointId create(const DbClientId& client, const EntityId& flawedEntity, const LabelStr& explanation) const = 0; + /** + * @brief Main factory method + */ + virtual DecisionPointId create(const DbClientId client, const EntityId flawedEntity, const std::string& explanation) const = 0; - /** - * @brief Get the prority - */ - virtual Priority getPriority(const EntityId& entity = EntityId::noId()); + /** + * @brief Get the prority + */ + virtual Priority getPriority(const EntityId entity = EntityId::noId()); - /** - * @brief Retrieves a weight based on the number of criteria satisfied. Used to select the most specific - * active flaw handler. - */ - double getWeight() const; + /** + * @brief Retrieves a weight based on the number of criteria satisfied. Used to select the most specific + * active flaw handler. + */ + double getWeight() const; - /** - * @brief Also provide a function to refresh the weight. This permits sub class methods to be used. Call this if custom static filters - * are used. - */ - void refreshWeight(); + /** + * @brief Also provide a function to refresh the weight. This permits sub class methods to be used. Call this if custom static filters + * are used. + */ + void refreshWeight(); - /** - * @brief Accessor for th emax number of choices to permit. - */ - unsigned int getMaxChoices() const; + /** + * @brief Accessor for th emax number of choices to permit. + */ + unsigned int getMaxChoices() const; - /** - * @brief Tests for a match between this factory and the entity - */ - virtual bool customStaticMatch(const EntityId& entity) const {return true;} + /** + * @brief Tests for a match between this factory and the entity + */ + virtual bool customStaticMatch(const EntityId entity) const; - /** - * @brief Tests how many costm static filters should be applied. Factors into comparative weights - */ - virtual unsigned int customStaticFilterCount() const {return 0;} + /** + * @brief Tests how many costm static filters should be applied. Factors into comparative weights + */ + virtual unsigned int customStaticFilterCount() const {return 0;} - /** - * @brief True if there are any guards posted on this heuristic. - */ - bool hasGuards() const; + /** + * @brief True if there are any guards posted on this heuristic. + */ + bool hasGuards() const; - /** - * @brief Evaluates dynamic matching - i.e. guards against variables - */ - bool test(const std::vector& scope); + /** + * @brief Evaluates dynamic matching - i.e. guards against variables + */ + bool test(const std::vector& scope); + + /** + * @brief Helper method to make the scope from guard data + * @return true if successful in obtaining all the guards required. + */ + bool makeConstraintScope(const EntityId entity, std::vector& scope) const; + + /** + * @brief Useful utility for eye-balling what the heuristic actually is. + */ + virtual std::string toString() const; + + /** + * @brief Handy default vector for no guards + */ + static const std::vector< GuardEntry >& noGuards(); + /** + * @brief Helper method to do value conversions for object domains. This one does the work. + */ + static edouble convertValueIfNecessary(const PlanDatabaseId db, + const ConstrainedVariableId guardVar, + const edouble& testValue); + + static unsigned int WEIGHT_BASE() {return 100000;} /*!< Used to weight active instances. + Establishes upper limit on priority values.*/ + + + friend class FlawManager; + + // This constraint notifies the FlawManager when a Guard on a FlawHandler is satisfied + class VariableListener: public Constraint { + public: /** - * @brief Helper method to make the scope from guard data - * @return true if successful in obtaining all the guards required. + * @brief Standard constraint constructor must be provided to facilitate + * creation of a copy during merging. */ - bool makeConstraintScope(const EntityId& entity, std::vector& scope) const; + VariableListener(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, + const std::vector& variables); /** - * @brief Useful utility for eye-balling what the heuristic actually is. + * @brief Specilized constructor also provided to create from the Heuristics Engine */ - virtual std::string toString() const; - + VariableListener(const ConstraintEngineId ce, + const EntityId target, + const FlawManagerId flawManager, + const FlawHandlerId flawHandler, + const std::vector& scope); + /** - * @brief Handy default vector for no guards + * @brief Standard constraint name */ - static const std::vector< GuardEntry >& noGuards(); + static const std::string& CONSTRAINT_NAME(){ + static const std::string sl_const("FlawListener"); + return sl_const; + } /** - * @brief Helper method to do value conversions for object domains. This one does the work. + * @brief Standard constraint name */ - static edouble convertValueIfNecessary(const PlanDatabaseId& db, - const ConstrainedVariableId& guardVar, - const edouble& testValue); - - static const unsigned int WEIGHT_BASE() {return 100000;} /*!< Used to weight active instances. - Establishes upper limit on priority values.*/ - - - friend class FlawManager; - - // This constraint notifies the FlawManager when a Guard on a FlawHandler is satisfied - class VariableListener: public Constraint { - public: - /** - * @brief Standard constraint constructor must be provided to facilitate - * creation of a copy during merging. - */ - VariableListener(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, - const std::vector& variables); - - /** - * @brief Specilized constructor also provided to create from the Heuristics Engine - */ - VariableListener(const ConstraintEngineId& ce, - const EntityId& target, - const FlawManagerId& flawManager, - const FlawHandlerId& flawHandler, - const std::vector& scope); - - /** - * @brief Standard constraint name - */ - static const LabelStr& CONSTRAINT_NAME(){ - static const LabelStr sl_const("FlawListener"); - return sl_const; - } - - /** - * @brief Standard constraint name - */ - static const LabelStr& PROPAGATOR_NAME(){ - static const LabelStr sl_const("Default"); - return sl_const; - } + static const std::string& PROPAGATOR_NAME(){ + static const std::string sl_const("Default"); + return sl_const; + } - const FlawHandlerId getHandler() const {return m_flawHandler;} - const EntityId getTarget() const {return m_target;} - private: - void handleExecute(); - bool isApplied() const; - void apply(); - void undo(); - - const EntityId m_target; - const FlawManagerId m_flawManager; - const FlawHandlerId m_flawHandler; - bool m_isApplied; - }; + const FlawHandlerId getHandler() const {return m_flawHandler;} + const EntityId getTarget() const {return m_target;} + private: + void handleExecute(); + bool isApplied() const; + void apply(); + void undo(); + + const EntityId m_target; + const FlawManagerId m_flawManager; + const FlawHandlerId m_flawHandler; + bool m_isApplied; + }; - protected: + protected: - /** - * @brief Constructor - * @param configData XML element of type . May have child elements - * particular to each derived class. - */ - FlawHandler(const TiXmlElement& configData); + /** + * @brief Constructor + * @param configData XML element of type . May have child elements + * particular to each derived class. + */ + FlawHandler(const TiXmlElement& configData); - TiXmlElement* m_configData; + TiXmlElement* m_configData; - Priority m_priority; /*!< The priority for the flaw. Used in flaw ordering */ - double m_weight; /*!< An input to determine the weight of the flaw. Used to tie-break when priorities are equal */ - const std::vector< GuardEntry > m_guards; /*!< tuples */ - const std::vector< GuardEntry > m_masterGuards; /*!< tuples */ + Priority m_priority; /*!< The priority for the flaw. Used in flaw ordering */ + double m_weight; /*!< An input to determine the weight of the flaw. Used to tie-break when priorities are equal */ + const std::vector< GuardEntry > m_guards; /*!< tuples */ + const std::vector< GuardEntry > m_masterGuards; /*!< tuples */ - private: - /** - * @brief Helper method to read the guards from XML element - */ - static const std::vector& readGuards(const TiXmlElement& configData, bool forMaster); + private: + FlawHandler(const FlawHandler&); + FlawHandler& operator=(const FlawHandler&); - /** - * @brief Helper method to get a double encoded value - */ - static edouble readValue(const char* data); + /** + * @brief Helper method to read the guards from XML element + */ + static const std::vector& readGuards(const TiXmlElement& configData, bool forMaster); - /** - * @brief Helper method to stringify a guard - */ - static std::string toString(const GuardEntry& entry); + /** + * @brief Helper method to get a double encoded value + */ + static edouble readValue(const char* data); - /** - * @brief Helper method to test a guard value - */ - bool matches(const ConstrainedVariableId& guardVar, const edouble& testValue); + /** + * @brief Helper method to stringify a guard + */ + static std::string toString(const GuardEntry& entry); - /** - * @brief Helper to get a token, if possible, from an entity (token, or variable) - */ - static TokenId getTokenFromEntity(const EntityId& entity); + /** + * @brief Helper method to test a guard value + */ + bool matches(const ConstrainedVariableId guardVar, const edouble& testValue); - static TiXmlElement* makeConfigData(const TiXmlElement& configData); + /** + * @brief Helper to get a token, if possible, from an entity (token, or variable) + */ + static TokenId getTokenFromEntity(const EntityId entity); - static TiXmlElement* s_element; /*!< Temporary holder for copied elements */ + static TiXmlElement* makeConfigData(const TiXmlElement& configData); - const PlanDatabaseId& getPlanDatabase(const ConstrainedVariableId& tokenVar); + const PlanDatabaseId getPlanDatabase(const ConstrainedVariableId tokenVar); - PlanDatabaseId m_db; + PlanDatabaseId m_db; - unsigned int m_maxChoices; /*!< Allows a cut operator on choices. xml attribute is 'maxChoices' */ - }; + unsigned int m_maxChoices; /*!< Allows a cut operator on choices. xml attribute is 'maxChoices' */ + }; /** * @brief Declares a Template class for concrete decision point factories @@ -218,7 +219,7 @@ namespace EUROPA { ConcreteFlawHandler(const TiXmlElement& config) : FlawHandler(config){} - DecisionPointId create(const DbClientId& client, const EntityId& flaw, const LabelStr& explanation) const { + DecisionPointId create(const DbClientId client, const EntityId flaw, const std::string& explanation) const { DecisionPoint* dp = new CLASS(client, flaw, *FlawHandler::m_configData, explanation); dp->setContext(m_context); return dp->getId(); @@ -227,7 +228,7 @@ namespace EUROPA { /** * @brief Tests for a match between this factory and the entity */ - bool customStaticMatch(const EntityId& entity) const { + bool customStaticMatch(const EntityId entity) const { return CLASS::customStaticMatch(entity); } diff --git a/src/PLASMA/Solvers/base/FlawManager.cc b/src/PLASMA/Solvers/base/FlawManager.cc index f64d5b778..910d0382d 100644 --- a/src/PLASMA/Solvers/base/FlawManager.cc +++ b/src/PLASMA/Solvers/base/FlawManager.cc @@ -12,110 +12,129 @@ * @date April, 2005 * @brief Provides implementation for FlawManager */ +#if 0 #ifdef _MSC_VER - using stdext::hash_map; +using stdext::hash_map; +#elif defined(__clang__) +typedef HASH_NS::unordered_map hash_map; #else - using __gnu_cxx::hash_map; +using HASH_NS::hash_map; #endif //_MSC_VER +#endif //0 namespace EUROPA { - namespace SOLVERS { - - FlawManager::FlawManager(const TiXmlElement& configData) - : Component(configData) - , m_timestamp(0) - { - } +namespace SOLVERS { + +FlawManager::FlawManager(const TiXmlElement& configData) + : Component(configData) + , m_db() + , m_parent() + , m_flawFilters() + , m_flawHandlers() + , m_staticFiltersByKey() + , m_dynamicFiltersByKey() + , m_flawHandlerGuards() + , m_activeFlawHandlersByKey() + , m_timestamp(0) + , m_context() +{ +} FlawManager::~FlawManager() { if (!m_flawFilters.isNoId()) - delete (MatchingEngine*)m_flawFilters; + delete static_cast(m_flawFilters); if (!m_flawHandlers.isNoId()) - delete (MatchingEngine*)m_flawHandlers; + delete static_cast(m_flawHandlers); } - bool FlawManager::isValid() const { - for(std::map::const_iterator it = m_staticFiltersByKey.begin(); it != m_staticFiltersByKey.end(); ++it) { - eint key = it->first; - EntityId entity = Entity::getEntity(key); - condDebugMsg(!entity.isValid(), "FlawManager:isValid", getId() << " Invalid id in m_staticFiltersByKey. Entity key: " << it->first); - } - for( Eint2FlawFilterVectorMap::const_iterator it = m_dynamicFiltersByKey.begin(); - it != m_dynamicFiltersByKey.end(); - ++it) { - EntityId entity = Entity::getEntity(it->first); - condDebugMsg(!entity.isValid(), "FlawManager:isValid", getId() << " Invalid id in m_dynamicFiltersByKey. Entity key: " << it->first); - const std::vector& filters(it->second); - for(std::vector::const_iterator subIt = filters.begin(); subIt != filters.end(); ++subIt) { - condDebugMsg(!(*subIt).isValid(), "FlawManager:isValid", getId() << " Invalid flaw filter id for entity " << it->first << - " in m_dynamicFiltersByKey"); - } + bool FlawManager::isValid() const { + for(std::map::const_iterator it = m_staticFiltersByKey.begin(); it != m_staticFiltersByKey.end(); ++it) { + eint key = it->first; + EntityId entity = Entity::getEntity(key); + condDebugMsg(!entity.isValid(), "FlawManager:isValid", getId() << " Invalid id in m_staticFiltersByKey. Entity key: " << it->first); + } + for( Eint2FlawFilterVectorMap::const_iterator it = m_dynamicFiltersByKey.begin(); + it != m_dynamicFiltersByKey.end(); + ++it) { + EntityId entity = Entity::getEntity(it->first); + condDebugMsg(!entity.isValid(), "FlawManager:isValid", getId() << " Invalid id in m_dynamicFiltersByKey. Entity key: " << it->first); + const std::vector& filters(it->second); + for(std::vector::const_iterator subIt = filters.begin(); subIt != filters.end(); ++subIt) { + condDebugMsg(!(*subIt).isValid(), "FlawManager:isValid", getId() << " Invalid flaw filter id for entity " << it->first << + " in m_dynamicFiltersByKey"); } - for(std::multimap::const_iterator it = m_flawHandlerGuards.begin(); it != m_flawHandlerGuards.end(); - ++it) { - EntityId entity = Entity::getEntity(it->first); - condDebugMsg(!entity.isValid(), "FlawManager:isValid", getId() << " Invalid id in m_flawHandlerGuards. Entity key:" << it->first); - condDebugMsg(!it->second.isValid(), "FlawManager:isValid", getId() << " Invalid constraint id in m_flawHandlerGuards. Entity key: " << it->first); - FlawHandler::VariableListener* listener = (FlawHandler::VariableListener*) (it->second); - condDebugMsg(!listener->getTarget().isValid(), "FlawManager:isValid", getId() << " Invalid target id in m_flawHandlerGuards. Entity key: " << it->first); - if(m_activeFlawHandlersByKey.find(it->first) == m_activeFlawHandlersByKey.end()) { - debugMsg("FlawManager:isValid", getId() << "Target '" << listener->getTarget()->toString() << "' has no active flaw handlers."); - std::stringstream scope; - for(std::vector::const_iterator scopeIt = listener->getScope().begin(); scopeIt != listener->getScope().end(); - ++scopeIt) - scope << (*scopeIt)->toString() << " "; - debugMsg("FlawManager:isValid", "Variable listener scope: " << scope.str()); - } + } + for(std::multimap::const_iterator it = m_flawHandlerGuards.begin(); it != m_flawHandlerGuards.end(); + ++it) { + EntityId entity = Entity::getEntity(it->first); + condDebugMsg(!entity.isValid(), "FlawManager:isValid", getId() << " Invalid id in m_flawHandlerGuards. Entity key:" << it->first); + condDebugMsg(!it->second.isValid(), "FlawManager:isValid", getId() << " Invalid constraint id in m_flawHandlerGuards. Entity key: " << it->first); + FlawHandler::VariableListener* listener = id_cast(it->second); + condDebugMsg(!listener->getTarget().isValid(), "FlawManager:isValid", getId() << " Invalid target id in m_flawHandlerGuards. Entity key: " << it->first); + if(m_activeFlawHandlersByKey.find(it->first) == m_activeFlawHandlersByKey.end()) { + debugMsg("FlawManager:isValid", getId() << "Target '" << listener->getTarget()->toString() << "' has no active flaw handlers."); + std::stringstream scope; + for(std::vector::const_iterator scopeIt = listener->getScope().begin(); scopeIt != listener->getScope().end(); + ++scopeIt) + scope << (*scopeIt)->toString() << " "; + debugMsg("FlawManager:isValid", "Variable listener scope: " << scope.str()); } + } - for(std::map::const_iterator it = m_activeFlawHandlersByKey.begin(); it != m_activeFlawHandlersByKey.end(); - ++it) { - EntityId entity = Entity::getEntity(it->first); - condDebugMsg(!entity.isValid(), "FlawManager:isValid", getId() << " Invalid id in m_activeFlawHandlersByKey. Entity key: " << it->first); - const FlawHandlerEntry& entry(it->second); - for(FlawHandlerEntry::const_iterator it = entry.begin(); it != entry.end(); ++it) - condDebugMsg(!it->second.isValid(), "FlawManager:isValid", getId() << " Invalid flaw handler id in m_activeFlawHandlersByKey. Entity key: " << it->first); - } - return true; + for(std::map::const_iterator it = m_activeFlawHandlersByKey.begin(); it != m_activeFlawHandlersByKey.end(); + ++it) { + EntityId entity = Entity::getEntity(it->first); + condDebugMsg(!entity.isValid(), "FlawManager:isValid", getId() << " Invalid id in m_activeFlawHandlersByKey. Entity key: " << it->first); + const FlawHandlerEntry& entry(it->second); + for(FlawHandlerEntry::const_iterator fIt = entry.begin(); fIt != entry.end(); ++fIt) + condDebugMsg(!fIt->second.isValid(), "FlawManager:isValid", getId() << " Invalid flaw handler id in m_activeFlawHandlersByKey. Entity key: " << it->first); } + return true; + } void FlawManager::initialize(const TiXmlElement& configData, - const PlanDatabaseId& db, - const ContextId& ctx, - const FlawManagerId& parent) + const PlanDatabaseId db, + const ContextId ctx, + const FlawManagerId parent) { checkError(m_db.isNoId(), "Can only be initialized once."); m_db = db; m_parent = parent; m_context = ctx; - EngineId& engine = m_db->getEngine(); + EngineId engine = m_db->getEngine(); m_flawFilters = (new MatchingEngine(engine,configData,"FlawFilter"))->getId(); m_flawHandlers = (new MatchingEngine(engine,configData,"FlawHandler"))->getId(); for(std::set::const_iterator it = m_flawFilters->getRules().begin(); it != m_flawFilters->getRules().end(); ++it) { MatchingRuleId rule = *it; check_error(rule.isValid()); + debugMsg("FlawManager:initialize", "Setting context on " << rule); rule->setContext(m_context); } for(std::set::const_iterator it = m_flawHandlers->getRules().begin(); it != m_flawHandlers->getRules().end(); ++it) { MatchingRuleId rule = *it; check_error(rule.isValid()); + debugMsg("FlawManager:initialize", "Setting context on " << rule); rule->setContext(m_context); } handleInitialize(); condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); } - IteratorId FlawManager::createIterator(){ return IteratorId::noId();} + IteratorId FlawManager::createIterator(){ + checkRuntimeError(ALWAYS_FAIL, "Should never get here."); + return IteratorId::noId(); + } - void FlawManager::notifyRemoved(const ConstraintId& constraint) { + void FlawManager::notifyAdded(const ConstraintId) {} + void FlawManager::notifyRemoved(const ConstraintId constraint) { // Check if it's the correct type (FlawHandler::VariableListener) // then we search through the map and remove any instances of it. if(Id::convertable(constraint)) { debugMsg("FlawManager:notifyRemoved:Constraint", getId() << "->notifyRemoved( " << - constraint->getName().toString() << "(" << constraint->getKey() << ") )"); + constraint->getName() << "(" << constraint->getKey() << ") )"); Id listener = constraint; // As the target of a FlawHandler::VariableListener is only set by its constructor, @@ -145,7 +164,7 @@ namespace EUROPA { for(std::multimap::iterator it = m_flawHandlerGuards.begin(); it != m_flawHandlerGuards.end();) { if(it->second == listener) { debugMsg("FlawManager:notifyRemoved:Constraint", "Removing ("<< constraint->getKey() << ") from m_flawHandlerGuards, its constraint is deleted."); - check_error_variable(unsigned int size = m_flawHandlerGuards.size()); + check_error_variable(unsigned long size = m_flawHandlerGuards.size()); debugMsg("FlawManager:erase:guards", " [" << __FILE__ << ":" << __LINE__ << "] removing entry with key " << it->first << " from m_flawHandlerGuards"); m_flawHandlerGuards.erase(it++); debugMsg("FlawManager:notifyRemoved:Constraint", "m_flawHandlerGuards.size() == " << m_flawHandlerGuards.size()); @@ -161,7 +180,7 @@ namespace EUROPA { * Remove flaw handler guard constraints for this variable, and if it is a state * variable also remove for the token. */ - void FlawManager::notifyRemoved(const ConstrainedVariableId& var){ + void FlawManager::notifyRemoved(const ConstrainedVariableId var){ debugMsg("FlawManager:notifyRemoved", getId() << " Removing active flaw handlers and guards for " << var->toString()); for(std::multimap::iterator it = m_flawHandlerGuards.find(var->getKey()); it != m_flawHandlerGuards.end() && it->first == var->getKey();) { @@ -222,7 +241,7 @@ namespace EUROPA { if(Token::isStateVariable(var)){ debugMsg("FlawManager:notifyRemoved", getId() << " Variable " << var->toString() << " is a state variable. Removing flaw handlers and guards for " << - ((Token*)var->parent())->getPredicateName().toString()); + id_cast(var->parent())->getPredicateName()); eint parentKey = var->parent()->getKey(); debugMsg("FlawManager:notifyRemoved", "Parent Key: " << parentKey); debugMsg("FlawManager:notifyRemoved", "m_flawHandlerGuards.size() == " << m_flawHandlerGuards.size()); @@ -250,8 +269,13 @@ namespace EUROPA { condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); } - void FlawManager::notifyRemoved(const TokenId& token) { - debugMsg("FlawManager:notifyRemoved", getId() << " Removing active flaw handlers and guards for " << token->getPredicateName().toString() << + void FlawManager::notifyChanged(const ConstrainedVariableId , + const DomainListener::ChangeType& ){} + + + void FlawManager::notifyAdded(const TokenId){} + void FlawManager::notifyRemoved(const TokenId token) { + debugMsg("FlawManager:notifyRemoved", getId() << " Removing active flaw handlers and guards for " << token->getPredicateName() << "(" << token->getKey() << ")"); for(std::multimap::iterator it = m_flawHandlerGuards.find(token->getKey()); it != m_flawHandlerGuards.end() && it->first == token->getKey();) { @@ -291,7 +315,7 @@ namespace EUROPA { Priority bestP = bestPriority - (2 * cast_double(EPSILON)); IteratorId it = createIterator(); - LabelStr explanation = "unknown"; + std::string explanation = "unknown"; // Now go through the candidates while(!it->done()){ @@ -341,7 +365,7 @@ namespace EUROPA { // flawToResolve->toString() << ")"); } - delete (Iterator*) it; + delete static_cast(it); DecisionPointId decision; if(flawToResolve.isId()){ @@ -353,7 +377,7 @@ namespace EUROPA { return decision; } - bool FlawManager::inScope(const EntityId& entity) { + bool FlawManager::inScope(const EntityId entity) { checkError(m_db->getConstraintEngine()->constraintConsistent(), "Assumes the database is constraint consistent but it is not."); IteratorId it = createIterator(); @@ -365,7 +389,7 @@ namespace EUROPA { } } - delete (Iterator*) it; + delete static_cast(it); return result; } @@ -374,61 +398,62 @@ namespace EUROPA { * is based on properties of the entity that cannot change. Dynamic matching is based on specific guard values or other * dynamic properties that must be re-evaluated on each cycle. */ - bool FlawManager::matches(const EntityId& entity){ + bool FlawManager::matches(const EntityId entity){ return staticMatch(entity) || dynamicMatch(entity); } - bool FlawManager::staticMatch(const EntityId& entity) { + bool FlawManager::staticMatch(const EntityId entity) { - // If there is a parent flaw manager ten it may already have excluded the given entity. Filters are inherited in this way. - if(m_parent.isId() && m_parent->staticMatch(entity)) { - debugMsg("FlawManager:staticMatch", "Excluding " << entity->getKey() << " based on parent flaw manager."); + // If there is a parent flaw manager ten it may already have excluded the given entity. Filters are inherited in this way. + if(m_parent.isId() && m_parent->staticMatch(entity)) { + debugMsg("FlawManager:staticMatch", "Excluding " << entity->getKey() << " based on parent flaw manager."); - return true; - } + return true; + } - condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); - /// If found in the static filters, then return the value - std::map::const_iterator it = m_staticFiltersByKey.find(entity->getKey()); - if(it != m_staticFiltersByKey.end()) { + condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); + /// If found in the static filters, then return the value + std::map::const_iterator it = m_staticFiltersByKey.find(entity->getKey()); + if(it != m_staticFiltersByKey.end()) { + debugMsg("FlawManager:staticMatch", + (it->second ? "Excluding " : "Including ") << entity->getKey() << " because it was previously " << + (it->second ? "excluded." : "included.")); + return it->second; + } + + // Load filters + std::vector filters; + if(TokenId::convertable(entity)) + m_flawFilters->getMatches(TokenId(entity), filters); + else + m_flawFilters->getMatches(ConstrainedVariableId(entity), filters); + + std::vector dynamicFilters; + for(std::vector::const_iterator fIt = filters.begin(); + fIt != filters.end(); ++fIt){ + FlawFilterId flawFilter = *fIt; + if(flawFilter->isDynamic()) + dynamicFilters.push_back(flawFilter); + else { // Static so prune and quit + debugMsg("FlawManager:staticMatch", getId() << " Sticking " << entity->getKey() << " into static filters."); + m_staticFiltersByKey.insert(std::make_pair(entity->getKey(), true)); debugMsg("FlawManager:staticMatch", - (it->second ? "Excluding " : "Including ") << entity->getKey() << " because it was previously " << - (it->second ? "excluded." : "included.")); - return it->second; - } + flawFilter->getName() <<" excluding " << entity->getKey() << ". Matched " << flawFilter->toString() << "."); - // Load filters - std::vector filters; - if(TokenId::convertable(entity)) - m_flawFilters->getMatches(TokenId(entity), filters); - else - m_flawFilters->getMatches(ConstrainedVariableId(entity), filters); - - std::vector dynamicFilters; - for(std::vector::const_iterator it = filters.begin(); it!= filters.end(); ++it){ - FlawFilterId flawFilter = (FlawFilterId) *it; - if(flawFilter->isDynamic()) - dynamicFilters.push_back(flawFilter); - else { // Static so prune and quit - debugMsg("FlawManager:staticMatch", getId() << " Sticking " << entity->getKey() << " into static filters."); - m_staticFiltersByKey.insert(std::make_pair(entity->getKey(), true)); - debugMsg("FlawManager:staticMatch", - flawFilter->getName().toString() <<" excluding " << entity->getKey() << ". Matched " << flawFilter->toString() << "."); - - return true; - } + return true; } - - // If we get here, it is not statically filtered and it we can add the entries, if any, for dynamic filtering - debugMsg("FlawManager:staticMatch", getId() << " Sticking " << entity->getKey() << " into static filters."); - m_staticFiltersByKey.insert(std::make_pair(entity->getKey(), false)); - debugMsg("FlawManager:staticMatch", getId() << " Sticking " << entity->getKey() << " into dynamic filters."); - m_dynamicFiltersByKey.insert(std::make_pair(entity->getKey(), dynamicFilters)); - condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); - return false; } - bool FlawManager::staticallyExcluded(const EntityId& entity) const { + // If we get here, it is not statically filtered and it we can add the entries, if any, for dynamic filtering + debugMsg("FlawManager:staticMatch", getId() << " Sticking " << entity->getKey() << " into static filters."); + m_staticFiltersByKey.insert(std::make_pair(entity->getKey(), false)); + debugMsg("FlawManager:staticMatch", getId() << " Sticking " << entity->getKey() << " into dynamic filters."); + m_dynamicFiltersByKey.insert(std::make_pair(entity->getKey(), dynamicFilters)); + condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); + return false; + } + + bool FlawManager::staticallyExcluded(const EntityId entity) const { if(m_parent.isId() && m_parent->staticallyExcluded(entity)) { debugMsg("FlawManager:staticallyExcluded", "Excluding " << entity->getKey() << " because its parent was statically excluded."); return true; @@ -442,7 +467,7 @@ namespace EUROPA { return it->second; } - bool FlawManager::dynamicMatch(const EntityId& entity) { + bool FlawManager::dynamicMatch(const EntityId entity) { checkError(!staticallyExcluded(entity), "Cannot call dynamic match if statically excluded"); if(m_parent.isId() && m_parent->dynamicMatch(entity)){ debugMsg("FlawManager:dynamicMatch", "Excluding " << entity->getKey() << " because of parent."); @@ -458,11 +483,11 @@ namespace EUROPA { FlawFilterId dynamicFilter = *it_a; checkError(dynamicFilter->isDynamic(), "Must be a bug in construction code."); debugMsg("FlawManager:dynamicMatch", "Evaluating " << entity->getKey() << ". " << - dynamicFilter->getName().toString() << " excluding " << entity->toString() << " with " << dynamicFilter->toString()); + dynamicFilter->getName() << " excluding " << entity->toString() << " with " << dynamicFilter->toString()); if(dynamicFilter->test(entity)){ debugMsg("FlawManager:dynamicMatch", "Excluding " << entity->getKey() << ". " << - dynamicFilter->getName().toString() << " excluding " << entity->toString() << " with " << dynamicFilter->toString()); + dynamicFilter->getName() << " excluding " << entity->toString() << " with " << dynamicFilter->toString()); condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); return true; @@ -474,7 +499,7 @@ namespace EUROPA { return false; } - Priority FlawManager::getPriority(const EntityId& entity){ + Priority FlawManager::getPriority(const EntityId entity){ debugMsg("FlawManager:getPriority", "Getting priority for " << entity->getKey()); FlawHandlerId flawHandler = getFlawHandler(entity); checkError(flawHandler.isValid(), "No flawHandler for " << entity->toString()); @@ -485,7 +510,7 @@ namespace EUROPA { /** * @brief Now we conduct a simple match where we select based on first avalaible. */ - DecisionPointId FlawManager::allocateDecisionPoint(const EntityId& entity, const LabelStr& explanation){ + DecisionPointId FlawManager::allocateDecisionPoint(const EntityId entity, const std::string& explanation){ static unsigned int sl_counter(0); // Helpful for debugging sl_counter++; @@ -496,86 +521,89 @@ namespace EUROPA { return dp; } - FlawHandlerId FlawManager::getFlawHandler(const EntityId& entity){ - condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); - static unsigned int sl_counter(0); // Helpful for debugging - sl_counter++; + FlawHandlerId FlawManager::getFlawHandler(const EntityId entity){ + condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); + static unsigned int sl_counter(0); // Helpful for debugging + sl_counter++; - // First, try to find if there is one available already - checkError(entity.isValid(), entity); - checkError(m_db->getConstraintEngine()->constraintConsistent(), "Must be propagated and consistent."); + // First, try to find if there is one available already + checkError(entity.isValid(), entity); + checkError(m_db->getConstraintEngine()->constraintConsistent(), "Must be propagated and consistent."); - std::map::const_iterator it = m_activeFlawHandlersByKey.find(entity->getKey()); - if(it != m_activeFlawHandlersByKey.end()){ - FlawHandlerEntry entry = it->second; - FlawHandlerEntry::const_iterator entryIt = entry.end(); - FlawHandlerId flawHandler = (--entryIt)->second; + std::map::const_iterator it = m_activeFlawHandlersByKey.find(entity->getKey()); + if(it != m_activeFlawHandlersByKey.end()){ + FlawHandlerEntry entry = it->second; + FlawHandlerEntry::const_iterator entryIt = entry.end(); + FlawHandlerId flawHandler = (--entryIt)->second; - debugMsg("FlawManager:getFlawHandler", "returning handler " << flawHandler->toString() << - " with priority " << flawHandler->getPriority() << " for key " << entity->getKey()); - return flawHandler; - } - else { // Have to load heuristics - debugMsg("FlawManager:getFlawHandler", "Loading heuristics."); - std::vector candidates; - m_flawHandlers->getMatches(entity, candidates); - - debugMsg("FlawManager:getFlawHandler", "There are " << candidates.size() << " flaw handlers to consider."); - FlawHandlerEntry entry; - bool requiresPropagation = false; - for(std::vector::const_iterator it = candidates.begin(); it!= candidates.end(); ++it){ - FlawHandlerId candidate = *it; - debugMsg("FlawManager:getFlawHandler", "Evaluating flaw handler " << candidate->toString() << " for (" << entity->getKey() << ")"); - - // If it does not pass a custom static match then ignore it - if(!candidate->customStaticMatch(entity)) - continue; - - if(candidate->hasGuards()){ - std::vector guards; - // Make the scope. If cant match up, then ignore this handler - if(!candidate->makeConstraintScope(entity, guards)) - continue; - - ConstraintId guardListener = (new FlawHandler::VariableListener(m_db->getConstraintEngine(), - entity, - getId(), - candidate, - guards))->getId(); - requiresPropagation = true; - debugMsg("FlawManager:getFlawHandler", getId() << " Sticking " << entity->getKey() << - " into flaw handler guards (Guard listener: " << guardListener->getKey() <<")."); - m_flawHandlerGuards.insert(std::make_pair(entity->getKey(), guardListener)); - // If we are not yet ready to move on. - if(!candidate->test(guards)) - continue; - } - - // Now insert in the list according to the weight. This will give the highest weight as the last entry - entry.insert(std::pair(candidate->getWeight(), candidate)); - debugMsg("FlawManager:getFlawHandler", "Added active FlawHandler " << candidate->toString() << std::endl << " for entity " << entity->getKey()); + debugMsg("FlawManager:getFlawHandler", "returning handler " << flawHandler->toString() << + " with priority " << flawHandler->getPriority() << " for key " << entity->getKey()); + return flawHandler; + } + else { // Have to load heuristics + debugMsg("FlawManager:getFlawHandler", "Loading heuristics."); + std::vector candidates; + m_flawHandlers->getMatches(entity, candidates); + + debugMsg("FlawManager:getFlawHandler", "There are " << candidates.size() << " flaw handlers to consider."); + FlawHandlerEntry entry; + bool requiresPropagation = false; + for(std::vector::const_iterator cIt = candidates.begin(); + cIt!= candidates.end(); ++cIt){ + FlawHandlerId candidate = *cIt; + debugMsg("FlawManager:getFlawHandler", + "Evaluating flaw handler " << candidate->toString() << " for (" << + entity->getKey() << ")"); + + // If it does not pass a custom static match then ignore it + if(!candidate->customStaticMatch(entity)) + continue; + + if(candidate->hasGuards()){ + std::vector guards; + // Make the scope. If cant match up, then ignore this handler + if(!candidate->makeConstraintScope(entity, guards)) + continue; + + ConstraintId guardListener = (new FlawHandler::VariableListener(m_db->getConstraintEngine(), + entity, + getId(), + candidate, + guards))->getId(); + requiresPropagation = true; + debugMsg("FlawManager:getFlawHandler", getId() << " Sticking " << entity->getKey() << + " into flaw handler guards (Guard listener: " << guardListener->getKey() <<")."); + m_flawHandlerGuards.insert(std::make_pair(entity->getKey(), guardListener)); + // If we are not yet ready to move on. + if(!candidate->test(guards)) + continue; } - debugMsg("FlawManager:getFlawHandler", "Found " << entry.size() << " possible heuristics" << " for entity " << entity->getKey()); - checkError(!entry.empty(), "No Heuristics for " << entity->toString()); - debugMsg("FlawManager:getFlawHandler", getId() << " Sticking " << entity->getKey() << " into active flaw handlers."); - m_activeFlawHandlersByKey.insert(std::make_pair(entity->getKey(), entry)); + // Now insert in the list according to the weight. This will give the highest weight as the last entry + entry.insert(std::pair(candidate->getWeight(), candidate)); + debugMsg("FlawManager:getFlawHandler", "Added active FlawHandler " << candidate->toString() << std::endl << " for entity " << entity->getKey()); + } + debugMsg("FlawManager:getFlawHandler", "Found " << entry.size() << " possible heuristics" << " for entity " << entity->getKey()); + checkError(!entry.empty(), "No Heuristics for " << entity->toString()); - // Propagate if necessary to process any constraints that have been added. This is required - // so that we get the most up to date flaw handler - if(requiresPropagation){ - m_db->getConstraintEngine()->propagate(); - synchronize(); - } + debugMsg("FlawManager:getFlawHandler", getId() << " Sticking " << entity->getKey() << " into active flaw handlers."); + m_activeFlawHandlersByKey.insert(std::make_pair(entity->getKey(), entry)); - // Now call recursively, but should get a hit this time - debugMsg("FlawManager:getFlawHandler", "Making recursive call."); - condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); - return getFlawHandler(entity); + // Propagate if necessary to process any constraints that have been added. This is required + // so that we get the most up to date flaw handler + if(requiresPropagation){ + m_db->getConstraintEngine()->propagate(); + synchronize(); } + + // Now call recursively, but should get a hit this time + debugMsg("FlawManager:getFlawHandler", "Making recursive call."); + condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); + return getFlawHandler(entity); } + } - void FlawManager::notifyActivated(const EntityId& target, const FlawHandlerId& flawHandler){ + void FlawManager::notifyActivated(const EntityId target, const FlawHandlerId flawHandler){ check_error(target.isValid()); check_error(!target->isDiscarded()); condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); @@ -588,7 +616,7 @@ namespace EUROPA { condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); } - void FlawManager::notifyDeactivated(const EntityId& target, const FlawHandlerId& flawHandler){ + void FlawManager::notifyDeactivated(const EntityId target, const FlawHandlerId flawHandler){ condDebugMsg(!isValid(), "FlawManager:isValid", "Invalid datastructures in flaw manger."); std::map::iterator it = m_activeFlawHandlersByKey.find(target->getKey()); checkError(it != m_activeFlawHandlersByKey.end(), @@ -605,7 +633,7 @@ namespace EUROPA { } } - bool FlawManager::betterThan(const EntityId& a, const EntityId& b, LabelStr& explanation){ + bool FlawManager::betterThan(const EntityId a, const EntityId b, std::string& explanation){ if(a.isId() && b.isId()) { explanation = "higherKey"; return (a->getKey() > b->getKey()); @@ -617,7 +645,7 @@ namespace EUROPA { } } - std::string FlawManager::toString(const EntityId& entity) const { + std::string FlawManager::toString(const EntityId entity) const { return entity->toString(); } @@ -638,14 +666,15 @@ namespace EUROPA { /** FLAW ITERATOR IMPLEMENTION **/ - FlawIterator::FlawIterator(FlawManager& manager) - : m_visited(0), - m_done(false), - m_manager(manager){ +FlawIterator::FlawIterator(FlawManager& manager) + : m_visited(0), + m_done(false), + m_manager(manager), + m_flaw() { - // Force the manager to synch up with the cycle count of the constraint engine - manager.synchronize(); - } + // Force the manager to synch up with the cycle count of the constraint engine + manager.synchronize(); +} void FlawIterator::advance(){ EntityId candidate = nextCandidate(); diff --git a/src/PLASMA/Solvers/base/FlawManager.hh b/src/PLASMA/Solvers/base/FlawManager.hh index d8b968bd5..aa88c1f88 100644 --- a/src/PLASMA/Solvers/base/FlawManager.hh +++ b/src/PLASMA/Solvers/base/FlawManager.hh @@ -14,13 +14,14 @@ #include "DomainListener.hh" #include "MatchingEngine.hh" #include "FlawHandler.hh" -#include "hash_map.hh" +#if 0 #ifdef _MSC_VER using namespace stdext; #else using namespace __gnu_cxx; #endif //_MSC_VER +#endif //0 namespace EUROPA { namespace SOLVERS { @@ -59,29 +60,29 @@ namespace EUROPA { const std::multimap getFlawHandlerGuards() const {return m_flawHandlerGuards;} - const PlanDatabaseId& getPlanDatabase() const {return m_db;} + const PlanDatabaseId getPlanDatabase() const {return m_db;} /** * @brief Initialize the constructed FlawManager. * @see handleInitialize for extension point. */ - void initialize(const TiXmlElement& configData, const PlanDatabaseId& db, const ContextId& ctx = ContextId::noId(), const FlawManagerId& parent = FlawManagerId::noId()); + void initialize(const TiXmlElement& configData, const PlanDatabaseId db, const ContextId ctx = ContextId::noId(), const FlawManagerId parent = FlawManagerId::noId()); /** * @brief True if the given entity is in scope. This is expensive. */ - bool inScope(const EntityId& entity); + bool inScope(const EntityId entity); /** * @brief True if the filter criteria are matched * @see inScope, staticMatch, dynamicMatch */ - bool matches(const EntityId& entity); + bool matches(const EntityId entity); /** * @brief Obtain the priority for the given entity */ - Priority getPriority(const EntityId& entity); + Priority getPriority(const EntityId entity); /** * @brief Obtains the first avaialble flaw that is forced i.e. a unit decision or a dead-end @@ -105,32 +106,33 @@ namespace EUROPA { */ virtual IteratorId createIterator(); - virtual void notifyAdded(const ConstraintId& constraint){} - virtual void notifyRemoved(const ConstraintId& constraint); - virtual void notifyRemoved(const ConstrainedVariableId& var); - virtual void notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType){} - virtual void notifyAdded(const TokenId& token) {} - virtual void notifyRemoved(const TokenId& token); + virtual void notifyAdded(const ConstraintId constraint); + virtual void notifyRemoved(const ConstraintId constraint); + virtual void notifyRemoved(const ConstrainedVariableId var); + virtual void notifyChanged(const ConstrainedVariableId variable, + const DomainListener::ChangeType& changeType); + virtual void notifyAdded(const TokenId token); + virtual void notifyRemoved(const TokenId token); /** * @brief Indicates that a flaw handler is now active, passing its guards */ - void notifyActivated(const EntityId& target, const FlawHandlerId& flawHandler); + void notifyActivated(const EntityId target, const FlawHandlerId flawHandler); /** * @brief Indicates that a flaw handelr is no longer active */ - void notifyDeactivated(const EntityId& target, const FlawHandlerId& flawhandler); + void notifyDeactivated(const EntityId target, const FlawHandlerId flawhandler); /** * @brief Retrieve the Flaw Handler for a given entity. */ - FlawHandlerId getFlawHandler(const EntityId& entity); + FlawHandlerId getFlawHandler(const EntityId entity); /** * @brief Generates a flaw manager specific string description for an entity contained by the flaw. */ - virtual std::string toString(const EntityId& entity) const; + virtual std::string toString(const EntityId entity) const; /** * @brief test if the timestamp is current @@ -145,15 +147,17 @@ namespace EUROPA { /** * Helper method to evaluate entity w.r.t static conditions only. Encapslates condition access. */ - virtual bool staticMatch(const EntityId& entity); + virtual bool staticMatch(const EntityId entity); /** * Helper method to evaluate entity w.r.t dynamic conditions only. Encapslates condition access. */ - virtual bool dynamicMatch(const EntityId& entity); + virtual bool dynamicMatch(const EntityId entity); ContextId getContext() const {return m_context;} + virtual bool noMoreFlaws() = 0; + protected: FlawManager(const TiXmlElement& configData); @@ -161,19 +165,19 @@ namespace EUROPA { /** * @brief Factory method to allocate instance for selected decision point */ - DecisionPointId allocateDecisionPoint(const EntityId& entity, const LabelStr& explanation); + DecisionPointId allocateDecisionPoint(const EntityId entity, const std::string& explanation); /** * @brief Subclass to implement in order to trigger database dependent data */ virtual void handleInitialize() = 0; - virtual bool betterThan(const EntityId& a, const EntityId& b, LabelStr& explanation); + virtual bool betterThan(const EntityId a, const EntityId b, std::string& explanation); PlanDatabaseId m_db; private: - bool staticallyExcluded(const EntityId& entity) const; + bool staticallyExcluded(const EntityId entity) const; bool isValid() const; FlawManagerId m_parent; diff --git a/src/PLASMA/Solvers/base/MatchingEngine.cc b/src/PLASMA/Solvers/base/MatchingEngine.cc index 2bf4883eb..10e4bbb6e 100644 --- a/src/PLASMA/Solvers/base/MatchingEngine.cc +++ b/src/PLASMA/Solvers/base/MatchingEngine.cc @@ -7,58 +7,70 @@ #include "Schema.hh" #include "Utils.hh" #include "SolverUtils.hh" +#include "tinyxml.h" namespace EUROPA { - namespace SOLVERS { - - - MatchingEngine::MatchingEngine(EngineId& engine,const TiXmlElement& configData, const char* ruleTag) - : m_id(this) - , m_engine(engine) - , m_cycleCount(1) - { - // Now load all the flaw managers - std::string ruleTagStr(ruleTag); - - for (TiXmlElement * child = configData.FirstChildElement(); - child != NULL; - child = child->NextSiblingElement()) { - const char* component = child->Attribute("component"); - - if(ruleTagStr.find(child->Value(), 0) != std::string::npos){ - // If no component name is provided, register it with the tag name of configuration element - // thus obtaining the default. - if(component == NULL) - child->SetAttribute("component", child->Value()); - - // Now allocate the particular flaw manager using an abstract factory pattern. - ComponentFactoryMgr* cfm = (ComponentFactoryMgr*)engine->getComponent("ComponentFactoryMgr"); - ComponentId componentInstance = cfm->createInstance(*child); - checkError(componentInstance.isValid(), componentInstance << ":" << child->Value()); - checkError(MatchingRuleId::convertable(componentInstance), "Bad component for " << child->Value()); - MatchingRuleId rule = componentInstance; - rule->initialize(getId()); - debugMsg("MatchingEngine:MatchingEngine", "Adding " << rule->toString()); - } - } +namespace SOLVERS { + +MatchingEngine::MatchingEngine(EngineId engine, + const TiXmlElement& configData, + const char* ruleTag) + : m_id(this) + , m_engine(engine) + , m_rulesByObjectType() + , m_rulesByPredicate() + , m_rulesByVariable() + , m_rulesByMasterObjectType() + , m_rulesByMasterPredicate() + , m_rulesByMasterRelation() + , m_rulesByTokenName() + , m_cycleCount(1), + m_rules(), + m_rulesByExpression(), + m_unfilteredRules() { + // Now load all the flaw managers + std::string ruleTagStr(ruleTag); + + for (TiXmlElement * child = configData.FirstChildElement(); + child != NULL; + child = child->NextSiblingElement()) { + const char* component = child->Attribute("component"); + + if(ruleTagStr.find(child->Value(), 0) != std::string::npos){ + // If no component name is provided, register it with the tag name of configuration element + // thus obtaining the default. + if(component == NULL) + child->SetAttribute("component", child->Value()); + + // Now allocate the particular flaw manager using an abstract factory pattern. + ComponentFactoryMgr* cfm = + reinterpret_cast(engine->getComponent("ComponentFactoryMgr")); + ComponentId componentInstance = cfm->createComponentInstance(*child); + checkError(componentInstance.isValid(), componentInstance << ":" << child->Value()); + checkError(MatchingRuleId::convertable(componentInstance), "Bad component for " << child->Value()); + MatchingRuleId rule = componentInstance; + rule->initialize(getId()); + debugMsg("MatchingEngine:MatchingEngine", "Adding " << rule->toString()); } + } +} - MatchingEngine::~MatchingEngine(){ - cleanup(m_rules); - m_id.remove(); - } +MatchingEngine::~MatchingEngine() { + cleanup(m_rules); + m_id.remove(); +} - MatchingEngineId& MatchingEngine::getId() { return m_id; } + MatchingEngineId MatchingEngine::getId() { return m_id; } - void MatchingEngine::registerRule(const MatchingRuleId& rule){ + void MatchingEngine::registerRule(const MatchingRuleId rule){ checkError(m_rules.find(rule) == m_rules.end(), rule->toString() << " already registered."); debugMsg("MatchingEngine:registerRule", rule->toString()); m_rules.insert(rule); std::string expression = rule->toString(); - LabelStr expressionLabel(expression); - m_rulesByExpression.insert(std::make_pair(expressionLabel.getKey(), rule)); + std::string expressionLabel(expression); + m_rulesByExpression.insert(std::make_pair(expressionLabel, rule)); if(rule->staticFilterCount() == 0){ m_unfilteredRules.push_back(rule); @@ -73,12 +85,12 @@ namespace EUROPA { addFilter(rule->tokenNameFilter(), rule, m_rulesByTokenName); if(rule->filteredByMasterRelation()){ - static const LabelStr BEFORE("before"); - static const LabelStr AFTER("after"); - static const LabelStr MEETS("meets"); - static const LabelStr MET_BY("met_by"); + static const std::string BEFORE("before"); + static const std::string AFTER("after"); + static const std::string MEETS("meets"); + static const std::string MET_BY("met_by"); - const LabelStr& relation = rule->masterRelationFilter(); + const std::string& relation = rule->masterRelationFilter(); addFilter(relation, rule, m_rulesByMasterRelation); // Post for matchable relations too @@ -89,127 +101,127 @@ namespace EUROPA { } } - void MatchingEngine::addFilter(const LabelStr& label, const MatchingRuleId& rule, - std::multimap& index){ - if(label != WILD_CARD()){ - debugMsg("MatchingEngine:addFilter", "Adding " << rule->toString() << " for label " << label.toString()); - index.insert(std::make_pair(label.getKey(), rule)); - } - } +void MatchingEngine::addFilter(const std::string& label, const MatchingRuleId rule, + std::multimap& index){ + if(label != WILD_CARD()){ + debugMsg("MatchingEngine:addFilter", + "Adding " << rule->toString() << " for label " << label); + index.insert(std::make_pair(label, rule)); + } +} - bool MatchingEngine::hasRule(const LabelStr& expression) const { - return m_rulesByExpression.find(expression.getKey()) != m_rulesByExpression.end(); - } +bool MatchingEngine::hasRule(const std::string& expression) const { + return m_rulesByExpression.find(expression) != m_rulesByExpression.end(); +} unsigned int MatchingEngine::cycleCount() const { return m_cycleCount; } - template<> - void MatchingEngine::getMatches(const EntityId& entity, - std::vector& results) { - std::map::iterator it = - getEntityMatchers().find(entity->entityType()); - checkError(it != getEntityMatchers().end(), - "No way to match entities of type " << entity->entityType().toString()); - it->second->getMatches(getId(), entity, results); - } - - template<> - void MatchingEngine::getMatches(const ConstrainedVariableId& var, - std::vector& results) { - m_cycleCount++; - results = m_unfilteredRules; - - // If it has a parent, then process that too - if(var->parent().isId()){ - if(TokenId::convertable(var->parent())) - getMatchesInternal(TokenId(var->parent()), results); - else if(RuleInstanceId::convertable(var->parent())) - getMatchesInternal(RuleInstanceId(var->parent())->getToken(), results); - else if(ObjectId::convertable(var->parent())){ - ObjectId object = var->parent(); - trigger(object->getPlanDatabase()->getSchema()->getAllObjectTypes(object->getType()), m_rulesByObjectType, results); - } - } +template<> +void MatchingEngine::getMatches(const EntityId entity, + std::vector& results) { + std::map::iterator it = + getEntityMatchers().find(entity->entityType()); + checkError(it != getEntityMatchers().end(), + "No way to match entities of type " << entity->entityType()); + it->second->getMatches(getId(), entity, results); +} - trigger(var->getName(), m_rulesByVariable, results); +template<> +void MatchingEngine::getMatches(const ConstrainedVariableId var, + std::vector& results) { + m_cycleCount++; + results = m_unfilteredRules; + + // If it has a parent, then process that too + if(var->parent().isId()){ + if(TokenId::convertable(var->parent())) + getMatchesInternal(TokenId(var->parent()), results); + else if(RuleInstanceId::convertable(var->parent())) + getMatchesInternal(RuleInstanceId(var->parent())->getToken(), results); + else if(ObjectId::convertable(var->parent())){ + ObjectId object = var->parent(); + trigger(object->getPlanDatabase()->getSchema()->getAllObjectTypes(object->getType()), m_rulesByObjectType, results); } + } + + trigger(var->getName(), m_rulesByVariable, results); +} template<> - void MatchingEngine::getMatches(const TokenId& token, std::vector& results) { + void MatchingEngine::getMatches(const TokenId token, std::vector& results) { m_cycleCount++; results = m_unfilteredRules; getMatchesInternal(token, results); } - unsigned int MatchingEngine::ruleCount() const { + unsigned long MatchingEngine::ruleCount() const { return m_rules.size(); } - std::string rulesToString(const std::multimap& rules) { - std::stringstream str; - edouble current = -1.0; - for(std::multimap::const_iterator it = rules.begin(); it != rules.end(); ++it) { - if(it->first != current) { - current = it->first; - str << "'" << LabelStr(current).toString() << "':" << std::endl; - } - str << " " <second->toString() << std::endl; - } - return str.str(); - } - - bool matches(MatchingRuleId rule, edouble value, edouble key) - { - if (rule->filteredByTokenName()) { - LabelStr valueLbl(value); - LabelStr keyLbl(key); - bool result = keyLbl.toString().find(valueLbl.toString()) != std::string::npos; - debugMsg("MatchingEngine:tokenName", "result=" << result << " key=" << keyLbl.toString() << " value=" << valueLbl.toString()); - return result; - } - else - return value==key; +namespace { +std::string rulesToString(const std::multimap& rules) { + std::stringstream str; + std::string current = ""; + for(std::multimap::const_iterator it = rules.begin(); + it != rules.end(); ++it) { + if(it->first != current) { + current = it->first; + str << "'" << current << "':" << std::endl; } + str << " " <second->toString() << std::endl; + } + return str.str(); +} - void triggerTokenByName(const LabelStr& lbl, - const std::multimap& rules, - std::vector& results) - { - debugMsg("MatchingEngine:trigger", "Searching with label " << lbl.toString()); - debugMsg("MatchingEngine:verboseTrigger", "Searching in " << std::endl << rulesToString(rules)); - unsigned int addedCount = 0; - edouble key = lbl.getKey(); - std::multimap::const_iterator it = rules.begin(); - while(it != rules.end()) { - if (matches(it->second,it->first,key)) { - MatchingRuleId rule = it->second; - if(rule->fire()) { - results.push_back(rule); - addedCount++; - } - } - ++it; - } - - debugMsg("MatchingEngine:trigger", - "Found " << results.size() << " matches for " << lbl.toString() << " so far. Added " << addedCount); +bool matches(MatchingRuleId rule, const std::string& value, const std::string& key) { + if (rule->filteredByTokenName()) { + bool result = key.find(value) != std::string::npos; + debugMsg("MatchingEngine:tokenName", + "result=" << result << " key=" << key << " value=" << value); + return result; + } + else + return value==key; +} + +void triggerTokenByName(const std::string& lbl, + const std::multimap& rules, + std::vector& results) { + debugMsg("MatchingEngine:trigger", "Searching with label " << lbl); + debugMsg("MatchingEngine:verboseTrigger", "Searching in " << std::endl << rulesToString(rules)); + unsigned int addedCount = 0; + std::multimap::const_iterator it = rules.begin(); + while(it != rules.end()) { + if (matches(it->second,it->first,lbl)) { + MatchingRuleId rule = it->second; + if(rule->fire()) { + results.push_back(rule); + addedCount++; + } } + ++it; + } + debugMsg("MatchingEngine:trigger", + "Found " << results.size() << " matches for " << lbl << + " so far. Added " << addedCount); +} +} /** * @brief todo. Fire for all cases */ template<> - void MatchingEngine::getMatchesInternal(const TokenId& token, std::vector& results){ + void MatchingEngine::getMatchesInternal(const TokenId token, std::vector& results){ // Fire for predicate - LabelStr unqualifiedName = token->getUnqualifiedPredicateName(); - debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for predicate " << unqualifiedName.toString()); + std::string unqualifiedName = token->getUnqualifiedPredicateName(); + debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for predicate " << unqualifiedName); trigger(unqualifiedName, m_rulesByPredicate, results); // Fire for tokenName - LabelStr tokenName = token->getName(); - debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for tokenName " << tokenName.toString()); + std::string tokenName = token->getName(); + debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for tokenName " << tokenName); triggerTokenByName(tokenName, m_rulesByTokenName, results); SchemaId schema = token->getPlanDatabase()->getSchema(); @@ -221,81 +233,78 @@ namespace EUROPA { // If it has a master, trigger on the relation if(token->master().isId()){ - debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for master object types (" << token->master()->getBaseObjectType().toString() << ")"); + debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for master object types (" << token->master()->getBaseObjectType() << ")"); trigger(schema->getAllObjectTypes(token->master()->getBaseObjectType()), m_rulesByMasterObjectType, results); - debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for master predicate " << token->master()->getUnqualifiedPredicateName().toString()); + debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for master predicate " << token->master()->getUnqualifiedPredicateName()); trigger(token->master()->getUnqualifiedPredicateName(), m_rulesByMasterPredicate, results); - debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for master relation " << token->getRelation().toString()); + debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for master relation " << token->getRelation()); trigger(token->getRelation(), m_rulesByMasterRelation, results); } else { // Trigger for those registered for 'none' explicitly - static const LabelStr none("none"); + static const std::string none("none"); debugMsg("MatchingEngine:getMatchesInternal", "Triggering matches for 'none' master relation."); trigger(none, m_rulesByMasterRelation, results); } } - void MatchingEngine::trigger(const LabelStr& lbl, - const std::multimap& rules, - std::vector& results){ - debugMsg("MatchingEngine:trigger", "Searching with label " << lbl.toString()); - debugMsg("MatchingEngine:verboseTrigger", "Searching in " << std::endl << rulesToString(rules)); - unsigned int addedCount = 0; - edouble key = lbl.getKey(); - std::multimap::const_iterator it = rules.find(key); - while(it != rules.end() && it->first==key) { - MatchingRuleId rule = it->second; - if(rule->fire()) { - results.push_back(rule); - addedCount++; - } - ++it; - } - - debugMsg("MatchingEngine:trigger", - "Found " << results.size() << " matches for " << lbl.toString() << " so far. Added " << addedCount); +void MatchingEngine::trigger(const std::string& lbl, + const std::multimap& rules, + std::vector& results){ + debugMsg("MatchingEngine:trigger", "Searching with label " << lbl); + debugMsg("MatchingEngine:verboseTrigger", "Searching in " << std::endl << rulesToString(rules)); + unsigned int addedCount = 0; + + std::multimap::const_iterator it = rules.find(lbl); + while(it != rules.end() && it->first==lbl) { + MatchingRuleId rule = it->second; + if(rule->fire()) { + results.push_back(rule); + addedCount++; } + ++it; + } - void MatchingEngine::trigger(const std::vector& labels, - const std::multimap& rules, - std::vector& results){ - for(std::vector::const_iterator it = labels.begin(); it != labels.end(); ++it){ - const LabelStr& label = *it; - trigger(label, rules, results); - } - } + debugMsg("MatchingEngine:trigger", + "Found " << results.size() << " matches for " << lbl << + " so far. Added " << addedCount); +} - std::map& MatchingEngine::getEntityMatchers() - { - MatchFinderMgr* mfm = (MatchFinderMgr*)m_engine->getComponent("MatchFinderMgr"); - return mfm->getEntityMatchers(); - } +void MatchingEngine::trigger(const std::vector& labels, + const std::multimap& rules, + std::vector& results) { + for(std::vector::const_iterator it = labels.begin(); it != labels.end(); ++it){ + const std::string& label = *it; + trigger(label, rules, results); + } +} + +std::map& MatchingEngine::getEntityMatchers() { + MatchFinderMgr* mfm = + reinterpret_cast(m_engine->getComponent("MatchFinderMgr")); + return mfm->getEntityMatchers(); +} - MatchFinderMgr::MatchFinderMgr() - { - } +MatchFinderMgr::MatchFinderMgr() : m_entityMatchers() {} - MatchFinderMgr::~MatchFinderMgr() - { - purgeAll(); - } +MatchFinderMgr::~MatchFinderMgr() { + purgeAll(); +} - void MatchFinderMgr::addMatchFinder(const LabelStr& type, const MatchFinderId& finder) { + void MatchFinderMgr::addMatchFinder(const std::string& type, const MatchFinderId finder) { // Remove first in case one already exists removeMatchFinder(type); getEntityMatchers().insert(std::make_pair(type, finder)); } - void MatchFinderMgr::removeMatchFinder(const LabelStr& type) - { - std::map::iterator it = getEntityMatchers().find(type); - if(it != getEntityMatchers().end()) { - MatchFinderId oldId = it->second; - getEntityMatchers().erase(type); - oldId.release(); - } - } +void MatchFinderMgr::removeMatchFinder(const std::string& type) { + std::map::iterator it = getEntityMatchers().find(type); + if(it != getEntityMatchers().end()) { + MatchFinderId oldId = it->second; + getEntityMatchers().erase(type); + oldId.release(); + } +} void MatchFinderMgr::purgeAll() { @@ -303,14 +312,14 @@ namespace EUROPA { removeMatchFinder(getEntityMatchers().begin()->first); } - std::map& MatchFinderMgr::getEntityMatchers() { return m_entityMatchers; } +std::map& MatchFinderMgr::getEntityMatchers() { return m_entityMatchers; } - void VariableMatchFinder::getMatches(const MatchingEngineId& engine, const EntityId& entity, + void VariableMatchFinder::getMatches(const MatchingEngineId engine, const EntityId entity, std::vector& results) { engine->getMatches(ConstrainedVariableId(entity), results); } - void TokenMatchFinder::getMatches(const MatchingEngineId& engine, const EntityId& entity, + void TokenMatchFinder::getMatches(const MatchingEngineId engine, const EntityId entity, std::vector& results) { engine->getMatches(TokenId(entity), results); } diff --git a/src/PLASMA/Solvers/base/MatchingEngine.hh b/src/PLASMA/Solvers/base/MatchingEngine.hh index 7b8a85eab..bcf5a546e 100644 --- a/src/PLASMA/Solvers/base/MatchingEngine.hh +++ b/src/PLASMA/Solvers/base/MatchingEngine.hh @@ -14,172 +14,174 @@ #include namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - class MatchFinder; - typedef Id MatchFinderId; +class MatchFinder; +typedef Id MatchFinderId; - class MatchFinderMgr : public EngineComponent - { - public: - MatchFinderMgr(); - virtual ~MatchFinderMgr(); +class MatchFinderMgr : public EngineComponent { + public: + MatchFinderMgr(); + virtual ~MatchFinderMgr(); - void addMatchFinder(const LabelStr& type, const MatchFinderId& finder); - void removeMatchFinder(const LabelStr& type); - void purgeAll(); + void addMatchFinder(const std::string& type, const MatchFinderId finder); + void removeMatchFinder(const std::string& type); + void purgeAll(); - std::map& getEntityMatchers(); + std::map& getEntityMatchers(); - protected: - std::map m_entityMatchers; - }; + protected: + std::map m_entityMatchers; +}; - class MatchingEngine { - public: - MatchingEngine(EngineId& engine,const TiXmlElement& configData, const char* ruleTag = "MatchingRule"); - - virtual ~MatchingEngine(); - - MatchingEngineId& getId(); - - /** - * @brief Retrieves all relevent matching rules for the given entity. - * @note This method has no implementation. It is expected that specializations will be - * written for each type. - */ - template - void getMatches(const T& entity, std::vector& results) { - checkError(ALWAYS_FAIL, - "Don't know how to match objects of type " << typeid(T).name()); - } - - /** - * @brief Adds a rule. Details of how it is indexed are internal - */ - void registerRule(const MatchingRuleId& rule); - - /** - * @brief test if a given rule expression is present. - * @param expression A string expression for the rule - * @see MatchingRule::toString(), MatchingRule::setExpression - */ - bool hasRule(const LabelStr& expression) const; - - /** - * @brief The last count of matches tried. - */ - unsigned int cycleCount() const; - - /** - * @brief Get the total number of registered rules. - */ - unsigned int ruleCount() const; - - const std::set& getRules() const {return m_rules;} - - private: - - /** - * @brief Utility method to add a rule to an index if it is required. - */ - void addFilter(const LabelStr& label, const MatchingRuleId& rule, - std::multimap& index); - - template - void getMatchesInternal(const T& entity, std::vector& results); - - /** - * @brief Utility method to trigger rules along a given index. - */ - void trigger(const LabelStr& lbl, - const std::multimap& rules, - std::vector& results); - - /** - * @brief Utility method to trigger rules along a given index for each element in the vector - */ - void trigger(const std::vector& labels, - const std::multimap& rules, - std::vector& results); - - /** - * @brief Utility to handle the recursive triggering for a class and its super class. - */ - MatchingEngineId m_id; - EngineId& m_engine; +class MatchingEngine { + public: + MatchingEngine(EngineId engine,const TiXmlElement& configData, const char* ruleTag = "MatchingRule"); + + virtual ~MatchingEngine(); + + MatchingEngineId getId(); + + /** + * @brief Retrieves all relevent matching rules for the given entity. + * @note This method has no implementation. It is expected that specializations will be + * written for each type. + */ + template + void getMatches(const T, std::vector&) { + checkError(ALWAYS_FAIL, + "Don't know how to match objects of type " << typeid(T).name()); + } + + /** + * @brief Adds a rule. Details of how it is indexed are internal + */ + void registerRule(const MatchingRuleId rule); + + /** + * @brief test if a given rule expression is present. + * @param expression A string expression for the rule + * @see MatchingRule::toString(), MatchingRule::setExpression + */ + bool hasRule(const std::string& expression) const; + + /** + * @brief The last count of matches tried. + */ + unsigned int cycleCount() const; + + /** + * @brief Get the total number of registered rules. + */ + unsigned long ruleCount() const; + + const std::set& getRules() const {return m_rules;} + + private: + + /** + * @brief Utility method to add a rule to an index if it is required. + */ + void addFilter(const std::string& label, const MatchingRuleId rule, + std::multimap& index); + + template + void getMatchesInternal(const T, std::vector&) { + checkError(ALWAYS_FAIL, + "Don't know how to match objects of type " << typeid(T).name()); + } + /** + * @brief Utility method to trigger rules along a given index. + */ + void trigger(const std::string& lbl, + const std::multimap& rules, + std::vector& results); + + /** + * @brief Utility method to trigger rules along a given index for each element in the vector + */ + void trigger(const std::vector& labels, + const std::multimap& rules, + std::vector& results); + + /** + * @brief Utility to handle the recursive triggering for a class and its super class. + */ + MatchingEngineId m_id; + EngineId m_engine; - /** - * Declarations basically support indexing by each criteria. - */ - std::multimap m_rulesByObjectType; - std::multimap m_rulesByPredicate; - std::multimap m_rulesByVariable; - std::multimap m_rulesByMasterObjectType; - std::multimap m_rulesByMasterPredicate; - std::multimap m_rulesByMasterRelation; - std::multimap m_rulesByTokenName; - - unsigned int m_cycleCount; /*!< Used to reset all rule firing data. Updated on each call to match. */ - std::set m_rules; /*!< The set of all rules. */ - std::multimap m_rulesByExpression; /*!< All rules by expression */ - std::vector m_unfilteredRules; /*!< All rules without filters */ - - std::map& getEntityMatchers(); - }; - - template<> - void MatchingEngine::getMatches(const EntityId& entity, - std::vector& results); - - /** - * @brief Retrives all relevant matching rules for the given variable - */ - template<> - void MatchingEngine::getMatches(const ConstrainedVariableId& var, - std::vector& results); + /** + * Declarations basically support indexing by each criteria. + */ + std::multimap m_rulesByObjectType; + std::multimap m_rulesByPredicate; + std::multimap m_rulesByVariable; + std::multimap m_rulesByMasterObjectType; + std::multimap m_rulesByMasterPredicate; + std::multimap m_rulesByMasterRelation; + std::multimap m_rulesByTokenName; + + unsigned int m_cycleCount; /*!< Used to reset all rule firing data. Updated on each call to match. */ + std::set m_rules; /*!< The set of all rules. */ + std::multimap m_rulesByExpression; /*!< All rules by expression */ + std::vector m_unfilteredRules; /*!< All rules without filters */ + + std::map& getEntityMatchers(); +}; - /** - * @brief Retrievs all relevant matching rules for te given token - */ - template<> - void MatchingEngine::getMatches(const TokenId& token, - std::vector& results); + +template<> +void MatchingEngine::getMatches(const EntityId entity, + std::vector& results); + +/** + * @brief Retrives all relevant matching rules for the given variable + */ +template<> +void MatchingEngine::getMatches(const ConstrainedVariableId var, + std::vector& results); + +/** + * @brief Retrievs all relevant matching rules for te given token + */ +template<> +void MatchingEngine::getMatches(const TokenId token, + std::vector& results); - template<> - void MatchingEngine::getMatchesInternal(const TokenId& token, - std::vector& results); - - /** - * Class for - */ - - class MatchFinder { - public: - MatchFinder() : m_id(this) {} - const MatchFinderId& getId() const {return m_id;} - virtual ~MatchFinder() {} - virtual void getMatches(const MatchingEngineId& engine, const EntityId& entity, - std::vector& results) = 0; - private: - MatchFinderId m_id; - }; - - class VariableMatchFinder : public MatchFinder { - public: - void getMatches(const MatchingEngineId& engine, const EntityId& entity, - std::vector& results); - }; - - class TokenMatchFinder : public MatchFinder { - public: - void getMatches(const MatchingEngineId& engine, const EntityId& entity, - std::vector& results); - }; +template<> +void MatchingEngine::getMatchesInternal(const TokenId token, + std::vector& results); + +/** + * Class for + */ + +class MatchFinder { + public: + MatchFinder() : m_id(this) {} + const MatchFinderId getId() const {return m_id;} + virtual ~MatchFinder() {} + virtual void getMatches(const MatchingEngineId engine, const EntityId entity, + std::vector& results) = 0; + private: + MatchFinderId m_id; +}; + +class VariableMatchFinder : public MatchFinder { + public: + void getMatches(const MatchingEngineId engine, const EntityId entity, + std::vector& results); +}; + +class TokenMatchFinder : public MatchFinder { + public: + void getMatches(const MatchingEngineId engine, const EntityId entity, + std::vector& results); +}; -#define REGISTER_MATCH_FINDER(MGR,CLASS,NAME) \ - (MGR->addMatchFinder(NAME,(new CLASS())->getId())); +#define REGISTER_MATCH_FINDER(MGR,CLASS,NAME) \ + (MGR->addMatchFinder(NAME,(new CLASS())->getId())); - } +} } #endif diff --git a/src/PLASMA/Solvers/base/MatchingRule.cc b/src/PLASMA/Solvers/base/MatchingRule.cc index f72933319..871d03004 100644 --- a/src/PLASMA/Solvers/base/MatchingRule.cc +++ b/src/PLASMA/Solvers/base/MatchingRule.cc @@ -5,6 +5,7 @@ #include "ConstrainedVariable.hh" #include "SolverUtils.hh" #include "Debug.hh" +#include "tinyxml.h" /** * @author Conor McGann @@ -12,80 +13,85 @@ * @file Provides implementation for core rule matching classes. */ namespace EUROPA { - namespace SOLVERS { - - MatchingRule::MatchingRule(const TiXmlElement& configData) - : Component(configData), - m_objectType(WILD_CARD()), m_predicate(WILD_CARD()), m_variable(WILD_CARD()), - m_masterObjectType(WILD_CARD()), m_masterPredicate(WILD_CARD()), m_masterRelation(WILD_CARD()), - m_tokenName(WILD_CARD()), - m_staticFilterCount(0), m_lastCycle(0), m_hitCount(0) { - - std::string expr; - if(configData.Attribute("label") != NULL){ - m_label = configData.Attribute("label"); - expr = "[" + m_label.toString() + "]"; - } +namespace SOLVERS { + +MatchingRule::MatchingRule(const TiXmlElement& configData) + : Component(configData), + m_context(), + m_label(), + m_expression(), + m_objectType(WILD_CARD()), m_predicate(WILD_CARD()), m_variable(WILD_CARD()), + m_masterObjectType(WILD_CARD()), m_masterPredicate(WILD_CARD()), + m_masterRelation(WILD_CARD()), + m_tokenName(WILD_CARD()), + m_staticFilterCount(0), m_lastCycle(0), m_hitCount(0), + m_matchingEngine() { + + std::string expr; + if(configData.Attribute("label") != NULL){ + m_label = configData.Attribute("label"); + expr = "[" + m_label + "]"; + } - if(configData.Attribute("class-match") != NULL){ - m_objectType = configData.Attribute("class-match"); - m_staticFilterCount++; - } - else if(configData.Attribute("class") != NULL){ - m_objectType = configData.Attribute("class"); - m_staticFilterCount++; - } + if(configData.Attribute("class-match") != NULL){ + m_objectType = configData.Attribute("class-match"); + m_staticFilterCount++; + } + else if(configData.Attribute("class") != NULL){ + m_objectType = configData.Attribute("class"); + m_staticFilterCount++; + } - if(configData.Attribute("predicate-match") != NULL){ - m_predicate = configData.Attribute("predicate-match"); - m_staticFilterCount++; - } - else if(configData.Attribute("predicate") != NULL){ - m_predicate = configData.Attribute("predicate"); - m_staticFilterCount++; - } + if(configData.Attribute("predicate-match") != NULL){ + m_predicate = configData.Attribute("predicate-match"); + m_staticFilterCount++; + } + else if(configData.Attribute("predicate") != NULL){ + m_predicate = configData.Attribute("predicate"); + m_staticFilterCount++; + } - if(configData.Attribute("var-match") != NULL){ - m_variable = configData.Attribute("var-match"); - m_staticFilterCount++;m_variable.toString(); - } - else if(configData.Attribute("variable") != NULL){ - m_variable = configData.Attribute("variable"); - m_staticFilterCount++; - } + if(configData.Attribute("var-match") != NULL){ + m_variable = configData.Attribute("var-match"); + m_staticFilterCount++; + } + else if(configData.Attribute("variable") != NULL){ + m_variable = configData.Attribute("variable"); + m_staticFilterCount++; + } - if(configData.Attribute("masterRelation") != NULL){ - m_masterRelation = configData.Attribute("masterRelation"); - m_staticFilterCount++; - } + if(configData.Attribute("masterRelation") != NULL){ + m_masterRelation = configData.Attribute("masterRelation"); + m_staticFilterCount++; + } - if(configData.Attribute("masterClass") != NULL){ - m_masterObjectType = configData.Attribute("masterClass"); - m_staticFilterCount++; - } + if(configData.Attribute("masterClass") != NULL){ + m_masterObjectType = configData.Attribute("masterClass"); + m_staticFilterCount++; + } - if(configData.Attribute("masterPredicate") != NULL){ - m_masterPredicate = configData.Attribute("masterPredicate"); - m_staticFilterCount++; - } + if(configData.Attribute("masterPredicate") != NULL){ + m_masterPredicate = configData.Attribute("masterPredicate"); + m_staticFilterCount++; + } - if(configData.Attribute("tokenName") != NULL){ - m_tokenName = configData.Attribute("tokenName"); - m_staticFilterCount++; - } + if(configData.Attribute("tokenName") != NULL){ + m_tokenName = configData.Attribute("tokenName"); + m_staticFilterCount++; + } - expr = expr + m_objectType.toString() + "." + - m_predicate.toString() + "." + - m_variable.toString() + "." + - m_masterRelation.toString() + "." + - m_masterObjectType.toString() + "." + - m_masterPredicate.toString(); //+ "." + - //m_tokenName.toString(); // TODO: add this and fix regresion tests + expr = expr + m_objectType + "." + + m_predicate + "." + + m_variable + "." + + m_masterRelation + "." + + m_masterObjectType + "." + + m_masterPredicate; //+ "." + + //m_tokenName.toString(); // TODO: add this and fix regresion tests - setExpression(expr); - } + setExpression(expr); +} - void MatchingRule::initialize(const MatchingEngineId& matchingEngine){ + void MatchingRule::initialize(const MatchingEngineId matchingEngine){ m_matchingEngine = matchingEngine; m_matchingEngine->registerRule(getId()); } @@ -116,30 +122,30 @@ namespace EUROPA { bool MatchingRule::filteredByObjectType() const { return m_objectType != WILD_CARD(); } - const LabelStr& MatchingRule::objectTypeFilter() const{ return m_objectType;} + const std::string& MatchingRule::objectTypeFilter() const{ return m_objectType;} bool MatchingRule::filteredByPredicate() const{ return m_predicate != WILD_CARD(); } - const LabelStr& MatchingRule::predicateFilter() const{ return m_predicate; } + const std::string& MatchingRule::predicateFilter() const{ return m_predicate; } bool MatchingRule::filteredByVariable() const{ return m_variable != WILD_CARD(); } - const LabelStr& MatchingRule::variableFilter() const { return m_variable; } + const std::string& MatchingRule::variableFilter() const { return m_variable; } bool MatchingRule::filteredByMasterObjectType() const{ return m_objectType != WILD_CARD(); } - const LabelStr& MatchingRule::masterObjectTypeFilter() const { return m_masterObjectType; } + const std::string& MatchingRule::masterObjectTypeFilter() const { return m_masterObjectType; } bool MatchingRule::filteredByMasterPredicate() const{ return m_objectType != WILD_CARD(); } - const LabelStr& MatchingRule::masterPredicateFilter() const { return m_masterPredicate; } + const std::string& MatchingRule::masterPredicateFilter() const { return m_masterPredicate; } bool MatchingRule::filteredByMasterRelation() const{ return m_masterRelation != WILD_CARD(); } - const LabelStr& MatchingRule::masterRelationFilter() const { return m_masterRelation; } + const std::string& MatchingRule::masterRelationFilter() const { return m_masterRelation; } bool MatchingRule::filteredByTokenName() const{ return m_tokenName != WILD_CARD(); } - const LabelStr& MatchingRule::tokenNameFilter() const { return m_tokenName; } + const std::string& MatchingRule::tokenNameFilter() const { return m_tokenName; } } } diff --git a/src/PLASMA/Solvers/base/MatchingRule.hh b/src/PLASMA/Solvers/base/MatchingRule.hh index 110249527..1b737d564 100644 --- a/src/PLASMA/Solvers/base/MatchingRule.hh +++ b/src/PLASMA/Solvers/base/MatchingRule.hh @@ -11,85 +11,85 @@ #include "ComponentFactory.hh" namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - class MatchingRule: public Component { - public: - /** - * @brief Construct a matching rule - */ - MatchingRule(const TiXmlElement& configData); +class MatchingRule: public Component { + public: + /** + * @brief Construct a matching rule + */ + MatchingRule(const TiXmlElement& configData); - /** - * @brief Sets link to matching engine to obtain cycle count - */ - void initialize(const MatchingEngineId& matchingEngine); + /** + * @brief Sets link to matching engine to obtain cycle count + */ + void initialize(const MatchingEngineId matchingEngine); - /** - * @brief Test if all conditions have been met for this rule, in this iteration of the matching engine - */ - bool fire(); + /** + * @brief Test if all conditions have been met for this rule, in this iteration of the matching engine + */ + bool fire(); - /** - * @brief Retrieves a string expression for the scope over which this filter is evaluated. - */ - virtual std::string toString() const; + /** + * @brief Retrieves a string expression for the scope over which this filter is evaluated. + */ + virtual std::string toString() const; - /** - * @brief The number of static filters on this rule - */ - virtual unsigned int staticFilterCount() const; + /** + * @brief The number of static filters on this rule + */ + virtual unsigned int staticFilterCount() const; - bool filteredByObjectType() const; + bool filteredByObjectType() const; - const LabelStr& objectTypeFilter() const; + const std::string& objectTypeFilter() const; - bool filteredByPredicate() const; + bool filteredByPredicate() const; - const LabelStr& predicateFilter() const; + const std::string& predicateFilter() const; - bool filteredByVariable() const; + bool filteredByVariable() const; - const LabelStr& variableFilter() const; + const std::string& variableFilter() const; - bool filteredByMasterObjectType() const; + bool filteredByMasterObjectType() const; - const LabelStr& masterObjectTypeFilter() const; + const std::string& masterObjectTypeFilter() const; - bool filteredByMasterPredicate() const; + bool filteredByMasterPredicate() const; - const LabelStr& masterPredicateFilter() const; + const std::string& masterPredicateFilter() const; - bool filteredByMasterRelation() const; + bool filteredByMasterRelation() const; - const LabelStr& masterRelationFilter() const; + const std::string& masterRelationFilter() const; - bool filteredByTokenName() const; + bool filteredByTokenName() const; - const LabelStr& tokenNameFilter() const; + const std::string& tokenNameFilter() const; - ContextId getContext() {return m_context;} - void setContext(ContextId ctx) {m_context = ctx;} - protected: - void setExpression(const std::string& expression); - ContextId m_context; - private: - MatchingRule(const MatchingRule&); /*!< NO IMPL */ - LabelStr m_label; /*!< Stores the label for the rule. Optional to set this. */ - std::string m_expression; /*!< Stores the matching expression as a string for display */ + ContextId getContext() const {return m_context;} + virtual void setContext(ContextId ctx) {check_error(ctx != ContextId::noId()); m_context = ctx;} + protected: + void setExpression(const std::string& expression); + ContextId m_context; + private: + MatchingRule(const MatchingRule&); /*!< NO IMPL */ + std::string m_label; /*!< Stores the label for the rule. Optional to set this. */ + std::string m_expression; /*!< Stores the matching expression as a string for display */ - LabelStr m_objectType; - LabelStr m_predicate; - LabelStr m_variable; - LabelStr m_masterObjectType; - LabelStr m_masterPredicate; - LabelStr m_masterRelation; - LabelStr m_tokenName; - unsigned int m_staticFilterCount; /*!< Count of the number of static filters on this rule */ - unsigned int m_lastCycle; /*!< The last MatchingEngine cycle */ - unsigned int m_hitCount; /*!< Count of hits in the current matching cycle */ - MatchingEngineId m_matchingEngine; - }; + std::string m_objectType; + std::string m_predicate; + std::string m_variable; + std::string m_masterObjectType; + std::string m_masterPredicate; + std::string m_masterRelation; + std::string m_tokenName; + unsigned int m_staticFilterCount; /*!< Count of the number of static filters on this rule */ + unsigned int m_lastCycle; /*!< The last MatchingEngine cycle */ + unsigned int m_hitCount; /*!< Count of hits in the current matching cycle */ + MatchingEngineId m_matchingEngine; +}; } } #endif diff --git a/src/PLASMA/Solvers/base/SearchListener.cc b/src/PLASMA/Solvers/base/SearchListener.cc new file mode 100644 index 000000000..5bf2d3383 --- /dev/null +++ b/src/PLASMA/Solvers/base/SearchListener.cc @@ -0,0 +1,20 @@ +#include "SearchListener.hh" + +namespace EUROPA { +namespace SOLVERS { +void SearchListener::notifyCreated(DecisionPointId) {}; + +void SearchListener::notifyDeleted(DecisionPointId) {}; + +void SearchListener::notifyUndone(DecisionPointId) {}; + +void SearchListener::notifyStepSucceeded(DecisionPointId) {}; + +void SearchListener::notifyStepFailed(DecisionPointId) {}; + +void SearchListener::notifyRetractSucceeded(DecisionPointId) {}; + +void SearchListener::notifyRetractNotDone(DecisionPointId) {}; +} +} + diff --git a/src/PLASMA/Solvers/base/SearchListener.hh b/src/PLASMA/Solvers/base/SearchListener.hh index 454cccfd5..c02cc1d38 100644 --- a/src/PLASMA/Solvers/base/SearchListener.hh +++ b/src/PLASMA/Solvers/base/SearchListener.hh @@ -42,45 +42,45 @@ namespace EUROPA { /** * @brief Get the Id for this SearchListener instance. */ - SearchListenerId& getId() {return m_id;}; + SearchListenerId getId() {return m_id;}; /** * @brief Notify that a new decision point was created. * @param dp The new decision point. */ - virtual void notifyCreated(DecisionPointId& dp) {}; + virtual void notifyCreated(DecisionPointId dp); /** * @brief Notify that a decision point was removed for some reason (i.e. backtracked over). * @param dp The removed decision point. */ - virtual void notifyDeleted(DecisionPointId& dp) {}; + virtual void notifyDeleted(DecisionPointId dp); /** * @brief Notify that a decision point was undone (the decision was retracted). * @param dp The retracted decision. */ - virtual void notifyUndone(DecisionPointId& dp) {}; + virtual void notifyUndone(DecisionPointId dp); /** * @brief Notify of a successful step (a decision followed by constraint propagation to quiescence). */ - virtual void notifyStepSucceeded(DecisionPointId& dp) {}; + virtual void notifyStepSucceeded(DecisionPointId dp); /** * @brief Notify of a failed step (a decision led to an inconsistency). */ - virtual void notifyStepFailed(DecisionPointId& dp) {}; + virtual void notifyStepFailed(DecisionPointId dp); /** * @brief Notify of a successful retraction. */ - virtual void notifyRetractSucceeded(DecisionPointId& dp) {}; + virtual void notifyRetractSucceeded(DecisionPointId dp); /** * @brief Notify of a retraction that requires further retraction */ - virtual void notifyRetractNotDone(DecisionPointId& dp) {}; + virtual void notifyRetractNotDone(DecisionPointId dp); /** * @brief Notify of a completed search (a consistent plan was found). diff --git a/src/PLASMA/Solvers/base/Solver.cc b/src/PLASMA/Solvers/base/Solver.cc index 4bfc26125..6a9fde47a 100644 --- a/src/PLASMA/Solvers/base/Solver.cc +++ b/src/PLASMA/Solvers/base/Solver.cc @@ -10,6 +10,7 @@ #include "PlanDatabaseWriter.hh" #include "FlawHandler.hh" #include "Context.hh" +#include "tinyxml.h" #include /** @@ -20,74 +21,100 @@ * @todo Generate notifications for Solver to publish (i.e. for the SearchListener). */ -#define publish(m,dp) { \ +#if 0 +#define publish3(m,n,o) { \ debugMsg("Solver:publish", "Publishing message " << #m); \ for(std::list::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) { \ - (*it)->m(dp); \ + (*it)->m(n, o); \ + } \ + } +#endif +#define publish2(m,n) { \ + debugMsg("Solver:publish", "Publishing message " << #m); \ + for(std::list::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) { \ + (*it)->m(n); \ } \ } +#define publish1(m) { \ + debugMsg("Solver:publish", "Publishing message " << #m); \ + for(std::list::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) { \ + (*it)->m(); \ + } \ + } +#define __publish(N, ...) publish ## N(__VA_ARGS__) +#define _publish(N, ...) __publish(N, __VA_ARGS__) +#define publish(...) _publish(NARG3(__VA_ARGS__), __VA_ARGS__) + namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - Solver::Solver(const PlanDatabaseId& db, const TiXmlElement& configData) - : m_id(this), m_db(db), - m_stepCountFloor(0), m_depthFloor(0), m_stepCount(0), - m_noFlawsFound(false), m_exhausted(false), m_timedOut(false), +Solver::Solver(const PlanDatabaseId db, const TiXmlElement& configData) + : m_baseConflictLevel(0.0), + m_id(this), m_name(), m_db(db), m_activeDecision(), + m_stepCountFloor(0), m_depthFloor(0), m_stepCount(0), + m_noFlawsFound(false), m_exhausted(false), m_timedOut(false), #ifdef _MSC_VER - m_maxSteps( UINT_MAX ), - m_maxDepth( UINT_MAX ), + m_maxSteps( UINT_MAX ), + m_maxDepth( UINT_MAX ), #else - m_maxSteps(std::numeric_limits::max()), - m_maxDepth(std::numeric_limits::max()), + m_maxSteps(std::numeric_limits::max()), + m_maxDepth(std::numeric_limits::max()), #endif //_MSC_VER - m_masterFlawFilter(configData), m_ceListener(db->getConstraintEngine(), *this), - m_dbListener(db, *this) { - checkError(strcmp(configData.Value(), "Solver") == 0, - "Configuration file error. Expected element but found " << configData.Value()); - - // Extract the name of the Solver - m_name = extractData(configData, "name"); - - m_context = ((new Context(m_name.toString() + "Context"))->getId()); - // Initialize the common filter - m_masterFlawFilter.initialize(configData, m_db, m_context); - - // Now load all the flaw managers - for (TiXmlElement * child = configData.FirstChildElement(); - child != NULL; - child = child->NextSiblingElement()) { - const char* component = child->Attribute("component"); - - if(strcmp(child->Value(), "FlawFilter") != 0){ - // If no component name is provided, register it with the tag name of configuration element - // thus obtaining the default. - if(component == NULL) - child->SetAttribute("component", child->Value()); - - // Now allocate the particular flaw manager using an abstract factory pattern. - EngineId& engine = db->getEngine(); - ComponentFactoryMgr* cfm = (ComponentFactoryMgr*)engine->getComponent("ComponentFactoryMgr"); - FlawManagerId flawManager = cfm->createInstance(*child); - debugMsg("Solver:Solver", "Created FlawManager with id " << flawManager); - flawManager->initialize(*child, m_db, m_context, m_masterFlawFilter.getId()); - m_flawManagers.push_back(flawManager); - } - } + m_masterFlawFilter(configData), + m_context(), + m_flawManagers(), + m_decisionStack(), + m_lastExecutedDecision(), + m_listeners(), + m_ceListener(db->getConstraintEngine(), *this), + m_dbListener(db, *this) { + checkError(strcmp(configData.Value(), "Solver") == 0, + "Configuration file error. Expected element but found " << configData.Value()); + + // Extract the name of the Solver + m_name = extractData(configData, "name"); + + m_context = ((new Context(m_name + "Context"))->getId()); + // Initialize the common filter + m_masterFlawFilter.initialize(configData, m_db, m_context); + + // Now load all the flaw managers + for (TiXmlElement * child = configData.FirstChildElement(); + child != NULL; + child = child->NextSiblingElement()) { + const char* component = child->Attribute("component"); + + if(strcmp(child->Value(), "FlawFilter") != 0){ + // If no component name is provided, register it with the tag name of configuration element + // thus obtaining the default. + if(component == NULL) + child->SetAttribute("component", child->Value()); + + // Now allocate the particular flaw manager using an abstract factory pattern. + EngineId engine = db->getEngine(); + ComponentFactoryMgr* cfm = + reinterpret_cast(engine->getComponent("ComponentFactoryMgr")); + FlawManagerId flawManager = cfm->createComponentInstance(*child); + debugMsg("Solver:Solver", "Created FlawManager with id " << flawManager); + flawManager->initialize(*child, m_db, m_context, m_masterFlawFilter.getId()); + m_flawManagers.push_back(flawManager); } + } +} - Solver::~Solver(){ - cleanupDecisions(); - EUROPA::cleanup(m_flawManagers); - delete (Context*) m_context; - m_id.remove(); - } +Solver::~Solver(){ + cleanupDecisions(); + EUROPA::cleanup(m_flawManagers); + delete static_cast(m_context); + m_id.remove(); +} - void Solver::addListener(const SearchListenerId& sl) { + void Solver::addListener(const SearchListenerId sl) { m_listeners.push_back(sl); } - void Solver::removeListener(const SearchListenerId& sl) { + void Solver::removeListener(const SearchListenerId sl) { for(std::list::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) if(*it == sl) { @@ -118,17 +145,24 @@ namespace EUROPA { return m_noFlawsFound; } - const SolverId& Solver::getId() const{ return m_id;} + const SolverId Solver::getId() const{ return m_id;} - const LabelStr& Solver::getName() const { return m_name;} +const std::string& Solver::getName() const { return m_name;} - unsigned int Solver::getDepth() const {return m_decisionStack.size();} + unsigned long Solver::getDepth() const {return m_decisionStack.size();} unsigned int Solver::getStepCount() const {return m_stepCount;} std::string Solver::getLastExecutedDecision() const {return m_lastExecutedDecision;} - bool Solver::noMoreFlaws() const{return m_noFlawsFound;} + bool Solver::noMoreFlaws() { + for(FlawManagers::const_iterator it = m_flawManagers.begin(); + it != m_flawManagers.end(); ++it) { + if(!(*it)->noMoreFlaws()) + return false; + } + return true; + } const DecisionStack& Solver::getDecisionStack() const {return m_decisionStack;} @@ -267,7 +301,7 @@ namespace EUROPA { if(!conflictLevelOk()){ m_exhausted = true; debugMsg("Solver:step", "No solution prior to stepping. Conflict before propagation: " << m_baseConflictLevel << ", after propagation:" << m_db->getConstraintEngine()->getViolation()); - publish(notifyExhausted,); + publish(notifyExhausted); return; } @@ -286,15 +320,18 @@ namespace EUROPA { if(m_activeDecision.isNoId()){ m_noFlawsFound = true; - publish(notifyCompleted,); + publish(notifyCompleted); return; } - if(m_maxSteps <= getStepCount() - m_stepCountFloor || m_maxDepth < getDepth() - m_depthFloor){ - debugMsg("Solver:step", "Timeout! Max steps: " << m_maxSteps << " step (above floor) " << getStepCount() - m_stepCountFloor << + if(m_maxSteps <= getStepCount() - m_stepCountFloor || + m_maxDepth < getDepth() - m_depthFloor){ + debugMsg("Solver:step", + "Timeout! Max steps: " << m_maxSteps << " step (above floor) " << + getStepCount() - m_stepCountFloor << " Max depth: " << m_maxDepth << " depth (above floor) " << getDepth() - m_depthFloor); - publish(notifyTimedOut,); + publish(notifyTimedOut); m_timedOut = true; return; } @@ -331,7 +368,7 @@ namespace EUROPA { if(m_exhausted) { checkError(m_decisionStack.empty(), "Must be exhausted if we failed to backtrack out."); debugMsg("Solver:step", "Solver exhausted at step " << getStepCount()); - publish(notifyExhausted,); + publish(notifyExhausted); } } @@ -385,7 +422,7 @@ namespace EUROPA { reset(m_decisionStack.size()); } - void Solver::reset(unsigned int depth){ + void Solver::reset(unsigned long depth){ checkError(depth <= getDepth(), "Cannot reset past current depth: " << depth << " exceeds " << getDepth()); if(m_activeDecision.isId()){ @@ -431,9 +468,7 @@ namespace EUROPA { m_timedOut = false; } - bool Solver::backjump(unsigned int stepCount){ - checkError(stepCount > 0, "Should not be allowed to backjump 0 steps."); - + bool Solver::backjump(unsigned long stepCount){ // If we have an active decision, then reset it if(m_activeDecision.isId()){ if(m_activeDecision->canUndo()) { @@ -494,8 +529,9 @@ namespace EUROPA { return (new FlawIterator(m_flawManagers))->getId(); } - Solver::FlawIterator::FlawIterator(const FlawManagers& flawManagers) { - for(FlawManagers::const_iterator it = flawManagers.begin(); it != flawManagers.end(); ++it) +Solver::FlawIterator::FlawIterator(const FlawManagers& flawManagers) + : Iterator(), m_visited(0), m_iterators(), m_it(m_iterators.end()) { + for(FlawManagers::const_iterator it = flawManagers.begin(); it != flawManagers.end(); ++it) m_iterators.push_back((*it)->createIterator()); m_it = m_iterators.begin(); @@ -511,7 +547,7 @@ namespace EUROPA { Solver::FlawIterator::~FlawIterator() { for(m_it = m_iterators.begin(); m_it != m_iterators.end(); ++m_it) - delete (Iterator*) (*m_it); + delete static_cast(*m_it); } bool Solver::FlawIterator::done() const @@ -552,7 +588,7 @@ namespace EUROPA { } \ } - bool Solver::isDecided(const EntityId& entity) { + bool Solver::isDecided(const EntityId entity) { for(DecisionStack::const_iterator it = m_decisionStack.begin(); it != m_decisionStack.end(); ++it) { if((*it)->getFlawedEntityKey() == entity->getKey()) return true; @@ -560,7 +596,7 @@ namespace EUROPA { return false; } - bool Solver::hasDecidedParameter(const TokenId& token) { + bool Solver::hasDecidedParameter(const TokenId token) { for(std::vector::const_iterator it = token->parameters().begin(); it != token->parameters().end(); ++it) { if(isDecided(*it)) return true; @@ -568,29 +604,38 @@ namespace EUROPA { return false; } - void Solver::notifyRemoved(const ConstrainedVariableId& variable){ + void Solver::notifyRemoved(const ConstrainedVariableId variable){ checkError(!isDecided(variable),"Attempt to remove decided variable "<< variable->toString()); notify(notifyRemoved(variable)); } - void Solver::notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType){ - - switch(changeType){ - case DomainListener::UPPER_BOUND_DECREASED: - case DomainListener::LOWER_BOUND_INCREASED: - case DomainListener::VALUE_REMOVED: - case DomainListener::EMPTIED: - return; - default: - notify(notifyChanged(variable, changeType)); - } - } +void Solver::notifyChanged(const ConstrainedVariableId variable, + const DomainListener::ChangeType& changeType){ + + switch(changeType){ + case DomainListener::UPPER_BOUND_DECREASED: + case DomainListener::LOWER_BOUND_INCREASED: + case DomainListener::VALUE_REMOVED: + case DomainListener::EMPTIED: + return; + case DomainListener::REFTIME_CHANGED: + case DomainListener::BOUNDS_RESTRICTED: + case DomainListener::RESTRICT_TO_SINGLETON: + case DomainListener::SET_TO_SINGLETON: + case DomainListener::RESET: + case DomainListener::RELAXED: + case DomainListener::CLOSED: + case DomainListener::OPENED: + default: + notify(notifyChanged(variable, changeType)); + } +} - void Solver::notifyAdded(const ConstraintId& constraint){ + void Solver::notifyAdded(const ConstraintId constraint){ notify(notifyAdded(constraint)); } - void Solver::notifyRemoved(const ConstraintId& constraint){ + void Solver::notifyRemoved(const ConstraintId constraint){ //notify(notifyRemoved(constraint)); m_masterFlawFilter.notifyRemoved(constraint); for(FlawManagers::const_iterator it = m_flawManagers.begin(); it != m_flawManagers.end(); ++it) { @@ -598,17 +643,17 @@ namespace EUROPA { } } - void Solver::notifyAdded(const TokenId& token) { + void Solver::notifyAdded(const TokenId token) { notify(notifyAdded(token)); } - void Solver::notifyRemoved(const TokenId& token) { + void Solver::notifyRemoved(const TokenId token) { checkError(!isDecided(token),"Attempt to remove decided token "<< token->toString()); checkError(!hasDecidedParameter(token),"Attempt to remove token with decided parameters "<< token->toString()); notify(notifyRemoved(token)); } - bool Solver::inScope(const EntityId& entity){ + bool Solver::inScope(const EntityId entity){ for(FlawManagers::const_iterator it = m_flawManagers.begin(); it != m_flawManagers.end(); ++it){ FlawManagerId fm = *it; @@ -656,7 +701,7 @@ namespace EUROPA { priorityQueue.insert(std::pair(priority + adjustment, fm->toString(flaw))); } - delete (Iterator*) flawIterator; + delete static_cast(flawIterator); } return priorityQueue; @@ -709,34 +754,34 @@ namespace EUROPA { return true; } - Solver::CeListener::CeListener(const ConstraintEngineId& ce, Solver& solver) + Solver::CeListener::CeListener(const ConstraintEngineId ce, Solver& solver) : ConstraintEngineListener(ce), m_solver(solver) {} - void Solver::CeListener::notifyRemoved(const ConstrainedVariableId& variable){ + void Solver::CeListener::notifyRemoved(const ConstrainedVariableId variable){ m_solver.notifyRemoved(variable); } - void Solver::CeListener::notifyChanged(const ConstrainedVariableId& variable, + void Solver::CeListener::notifyChanged(const ConstrainedVariableId variable, const DomainListener::ChangeType& changeType){ m_solver.notifyChanged(variable, changeType); } - void Solver::CeListener::notifyAdded(const ConstraintId& constraint){ + void Solver::CeListener::notifyAdded(const ConstraintId constraint){ m_solver.notifyAdded(constraint); } - void Solver::CeListener::notifyRemoved(const ConstraintId& constraint){ + void Solver::CeListener::notifyRemoved(const ConstraintId constraint){ m_solver.notifyRemoved(constraint); } - Solver::DbListener::DbListener(const PlanDatabaseId& db, Solver& solver) + Solver::DbListener::DbListener(const PlanDatabaseId db, Solver& solver) : PlanDatabaseListener(db), m_solver(solver) {} - void Solver::DbListener::notifyRemoved(const TokenId& token) { + void Solver::DbListener::notifyRemoved(const TokenId token) { m_solver.notifyRemoved(token); } - void Solver::DbListener::notifyAdded(const TokenId& token) { + void Solver::DbListener::notifyAdded(const TokenId token) { m_solver.notifyAdded(token); } } diff --git a/src/PLASMA/Solvers/base/Solver.hh b/src/PLASMA/Solvers/base/Solver.hh index 435855c47..6b58eed12 100644 --- a/src/PLASMA/Solvers/base/Solver.hh +++ b/src/PLASMA/Solvers/base/Solver.hh @@ -17,312 +17,313 @@ #include "PlanDatabaseListener.hh" namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - /** - * @brief Defines the main solver interface for identification and resolution of flaws on a plan database. - * - * A solver may or may not do planning i.e. goal decomposition. Most generally, it will process a set of flaws in a partial plan until - * there are no more in scope.The Solver is a mediator between Flaw Managers and Decision Points. This solver provides a chronological backtracking search. - * - * @see FlawManager, DecisionPoint - */ - class Solver { - public: - - /** - * @brief Constructor - */ - Solver(const PlanDatabaseId& db, const TiXmlElement& configData); - - /** - * @brief Required for safe deletion of subclasses - */ - virtual ~Solver(); - - /** - * @brief Invocation to solve any flaws in scope for the current Partial Plan - * - * This method will NOT reset a prior search stack. - * @param maxSteps The maximum number of additional steps permitted to resolve all flaws in THIS iteration. - * @param maxDepth The maximum growth in stack size permitted to resolve all flaws in THIS iteration. - * @return true if all flaws resolved within maxSteps and maxDepth, otherwise false. - * @see reset, clear. - */ +/** + * @brief Defines the main solver interface for identification and resolution of flaws on a plan database. + * + * A solver may or may not do planning i.e. goal decomposition. Most generally, it will process a set of flaws in a partial plan until + * there are no more in scope.The Solver is a mediator between Flaw Managers and Decision Points. This solver provides a chronological backtracking search. + * + * @see FlawManager, DecisionPoint + */ +class Solver { + public: + + /** + * @brief Constructor + */ + Solver(const PlanDatabaseId db, const TiXmlElement& configData); + + /** + * @brief Required for safe deletion of subclasses + */ + virtual ~Solver(); + + /** + * @brief Invocation to solve any flaws in scope for the current Partial Plan + * + * This method will NOT reset a prior search stack. + * @param maxSteps The maximum number of additional steps permitted to resolve all flaws in THIS iteration. + * @param maxDepth The maximum growth in stack size permitted to resolve all flaws in THIS iteration. + * @return true if all flaws resolved within maxSteps and maxDepth, otherwise false. + * @see reset, clear. + */ #ifdef _MSC_VER - bool solve(unsigned int maxSteps = UINT_MAX, - unsigned int maxDepth = UINT_MAX); + bool solve(unsigned int maxSteps = UINT_MAX, + unsigned int maxDepth = UINT_MAX); #else - bool solve(unsigned int maxSteps = std::numeric_limits::max(), - unsigned int maxDepth = std::numeric_limits::max()); + bool solve(unsigned int maxSteps = std::numeric_limits::max(), + unsigned int maxDepth = std::numeric_limits::max()); #endif // _MSC_VER - /** - * @brief Invocation for a single step of flaw resolution. - * - * Prior to executing this, the solver must not be backtracking. There may be side-effects as one or more - * decisions (or even all decisions) may be backtracked by attempting a step. - */ - void step(); - - /** - * @brief Retracts all decisions stored in the internal decision stack. - * @note Will not force propagation. - */ - void reset(); - - /** - * @brief Resets (undo and delete) a specific number of decisions, in reverse chronological order, - * in the internal decision stack - * @param depth The number of decisions to reset. - */ - void reset(unsigned int depth); - - /** - * @brief Backjumps a specific number of decisions, in reverse chronological order. - * @param stepCount the number of steps to undo. Will delete all but the last one. - * @return false if there are more choices to make, otherwise true. - * @see backtrack - */ - bool backjump(unsigned int stepCount); - - /** - * @brief Clears current decisions on the stack without any modifications to the plan. - * - * Used if we want the solver to work on a set of flaws without coupling this work to prior search. - */ - void clear(); - - /** - * @brief Standard Id accessor. - */ - const SolverId& getId() const; - - /** - * @brief Name accessor - */ - const LabelStr& getName() const; - - /** - * @brief The size of the search stack - */ - unsigned int getDepth() const; - - /** - * @brief The total number of search steps since the Solver was previously cleared. - */ - unsigned int getStepCount() const; - - /** - * @brief Tests if we have concluded there are no more flaws. - */ - bool noMoreFlaws() const; - - /** - * @brief Tests if the search space have been exhausted. - */ - bool isExhausted() const; - - /** - * @brief tests if the search step and depth limits hane been exceeded - */ - bool isTimedOut() const; - - /** - * @brief Retrieve all decisions on the stack. - */ - const DecisionStack& getDecisionStack() const; - - std::string getDecisionStackAsString() const; - - /** - * @brief Register a listener for search actions and status. - */ - void addListener(const SearchListenerId& sl); - - /** - * @brief Unregister a listener for search actions and status. - */ - void removeListener(const SearchListenerId& sl); - - /** - * @brief Set the maximum number of steps to take when planning under PlanWorks control. - */ - void setMaxSteps(const unsigned int steps); - - /** - * @brief Set the maximum depth to search when planning under PlanWorks control. - */ - void setMaxDepth(const unsigned int depth); - - /** - * @brief Create an iterator over the set of flaws. - */ - IteratorId createIterator(); - - /** - * @brief True if the given entity is in scope. - * @see FlawManager::inScope - */ - bool inScope(const EntityId& entity); - - /** - * @brief Retrieve an active flaw handler for the given entity - */ - FlawHandlerId getFlawHandler(const EntityId entity); - - bool isConstraintConsistent() const; - - std::string getLastExecutedDecision() const; - - std::multimap getOpenDecisions() const; - - std::string printOpenDecisions() const; - - /** - * @brief Access the context of this Solver. - */ - ContextId getContext() const {return m_context;} - - /** - * @brief Verify that the state of the Solver is consistent with our expectaions. - */ - bool isValid() const; - - protected: - - /** - * @brief Retrieves a new DecisionPoint from the set of Flaw Managers. - * - * @note Customize this method in a derived class to change the overall algorithm for selecting the next flaw to work on. - */ - virtual void allocateNewDecisionPoint(); - - /** - * @brief Will backtrack from current failed state in the search to a point from which the search can resume. - * @return true if search can resume. Otherwise false, indicating search is exhausted. - */ - bool backtrack(); - - /** - * @brief Iterates over Flaw Managers to obtain a flaw that is forced i.e. a dead-end or a unit decision. - * @return DecisionPointId::noId() if there is no such flaw, otherwise the decision point to take next. - */ - DecisionPointId getZeroCommitmentDecision(); - - void doStep(); - bool conflictLevelOk(); - double m_baseConflictLevel; // Keeps track of initial conflict level before a solver step is taken - - static void cleanup(DecisionStack& decisionStack); - - private: - - /** - * @brief Internal utility to cleanup all decision data - * @see cleanup(DecisionStack& decisionStack) - */ - void cleanupDecisions(); - - void notifyAdded(const TokenId& token); - - void notifyRemoved(const TokenId& token); - - bool isDecided(const EntityId& entity); - - bool hasDecidedParameter(const TokenId& token); - - /** - * @brief Used to enforce scope restrictions for common filters across all flaw managers - */ - class MasterFilter: public FlawManager { - public: - MasterFilter(const TiXmlElement& configData): FlawManager(configData){} - IteratorId createIterator() {return IteratorId::noId();} - private: - friend class Solver; - void handleInitialize(){} - - /** - * @brief Over-ride standard behavior to do nothing - */ -// void notifyRemoved(const ConstrainedVariableId& var){} -// void notifyRemoved(const ConstraintId& var) {} -// void notifyRemoved(const TokenId& tok) {FlawManager::notifyRemoved(tok);} - }; - - /* Data Members */ - SolverId m_id; - LabelStr m_name; - const PlanDatabaseId m_db; - DecisionPointId m_activeDecision; /*!< Stores the decision point we are currently working on. - It should not be in the decision stack. */ - unsigned int m_stepCountFloor; /*!< Stores previous step count where multiple solution iterations are tried. */ - unsigned int m_depthFloor; /*!< Stores previous depth where multiple solution iterations are tried.*/ - unsigned int m_stepCount; /*!< The aggregate number of steps over one or more calls to solve, - without reseting or clearing. */ - bool m_noFlawsFound; /*!< True when we have no more flaws to work on. */ - bool m_exhausted; /*!< True when we if and only if we have failed to recover from a dead-end */ - bool m_timedOut;/*!< True of the depth or step limits are exceeded */ - unsigned int m_maxSteps; /*!< The maximum number of steps to take. Used only for planner control.*/ - unsigned int m_maxDepth; /*!< The maximum depth to search. Used only for planner control.*/ - MasterFilter m_masterFlawFilter; /*!< Used to handle shared filter data across contained flaw managers */ - ContextId m_context; /* m_listeners; /*!< The set of listeners for the search */ - - class FlawIterator : public Iterator { - public: - FlawIterator(const FlawManagers& flawManagers); - ~FlawIterator(); - bool done() const; - const EntityId next(); - unsigned int visited() const {return m_visited;} - protected: - private: - unsigned int m_visited; - std::list m_iterators; - std::list::iterator m_it; - }; - - - /** - * @brief Plugs manager into ConstraintEngine events to synchronize flaw candidates - */ - class CeListener: public ConstraintEngineListener { - public: - CeListener(const ConstraintEngineId& ce, Solver& dm); - - void notifyRemoved(const ConstrainedVariableId& variable); - void notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType); - void notifyAdded(const ConstraintId& constraint); - void notifyRemoved(const ConstraintId& constraint); - - private: - Solver& m_solver; - }; - - void notifyRemoved(const ConstrainedVariableId& variable); - void notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType); - void notifyAdded(const ConstraintId& constraint); - void notifyRemoved(const ConstraintId& constraint); - - friend class Solver::CeListener; - Solver::CeListener m_ceListener; /*!< For Processing constraint engine events */ - - class DbListener : public PlanDatabaseListener { - public: - DbListener(const PlanDatabaseId& db, Solver& dm); - void notifyRemoved(const TokenId& token); - void notifyAdded(const TokenId& token); - private: - Solver& m_solver; - }; - - friend class Solver::DbListener; - Solver::DbListener m_dbListener; - }; - } + /** + * @brief Invocation for a single step of flaw resolution. + * + * Prior to executing this, the solver must not be backtracking. There may be side-effects as one or more + * decisions (or even all decisions) may be backtracked by attempting a step. + */ + void step(); + + /** + * @brief Retracts all decisions stored in the internal decision stack. + * @note Will not force propagation. + */ + void reset(); + + /** + * @brief Resets (undo and delete) a specific number of decisions, in reverse chronological order, + * in the internal decision stack + * @param depth The number of decisions to reset. + */ + void reset(unsigned long depth); + + /** + * @brief Backjumps a specific number of decisions, in reverse chronological order. + * @param stepCount the number of steps to undo. Will delete all but the last one. + * @return false if there are more choices to make, otherwise true. + * @see backtrack + */ + bool backjump(unsigned long stepCount); + + /** + * @brief Clears current decisions on the stack without any modifications to the plan. + * + * Used if we want the solver to work on a set of flaws without coupling this work to prior search. + */ + void clear(); + + /** + * @brief Standard Id accessor. + */ + const SolverId getId() const; + + /** + * @brief Name accessor + */ + const std::string& getName() const; + + /** + * @brief The size of the search stack + */ + unsigned long getDepth() const; + + /** + * @brief The total number of search steps since the Solver was previously cleared. + */ + unsigned int getStepCount() const; + + /** + * @brief Tests if we have concluded there are no more flaws. + */ + bool noMoreFlaws(); + + /** + * @brief Tests if the search space have been exhausted. + */ + bool isExhausted() const; + + /** + * @brief tests if the search step and depth limits hane been exceeded + */ + bool isTimedOut() const; + + /** + * @brief Retrieve all decisions on the stack. + */ + const DecisionStack& getDecisionStack() const; + + std::string getDecisionStackAsString() const; + + /** + * @brief Register a listener for search actions and status. + */ + void addListener(const SearchListenerId sl); + + /** + * @brief Unregister a listener for search actions and status. + */ + void removeListener(const SearchListenerId sl); + + /** + * @brief Set the maximum number of steps to take when planning under PlanWorks control. + */ + void setMaxSteps(const unsigned int steps); + + /** + * @brief Set the maximum depth to search when planning under PlanWorks control. + */ + void setMaxDepth(const unsigned int depth); + + /** + * @brief Create an iterator over the set of flaws. + */ + IteratorId createIterator(); + + /** + * @brief True if the given entity is in scope. + * @see FlawManager::inScope + */ + bool inScope(const EntityId entity); + + /** + * @brief Retrieve an active flaw handler for the given entity + */ + FlawHandlerId getFlawHandler(const EntityId entity); + + bool isConstraintConsistent() const; + + std::string getLastExecutedDecision() const; + + std::multimap getOpenDecisions() const; + + std::string printOpenDecisions() const; + + /** + * @brief Access the context of this Solver. + */ + ContextId getContext() const {return m_context;} + + /** + * @brief Verify that the state of the Solver is consistent with our expectaions. + */ + bool isValid() const; + + protected: + + /** + * @brief Retrieves a new DecisionPoint from the set of Flaw Managers. + * + * @note Customize this method in a derived class to change the overall algorithm for selecting the next flaw to work on. + */ + virtual void allocateNewDecisionPoint(); + + /** + * @brief Will backtrack from current failed state in the search to a point from which the search can resume. + * @return true if search can resume. Otherwise false, indicating search is exhausted. + */ + bool backtrack(); + + /** + * @brief Iterates over Flaw Managers to obtain a flaw that is forced i.e. a dead-end or a unit decision. + * @return DecisionPointId::noId() if there is no such flaw, otherwise the decision point to take next. + */ + DecisionPointId getZeroCommitmentDecision(); + + void doStep(); + bool conflictLevelOk(); + double m_baseConflictLevel; // Keeps track of initial conflict level before a solver step is taken + + static void cleanup(DecisionStack& decisionStack); + + private: + + /** + * @brief Internal utility to cleanup all decision data + * @see cleanup(DecisionStack& decisionStack) + */ + void cleanupDecisions(); + + void notifyAdded(const TokenId token); + + void notifyRemoved(const TokenId token); + + bool isDecided(const EntityId entity); + + bool hasDecidedParameter(const TokenId token); + + /** + * @brief Used to enforce scope restrictions for common filters across all flaw managers + */ + class MasterFilter: public FlawManager { + public: + MasterFilter(const TiXmlElement& configData): FlawManager(configData){} + IteratorId createIterator() {return IteratorId::noId();} + bool noMoreFlaws() {return true;} + private: + friend class Solver; + void handleInitialize(){} + + /** + * @brief Over-ride standard behavior to do nothing + */ + // void notifyRemoved(const ConstrainedVariableId var){} + // void notifyRemoved(const ConstraintId var) {} + // void notifyRemoved(const TokenId tok) {FlawManager::notifyRemoved(tok);} + }; + + /* Data Members */ + SolverId m_id; + std::string m_name; + const PlanDatabaseId m_db; + DecisionPointId m_activeDecision; /*!< Stores the decision point we are currently working on. + It should not be in the decision stack. */ + unsigned int m_stepCountFloor; /*!< Stores previous step count where multiple solution iterations are tried. */ + unsigned long m_depthFloor; /*!< Stores previous depth where multiple solution iterations are tried.*/ + unsigned int m_stepCount; /*!< The aggregate number of steps over one or more calls to solve, + without reseting or clearing. */ + bool m_noFlawsFound; /*!< True when we have no more flaws to work on. */ + bool m_exhausted; /*!< True when we if and only if we have failed to recover from a dead-end */ + bool m_timedOut;/*!< True of the depth or step limits are exceeded */ + unsigned int m_maxSteps; /*!< The maximum number of steps to take. Used only for planner control.*/ + unsigned int m_maxDepth; /*!< The maximum depth to search. Used only for planner control.*/ + MasterFilter m_masterFlawFilter; /*!< Used to handle shared filter data across contained flaw managers */ + ContextId m_context; /*!< Used to share data from the Solver on down.*/ + FlawManagers m_flawManagers; /*!< Sequence of flaw managers to include in scope */ + DecisionStack m_decisionStack; /*!< Stack of decisions made */ + std::string m_lastExecutedDecision; /*!< Kept for debugging and UI purposes */ + std::list m_listeners; /*!< The set of listeners for the search */ + + class FlawIterator : public Iterator { + public: + FlawIterator(const FlawManagers& flawManagers); + ~FlawIterator(); + bool done() const; + const EntityId next(); + unsigned int visited() const {return m_visited;} + protected: + private: + unsigned int m_visited; + std::list m_iterators; + std::list::iterator m_it; + }; + + + /** + * @brief Plugs manager into ConstraintEngine events to synchronize flaw candidates + */ + class CeListener: public ConstraintEngineListener { + public: + CeListener(const ConstraintEngineId ce, Solver& dm); + + void notifyRemoved(const ConstrainedVariableId variable); + void notifyChanged(const ConstrainedVariableId variable, const DomainListener::ChangeType& changeType); + void notifyAdded(const ConstraintId constraint); + void notifyRemoved(const ConstraintId constraint); + + private: + Solver& m_solver; + }; + + void notifyRemoved(const ConstrainedVariableId variable); + void notifyChanged(const ConstrainedVariableId variable, const DomainListener::ChangeType& changeType); + void notifyAdded(const ConstraintId constraint); + void notifyRemoved(const ConstraintId constraint); + + friend class Solver::CeListener; + Solver::CeListener m_ceListener; /*!< For Processing constraint engine events */ + + class DbListener : public PlanDatabaseListener { + public: + DbListener(const PlanDatabaseId db, Solver& dm); + void notifyRemoved(const TokenId token); + void notifyAdded(const TokenId token); + private: + Solver& m_solver; + }; + + friend class Solver::DbListener; + Solver::DbListener m_dbListener; +}; +} } #endif diff --git a/src/PLASMA/Solvers/base/SolverDecisionPoint.cc b/src/PLASMA/Solvers/base/SolverDecisionPoint.cc index 122ebdd15..0df57d914 100644 --- a/src/PLASMA/Solvers/base/SolverDecisionPoint.cc +++ b/src/PLASMA/Solvers/base/SolverDecisionPoint.cc @@ -5,14 +5,16 @@ #include "Solver.hh" namespace EUROPA { - namespace SOLVERS { - DecisionPoint::DecisionPoint(const DbClientId& client, eint entityKey, const LabelStr& explanation) +namespace SOLVERS { +DecisionPoint::DecisionPoint(const DbClientId client, eint entityKey, + const std::string& explanation) : Entity(), m_client(client), m_entityKey(entityKey), m_id(this), - m_explanation(explanation), m_isExecuted(false), m_initialized(false), m_maxChoices(0), m_counter(0) {} + m_explanation(explanation), m_isExecuted(false), m_initialized(false), + m_context(), m_maxChoices(0), m_counter(0) {} DecisionPoint::~DecisionPoint() {m_id.remove();} - const DecisionPointId& DecisionPoint::getId() const {return m_id;} + const DecisionPointId DecisionPoint::getId() const {return m_id;} void DecisionPoint::initialize(){ if(!m_initialized){ @@ -52,5 +54,7 @@ namespace EUROPA { bool DecisionPoint::isInitialized() const { return m_initialized; } - } + +bool DecisionPoint::customStaticMatch(const EntityId) {return true;} +} } diff --git a/src/PLASMA/Solvers/base/SolverDecisionPoint.hh b/src/PLASMA/Solvers/base/SolverDecisionPoint.hh index a5c687419..353a7626d 100644 --- a/src/PLASMA/Solvers/base/SolverDecisionPoint.hh +++ b/src/PLASMA/Solvers/base/SolverDecisionPoint.hh @@ -28,7 +28,7 @@ namespace EUROPA { public: virtual ~DecisionPoint(); - const DecisionPointId& getId() const; + const DecisionPointId getId() const; /** * @brief Does initialization of choices. This is an explicit call since we may wish to defer actual population @@ -49,10 +49,11 @@ namespace EUROPA { /** * @brief Hook for default behavior. Subclasses can make new static methods to specialize the static matching. + * @param entity The entity to match. * @see FlawHandler * @return true if the entity can be dynamically matched. Otherwise false. */ - static bool customStaticMatch(const EntityId& entity) {return true;} + static bool customStaticMatch(const EntityId entity); /** * @brief Hook for default behavior. Will allow subclasses to add a weighting @@ -62,15 +63,16 @@ namespace EUROPA { ContextId getContext() const {return m_context;} - void setContext(const ContextId& ctx) {m_context = ctx;} + void setContext(const ContextId ctx) {m_context = ctx;} void setCutoff(unsigned int maxChoices) {m_maxChoices = maxChoices;} const eint getFlawedEntityKey() {return m_entityKey;} - protected: - DecisionPoint(const DbClientId& client, eint entityKey, const LabelStr& explanation); + // protected: + DecisionPoint(const DbClientId client, eint entityKey, const std::string& explanation); - friend class Solver; /*!< grants special access to execute and undo methods */ + // friend class Solver; /*!< grants special access to execute and undo methods */ + // friend class ::FlawManagerTests; /** * @brief Tests if execute has been called more times than undo. @@ -124,13 +126,11 @@ namespace EUROPA { /** * @brief Implement this method with behavior for making an update to the Plan * Database reflecting the current choice. - * @param client The databasse client on which to invoke decision execution operations. */ virtual void handleExecute() = 0; /** * @brief Implement this method to handle retraction of last choice executed. - * @param client The databasse client on which to invoke decision retraction operations. */ virtual void handleUndo() = 0; @@ -140,10 +140,10 @@ namespace EUROPA { /** * @brief Get the justification behind the selection of this decision point */ - const LabelStr& getExplanation() {return m_explanation;} + const std::string& getExplanation() {return m_explanation;} private: DecisionPointId m_id; - LabelStr m_explanation; + std::string m_explanation; bool m_isExecuted; /*!< True if executed has been called, and undo has not */ bool m_initialized; /*!< True if choices have been set up. Otherwise false.*/ ContextId m_context; diff --git a/src/PLASMA/Solvers/base/SolverUtils.cc b/src/PLASMA/Solvers/base/SolverUtils.cc index d2c268125..9312f2c2b 100644 --- a/src/PLASMA/Solvers/base/SolverUtils.cc +++ b/src/PLASMA/Solvers/base/SolverUtils.cc @@ -2,9 +2,9 @@ namespace EUROPA { namespace SOLVERS { - DEFINE_GLOBAL_CONST(LabelStr, WILD_CARD, "*"); - DEFINE_GLOBAL_CONST(LabelStr, DELIMITER, "."); - DEFINE_GLOBAL_CONST(unsigned int, ZERO_COMMITMENT_SCORE, 1); - DEFINE_GLOBAL_CONST(unsigned int, WORST_SCORE, cast_int(PLUS_INFINITY)+1); + DEFINE_GLOBAL_CONST(std::string, WILD_CARD, "*"); + DEFINE_GLOBAL_CONST(std::string, DELIMITER, "."); + DEFINE_GLOBAL_CONST(long, ZERO_COMMITMENT_SCORE, 1); + DEFINE_GLOBAL_CONST(long, WORST_SCORE, cast_int(PLUS_INFINITY)+1); } } diff --git a/src/PLASMA/Solvers/base/SolverUtils.hh b/src/PLASMA/Solvers/base/SolverUtils.hh index 7518f69bf..9d86c05ef 100644 --- a/src/PLASMA/Solvers/base/SolverUtils.hh +++ b/src/PLASMA/Solvers/base/SolverUtils.hh @@ -1,7 +1,6 @@ #ifndef H_PlannerUtils #define H_PlannerUtils -#include "LabelStr.hh" #include "ConstrainedVariable.hh" #include "RuleInstance.hh" #include "Token.hh" @@ -10,13 +9,13 @@ #include "SolverDefs.hh" namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - DECLARE_GLOBAL_CONST(LabelStr, WILD_CARD); - DECLARE_GLOBAL_CONST(LabelStr, DELIMITER); - DECLARE_GLOBAL_CONST(unsigned int, ZERO_COMMITMENT_SCORE); - DECLARE_GLOBAL_CONST(unsigned int, WORST_SCORE); +DECLARE_GLOBAL_CONST(std::string, WILD_CARD); +DECLARE_GLOBAL_CONST(std::string, DELIMITER); +DECLARE_GLOBAL_CONST(long, ZERO_COMMITMENT_SCORE); +DECLARE_GLOBAL_CONST(long, WORST_SCORE); - } +} } #endif diff --git a/src/PLASMA/Solvers/component/Filters.cc b/src/PLASMA/Solvers/component/Filters.cc index b4122ec04..2569b59f9 100644 --- a/src/PLASMA/Solvers/component/Filters.cc +++ b/src/PLASMA/Solvers/component/Filters.cc @@ -5,6 +5,8 @@ #include "RuleVariableListener.hh" #include "TokenVariable.hh" #include "RuleInstance.hh" +#include "Context.hh" +#include "tinyxml.h" #include @@ -16,7 +18,7 @@ namespace EUROPA { debugMsg("ParameterFilter:constructor", "Constructing a parameter filter."); } - bool ParameterFilter::test(const EntityId& entity) { + bool ParameterFilter::test(const EntityId entity) { if(!ConstrainedVariableId::convertable(entity)) return false; ConstrainedVariableId var = entity; @@ -30,7 +32,7 @@ namespace EUROPA { debugMsg("LocalVariableFilter:constructor", "Constructing a local variable filter."); } - bool LocalVariableFilter::test(const EntityId& entity) { + bool LocalVariableFilter::test(const EntityId entity) { if(!ConstrainedVariableId::convertable(entity)) return false; ConstrainedVariableId var = entity; @@ -44,7 +46,7 @@ namespace EUROPA { debugMsg("GuardFilter:constructor", "Constructing a guard filter."); } - bool GuardFilter::test(const EntityId& entity) { + bool GuardFilter::test(const EntityId entity) { if(!ConstrainedVariableId::convertable(entity)) return false; ConstrainedVariableId var = entity; @@ -52,10 +54,10 @@ namespace EUROPA { std::set constraints; var->constraints(constraints); debugMsg("GuardFilter:test", - "Testing for " << RuleVariableListener::CONSTRAINT_NAME().toString() << " constraints."); + "Testing for " << RuleVariableListener::CONSTRAINT_NAME() << " constraints."); for(std::set::iterator it = constraints.begin(); it != constraints.end(); ++it) { ConstraintId constr = *it; - debugMsg("GuardFilter:test", "Variable has a " << constr->getName().toString() << " constraint."); + debugMsg("GuardFilter:test", "Variable has a " << constr->getName() << " constraint."); //indicate a match if this variable is a guard (will be filtered out) if(constr->getName() == RuleVariableListener::CONSTRAINT_NAME()) { debugMsg("GuardFilter:test", "Variable has a " << constr->toString() << "."); @@ -71,7 +73,7 @@ namespace EUROPA { debugMsg("NotGuardFilter:constructor", "Constructing a not guard filter."); } - bool NotGuardFilter::test(const EntityId& entity) { + bool NotGuardFilter::test(const EntityId entity) { if(!ConstrainedVariableId::convertable(entity)) return false; debugMsg("NotGuardFilter:test", "Testing " << entity->toLongString() << " for not-guard-ness."); @@ -84,7 +86,7 @@ namespace EUROPA { setExpression(toString() + ":infinite/dynamic"); } - bool InfiniteDynamicFilter::test(const EntityId& entity){ + bool InfiniteDynamicFilter::test(const EntityId entity){ if(!ConstrainedVariableId::convertable(entity)) return false; @@ -100,7 +102,7 @@ namespace EUROPA { setExpression(toString() + ":singleton"); } - bool SingletonFilter::test(const EntityId& entity) { + bool SingletonFilter::test(const EntityId entity) { if(!ConstrainedVariableId::convertable(entity)) return false; @@ -117,7 +119,7 @@ namespace EUROPA { setExpression(toString() + ":tokenMustBeAssigned"); } - bool TokenMustBeAssignedFilter::test(const EntityId& entity) { + bool TokenMustBeAssignedFilter::test(const EntityId entity) { checkError(ConstrainedVariableId::convertable(entity), "Configuration Error. Cannot apply to " << entity->toString()); @@ -143,7 +145,7 @@ namespace EUROPA { setExpression(toString() + ":masterMustBeAssigned"); } - bool MasterMustBeAssignedFilter::test(const EntityId& entity) { + bool MasterMustBeAssignedFilter::test(const EntityId entity) { checkError(TokenId::convertable(entity), "Configuration error. Cannot apply to " << entity->toString()); TokenId tok = entity; @@ -155,30 +157,26 @@ namespace EUROPA { return !tok->master()->isAssigned(); } - /** HORIZON FILTERING **/ - IntervalIntDomain& HorizonFilter::getHorizon() { - static IntervalIntDomain sl_instance; - return sl_instance; - } - HorizonFilter::HorizonFilter(const TiXmlElement& configData) - : FlawFilter(configData, true) { - static const LabelStr sl_defaultPolicy("PartiallyContained"); - const char* argData = NULL; - argData = configData.Attribute("policy"); - if(argData != NULL){ - checkError(policies().contains(argData), argData << " is not a valid policy. Choose one of " << policies().toString()); - m_policy = LabelStr(argData); - } - else - m_policy = sl_defaultPolicy; - setExpression(toString() + ":horizonFilter:" + m_policy.toString()); + HorizonFilter::HorizonFilter(const TiXmlElement& configData) + : FlawFilter(configData, true), m_policy() { + static const std::string sl_defaultPolicy("PartiallyContained"); + const char* argData = NULL; + argData = configData.Attribute("policy"); + if(argData != NULL){ + checkError(policies().find(argData) != std::string::npos, + argData << " is not a valid policy. Choose one of " << policies()); + m_policy = argData; } + else + m_policy = sl_defaultPolicy; + setExpression(toString() + ":horizonFilter:" + m_policy); + } - bool HorizonFilter::test(const EntityId& entity) { - static const LabelStr sl_possiblyContained("PossiblyContained"); - static const LabelStr sl_partiallyContained("PartiallyContained"); - static const LabelStr sl_totallyContained("TotallyContained"); + bool HorizonFilter::test(const EntityId entity) { + static const std::string sl_possiblyContained("PossiblyContained"); + static const std::string sl_partiallyContained("PartiallyContained"); + static const std::string sl_totallyContained("TotallyContained"); TokenId token; if(ConstrainedVariableId::convertable(entity)){ @@ -194,17 +192,22 @@ namespace EUROPA { else token = entity; - const IntervalIntDomain& horizon = getHorizon(); + checkRuntimeError(getContext() != ContextId::noId(), + "HorizonFilter::test called without a valid context on " << + MatchingRule::getId()); + const IntervalIntDomain horizon = + IntervalIntDomain(static_cast(getContext()->get("horizonStart")), + static_cast(getContext()->get("horizonEnd"))); checkError(horizon.isFinite(), "Infinite Horizon not permitted." << horizon.toString()); const IntervalIntDomain& startTime = token->start()->lastDomain(); const IntervalIntDomain& endTime = token->end()->lastDomain(); bool withinHorizon = false; - + debugMsg("HorizonFilter:test", "Evaluating: " << token->toString() << " Start=" << startTime.toString() << ", End=" << endTime.toString() << - ", Policy='" << m_policy.toString() << "', Horizon =" << horizon.toString()); + ", Policy='" << m_policy << "', Horizon =" << horizon.toString()); if(m_policy == sl_possiblyContained) withinHorizon = startTime.intersects(horizon) && endTime.intersects(horizon); @@ -223,9 +226,17 @@ namespace EUROPA { std::string HorizonFilter::toString() const { - const IntervalIntDomain& horizon = getHorizon(); - std::string expr = FlawFilter::toString(); - expr = expr + " Policy='" + m_policy.toString() + "' Horizon=" + horizon.toString(); + std::string expr = + FlawFilter::toString() + " Policy='" + m_policy + "' Horizon="; + if(getContext().isValid()) { + const IntervalIntDomain horizon = + IntervalIntDomain(static_cast(getContext()->get("horizonStart")), + static_cast(getContext()->get("horizonEnd"))); + expr = expr + horizon.toString(); + } + else { + expr = expr + "Undetermined"; + } return expr; } @@ -234,7 +245,12 @@ namespace EUROPA { setExpression(toString() + ":variable"); } - bool HorizonVariableFilter::test(const EntityId& entity) { + void HorizonVariableFilter::setContext(ContextId ctx) { + MatchingRule::setContext(ctx); + m_horizonFilter.setContext(ctx); + } + + bool HorizonVariableFilter::test(const EntityId entity) { if(!ConstrainedVariableId::convertable(entity)) return false; @@ -254,7 +270,7 @@ namespace EUROPA { else { checkError(TokenId::convertable(parent), "If we have covered our bases, it must be a token, but it ain't:" << var->toString()); - token = (TokenId) parent; + token = static_cast(parent); } // Now simply delegate to the filter stored internally. diff --git a/src/PLASMA/Solvers/component/Filters.hh b/src/PLASMA/Solvers/component/Filters.hh index 66c7f8124..cfdd393f0 100644 --- a/src/PLASMA/Solvers/component/Filters.hh +++ b/src/PLASMA/Solvers/component/Filters.hh @@ -18,7 +18,7 @@ namespace EUROPA { class ParameterFilter : public FlawFilter { public: ParameterFilter(const TiXmlElement& configData); - virtual bool test(const EntityId& entity); + virtual bool test(const EntityId entity); }; /** @@ -27,7 +27,7 @@ namespace EUROPA { class LocalVariableFilter : public FlawFilter{ public: LocalVariableFilter(const TiXmlElement& configData); - bool test(const EntityId& entity); + bool test(const EntityId entity); }; /** @@ -36,7 +36,7 @@ namespace EUROPA { class GuardFilter : public FlawFilter { public: GuardFilter(const TiXmlElement& configData); - virtual bool test(const EntityId& entity); + virtual bool test(const EntityId entity); }; /** @@ -45,7 +45,7 @@ namespace EUROPA { class NotGuardFilter : public GuardFilter { public: NotGuardFilter(const TiXmlElement& configData); - bool test(const EntityId& entity); + bool test(const EntityId entity); }; /** @@ -55,7 +55,7 @@ namespace EUROPA { class InfiniteDynamicFilter : public FlawFilter { public: InfiniteDynamicFilter(const TiXmlElement& configData); - bool test(const EntityId& entity); + bool test(const EntityId entity); }; /** @@ -64,7 +64,7 @@ namespace EUROPA { class SingletonFilter: public FlawFilter { public: SingletonFilter(const TiXmlElement& configData); - bool test(const EntityId& entity); + bool test(const EntityId entity); }; /** @@ -73,7 +73,7 @@ namespace EUROPA { class TokenMustBeAssignedFilter: public FlawFilter { public: TokenMustBeAssignedFilter(const TiXmlElement& configData); - bool test(const EntityId& entity); + bool test(const EntityId entity); }; @@ -83,7 +83,7 @@ namespace EUROPA { class MasterMustBeAssignedFilter : public FlawFilter { public: MasterMustBeAssignedFilter(const TiXmlElement& configData); - bool test(const EntityId& entity); + bool test(const EntityId entity); }; /** @@ -100,24 +100,19 @@ namespace EUROPA { class HorizonFilter: public FlawFilter { public: HorizonFilter(const TiXmlElement& configData); - bool test(const EntityId& entity); + bool test(const EntityId entity); std::string toString() const; /** * @brief Allowed policy strings for customization */ - static const LabelStr& policies(){ - static const LabelStr sl_policies("PossiblyContained:PartiallyContained:TotallyContained:"); + static const std::string& policies(){ + static const std::string sl_policies("PossiblyContained:PartiallyContained:TotallyContained:"); return sl_policies; } - /** - * @brief uses a singleton horizon that is regularly adjusted. - */ - static IntervalIntDomain& getHorizon(); - private: - LabelStr m_policy; + std::string m_policy; }; /** @@ -127,9 +122,9 @@ namespace EUROPA { class HorizonVariableFilter: public FlawFilter { public: HorizonVariableFilter(const TiXmlElement& configData); - bool test(const EntityId& entity); + bool test(const EntityId entity); std::string toString() const; - + void setContext(ContextId ctx); private: HorizonFilter m_horizonFilter; }; diff --git a/src/PLASMA/Solvers/component/HSTSDecisionPoints.cc b/src/PLASMA/Solvers/component/HSTSDecisionPoints.cc index 1ef740414..95f35dc2a 100644 --- a/src/PLASMA/Solvers/component/HSTSDecisionPoints.cc +++ b/src/PLASMA/Solvers/component/HSTSDecisionPoints.cc @@ -8,391 +8,414 @@ #include "TokenVariable.hh" #include "ValueSource.hh" #include "Utils.hh" +#include "tinyxml.h" #include #include -namespace EUROPA { - namespace SOLVERS { - namespace HSTS { +#include - ValueEnum::ValueEnum(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, const LabelStr& explanation) - : UnboundVariableDecisionPoint(client, flawedVariable, configData, explanation), m_choiceIndex(0) { +namespace EUROPA { +namespace SOLVERS { +namespace HSTS { + +ValueEnum::ValueEnum(const DbClientId client, + const ConstrainedVariableId flawedVariable, + const TiXmlElement& configData, const std::string& explanation) + : UnboundVariableDecisionPoint(client, flawedVariable, configData, explanation), + m_choiceIndex(0) { - // have to get rid of the old choice set that UnboundVaraibleDecisionPoint came up with - delete m_choices; + // have to get rid of the old choice set that UnboundVaraibleDecisionPoint came up with + delete m_choices; - debugMsg("Solver:ValueEnum", "Instantiating value source for " << flawedVariable->toString()); - m_choices = ValueSource::getSource(client->getSchema(),flawedVariable, true); - checkError(m_choices != NULL, "Failed to correctly allocate a value source for " << flawedVariable->toString()); + debugMsg("Solver:ValueEnum", "Instantiating value source for " << flawedVariable->toString()); + m_choices = ValueSource::getSource(client->getSchema(),flawedVariable, true); + checkError(m_choices != NULL, "Failed to correctly allocate a value source for " << flawedVariable->toString()); - bool convertToObject = client->getSchema()->isObjectType(flawedVariable->baseDomain().getTypeName()); + bool convertToObject = client->getSchema()->isObjectType(flawedVariable->baseDomain().getTypeName()); - if(flawedVariable->lastDomain().isSingleton()) { - debugMsg("Solver:ValueEnum", "Ignoring ordering heuristic because '" << flawedVariable->toString() << "' is singleton."); - ((OrderedValueSource*) m_choices)->addValue(flawedVariable->lastDomain().getSingletonValue()); - } - else { - TiXmlElement* value = configData.FirstChildElement(); - checkError(value != NULL, "Attempted to define an empty value enumeration."); + if(flawedVariable->lastDomain().isSingleton()) { + debugMsg("Solver:ValueEnum", "Ignoring ordering heuristic because '" << flawedVariable->toString() << "' is singleton."); + boost::polymorphic_cast(m_choices)->addValue(flawedVariable->lastDomain().getSingletonValue()); + } + else { + TiXmlElement* value = configData.FirstChildElement(); + checkError(value != NULL, "Attempted to define an empty value enumeration."); - while(value != NULL) { - if(strcmp(value->Value(), "Value") == 0) { - edouble v = readValue(*value); - debugMsg("Solver:ValueEnum", "Read value " << v << " from " << *value << " convertToObject " << convertToObject); - if(convertToObject) { - ObjectId obj = client->getObject((LabelStr(v)).c_str()); - checkError(obj.isValid(), "No object named '" << LabelStr(v) << "' exists, which is listed in choice ordering for " - << flawedVariable->toString()); - v = obj->getKey(); - } - ((OrderedValueSource*)m_choices)->addValue(v); - } - value = value->NextSiblingElement(); - } + while(value != NULL) { + if(strcmp(value->Value(), "Value") == 0) { + edouble v = readValue(*value); + debugMsg("Solver:ValueEnum", "Read value " << v << " from " << *value << " convertToObject " << convertToObject); + if(convertToObject) { + ObjectId obj = client->getObject(LabelStr(v)); + checkError(obj.isValid(), "No object named '" << LabelStr(v) << "' exists, which is listed in choice ordering for " + << flawedVariable->toString()); + v = obj->getKey(); } + boost::polymorphic_cast(m_choices)->addValue(v); } + value = value->NextSiblingElement(); + } + } +} - edouble ValueEnum::readValue(const TiXmlElement& element) const { - const char* data = element.Attribute("val"); - checkError(data != NULL && strcmp(data, "") != 0, "Value element with missing or empty val attribute."); +edouble ValueEnum::readValue(const TiXmlElement& element) const { + const char* data = element.Attribute("val"); + checkError(data != NULL && strcmp(data, "") != 0, "Value element with missing or empty val attribute."); - edouble retval; - - if(!toValue(data, retval)) { - if(strcmp(data, "true") == 0 || strcmp(data, "TRUE") == 0 || strcmp(data, "True") == 0) - retval = 1; - else if(strcmp(data, "false") == 0 || strcmp(data, "FALSE") == 0 || strcmp(data, "False") == 0) - retval = 0; - else - retval = LabelStr::getKey(data); - } + edouble retval; + + if(!toValue(data, retval)) { + if(strcmp(data, "true") == 0 || strcmp(data, "TRUE") == 0 || strcmp(data, "True") == 0) + retval = 1; + else if(strcmp(data, "false") == 0 || strcmp(data, "FALSE") == 0 || strcmp(data, "False") == 0) + retval = 0; + else + retval = LabelStr::getKey(data); + } - return retval; - } + return retval; +} - edouble ValueEnum::getNext(){ - debugMsg("Solver:ValueEnum:getNext", "Getting value " << m_choices->getValue(m_choiceIndex) << " for variable " << - getFlawedVariable()->toString() << " (index " << m_choiceIndex << ")"); - return m_choices->getValue(m_choiceIndex++); - } +edouble ValueEnum::getNext(){ + debugMsg("Solver:ValueEnum:getNext", "Getting value " << m_choices->getValue(m_choiceIndex) << " for variable " << + getFlawedVariable()->toString() << " (index " << m_choiceIndex << ")"); + return m_choices->getValue(m_choiceIndex++); +} - bool ValueEnum::hasNext() const { - debugMsg("Solver:ValueEnum:hasNext", "Current index " << m_choiceIndex << " total count " << m_choices->getCount()); - return m_choiceIndex < m_choices->getCount(); - } +bool ValueEnum::hasNext() const { + debugMsg("Solver:ValueEnum:hasNext", "Current index " << m_choiceIndex << " total count " << m_choices->getCount()); + return m_choiceIndex < m_choices->getCount(); +} - //accepted choice options: mergeFirst, activateFirst, mergeOnly, activateOnly - //accepted order options (only for merge): early, late, near, far - OpenConditionDecisionPoint::OpenConditionDecisionPoint(const DbClientId& client, const TokenId& flawedToken, const TiXmlElement& configData, const LabelStr& explanation) - : SOLVERS::OpenConditionDecisionPoint(client, flawedToken, configData, explanation) { - std::string choice(configData.Attribute("choice") == NULL ? "mergeFirst" : configData.Attribute("choice")); - std::string order(configData.Attribute("order") == NULL ? "early" : configData.Attribute("order")); - - debugMsg("OpenConditionDecisionPoint:constructor", "Constructing for " << m_flawedToken->getKey() << " with choice order " << choice << " and merge order " << order); - - if(choice == "activateFirst") - m_action = activateFirst; - else if(choice == "mergeFirst") - m_action = mergeFirst; - else if(choice == "activateOnly") - m_action = activateOnly; - else if(choice == "mergeOnly") - m_action = mergeOnly; - else - checkError(ALWAYS_FAIL, "No such open condition resolution order '" << choice << "'"); - - TiXmlElement orderElem("order"); - orderElem.SetAttribute("component", order); - - EngineId& engine = flawedToken->getPlanDatabase()->getEngine(); - ComponentFactoryMgr* cfm = (ComponentFactoryMgr*)engine->getComponent("ComponentFactoryMgr"); - ComponentId newComponent = cfm->createInstance(orderElem); - m_comparator = new TokenComparatorWrapper((TokenComparator*) newComponent, flawedToken); - - checkError(m_comparator != NULL, "Failed to allocate comparator."); - } +//accepted choice options: mergeFirst, activateFirst, mergeOnly, activateOnly +//accepted order options (only for merge): early, late, near, far +OpenConditionDecisionPoint::OpenConditionDecisionPoint(const DbClientId client, + const TokenId flawedToken, + const TiXmlElement& configData, + const std::string& explanation) + : SOLVERS::OpenConditionDecisionPoint(client, flawedToken, configData, + explanation), + m_action(mergeFirst), + m_comparator(NULL) { + std::string choice(configData.Attribute("choice") == NULL ? "mergeFirst" : configData.Attribute("choice")); + std::string order(configData.Attribute("order") == NULL ? "early" : configData.Attribute("order")); + + debugMsg("OpenConditionDecisionPoint:constructor", "Constructing for " << m_flawedToken->getKey() << " with choice order " << choice << " and merge order " << order); + + if(choice == "activateFirst") + m_action = activateFirst; + else if(choice == "mergeFirst") + m_action = mergeFirst; + else if(choice == "activateOnly") + m_action = activateOnly; + else if(choice == "mergeOnly") + m_action = mergeOnly; + else + checkError(ALWAYS_FAIL, "No such open condition resolution order '" << choice << "'"); + + TiXmlElement orderElem("order"); + orderElem.SetAttribute("component", order); + + EngineId engine = flawedToken->getPlanDatabase()->getEngine(); + ComponentFactoryMgr* cfm = + reinterpret_cast(engine->getComponent("ComponentFactoryMgr")); + ComponentId newComponent = cfm->createComponentInstance(orderElem); + m_comparator = new TokenComparatorWrapper(id_cast(newComponent), + flawedToken); + + checkError(m_comparator != NULL, "Failed to allocate comparator."); +} - void OpenConditionDecisionPoint::handleInitialize() { - const StateDomain stateDomain(m_flawedToken->getState()->lastDomain()); +void OpenConditionDecisionPoint::handleInitialize() { + const StateDomain stateDomain(m_flawedToken->getState()->lastDomain()); - if(stateDomain.isMember(Token::ACTIVE) && (m_action == activateFirst || m_action == activateOnly) && - m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken)) { - debugMsg("OpenConditionDecisionPoint:handleInitialize", "Adding choice '" << Token::ACTIVE.toString() << "' for token " << m_flawedToken->getKey()); - m_choices.push_back(Token::ACTIVE); - } - else { - condDebugMsg(!stateDomain.isMember(Token::ACTIVE), - "OpenConditionDecisionPoint:handleInitialize", - "Skipping choice '" << Token::ACTIVE.toString() << "' for token " << - m_flawedToken->getKey() << " because it isn't in the state domain."); - condDebugMsg(!m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken), - "OpenConditionDecisionPoint:handleInitialize", - "Skipping choice '" << Token::ACTIVE.toString() << "' for token " << - m_flawedToken->getKey() << " because it has no ordering choices."); - } - - if((m_action == mergeFirst || m_action == mergeOnly || m_action == activateFirst)) { - - if(stateDomain.isMember(Token::MERGED)) { - m_flawedToken->getPlanDatabase()->getCompatibleTokens(m_flawedToken, m_compatibleTokens, + if(stateDomain.isMember(Token::ACTIVE) && (m_action == activateFirst || m_action == activateOnly) && + m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken)) { + debugMsg("OpenConditionDecisionPoint:handleInitialize", "Adding choice '" << Token::ACTIVE.toString() << "' for token " << m_flawedToken->getKey()); + m_choices.push_back(Token::ACTIVE); + } + else { + condDebugMsg(!stateDomain.isMember(Token::ACTIVE), + "OpenConditionDecisionPoint:handleInitialize", + "Skipping choice '" << Token::ACTIVE.toString() << "' for token " << + m_flawedToken->getKey() << " because it isn't in the state domain."); + condDebugMsg(!m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken), + "OpenConditionDecisionPoint:handleInitialize", + "Skipping choice '" << Token::ACTIVE.toString() << "' for token " << + m_flawedToken->getKey() << " because it has no ordering choices."); + } + + if((m_action == mergeFirst || m_action == mergeOnly || m_action == activateFirst)) { + + if(stateDomain.isMember(Token::MERGED)) { + m_flawedToken->getPlanDatabase()->getCompatibleTokens(m_flawedToken, m_compatibleTokens, #ifdef _MSC_VER - UINT_MAX, + UINT_MAX, #else - std::numeric_limits::max(), + std::numeric_limits::max(), #endif //_MSC_VER - true); - m_mergeCount = m_compatibleTokens.size(); + true); + m_mergeCount = m_compatibleTokens.size(); - if(m_mergeCount > 0) { - debugMsg("OpenConditionDecisionPoint:handleInitialize", "Adding choice '" << Token::MERGED.toString() << "' for token " << m_flawedToken->getKey()); - m_choices.push_back(Token::MERGED); - std::sort::iterator, TokenComparatorWrapper& >(m_compatibleTokens.begin(), m_compatibleTokens.end(), *m_comparator); - } - else { - debugMsg("OpenConditionDecisionPoint:handleInitialize", "Skipping choice '" << Token::MERGED.toString() << "' for token " << m_flawedToken->getKey() - << " because there were no compatible tokens."); - } - } - else { - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Skipping choice '" << Token::MERGED.toString() << "' for token " << - m_flawedToken->getKey() << " because it isn't in the domain."); - } - - if(m_action == mergeFirst && stateDomain.isMember(Token::ACTIVE) && - m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken)) { - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Adding choice '" << Token::ACTIVE.toString() << - "' for token " << m_flawedToken->getKey()); - m_choices.push_back(Token::ACTIVE); - } - else { - condDebugMsg(m_action == mergeFirst && !m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken), - "OpenConditionDecisionPoint:handleInitialize", - "Skipping choice '" << Token::ACTIVE.toString() << "' for token " << - m_flawedToken->getKey() << " because it has no ordering chioces."); + if(m_mergeCount > 0) { + debugMsg("OpenConditionDecisionPoint:handleInitialize", "Adding choice '" << Token::MERGED.toString() << "' for token " << m_flawedToken->getKey()); + m_choices.push_back(Token::MERGED); + std::sort::iterator, TokenComparatorWrapper& >(m_compatibleTokens.begin(), m_compatibleTokens.end(), *m_comparator); + } + else { + debugMsg("OpenConditionDecisionPoint:handleInitialize", "Skipping choice '" << Token::MERGED.toString() << "' for token " << m_flawedToken->getKey() + << " because there were no compatible tokens."); + } + } + else { + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Skipping choice '" << Token::MERGED.toString() << "' for token " << + m_flawedToken->getKey() << " because it isn't in the domain."); + } + + if(m_action == mergeFirst && stateDomain.isMember(Token::ACTIVE) && + m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken)) { + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Adding choice '" << Token::ACTIVE.toString() << + "' for token " << m_flawedToken->getKey()); + m_choices.push_back(Token::ACTIVE); + } + else { + condDebugMsg(m_action == mergeFirst && !m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken), + "OpenConditionDecisionPoint:handleInitialize", + "Skipping choice '" << Token::ACTIVE.toString() << "' for token " << + m_flawedToken->getKey() << " because it has no ordering chioces."); - } + } - } + } - if(stateDomain.isMember(Token::REJECTED)) { - debugMsg("OpenConditionDecisionPoint:handleInitialize", "Adding choice '" << Token::REJECTED.toString() << "' for token " << m_flawedToken->getKey()); - m_choices.push_back(Token::REJECTED); - } + if(stateDomain.isMember(Token::REJECTED)) { + debugMsg("OpenConditionDecisionPoint:handleInitialize", "Adding choice '" << Token::REJECTED.toString() << "' for token " << m_flawedToken->getKey()); + m_choices.push_back(Token::REJECTED); + } - m_choiceCount = m_choices.size(); - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Have " << m_choices.size() << " choices for " << m_flawedToken->getKey()); - } + m_choiceCount = m_choices.size(); + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Have " << m_choices.size() << " choices for " << m_flawedToken->getKey()); +} - OpenConditionDecisionPoint::~OpenConditionDecisionPoint() { - delete m_comparator; - } +OpenConditionDecisionPoint::~OpenConditionDecisionPoint() { + delete m_comparator; +} - void TokenComparator::extractTokens(const std::pair >& p1, - const std::pair >& p2, - TokenId& t1, TokenId& t2) { - t1 = (p1.second.first == m_flawedTok ? p1.second.second : p1.second.first); - t2 = (p2.second.first == m_flawedTok ? p2.second.second : p2.second.first); - } +void TokenComparator::extractTokens(const std::pair >& p1, + const std::pair >& p2, + TokenId& t1, TokenId& t2) { + t1 = (p1.second.first == m_flawedTok ? p1.second.second : p1.second.first); + t2 = (p2.second.first == m_flawedTok ? p2.second.second : p2.second.first); +} - bool TokenComparator::compare(const std::pair >& p1, - const std::pair >& p2) { - TokenId x, y; - extractTokens(p1, p2, x, y); - return compare(x, y); - } +bool TokenComparator::compare(const std::pair >& p1, + const std::pair >& p2) { + TokenId x, y; + extractTokens(p1, p2, x, y); + return compare(x, y); +} - bool EarlyTokenComparator::compare(const TokenId x, const TokenId y) { - return x->start()->lastDomain().getLowerBound() < y->start()->lastDomain().getLowerBound(); - } +bool EarlyTokenComparator::compare(const TokenId x, const TokenId y) { + return x->start()->lastDomain().getLowerBound() < y->start()->lastDomain().getLowerBound(); +} - bool EarlyTokenComparator::compare(const std::pair >& p1, - const std::pair >& p2) { - check_error(m_flawedTok.isValid()); - if(m_flawedTok == p1.second.second) { - if(m_flawedTok == p2.second.second) { - return p1.second.second->end()->lastDomain().getLowerBound() < - p2.second.second->end()->lastDomain().getLowerBound(); - } - else - return false; - } - else if(m_flawedTok == p2.second.second) - return true; - else - return compare(p1.second.second, p2.second.second); - check_error(ALWAYS_FAIL); - return true; - } +bool EarlyTokenComparator::compare(const std::pair >& p1, + const std::pair >& p2) { + check_error(m_flawedTok.isValid()); + if(m_flawedTok == p1.second.second) { + if(m_flawedTok == p2.second.second) { + return p1.second.second->end()->lastDomain().getLowerBound() < + p2.second.second->end()->lastDomain().getLowerBound(); + } + else + return false; + } + else if(m_flawedTok == p2.second.second) + return true; + else + return compare(p1.second.second, p2.second.second); + check_error(ALWAYS_FAIL); + return true; +} - TokenComparator* EarlyTokenComparator::copy() { - return new EarlyTokenComparator(m_flawedTok); - } +TokenComparator* EarlyTokenComparator::copy() { + return new EarlyTokenComparator(m_flawedTok); +} - bool LateTokenComparator::compare(const TokenId x, const TokenId y) { - return x->start()->lastDomain().getLowerBound() > y->start()->lastDomain().getLowerBound(); - } +bool LateTokenComparator::compare(const TokenId x, const TokenId y) { + return x->start()->lastDomain().getLowerBound() > y->start()->lastDomain().getLowerBound(); +} - bool LateTokenComparator::compare(const std::pair >& p1, - const std::pair >& p2) { - check_error(m_flawedTok.isValid()); - if(m_flawedTok == p1.second.second) { - if(m_flawedTok == p2.second.second) { - return p1.second.second->end()->lastDomain().getLowerBound() > - p2.second.second->end()->lastDomain().getLowerBound(); - } - else - return true; - } - else if(m_flawedTok == p2.second.second) - return false; - else - return compare(p1.second.second, p2.second.second); - check_error(ALWAYS_FAIL); - return true; - } +bool LateTokenComparator::compare(const std::pair >& p1, + const std::pair >& p2) { + check_error(m_flawedTok.isValid()); + if(m_flawedTok == p1.second.second) { + if(m_flawedTok == p2.second.second) { + return p1.second.second->end()->lastDomain().getLowerBound() > + p2.second.second->end()->lastDomain().getLowerBound(); + } + else + return true; + } + else if(m_flawedTok == p2.second.second) + return false; + else + return compare(p1.second.second, p2.second.second); + check_error(ALWAYS_FAIL); + return true; +} - TokenComparator* LateTokenComparator::copy() { - return new LateTokenComparator(m_flawedTok); - } +TokenComparator* LateTokenComparator::copy() { + return new LateTokenComparator(m_flawedTok); +} - bool NearTokenComparator::compare(const TokenId x, const TokenId y) { - bool retval = absoluteDistance(m_flawedTok, x) < absoluteDistance(m_flawedTok, y); - debugMsg("NearTokenComparator:compare", "" << x->getKey() << " before " << y->getKey() << " ? " - << (retval ? "true" : "false")); - return retval; - } +bool NearTokenComparator::compare(const TokenId x, const TokenId y) { + bool retval = absoluteDistance(m_flawedTok, x) < absoluteDistance(m_flawedTok, y); + debugMsg("NearTokenComparator:compare", "" << x->getKey() << " before " << y->getKey() << " ? " + << (retval ? "true" : "false")); + return retval; +} - TokenComparator* NearTokenComparator::copy() { - return new NearTokenComparator(m_flawedTok); - } +TokenComparator* NearTokenComparator::copy() { + return new NearTokenComparator(m_flawedTok); +} - eint NearTokenComparator::absoluteDistance(const TokenId& a, const TokenId& b) { - return std::abs(midpoint(a) - midpoint(b)); - } +eint NearTokenComparator::absoluteDistance(const TokenId a, const TokenId b) { + return std::abs(midpoint(a) - midpoint(b)); +} - eint NearTokenComparator::midpoint(const TokenId& token) { - edouble maxTemporalExtent = (token->end()->lastDomain().getUpperBound() - - token->start()->lastDomain().getLowerBound()); - return cast_int(token->start()->lastDomain().getLowerBound() + maxTemporalExtent / 2); - } +eint NearTokenComparator::midpoint(const TokenId token) { + edouble maxTemporalExtent = (token->end()->lastDomain().getUpperBound() - + token->start()->lastDomain().getLowerBound()); + return cast_int(token->start()->lastDomain().getLowerBound() + maxTemporalExtent / 2); +} - bool FarTokenComparator::compare(const TokenId x, const TokenId y) { - bool retval = absoluteDistance(m_flawedTok, x) > absoluteDistance(m_flawedTok, y); - debugMsg("FarTokenComparator:compare", "" << x->getKey() << " before " << y->getKey() << " ? " - << (retval ? "true" : "false")); - return retval; - } +bool FarTokenComparator::compare(const TokenId x, const TokenId y) { + bool retval = absoluteDistance(m_flawedTok, x) > absoluteDistance(m_flawedTok, y); + debugMsg("FarTokenComparator:compare", "" << x->getKey() << " before " << y->getKey() << " ? " + << (retval ? "true" : "false")); + return retval; +} - TokenComparator* FarTokenComparator::copy() { - return new FarTokenComparator(m_flawedTok); - } +TokenComparator* FarTokenComparator::copy() { + return new FarTokenComparator(m_flawedTok); +} - bool AscendingKeyTokenComparator::compare(const TokenId x, const TokenId y) { - return x->getKey() < y->getKey(); - } +bool AscendingKeyTokenComparator::compare(const TokenId x, const TokenId y) { + return x->getKey() < y->getKey(); +} - bool AscendingKeyTokenComparator::compare(const std::pair >& p1, - const std::pair >& p2) { - if(p1.first->getKey() < p2.first->getKey()) - return true; - if(p1.first->getKey() > p2.first->getKey()) - return false; - return TokenComparator::compare(p1, p2); - } +bool AscendingKeyTokenComparator::compare(const std::pair >& p1, + const std::pair >& p2) { + if(p1.first->getKey() < p2.first->getKey()) + return true; + if(p1.first->getKey() > p2.first->getKey()) + return false; + return TokenComparator::compare(p1, p2); +} - TokenComparator* AscendingKeyTokenComparator::copy() { - return new AscendingKeyTokenComparator(m_flawedTok); - } +TokenComparator* AscendingKeyTokenComparator::copy() { + return new AscendingKeyTokenComparator(m_flawedTok); +} - TokenComparatorWrapper::TokenComparatorWrapper(TokenComparator* cmp, TokenId flawedToken) : m_comparator(cmp) { - checkError(m_comparator != NULL, "Invalid comparator object."); - checkError(flawedToken.isValid(), "Cannot base a comparator on an invalid token."); +TokenComparatorWrapper::TokenComparatorWrapper(TokenComparator* cmp, TokenId flawedToken) : m_comparator(cmp) { + checkError(m_comparator != NULL, "Invalid comparator object."); + checkError(flawedToken.isValid(), "Cannot base a comparator on an invalid token."); - m_comparator->m_flawedTok = flawedToken; - } + m_comparator->m_flawedTok = flawedToken; +} - TokenComparatorWrapper::TokenComparatorWrapper(const TokenComparatorWrapper& other) { - m_comparator = other.m_comparator->copy(); - checkError(m_comparator != NULL, "Invalid comparator object."); - } +TokenComparatorWrapper::TokenComparatorWrapper(const TokenComparatorWrapper& other) + : m_comparator(NULL) { + m_comparator = other.m_comparator->copy(); + checkError(m_comparator != NULL, "Invalid comparator object."); +} - TokenComparatorWrapper::~TokenComparatorWrapper() { - delete m_comparator; - } +TokenComparatorWrapper& TokenComparatorWrapper::operator=(const TokenComparatorWrapper& other) { + m_comparator = other.m_comparator->copy(); + checkError(m_comparator != NULL, "Invalid comparator object."); + return *this; +} + +TokenComparatorWrapper::~TokenComparatorWrapper() { + delete m_comparator; +} - ThreatDecisionPoint::ThreatDecisionPoint(const DbClientId& client, const TokenId& tokenToOrder, const TiXmlElement& configData, const LabelStr& explanation) - : SOLVERS::ThreatDecisionPoint(client, tokenToOrder, configData, explanation) { - std::string order((configData.Attribute("order") == NULL ? "early" : configData.Attribute("order"))); +ThreatDecisionPoint::ThreatDecisionPoint(const DbClientId client, const TokenId tokenToOrder, const TiXmlElement& configData, const std::string& explanation) + : SOLVERS::ThreatDecisionPoint(client, tokenToOrder, configData, explanation), + m_comparator(NULL) { + std::string order((configData.Attribute("order") == NULL ? "early" : configData.Attribute("order"))); - debugMsg("ThreatDecisionPoint:constructor", "Constructing for " << tokenToOrder->getKey() << " with choice order " << order); - TiXmlElement orderElem("order"); - orderElem.SetAttribute("component", order); - EngineId& engine = tokenToOrder->getPlanDatabase()->getEngine(); - ComponentFactoryMgr* cfm = (ComponentFactoryMgr*)engine->getComponent("ComponentFactoryMgr"); - ComponentId newComponent = cfm->createInstance(orderElem); - m_comparator = new ThreatComparator((TokenComparator*) newComponent, tokenToOrder); - } + debugMsg("ThreatDecisionPoint:constructor", "Constructing for " << tokenToOrder->getKey() << " with choice order " << order); + TiXmlElement orderElem("order"); + orderElem.SetAttribute("component", order); + EngineId engine = tokenToOrder->getPlanDatabase()->getEngine(); + ComponentFactoryMgr* cfm = + reinterpret_cast(engine->getComponent("ComponentFactoryMgr")); + ComponentId newComponent = cfm->createComponentInstance(orderElem); + m_comparator = new ThreatComparator(id_cast(newComponent), tokenToOrder); +} - // class ObjectComparator { - // public: - // bool operator() (const std::pair >& p1, - // const std::pair >& p2) const { - // ObjectId o1 = p1.first; - // ObjectId o2 = p2.first; - // return o1->getKey() < o2->getKey(); - // } - // bool operator==(const ObjectComparator& c){return true;} - // }; - - void ThreatDecisionPoint::handleInitialize() { - SOLVERS::ThreatDecisionPoint::handleInitialize(); - //first order choices by object key - // ObjectComparator cmp; - // std::sort > >::iterator, ObjectComparator&>(m_choices.begin(), m_choices.end(), cmp); - //then order them by the heuristic - std::sort > >::iterator, ThreatComparator&>(m_choices.begin(), m_choices.end(), *m_comparator); - debugMsg("ThreatDecisionPoint:handleInitialize", "Final choice order for " << m_tokenToOrder->getKey() << ": " << choicesToString()); - } +// class ObjectComparator { +// public: +// bool operator() (const std::pair >& p1, +// const std::pair >& p2) const { +// ObjectId o1 = p1.first; +// ObjectId o2 = p2.first; +// return o1->getKey() < o2->getKey(); +// } +// bool operator==(const ObjectComparator& c){return true;} +// }; + +void ThreatDecisionPoint::handleInitialize() { + SOLVERS::ThreatDecisionPoint::handleInitialize(); + //first order choices by object key + // ObjectComparator cmp; + // std::sort > >::iterator, ObjectComparator&>(m_choices.begin(), m_choices.end(), cmp); + //then order them by the heuristic + std::sort > >::iterator, ThreatComparator&>(m_choices.begin(), m_choices.end(), *m_comparator); + debugMsg("ThreatDecisionPoint:handleInitialize", "Final choice order for " << m_tokenToOrder->getKey() << ": " << choicesToString()); +} - ThreatDecisionPoint::~ThreatDecisionPoint() { - delete m_comparator; - } +ThreatDecisionPoint::~ThreatDecisionPoint() { + delete m_comparator; +} - std::string ThreatDecisionPoint::choicesToString() { - std::stringstream retval; - for(std::vector > >::const_iterator it = m_choices.begin(); - it != m_choices.end(); ++it) { - ObjectId o = (*it).first; - TokenId t1 = (*it).second.first; - TokenId t2 = (*it).second.second; - retval << o->toString() << "(" << o->getKey() << "):" << t1->getKey() << "<" << t2->getKey() << ","; - } - return retval.str(); - } +std::string ThreatDecisionPoint::choicesToString() { + std::stringstream retval; + for(std::vector > >::const_iterator it = m_choices.begin(); + it != m_choices.end(); ++it) { + ObjectId o = (*it).first; + TokenId t1 = (*it).second.first; + TokenId t2 = (*it).second.second; + retval << o->toString() << "(" << o->getKey() << "):" << t1->getKey() << "<" << t2->getKey() << ","; + } + return retval.str(); +} - ThreatDecisionPoint::ThreatComparator::ThreatComparator(TokenComparator* comparator, const TokenId& tok) : m_comparator(comparator) { - m_comparator->m_flawedTok = tok; - } +ThreatDecisionPoint::ThreatComparator::ThreatComparator(TokenComparator* comparator, const TokenId tok) : m_comparator(comparator) { + m_comparator->m_flawedTok = tok; +} - ThreatDecisionPoint::ThreatComparator::ThreatComparator(const ThreatComparator& other) { - m_comparator = other.m_comparator->copy(); - } +ThreatDecisionPoint::ThreatComparator::ThreatComparator(const ThreatComparator& other) :m_comparator(NULL) { + m_comparator = other.m_comparator->copy(); +} - ThreatDecisionPoint::ThreatComparator::~ThreatComparator() { - delete m_comparator; - } +ThreatDecisionPoint::ThreatComparator::~ThreatComparator() { + delete m_comparator; +} - bool ThreatDecisionPoint::ThreatComparator::operator() (const std::pair >& p1, - const std::pair >& p2) { - return m_comparator->compare(p1, p2); - } - } - } +bool ThreatDecisionPoint::ThreatComparator::operator() (const std::pair >& p1, + const std::pair >& p2) { + return m_comparator->compare(p1, p2); +} +} +} } diff --git a/src/PLASMA/Solvers/component/HSTSDecisionPoints.hh b/src/PLASMA/Solvers/component/HSTSDecisionPoints.hh index 19e073997..14394899a 100644 --- a/src/PLASMA/Solvers/component/HSTSDecisionPoints.hh +++ b/src/PLASMA/Solvers/component/HSTSDecisionPoints.hh @@ -22,7 +22,8 @@ namespace EUROPA { class ValueEnum : public UnboundVariableDecisionPoint { public: - ValueEnum(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, const LabelStr& explanation = "unknown"); + ValueEnum(const DbClientId client, const ConstrainedVariableId flawedVariable, + const TiXmlElement& configData, const std::string& explanation = "unknown"); edouble getNext(); bool hasNext() const; private: @@ -33,50 +34,56 @@ namespace EUROPA { class TokenComparator; class TokenComparatorWrapper; - class OpenConditionDecisionPoint : public SOLVERS::OpenConditionDecisionPoint { - public: - OpenConditionDecisionPoint(const DbClientId& client, const TokenId& flawedToken, const TiXmlElement& configData, const LabelStr& explanation = "unknown"); - void handleInitialize(); - ~OpenConditionDecisionPoint(); - const std::vector& getStateChoices(){return m_choices;} - const std::vector& getCompatibleTokens(){return m_compatibleTokens;} - private: - enum Actions { - activateFirst = 0, - mergeFirst, - activateOnly, - mergeOnly - }; + class OpenConditionDecisionPoint : public SOLVERS::OpenConditionDecisionPoint { + public: + OpenConditionDecisionPoint(const DbClientId client, const TokenId flawedToken, const TiXmlElement& configData, const std::string& explanation = "unknown"); + void handleInitialize(); + ~OpenConditionDecisionPoint(); + const std::vector& getStateChoices(){return m_choices;} + const std::vector& getCompatibleTokens(){return m_compatibleTokens;} + private: + OpenConditionDecisionPoint(const OpenConditionDecisionPoint&); + OpenConditionDecisionPoint& operator=(const OpenConditionDecisionPoint&); + + enum Actions { + activateFirst = 0, + mergeFirst, + activateOnly, + mergeOnly + }; - Actions m_action; - TokenComparatorWrapper* m_comparator; + Actions m_action; + TokenComparatorWrapper* m_comparator; + }; + + class ThreatDecisionPoint : public SOLVERS::ThreatDecisionPoint { + public: + ThreatDecisionPoint(const DbClientId client, const TokenId tokenToOrder, const TiXmlElement& configData, const std::string& explanation = "unknown"); + void handleInitialize(); + ~ThreatDecisionPoint(); + const std::vector > >& getOrderingChoices(){return m_choices;} + private: + ThreatDecisionPoint(const ThreatDecisionPoint&); + ThreatDecisionPoint& operator=(const ThreatDecisionPoint&); + std::string choicesToString(); + class ThreatComparator { + public: + ThreatComparator(TokenComparator* comparator, const TokenId tok); + ThreatComparator(const ThreatComparator& other); + ~ThreatComparator(); + bool operator() (const std::pair >& p1, + const std::pair >& p2); + private: + ThreatComparator& operator=(const ThreatComparator&); + TokenComparator* m_comparator; }; - class ThreatDecisionPoint : public SOLVERS::ThreatDecisionPoint { - public: - ThreatDecisionPoint(const DbClientId& client, const TokenId& tokenToOrder, const TiXmlElement& configData, const LabelStr& explanation = "unknown"); - void handleInitialize(); - ~ThreatDecisionPoint(); - const std::vector > >& getOrderingChoices(){return m_choices;} - private: - std::string choicesToString(); - class ThreatComparator { - public: - ThreatComparator(TokenComparator* comparator, const TokenId& tok); - ThreatComparator(const ThreatComparator& other); - ~ThreatComparator(); - bool operator() (const std::pair >& p1, - const std::pair >& p2); - private: - TokenComparator* m_comparator; - }; - - ThreatComparator* m_comparator; - }; + ThreatComparator* m_comparator; + }; class TokenComparator : public Component { public: - TokenComparator(const TiXmlElement& configData) : Component(configData) {} + TokenComparator(const TiXmlElement& configData) : Component(configData), m_flawedTok() {} TokenComparator(TokenId tok) : m_flawedTok(tok) {} virtual bool compare(const TokenId x, const TokenId y) = 0; virtual bool compare(const std::pair >& p1, @@ -89,15 +96,16 @@ namespace EUROPA { }; //have to stick this in because STL wants to copy the comparator object. - class TokenComparatorWrapper { - public: - TokenComparatorWrapper(TokenComparator* cmp, TokenId flawedToken); - TokenComparatorWrapper(const TokenComparatorWrapper& other); - ~TokenComparatorWrapper(); - bool operator() (TokenId x, TokenId y) {return m_comparator->compare(x, y);} - private: - TokenComparator* m_comparator; - }; + class TokenComparatorWrapper { + public: + TokenComparatorWrapper(TokenComparator* cmp, TokenId flawedToken); + TokenComparatorWrapper(const TokenComparatorWrapper& other); + TokenComparatorWrapper& operator=(const TokenComparatorWrapper& other); + ~TokenComparatorWrapper(); + bool operator() (TokenId x, TokenId y) {return m_comparator->compare(x, y);} + private: + TokenComparator* m_comparator; + }; class EarlyTokenComparator : public TokenComparator { public: @@ -125,8 +133,8 @@ namespace EUROPA { NearTokenComparator(TokenId tok) : TokenComparator(tok) {} virtual bool compare(const TokenId x, const TokenId y); virtual TokenComparator* copy(); - static eint absoluteDistance(const TokenId& a, const TokenId& b); - static eint midpoint(const TokenId& token); + static eint absoluteDistance(const TokenId a, const TokenId b); + static eint midpoint(const TokenId token); }; class FarTokenComparator : public NearTokenComparator { diff --git a/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc b/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc index 1e2457958..53ad0fbef 100644 --- a/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc +++ b/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc @@ -12,626 +12,631 @@ #endif //_MSC_VER namespace EUROPA { - namespace SOLVERS { - - bool OpenConditionDecisionPoint::test(const EntityId& entity){ - return(TokenId::convertable(entity) || TokenId(entity)->isInactive()); - } - - OpenConditionDecisionPoint::OpenConditionDecisionPoint(const DbClientId& client, const TokenId& flawedToken, const TiXmlElement& configData, - const LabelStr& explanation) - : DecisionPoint(client, flawedToken->getKey(), explanation), - m_flawedToken(flawedToken), - m_mergeCount(0), - m_choiceCount(0), - m_mergeIndex(0), - m_choiceIndex(0) { - - // Retrieve policy information from configuration node - - // Ordering preference - merge vs. activation. Default is to merge, activate, reject. - - // Activation preference - direct vs. indirect. Default is to use direct activation - } - - OpenConditionDecisionPoint::~OpenConditionDecisionPoint() {} - - const TokenId& OpenConditionDecisionPoint::getToken() const{ return m_flawedToken; } - - void OpenConditionDecisionPoint::handleInitialize(){ - const StateDomain stateDomain(m_flawedToken->getState()->lastDomain()); - - // Next merge choices if there are any. - if(stateDomain.isMember(Token::MERGED)){ - // Use exact test in this case - m_flawedToken->getPlanDatabase()->getCompatibleTokens( - m_flawedToken, - m_compatibleTokens, - EUROPA_UINT_MAX, - true); - m_mergeCount = m_compatibleTokens.size(); - if(m_mergeCount > 0) { - m_choices.push_back(Token::MERGED); - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Adding choice '" << Token::MERGED.toString() << "' for token " << - m_flawedToken->getKey()); - } - else { - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Skipping choice '" << Token::MERGED.toString() << "' for token " << - m_flawedToken->getKey() << " because there are no compatible tokens."); - } - } - else { - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Skipping choice '" << Token::MERGED.toString() << "' for token " << - m_flawedToken->getKey() << " because it isn't in the state domain."); - } - - if(stateDomain.isMember(Token::ACTIVE) ) {//&& m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken)) - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Adding choice '" << Token::ACTIVE.toString() << "' for token " << - m_flawedToken->getKey()); - m_choices.push_back(Token::ACTIVE); - } - else { - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Skipping choice '" << Token::ACTIVE.toString() << "' for token " << - m_flawedToken->getKey() << " because it isn't in the state domain."); - } - - if(stateDomain.isMember(Token::REJECTED)) { - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Adding choice '" << Token::REJECTED.toString() << "' for token " << - m_flawedToken->getKey()); - m_choices.push_back(Token::REJECTED); - } - else { - debugMsg("OpenConditionDecisionPoint:handleInitialize", - "Skipping choice '" << Token::REJECTED.toString() << "' for token " << - m_flawedToken->getKey() << " because it isn't in the state domain."); - } - - m_choiceCount = m_choices.size(); - } - - void OpenConditionDecisionPoint::handleExecute() { - checkError(m_choiceIndex < m_choiceCount, - "Tried to execute past available choices:" << m_choiceIndex << ">=" << m_choiceCount); - if(m_choices[m_choiceIndex] == Token::ACTIVE) { - debugMsg("SolverDecisionPoint:handleExecute", "For " << m_flawedToken->getPredicateName().toString() << "(" << - m_flawedToken->getKey() << "), assigning ACTIVE."); - m_client->activate(m_flawedToken); - } - else if(m_choices[m_choiceIndex] == Token::MERGED) { - checkError(m_mergeIndex < m_mergeCount, "Tried to merge past available compatible tokens."); - TokenId activeToken = m_compatibleTokens[m_mergeIndex]; - debugMsg("SolverDecisionPoint:handleExecute", "For " << m_flawedToken->getPredicateName().toString() << "(" << - m_flawedToken->getKey() << "), assigning MERGED onto " << activeToken->getPredicateName().toString() << - "(" << activeToken->getKey() << ")."); - m_client->merge(m_flawedToken, activeToken); - } - else { - checkError(m_choices[m_choiceIndex] == Token::REJECTED, - "Expect this choice to be REJECTED instead of " + m_choices[m_choiceIndex].toString()); - debugMsg("SolverDecisionPoint:handleExecute", "For " << m_flawedToken->getPredicateName().toString() << "(" << - m_flawedToken->getKey() << "), assigning REJECTED."); - m_client->reject(m_flawedToken); - } - } - - void OpenConditionDecisionPoint::handleUndo() { - debugMsg("SolverDecisionPoint:handleUndo", "Retracting open condition decision on " << m_flawedToken->getPredicateName().toString() << - "(" << m_flawedToken->getKey() << ")."); - m_client->cancel(m_flawedToken); - - if(m_choices[m_choiceIndex] == Token::MERGED) { - m_mergeIndex++; - if(m_mergeIndex == m_mergeCount) - m_choiceIndex++; - } - else - m_choiceIndex++; - } - - bool OpenConditionDecisionPoint::hasNext() const { - return m_choiceIndex < m_choiceCount; - } - - std::string OpenConditionDecisionPoint::toShortString() const{ - // This returns the last executed choice - int idx = m_choiceIndex; - std::stringstream os; - - if(m_choices.empty()) { - os << "EMPTY"; - } - else if(m_choices[idx] == Token::MERGED) { - os << "MRG(" << m_flawedToken->getKey() << "," << m_compatibleTokens[m_mergeIndex]->getKey() << ")"; - } - else if(m_choices[idx] == Token::ACTIVE) { - os << "ACT(" << m_flawedToken->getKey() << ")"; - } - else if(m_choices[idx] == Token::REJECTED) { - os << "REJ(" << m_flawedToken->getKey() << ")"; - } - else { - check_error(ALWAYS_FAIL,"Unknown choice:"+m_choices[idx].toString()); - } - - return os.str(); - } - - std::string OpenConditionDecisionPoint::toString() const{ - std::stringstream strStream; - strStream - << "TOKEN STATE:" - << " TOKEN=" << m_flawedToken->getPredicateName().toString() << "(" << m_flawedToken->getKey() << "):" - << " OBJECT=" << Object::toString(m_flawedToken->getObject()) << ":" - << " CHOICES(current=" << m_choiceIndex << ")="; - - if(!m_compatibleTokens.empty()){ - strStream << "MERGED {"; - for(std::vector::const_iterator it = m_compatibleTokens.begin(); it != m_compatibleTokens.end(); ++it){ - TokenId token = *it; - strStream << " " << token->getKey() << " "; - } - strStream << "}"; - } - - if (m_flawedToken->getState()->lastDomain().isMember(Token::ACTIVE) && - (!m_flawedToken->getPlanDatabase()->getConstraintEngine()->constraintConsistent() || - m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken))) - strStream << " ACTIVE "; - - if (m_flawedToken->getState()->lastDomain().isMember(Token::REJECTED)) - strStream << " REJECTED "; - - return strStream.str(); - } - - bool OpenConditionDecisionPoint::canUndo() const { - return DecisionPoint::canUndo() && m_flawedToken->getState()->isSpecified(); - } - - - SupportedOCDecisionPoint::SupportedOCDecisionPoint( - const DbClientId& client, - const TokenId& flawedToken, - const TiXmlElement& configData, - const LabelStr& explanation) - : DecisionPoint(client, flawedToken->getKey(), explanation) - , m_flawedToken(flawedToken) - , m_currentChoice(0) - , m_heuristic(NULL) - { - } +namespace SOLVERS { - SupportedOCDecisionPoint::~SupportedOCDecisionPoint() - { - for(unsigned int i=0;iisInactive()); +} - m_choices.clear(); +OpenConditionDecisionPoint::OpenConditionDecisionPoint(const DbClientId client, + const TokenId flawedToken, + const TiXmlElement&, + const std::string& explanation) + : DecisionPoint(client, flawedToken->getKey(), explanation), + m_flawedToken(flawedToken), + m_choices(), + m_compatibleTokens(), + m_mergeCount(0), + m_choiceCount(0), + m_mergeIndex(0), + m_choiceIndex(0) { - if (m_heuristic != NULL) - delete m_heuristic; - } + // Retrieve policy information from configuration node - std::string SupportedOCDecisionPoint::toString() const - { - std::ostringstream os; - os << "SupportedOCDecisionPoint:" + m_flawedToken->toString() << ":"; - os << (m_currentChoice+1) << " of " << m_choices.size() << ":"; - for (unsigned int i=0;itoString() << ":"; + // Ordering preference - merge vs. activation. Default is to merge, activate, reject. - return os.str(); - } + // Activation preference - direct vs. indirect. Default is to use direct activation +} - std::string SupportedOCDecisionPoint::toShortString() const - { - std::ostringstream os; - os << "SupportedOCDecisionPoint:" << m_flawedToken->toString() << "[" << m_currentChoice << " of " << m_choices.size() << "]"; - return os.str(); +OpenConditionDecisionPoint::~OpenConditionDecisionPoint() {} + +const TokenId OpenConditionDecisionPoint::getToken() const{ return m_flawedToken; } + +void OpenConditionDecisionPoint::handleInitialize(){ + const StateDomain stateDomain(m_flawedToken->getState()->lastDomain()); + + // Next merge choices if there are any. + if(stateDomain.isMember(Token::MERGED)){ + // Use exact test in this case + m_flawedToken->getPlanDatabase()->getCompatibleTokens( + m_flawedToken, + m_compatibleTokens, + EUROPA_UINT_MAX, + true); + m_mergeCount = m_compatibleTokens.size(); + if(m_mergeCount > 0) { + m_choices.push_back(Token::MERGED); + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Adding choice '" << Token::MERGED.toString() << "' for token " << + m_flawedToken->getKey()); } - - // TODO: move to Schema? - bool hasSupports(const TokenId& token) - { - SchemaId schema = token->getPlanDatabase()->getSchema(); - // TODO: PSToken::getTokenType() should return token type, not token type name - TokenTypeId tokenType = schema->getTokenType(token->getFullTokenType()); - std::vector supportActionTypes = schema->getTypeSupporters(tokenType); - return (supportActionTypes.size() > 0); + else { + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Skipping choice '" << Token::MERGED.toString() << "' for token " << + m_flawedToken->getKey() << " because there are no compatible tokens."); } + } + else { + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Skipping choice '" << Token::MERGED.toString() << "' for token " << + m_flawedToken->getKey() << " because it isn't in the state domain."); + } - void SupportedOCDecisionPoint::handleInitialize() - { - const StateDomain stateDomain(m_flawedToken->getState()->lastDomain()); + if(stateDomain.isMember(Token::ACTIVE) ) {//&& m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken)) + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Adding choice '" << Token::ACTIVE.toString() << "' for token " << + m_flawedToken->getKey()); + m_choices.push_back(Token::ACTIVE); + } + else { + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Skipping choice '" << Token::ACTIVE.toString() << "' for token " << + m_flawedToken->getKey() << " because it isn't in the state domain."); + } - if(stateDomain.isMember(Token::MERGED)){ - std::vector compatibleTokens; + if(stateDomain.isMember(Token::REJECTED)) { + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Adding choice '" << Token::REJECTED.toString() << "' for token " << + m_flawedToken->getKey()); + m_choices.push_back(Token::REJECTED); + } + else { + debugMsg("OpenConditionDecisionPoint:handleInitialize", + "Skipping choice '" << Token::REJECTED.toString() << "' for token " << + m_flawedToken->getKey() << " because it isn't in the state domain."); + } - m_flawedToken->getPlanDatabase()->getCompatibleTokens( - m_flawedToken, - compatibleTokens, - EUROPA_UINT_MAX, - true); + m_choiceCount = m_choices.size(); +} - // TODO: if flawed token is a fact, make sure we only look at other facts - if (compatibleTokens.size() > 0) - m_choices.push_back(new MergeToken(m_client,m_flawedToken,compatibleTokens)); - } +void OpenConditionDecisionPoint::handleExecute() { + checkError(m_choiceIndex < m_choiceCount, + "Tried to execute past available choices:" << m_choiceIndex << ">=" << m_choiceCount); + if(m_choices[m_choiceIndex] == Token::ACTIVE) { + debugMsg("SolverDecisionPoint:handleExecute", "For " << m_flawedToken->getPredicateName() << "(" << + m_flawedToken->getKey() << "), assigning ACTIVE."); + m_client->activate(m_flawedToken); + } + else if(m_choices[m_choiceIndex] == Token::MERGED) { + checkError(m_mergeIndex < m_mergeCount, "Tried to merge past available compatible tokens."); + TokenId activeToken = m_compatibleTokens[m_mergeIndex]; + debugMsg("SolverDecisionPoint:handleExecute", "For " << m_flawedToken->getPredicateName() << "(" << + m_flawedToken->getKey() << "), assigning MERGED onto " << activeToken->getPredicateName() << + "(" << activeToken->getKey() << ")."); + m_client->merge(m_flawedToken, activeToken); + } + else { + checkError(m_choices[m_choiceIndex] == Token::REJECTED, + "Expect this choice to be REJECTED instead of " + m_choices[m_choiceIndex].toString()); + debugMsg("SolverDecisionPoint:handleExecute", "For " << m_flawedToken->getPredicateName() << "(" << + m_flawedToken->getKey() << "), assigning REJECTED."); + m_client->reject(m_flawedToken); + } +} - if(stateDomain.isMember(Token::ACTIVE)) { - if (!m_flawedToken->isFact() && - !m_flawedToken->hasAttributes(PSTokenType::EFFECT) && - hasSupports(m_flawedToken)) - m_choices.push_back(new SupportToken(m_client,m_flawedToken,getSupportHeuristic())); - else - m_choices.push_back(new ActivateToken(m_client,m_flawedToken)); - } - - if(stateDomain.isMember(Token::REJECTED)) - m_choices.push_back(new RejectToken(m_client,m_flawedToken)); - } +void OpenConditionDecisionPoint::handleUndo() { + debugMsg("SolverDecisionPoint:handleUndo", "Retracting open condition decision on " << m_flawedToken->getPredicateName() << + "(" << m_flawedToken->getKey() << ")."); + m_client->cancel(m_flawedToken); - void SupportedOCDecisionPoint::handleExecute() - { - OCDecision* currentChoice = m_choices[m_currentChoice]; - currentChoice->execute(); - } + if(m_choices[m_choiceIndex] == Token::MERGED) { + m_mergeIndex++; + if(m_mergeIndex == m_mergeCount) + m_choiceIndex++; + } + else + m_choiceIndex++; +} - void SupportedOCDecisionPoint::handleUndo() - { - OCDecision* currentChoice = m_choices[m_currentChoice]; - currentChoice->undo(); - if (!currentChoice->hasNext()) - m_currentChoice++; - } +bool OpenConditionDecisionPoint::hasNext() const { + return m_choiceIndex < m_choiceCount; +} - bool SupportedOCDecisionPoint::hasNext() const - { - return (m_currentChoice < m_choices.size()); - } +std::string OpenConditionDecisionPoint::toShortString() const{ + // This returns the last executed choice + unsigned long idx = m_choiceIndex; + std::stringstream os; - bool SupportedOCDecisionPoint::canUndo() const - { - return DecisionPoint::canUndo() && m_flawedToken->getState()->isSpecified(); - } + if(m_choices.empty()) { + os << "EMPTY"; + } + else if(m_choices[idx] == Token::MERGED) { + os << "MRG(" << m_flawedToken->getKey() << "," << m_compatibleTokens[m_mergeIndex]->getKey() << ")"; + } + else if(m_choices[idx] == Token::ACTIVE) { + os << "ACT(" << m_flawedToken->getKey() << ")"; + } + else if(m_choices[idx] == Token::REJECTED) { + os << "REJ(" << m_flawedToken->getKey() << ")"; + } + else { + check_error(ALWAYS_FAIL,"Unknown choice:"+m_choices[idx].toString()); + } + return os.str(); +} - ChangeTokenState::ChangeTokenState(const DbClientId& dbClient, const TokenId& token) - : m_dbClient(dbClient) - , m_token(token) - , m_isExecuted(false) - { +std::string OpenConditionDecisionPoint::toString() const{ + std::stringstream strStream; + strStream + << "TOKEN STATE:" + << " TOKEN=" << m_flawedToken->getPredicateName() << "(" << m_flawedToken->getKey() << "):" + << " OBJECT=" << Object::toString(m_flawedToken->getObject()) << ":" + << " CHOICES(current=" << m_choiceIndex << ")="; + + if(!m_compatibleTokens.empty()){ + strStream << "MERGED {"; + for(std::vector::const_iterator it = m_compatibleTokens.begin(); it != m_compatibleTokens.end(); ++it){ + TokenId token = *it; + strStream << " " << token->getKey() << " "; } + strStream << "}"; + } - ChangeTokenState::~ChangeTokenState() - { - } - - void ChangeTokenState::undo() - { - m_dbClient->cancel(m_token); - } - - bool ChangeTokenState::hasNext() - { - return !m_isExecuted; - } - - ActivateToken::ActivateToken(const DbClientId& dbClient, const TokenId& token) - : ChangeTokenState(dbClient,token) - { - } - - ActivateToken::~ActivateToken() - { - } - - void ActivateToken::execute() - { - m_dbClient->activate(m_token); - m_isExecuted=true; - } - - std::string ActivateToken::toString() - { - return "ACTIVATE"; - } - - MergeToken::MergeToken(const DbClientId& dbClient, const TokenId& token, const std::vector& compatibleTokens) - : ChangeTokenState(dbClient,token) - , m_compatibleTokens(compatibleTokens) - , m_currentChoice(0) - { - } - - MergeToken::~MergeToken() - { - } - - void MergeToken::execute() - { - TokenId activeToken = m_compatibleTokens[m_currentChoice++]; - m_dbClient->merge(m_token,activeToken); - m_isExecuted=(m_currentChoice >= m_compatibleTokens.size()); - } - - std::string MergeToken::toString() - { - std::ostringstream os; - - os << "MERGE[" << (m_currentChoice+1) << " of " << m_compatibleTokens.size() << "] = {"; - for (unsigned int i=0;i0) - os << ","; - os << m_compatibleTokens[i]->getEntityKey(); - } - os << "}"; - - return os.str(); - } - - RejectToken::RejectToken(const DbClientId& dbClient, const TokenId& token) - : ChangeTokenState(dbClient,token) - { - } - - RejectToken::~RejectToken() - { - } - - void RejectToken::execute() - { - m_dbClient->reject(m_token); - m_isExecuted=true; - } - - std::string RejectToken::toString() - { - return "REJECT"; - } - - SupportToken::SupportToken(const DbClientId& dbClient, const TokenId& token, ActionSupportHeuristic* heuristic) - : ChangeTokenState(dbClient,token) - , m_heuristic(heuristic) - { - m_initialized = false; - } - - SupportToken::~SupportToken() - { - } - - /* - * TODO: some performance optimizations can be added for chronological backtracking: - * 1. Activate token that needs support only once - * 2. Activate each action only once and only change which effect is merged into token - */ - - std::string autoName(const std::string& prefix) - { - static int i=0; - std::stringstream os; - - os << prefix << "-" << (i++); - - return os.str(); - } - - void SupportToken::init() - { - SchemaId schema = m_dbClient->getSchema(); - // TODO: PSToken::getTokenType() should return token type, not token type name - TokenTypeId target = schema->getTokenType(m_token->getFullTokenType()); - - std::vector supports; - m_heuristic->getSupportCandidates(target,supports); - - checkError(supports.size() > 0, "Expected to find at list one support for " << target->getName()); - for (unsigned int i = 0; i(choice.m_actionType,choice.m_effectCount)); - } - - m_actionIndex = 0; - m_effectIndex = 0; - m_action = TokenId::noId(); - m_targetEffect = TokenId::noId(); - - m_initialized = true; - } - - /* For each candidate action - * For each possible effect that this token can be merged with - * 1. Activate token that needs support - * 2. Activate candidate supporting action - * 3. Merge target effect from action into token that needs support - * 4. Add all of the action's effects into the plan - */ - void SupportToken::execute() - { - if (!m_initialized) - init(); - - TokenTypeId actionType = m_choices[m_actionIndex].first; - - debugMsg("SupportToken", "Activating supporting action:" << actionType->getName() << " for \n" << m_token->toLongString()); - - // 1. Activate token that needs support - m_dbClient->activate(m_token); - - // 2. Activate candidate supporting action - m_action = m_dbClient->createToken( - actionType->getSignature().c_str(), // TODO: getSignature() should be getQualifiedName(), or something like that - autoName(actionType->getName()).c_str(), - false, //isRejectable - false //isFact - ); - m_dbClient->activate(m_action); - - debugMsg("SupportToken", "Activated supporting action:\n" << m_action->toLongString()); - - // 3. Merge target effect from action into token that needs support - int effectCnt = 0; - PSList slaves = m_action->getSlaves(); - for (int i=0;ihasAttributes(PSTokenType::EFFECT)) { - if (slave->getFullTokenType() == m_token->getFullTokenType()) { // TODO: use ids - if (effectCnt == m_effectIndex) { - // TODO: eliminate the need for the dynamic cast below - TokenId slaveId = dynamic_cast(slave)->getId(); - m_targetEffect = slaveId; - m_dbClient->merge(m_targetEffect,m_token); - break; - } - else - effectCnt++; - } - } - } - checkError(m_targetEffect.isId(),"Expected effect to support fluent"); - - debugMsg("SupportToken", "Merged with target effect:\n" << m_targetEffect->toLongString()); - debugMsg("SupportToken", "Supported token:\n" << m_token->toLongString()); - debugMsg("SupportToken", "Supporting action:\n" << m_action->toLongString()); - - // 4. Add all of the action's effects into the plan - // TODO: make sure that all of the activate/merge decisions for the action's effects are processed next - // before any other choicepoints are considered - - m_effectIndex++; - if (m_effectIndex >= m_choices[m_actionIndex].second) { - m_actionIndex++; - m_effectIndex=0; - } - m_isExecuted = ((unsigned int)m_actionIndex >= m_choices.size()); - } - - /* - * Rollback execute() in reverse order: - * 1. Remove action's effects from the plan - * 2. Cancel the support provided by the candidate action - * 3. Destroy candidate action that was created by this decision point - * 4. Cancel the activation of the token that needed support - */ - void SupportToken::undo() - { - // 1. Remove action's effects from the plan - // TODO: In the context of chronological backtracking all the effects should be removed by now - // otherwise we may have to explicitly undo the entire slave tree for the supporting action - - // 2. Cancel the support provided by the candidate action - m_dbClient->cancel(m_targetEffect); - m_targetEffect = TokenId::noId(); - - // 3. Destroy candidate action that was created by this decision point - m_dbClient->cancel(m_action); - delete (Token*)m_action; - m_action = TokenId::noId(); - - // 4. Cancel the activation of the token that needed support - m_dbClient->cancel(m_token); - } - - std::string SupportToken::toString() - { - std::ostringstream os; - - os << "SUPPORT[" << (m_actionIndex+1) << " of " << m_choices.size() << "] = {"; - for (unsigned int i=0;i0) - os << ","; - os << m_choices[i].first->getName(); - } - os << "}"; - - return os.str(); - } - - SupportChoice::SupportChoice( - const TokenTypeId& target, - const TokenTypeId& actionType, - int effectCount, - const std::vector< ParamValues >& paramValues) - : m_target(target) - , m_actionType(actionType) - , m_effectCount(effectCount) - , m_paramValues(paramValues) - { - - } - - SupportChoice::~SupportChoice() - { - } - - - class DefaultActionSupportHeuristic : public ActionSupportHeuristic - { - public: - DefaultActionSupportHeuristic(const SchemaId& schema); - virtual ~DefaultActionSupportHeuristic(); - - void getSupportCandidates( - const TokenTypeId& target, - std::vector& supports); - protected: - SchemaId m_schema; - }; - - DefaultActionSupportHeuristic::DefaultActionSupportHeuristic(const SchemaId& schema) - : m_schema(schema) - { - } + if (m_flawedToken->getState()->lastDomain().isMember(Token::ACTIVE) && + (!m_flawedToken->getPlanDatabase()->getConstraintEngine()->constraintConsistent() || + m_flawedToken->getPlanDatabase()->hasOrderingChoice(m_flawedToken))) + strStream << " ACTIVE "; - DefaultActionSupportHeuristic::~DefaultActionSupportHeuristic() - { - } + if (m_flawedToken->getState()->lastDomain().isMember(Token::REJECTED)) + strStream << " REJECTED "; + + return strStream.str(); +} + +bool OpenConditionDecisionPoint::canUndo() const { + return DecisionPoint::canUndo() && m_flawedToken->getState()->isSpecified(); +} - void DefaultActionSupportHeuristic::getSupportCandidates( - const TokenTypeId& target, - std::vector& supports) - { - debugMsg("getSupportCandidates", "Flawed Token Type:" << target->getName()); - //target->getObjectType()->getNameString() << ":" << target->getName()); - - std::vector supportActionTypes = m_schema->getTypeSupporters(target); - for (unsigned int i = 0;i effectTypes = tt->getSubgoalsByAttr(PSTokenType::EFFECT); - debugMsg("getSupportCandidates", "Support Type:" << tt->getObjectType()->getNameString() << ":" << tt->getName()); - for (int j=0;jgetName() << " and " << effectTypes.get(j)->getName()); - if (target->getName() == effectTypes.get(j)->getName()) { - mergeCnt++; - debugMsg("getSupportCandidates", "Found match!"); - } - } - - checkError(mergeCnt > 0, "Expected to find at list one merge point for " << target->getName() << " in " << tt->getName()); - // TODO: cache this result - supports.push_back(SupportChoice(target,tt,mergeCnt)); - } + +SupportedOCDecisionPoint::SupportedOCDecisionPoint( + const DbClientId client, + const TokenId flawedToken, + const TiXmlElement&, + const std::string& explanation) + : DecisionPoint(client, flawedToken->getKey(), explanation) + , m_flawedToken(flawedToken) + , m_choices() + , m_currentChoice(0) + , m_heuristic(NULL) +{ +} + +SupportedOCDecisionPoint::~SupportedOCDecisionPoint() +{ + for(unsigned int i=0;itoString() << ":"; + os << (m_currentChoice+1) << " of " << m_choices.size() << ":"; + for (unsigned int i=0;itoString() << ":"; + + return os.str(); +} + +std::string SupportedOCDecisionPoint::toShortString() const +{ + std::ostringstream os; + os << "SupportedOCDecisionPoint:" << m_flawedToken->toString() << "[" << m_currentChoice << " of " << m_choices.size() << "]"; + return os.str(); +} + +namespace { +// TODO: move to Schema? +bool hasSupports(const TokenId token) +{ + SchemaId schema = token->getPlanDatabase()->getSchema(); + // TODO: PSToken::getTokenType() should return token type, not token type name + TokenTypeId tokenType = schema->getTokenType(token->getFullTokenType()); + std::vector supportActionTypes = schema->getTypeSupporters(tokenType); + return (supportActionTypes.size() > 0); +} +} + +void SupportedOCDecisionPoint::handleInitialize() +{ + const StateDomain stateDomain(m_flawedToken->getState()->lastDomain()); + + if(stateDomain.isMember(Token::MERGED)){ + std::vector compatibleTokens; + + m_flawedToken->getPlanDatabase()->getCompatibleTokens( + m_flawedToken, + compatibleTokens, + EUROPA_UINT_MAX, + true); + + // TODO: if flawed token is a fact, make sure we only look at other facts + if (compatibleTokens.size() > 0) + m_choices.push_back(new MergeToken(m_client,m_flawedToken,compatibleTokens)); + } + + if(stateDomain.isMember(Token::ACTIVE)) { + if (!m_flawedToken->isFact() && + !m_flawedToken->hasAttributes(PSTokenType::EFFECT) && + hasSupports(m_flawedToken)) + m_choices.push_back(new SupportToken(m_client,m_flawedToken,getSupportHeuristic())); + else + m_choices.push_back(new ActivateToken(m_client,m_flawedToken)); + } + + if(stateDomain.isMember(Token::REJECTED)) + m_choices.push_back(new RejectToken(m_client,m_flawedToken)); +} + +void SupportedOCDecisionPoint::handleExecute() +{ + OCDecision* currentChoice = m_choices[m_currentChoice]; + currentChoice->execute(); +} + +void SupportedOCDecisionPoint::handleUndo() +{ + OCDecision* currentChoice = m_choices[m_currentChoice]; + currentChoice->undo(); + if (!currentChoice->hasNext()) + m_currentChoice++; +} + +bool SupportedOCDecisionPoint::hasNext() const +{ + return (m_currentChoice < m_choices.size()); +} + +bool SupportedOCDecisionPoint::canUndo() const +{ + return DecisionPoint::canUndo() && m_flawedToken->getState()->isSpecified(); +} + + +ChangeTokenState::ChangeTokenState(const DbClientId dbClient, const TokenId token) + : m_dbClient(dbClient) + , m_token(token) + , m_isExecuted(false) +{ +} + +ChangeTokenState::~ChangeTokenState() +{ +} + +void ChangeTokenState::undo() +{ + m_dbClient->cancel(m_token); +} + +bool ChangeTokenState::hasNext() +{ + return !m_isExecuted; +} + +ActivateToken::ActivateToken(const DbClientId dbClient, const TokenId token) + : ChangeTokenState(dbClient,token) +{ +} + +ActivateToken::~ActivateToken() +{ +} + +void ActivateToken::execute() +{ + m_dbClient->activate(m_token); + m_isExecuted=true; +} + +std::string ActivateToken::toString() +{ + return "ACTIVATE"; +} + +MergeToken::MergeToken(const DbClientId dbClient, const TokenId token, const std::vector& compatibleTokens) + : ChangeTokenState(dbClient,token) + , m_compatibleTokens(compatibleTokens) + , m_currentChoice(0) +{ +} + +MergeToken::~MergeToken() +{ +} + +void MergeToken::execute() +{ + TokenId activeToken = m_compatibleTokens[m_currentChoice++]; + m_dbClient->merge(m_token,activeToken); + m_isExecuted=(m_currentChoice >= m_compatibleTokens.size()); +} + +std::string MergeToken::toString() +{ + std::ostringstream os; + + os << "MERGE[" << (m_currentChoice+1) << " of " << m_compatibleTokens.size() << "] = {"; + for (unsigned int i=0;i0) + os << ","; + os << m_compatibleTokens[i]->getEntityKey(); + } + os << "}"; + + return os.str(); +} + +RejectToken::RejectToken(const DbClientId dbClient, const TokenId token) + : ChangeTokenState(dbClient,token) +{ +} + +RejectToken::~RejectToken() +{ +} + +void RejectToken::execute() +{ + m_dbClient->reject(m_token); + m_isExecuted=true; +} + +std::string RejectToken::toString() +{ + return "REJECT"; +} + +SupportToken::SupportToken(const DbClientId dbClient, const TokenId token, + ActionSupportHeuristic* heuristic) + : ChangeTokenState(dbClient,token), m_choices(), m_actionIndex(0), + m_effectIndex(0), m_action(), m_targetEffect(), m_heuristic(heuristic), + m_initialized(false) {} + +SupportToken::~SupportToken() {} + +/* + * TODO: some performance optimizations can be added for chronological backtracking: + * 1. Activate token that needs support only once + * 2. Activate each action only once and only change which effect is merged into token + */ + +namespace { +std::string autoName(const std::string& prefix) { + static int i=0; + std::stringstream os; + + os << prefix << "-" << (i++); + + return os.str(); +} +} + +void SupportToken::init() +{ + SchemaId schema = m_dbClient->getSchema(); + // TODO: PSToken::getTokenType() should return token type, not token type name + TokenTypeId target = schema->getTokenType(m_token->getFullTokenType()); + + std::vector supports; + m_heuristic->getSupportCandidates(target,supports); + + checkError(supports.size() > 0, "Expected to find at list one support for " << target->getName()); + for (unsigned int i = 0; i(choice.m_actionType,choice.m_effectCount)); + } + + m_actionIndex = 0; + m_effectIndex = 0; + m_action = TokenId::noId(); + m_targetEffect = TokenId::noId(); + + m_initialized = true; +} + +/* For each candidate action + * For each possible effect that this token can be merged with + * 1. Activate token that needs support + * 2. Activate candidate supporting action + * 3. Merge target effect from action into token that needs support + * 4. Add all of the action's effects into the plan + */ +void SupportToken::execute() +{ + if (!m_initialized) + init(); + + TokenTypeId actionType = m_choices[m_actionIndex].first; + + debugMsg("SupportToken", "Activating supporting action:" << actionType->getName() << " for \n" << m_token->toLongString()); + + // 1. Activate token that needs support + m_dbClient->activate(m_token); + + // 2. Activate candidate supporting action + m_action = m_dbClient->createToken( + actionType->getSignature().c_str(), // TODO: getSignature() should be getQualifiedName(), or something like that + autoName(actionType->getName()).c_str(), + false, //isRejectable + false //isFact + ); + m_dbClient->activate(m_action); + + debugMsg("SupportToken", "Activated supporting action:\n" << m_action->toLongString()); + + // 3. Merge target effect from action into token that needs support + unsigned long effectCnt = 0; + PSList slaves = m_action->getSlaves(); + for (long i=0; ihasAttributes(PSTokenType::EFFECT)) { + if (slave->getFullTokenType() == m_token->getFullTokenType()) { // TODO: use ids + if (effectCnt == m_effectIndex) { + // TODO: eliminate the need for the dynamic cast below + TokenId slaveId = dynamic_cast(slave)->getId(); + m_targetEffect = slaveId; + m_dbClient->merge(m_targetEffect,m_token); + break; + } + else + effectCnt++; + } } + } + checkError(m_targetEffect.isId(),"Expected effect to support fluent"); + + debugMsg("SupportToken", "Merged with target effect:\n" << m_targetEffect->toLongString()); + debugMsg("SupportToken", "Supported token:\n" << m_token->toLongString()); + debugMsg("SupportToken", "Supporting action:\n" << m_action->toLongString()); + + // 4. Add all of the action's effects into the plan + // TODO: make sure that all of the activate/merge decisions for the action's effects are processed next + // before any other choicepoints are considered + + m_effectIndex++; + if (m_effectIndex >= m_choices[m_actionIndex].second) { + m_actionIndex++; + m_effectIndex=0; + } + m_isExecuted = (m_actionIndex >= m_choices.size()); +} + +/* + * Rollback execute() in reverse order: + * 1. Remove action's effects from the plan + * 2. Cancel the support provided by the candidate action + * 3. Destroy candidate action that was created by this decision point + * 4. Cancel the activation of the token that needed support + */ +void SupportToken::undo() +{ + // 1. Remove action's effects from the plan + // TODO: In the context of chronological backtracking all the effects should be removed by now + // otherwise we may have to explicitly undo the entire slave tree for the supporting action + + // 2. Cancel the support provided by the candidate action + m_dbClient->cancel(m_targetEffect); + m_targetEffect = TokenId::noId(); + + // 3. Destroy candidate action that was created by this decision point + m_dbClient->cancel(m_action); + delete static_cast(m_action); + m_action = TokenId::noId(); + + // 4. Cancel the activation of the token that needed support + m_dbClient->cancel(m_token); +} + +std::string SupportToken::toString() +{ + std::ostringstream os; + + os << "SUPPORT[" << (m_actionIndex+1) << " of " << m_choices.size() << "] = {"; + for (unsigned int i=0;i0) + os << ","; + os << m_choices[i].first->getName(); + } + os << "}"; - ActionSupportHeuristic* SupportedOCDecisionPoint::getSupportHeuristic() - { - // TODO: get heuristic from FlawManager, set through configuration - if (m_heuristic == NULL) - m_heuristic = new DefaultActionSupportHeuristic(m_client->getSchema()); + return os.str(); +} + +SupportChoice::SupportChoice( + const TokenTypeId target, + const TokenTypeId actionType, + int effectCount, + const std::vector< ParamValues >& paramValues) + : m_target(target) + , m_actionType(actionType) + , m_effectCount(effectCount) + , m_paramValues(paramValues) +{ + +} + +SupportChoice::~SupportChoice() +{ +} + + +class DefaultActionSupportHeuristic : public ActionSupportHeuristic +{ + public: + DefaultActionSupportHeuristic(const SchemaId schema); + virtual ~DefaultActionSupportHeuristic(); - return m_heuristic; + void getSupportCandidates( + const TokenTypeId target, + std::vector& supports); + protected: + SchemaId m_schema; +}; + +DefaultActionSupportHeuristic::DefaultActionSupportHeuristic(const SchemaId schema) + : m_schema(schema) +{ +} + +DefaultActionSupportHeuristic::~DefaultActionSupportHeuristic() +{ +} + +void DefaultActionSupportHeuristic::getSupportCandidates( + const TokenTypeId target, + std::vector& supports) +{ + debugMsg("getSupportCandidates", "Flawed Token Type:" << target->getName()); + //target->getObjectType()->getNameString() << ":" << target->getName()); + + std::vector supportActionTypes = m_schema->getTypeSupporters(target); + for (unsigned int i = 0;i effectTypes = tt->getSubgoalsByAttr(PSTokenType::EFFECT); + debugMsg("getSupportCandidates", "Support Type:" << tt->getObjectType()->getNameString() << ":" << tt->getName()); + for (int j=0;jgetName() << " and " << effectTypes.get(j)->getName()); + if (target->getName() == effectTypes.get(j)->getName()) { + mergeCnt++; + debugMsg("getSupportCandidates", "Found match!"); + } } + checkError(mergeCnt > 0, "Expected to find at list one merge point for " << target->getName() << " in " << tt->getName()); + // TODO: cache this result + supports.push_back(SupportChoice(target,tt,mergeCnt)); } } +ActionSupportHeuristic* SupportedOCDecisionPoint::getSupportHeuristic() +{ + // TODO: get heuristic from FlawManager, set through configuration + if (m_heuristic == NULL) + m_heuristic = new DefaultActionSupportHeuristic(m_client->getSchema()); + + return m_heuristic; +} + +} +} + diff --git a/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.hh b/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.hh index 286b621a7..f776b9756 100644 --- a/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.hh +++ b/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.hh @@ -29,8 +29,8 @@ namespace EUROPA { /** * @brief Constructor. Test signature for DecisionPointFactory */ - OpenConditionDecisionPoint(const DbClientId& client, const TokenId& flawedToken, const TiXmlElement& configData, - const LabelStr& explanation = "unknown"); + OpenConditionDecisionPoint(const DbClientId client, const TokenId flawedToken, const TiXmlElement& configData, + const std::string& explanation = "unknown"); virtual ~OpenConditionDecisionPoint(); @@ -48,7 +48,7 @@ namespace EUROPA { /** * @brief Used to prune entities out which are not inactive tokens */ - static bool test(const EntityId& entity); + static bool test(const EntityId entity); virtual std::string toString() const; virtual std::string toShortString() const; @@ -56,7 +56,7 @@ namespace EUROPA { /** * @brief Accessor to flawed token */ - const TokenId& getToken() const; + const TokenId getToken() const; protected: virtual void handleInitialize(); @@ -68,10 +68,10 @@ namespace EUROPA { const TokenId m_flawedToken; /*!< The token to be resolved. */ std::vector m_choices; /*!< The sequences list of states to choose. */ std::vector m_compatibleTokens; /*!< A possibly empty collection of tokens to merge with. */ - unsigned int m_mergeCount; /*!< The size of m_compatibleTokens */ - unsigned int m_choiceCount; /*!< The size of m_choices. */ - unsigned int m_mergeIndex; /*!< The position of the next choice in m_compatibleTokens. */ - unsigned int m_choiceIndex; /*!< The position of the next choice in m_choices. */ + unsigned long m_mergeCount; /*!< The size of m_compatibleTokens */ + unsigned long m_choiceCount; /*!< The size of m_choices. */ + unsigned long m_mergeIndex; /*!< The position of the next choice in m_compatibleTokens. */ + unsigned long m_choiceIndex; /*!< The position of the next choice in m_choices. */ }; @@ -96,39 +96,41 @@ namespace EUROPA { class ActionSupportHeuristic; - class SupportedOCDecisionPoint : public DecisionPoint - { - public: - SupportedOCDecisionPoint( - const DbClientId& client, - const TokenId& flawedToken, - const TiXmlElement& configData, - const LabelStr& explanation = "unknown"); - - virtual ~SupportedOCDecisionPoint(); - - virtual std::string toString() const; - virtual std::string toShortString() const; - - protected: - virtual void handleInitialize(); - virtual void handleExecute(); - virtual void handleUndo(); - virtual bool hasNext() const; - virtual bool canUndo() const; - - ActionSupportHeuristic* getSupportHeuristic(); - - const TokenId m_flawedToken; /*!< The token to be resolved. */ - std::vector m_choices; - unsigned int m_currentChoice; - ActionSupportHeuristic* m_heuristic; - }; + class SupportedOCDecisionPoint : public DecisionPoint { + public: + SupportedOCDecisionPoint( + const DbClientId client, + const TokenId flawedToken, + const TiXmlElement& configData, + const std::string& explanation = "unknown"); + + virtual ~SupportedOCDecisionPoint(); + + virtual std::string toString() const; + virtual std::string toShortString() const; + + protected: + virtual void handleInitialize(); + virtual void handleExecute(); + virtual void handleUndo(); + virtual bool hasNext() const; + virtual bool canUndo() const; + + ActionSupportHeuristic* getSupportHeuristic(); + + const TokenId m_flawedToken; /*!< The token to be resolved. */ + std::vector m_choices; + unsigned int m_currentChoice; + ActionSupportHeuristic* m_heuristic; +private: + SupportedOCDecisionPoint(const SupportedOCDecisionPoint&); + SupportedOCDecisionPoint& operator=(const SupportedOCDecisionPoint&); + }; class ChangeTokenState : public OCDecision { public: - ChangeTokenState(const DbClientId& dbClient, const TokenId& token); + ChangeTokenState(const DbClientId dbClient, const TokenId token); virtual ~ChangeTokenState(); virtual void undo(); @@ -143,7 +145,7 @@ namespace EUROPA { class ActivateToken : public ChangeTokenState { public: - ActivateToken(const DbClientId& dbClient, const TokenId& token); + ActivateToken(const DbClientId dbClient, const TokenId token); virtual ~ActivateToken(); virtual void execute(); @@ -154,7 +156,7 @@ namespace EUROPA { class MergeToken : public ChangeTokenState { public: - MergeToken(const DbClientId& dbClient, const TokenId& token, const std::vector& compatibleTokens); + MergeToken(const DbClientId dbClient, const TokenId token, const std::vector& compatibleTokens); virtual ~MergeToken(); virtual void execute(); @@ -169,7 +171,7 @@ namespace EUROPA { class RejectToken : public ChangeTokenState { public: - RejectToken(const DbClientId& dbClient, const TokenId& token); + RejectToken(const DbClientId dbClient, const TokenId token); virtual ~RejectToken(); virtual void execute(); @@ -177,27 +179,29 @@ namespace EUROPA { }; - class SupportToken : public ChangeTokenState - { - public: - SupportToken(const DbClientId& dbClient, const TokenId& token, ActionSupportHeuristic* heuristic); - virtual ~SupportToken(); - - virtual void execute(); - virtual void undo(); - virtual std::string toString(); - - protected: - std::vector > m_choices; - int m_actionIndex; - int m_effectIndex; - TokenId m_action; - TokenId m_targetEffect; - ActionSupportHeuristic* m_heuristic; - bool m_initialized; - - void init(); - }; + class SupportToken : public ChangeTokenState { + public: + SupportToken(const DbClientId dbClient, const TokenId token, ActionSupportHeuristic* heuristic); + virtual ~SupportToken(); + + virtual void execute(); + virtual void undo(); + virtual std::string toString(); + + protected: + std::vector > m_choices; + unsigned long m_actionIndex; + unsigned long m_effectIndex; + TokenId m_action; + TokenId m_targetEffect; + ActionSupportHeuristic* m_heuristic; + bool m_initialized; + + void init(); +private: + SupportToken(const SupportToken&); + SupportToken& operator=(const SupportToken&); + }; typedef std::vector< std::pair > ParamValues; @@ -205,8 +209,8 @@ namespace EUROPA { { public: SupportChoice( - const TokenTypeId& target, - const TokenTypeId& actionType, + const TokenTypeId target, + const TokenTypeId actionType, int effectCount, const std::vector< ParamValues >& paramValues = std::vector< ParamValues >()); virtual ~SupportChoice(); @@ -223,7 +227,7 @@ namespace EUROPA { virtual ~ActionSupportHeuristic() {}; virtual void getSupportCandidates( - const TokenTypeId& target, + const TokenTypeId target, std::vector& supports) = 0; protected: ActionSupportHeuristic() {}; diff --git a/src/PLASMA/Solvers/component/OpenConditionManager.cc b/src/PLASMA/Solvers/component/OpenConditionManager.cc index bbbdc9d50..669f19ad6 100644 --- a/src/PLASMA/Solvers/component/OpenConditionManager.cc +++ b/src/PLASMA/Solvers/component/OpenConditionManager.cc @@ -12,10 +12,10 @@ * @date March, 2005 */ namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - OpenConditionManager::OpenConditionManager(const TiXmlElement& configData) - : FlawManager(configData) {} +OpenConditionManager::OpenConditionManager(const TiXmlElement& configData) + : FlawManager(configData), m_flawCandidates() {} void OpenConditionManager::handleInitialize(){ // FILL UP TOKENS @@ -25,15 +25,20 @@ namespace EUROPA { addFlaw(token); } } + + bool OpenConditionManager::noMoreFlaws() { + return m_flawCandidates.empty(); + } + /** * Filter out if not a token */ - bool OpenConditionManager::staticMatch(const EntityId& entity){ + bool OpenConditionManager::staticMatch(const EntityId entity){ return !TokenId::convertable(entity) || FlawManager::staticMatch(entity); } - void OpenConditionManager::addFlaw(const TokenId& token){ + void OpenConditionManager::addFlaw(const TokenId token){ if(token->isInactive() && !staticMatch(token)){ debugMsg("OpenConditionManager:addFlaw", "Adding " << token->toString() << " as a candidate flaw."); @@ -41,18 +46,18 @@ namespace EUROPA { } } - void OpenConditionManager::removeFlaw(const TokenId& token){ + void OpenConditionManager::removeFlaw(const TokenId token){ condDebugMsg(m_flawCandidates.find(token) != m_flawCandidates.end(), "OpenConditionManager:removeFlaw", "Removing " << token->toString() << " as a flaw."); m_flawCandidates.erase(token); } - void OpenConditionManager::notifyRemoved(const ConstrainedVariableId& variable){ + void OpenConditionManager::notifyRemoved(const ConstrainedVariableId variable){ FlawManager::notifyRemoved(variable); if(Token::isStateVariable(variable)) removeFlaw(variable->parent()); } - void OpenConditionManager::notifyChanged(const ConstrainedVariableId& variable, + void OpenConditionManager::notifyChanged(const ConstrainedVariableId variable, const DomainListener::ChangeType& changeType){ if(!Token::isStateVariable(variable)) return; @@ -67,7 +72,7 @@ namespace EUROPA { DecisionPointId OpenConditionManager::nextZeroCommitmentDecision() { - static LabelStr explanation("Processing action effects first"); + static std::string explanation("Processing action effects first"); for(TokenSet::const_iterator it=m_flawCandidates.begin();it != m_flawCandidates.end();++it) { TokenId token = *it; @@ -83,7 +88,7 @@ namespace EUROPA { return DecisionPointId::noId(); } - std::string OpenConditionManager::toString(const EntityId& entity) const { + std::string OpenConditionManager::toString(const EntityId entity) const { checkError(TokenId::convertable(entity), entity->toString()); TokenId token = entity; std::stringstream os; diff --git a/src/PLASMA/Solvers/component/OpenConditionManager.hh b/src/PLASMA/Solvers/component/OpenConditionManager.hh index d8e5e8cca..24e9d50fa 100644 --- a/src/PLASMA/Solvers/component/OpenConditionManager.hh +++ b/src/PLASMA/Solvers/component/OpenConditionManager.hh @@ -12,29 +12,30 @@ * @date March, 2005 */ namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { class OpenConditionManager: public FlawManager { public: OpenConditionManager(const TiXmlElement& configData); - virtual bool staticMatch(const EntityId& entity); + virtual bool staticMatch(const EntityId entity); virtual IteratorId createIterator(); virtual DecisionPointId nextZeroCommitmentDecision(); - virtual std::string toString(const EntityId& entity) const; + virtual std::string toString(const EntityId entity) const; + bool noMoreFlaws(); protected: - virtual void addFlaw(const TokenId& token); - virtual void removeFlaw(const TokenId& token); + virtual void addFlaw(const TokenId token); + virtual void removeFlaw(const TokenId token); virtual void handleInitialize(); private: friend class OpenConditionIterator; - void notifyRemoved(const ConstrainedVariableId& variable); - void notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType); + void notifyRemoved(const ConstrainedVariableId variable); + void notifyChanged(const ConstrainedVariableId variable, const DomainListener::ChangeType& changeType); TokenSet m_flawCandidates; /*!< The set of candidate token flaws */ }; diff --git a/src/PLASMA/Solvers/component/PSSolversImpl.cc b/src/PLASMA/Solvers/component/PSSolversImpl.cc index daa722a19..f772cec1c 100644 --- a/src/PLASMA/Solvers/component/PSSolversImpl.cc +++ b/src/PLASMA/Solvers/component/PSSolversImpl.cc @@ -2,6 +2,8 @@ #include "PSSolversImpl.hh" #include "Filters.hh" #include "Solver.hh" +#include "Context.hh" +#include "tinyxml.h" namespace EUROPA { @@ -21,7 +23,7 @@ namespace EUROPA return new PSSolverImpl(solver,configurationFile); } - PSSolverImpl::PSSolverImpl(const SOLVERS::SolverId& solver, const std::string& configFilename) + PSSolverImpl::PSSolverImpl(const SOLVERS::SolverId solver, const std::string& configFilename) : m_solver(solver) , m_configFile(configFilename) { @@ -36,9 +38,10 @@ namespace EUROPA m_solver->step(); } - void PSSolverImpl::solve(int maxSteps, int maxDepth) { - m_solver->solve(maxSteps, maxDepth); - } +bool PSSolverImpl::solve(int maxSteps, int maxDepth) { + return m_solver->solve(static_cast(maxSteps), + static_cast(maxDepth)); +} bool PSSolverImpl::backjump(unsigned int stepCount) { return m_solver->backjump(stepCount); @@ -53,16 +56,16 @@ namespace EUROPA } void PSSolverImpl::destroy() { - delete (SOLVERS::Solver*) m_solver; + delete static_cast(m_solver); m_solver = SOLVERS::SolverId::noId(); } int PSSolverImpl::getStepCount() { - return (int) m_solver->getStepCount(); + return static_cast(m_solver->getStepCount()); } int PSSolverImpl::getDepth() { - return (int) m_solver->getDepth(); + return static_cast(m_solver->getDepth()); } bool PSSolverImpl::isExhausted() { @@ -88,7 +91,7 @@ namespace EUROPA count++; flawIt->next(); } - delete (Iterator*) flawIt; + delete static_cast(flawIt); return count; } @@ -122,17 +125,17 @@ namespace EUROPA const std::string& PSSolverImpl::getConfigFilename() {return m_configFile;} eint::basis_type PSSolverImpl::getHorizonStart() { - return cast_int(SOLVERS::HorizonFilter::getHorizon().getLowerBound()); + return static_cast(m_solver->getContext()->get("horizonStart")); } eint::basis_type PSSolverImpl::getHorizonEnd() { - return cast_int(SOLVERS::HorizonFilter::getHorizon().getUpperBound()); + return static_cast(m_solver->getContext()->get("horizonEnd")); } void PSSolverImpl::configure(eint::basis_type horizonStart, eint::basis_type horizonEnd) { check_runtime_error(horizonStart <= horizonEnd); - SOLVERS::HorizonFilter::getHorizon().reset(IntervalIntDomain()); - SOLVERS::HorizonFilter::getHorizon().intersect(horizonStart, horizonEnd); + m_solver->getContext()->put("horizonStart", static_cast(horizonStart)); + m_solver->getContext()->put("horizonEnd", static_cast(horizonEnd)); } } diff --git a/src/PLASMA/Solvers/component/PSSolversImpl.hh b/src/PLASMA/Solvers/component/PSSolversImpl.hh index ed5e49aff..5bed1f724 100644 --- a/src/PLASMA/Solvers/component/PSSolversImpl.hh +++ b/src/PLASMA/Solvers/component/PSSolversImpl.hh @@ -1,5 +1,5 @@ -#ifndef _H_PSSolversImpl -#define _H_PSSolversImpl +#ifndef H_PSSolversImpl +#define H_PSSolversImpl #include "PSSolvers.hh" #include "ConstraintEngineDefs.hh" @@ -20,42 +20,41 @@ namespace EUROPA PlanDatabaseId m_pdb; }; - class PSSolverImpl : public PSSolver - { - public: - PSSolverImpl(const SOLVERS::SolverId& solver, - const std::string& configFilename); - virtual ~PSSolverImpl(); - - virtual void step(); - virtual void solve(int maxSteps,int maxDepth); - virtual bool backjump(unsigned int stepCount); - virtual void reset(); - virtual void reset(unsigned int depth); - virtual void destroy(); - - virtual int getStepCount(); - virtual int getDepth(); - virtual int getOpenDecisionCnt(); - - virtual bool isExhausted(); - virtual bool isTimedOut(); - virtual bool isConstraintConsistent(); - - virtual bool hasFlaws(); - virtual PSList getFlaws(); - virtual std::string getLastExecutedDecision(); - - virtual const std::string& getConfigFilename(); - virtual eint::basis_type getHorizonStart(); - virtual eint::basis_type getHorizonEnd(); - - virtual void configure(eint::basis_type horizonStart, eint::basis_type horizonEnd); - - protected: - SOLVERS::SolverId m_solver; - std::string m_configFile; - }; +class PSSolverImpl : public PSSolver { + public: + PSSolverImpl(const SOLVERS::SolverId solver, + const std::string& configFilename); + virtual ~PSSolverImpl(); + + virtual void step(); + virtual bool solve(int maxSteps,int maxDepth); + virtual bool backjump(unsigned int stepCount); + virtual void reset(); + virtual void reset(unsigned int depth); + virtual void destroy(); + + virtual int getStepCount(); + virtual int getDepth(); + virtual int getOpenDecisionCnt(); + + virtual bool isExhausted(); + virtual bool isTimedOut(); + virtual bool isConstraintConsistent(); + + virtual bool hasFlaws(); + virtual PSList getFlaws(); + virtual std::string getLastExecutedDecision(); + + virtual const std::string& getConfigFilename(); + virtual eint::basis_type getHorizonStart(); + virtual eint::basis_type getHorizonEnd(); + + virtual void configure(eint::basis_type horizonStart, eint::basis_type horizonEnd); + + protected: + SOLVERS::SolverId m_solver; + std::string m_configFile; +}; } diff --git a/src/PLASMA/Solvers/component/ThreatDecisionPoint.cc b/src/PLASMA/Solvers/component/ThreatDecisionPoint.cc index aa41debed..a457b2b1b 100644 --- a/src/PLASMA/Solvers/component/ThreatDecisionPoint.cc +++ b/src/PLASMA/Solvers/component/ThreatDecisionPoint.cc @@ -14,12 +14,16 @@ namespace EUROPA { namespace SOLVERS { - bool ThreatDecisionPoint::test(const EntityId& entity){ + bool ThreatDecisionPoint::test(const EntityId entity){ return(TokenId::convertable(entity) || TokenId(entity)->isActive()); } - ThreatDecisionPoint::ThreatDecisionPoint(const DbClientId& client, const TokenId& tokenToOrder, const TiXmlElement& configData, const LabelStr& explanation) - : DecisionPoint(client, tokenToOrder->getKey(), explanation), m_tokenToOrder(tokenToOrder), m_index(0) { + ThreatDecisionPoint::ThreatDecisionPoint(const DbClientId client, + const TokenId tokenToOrder, + const TiXmlElement&, + const std::string& explanation) + : DecisionPoint(client, tokenToOrder->getKey(), explanation), + m_tokenToOrder(tokenToOrder), m_choices(), m_choiceCount(0), m_index(0) { // Here is where we would look for custom processing for configuration of the decision point } @@ -34,15 +38,15 @@ namespace EUROPA { "Given token must be part of assignment." << m_tokenToOrder->toString() << ";" << predecessor->toString() << "; " << successor->toString()); - debugMsg("SolverDecisionPoint:handleExecute", "For " << m_tokenToOrder->getPredicateName().toString() << "(" << - m_tokenToOrder->getKey() << "), assigning " << predecessor->getPredicateName().toString() << "(" << - predecessor->getKey() << ") to be before " << successor->getPredicateName().toString() << "(" << + debugMsg("SolverDecisionPoint:handleExecute", "For " << m_tokenToOrder->getPredicateName() << "(" << + m_tokenToOrder->getKey() << "), assigning " << predecessor->getPredicateName() << "(" << + predecessor->getKey() << ") to be before " << successor->getPredicateName() << "(" << successor->getKey() << ")."); m_client->constrain(object, predecessor, successor); } void ThreatDecisionPoint::handleUndo(){ - debugMsg("SolverDecisionPoint:handleUndo", "Retracting ordering decision on " << m_tokenToOrder->getPredicateName().toString() << + debugMsg("SolverDecisionPoint:handleUndo", "Retracting ordering decision on " << m_tokenToOrder->getPredicateName() << "(" << m_tokenToOrder->getKey() << ")."); ObjectId object; TokenId predecessor; @@ -68,7 +72,7 @@ namespace EUROPA { ObjectId o2 = p2.first; return o1->getKey() < o2->getKey(); } - bool operator==(const ObjectComparator& c){return true;} + bool operator==(const ObjectComparator&){return true;} }; /** @@ -87,7 +91,7 @@ namespace EUROPA { ObjectId object; TokenId predecessor, successor; extractParts(m_index, object, predecessor, successor); - os << "THR{" << object->getName().toString() << " (" << predecessor->getKey() << ")<(" << successor->getKey() << ")}"; + os << "THR{" << object->getName() << " (" << predecessor->getKey() << ")<(" << successor->getKey() << ")}"; return os.str(); } @@ -109,21 +113,23 @@ namespace EUROPA { return strStream.str(); } - std::string ThreatDecisionPoint::toString(unsigned int index, const std::pair >& choice) const { - std::stringstream strStream; - ObjectId object; - TokenId predecessor; - TokenId successor; - extractParts(index, object, predecessor, successor); - strStream << "{" << object->getName().toString() << " " << predecessor->toString() << " < " << successor->toString() << "}"; - return strStream.str(); - } + std::string ThreatDecisionPoint::toString(unsigned long index, + const std::pair >&) const { + std::stringstream strStream; + ObjectId object; + TokenId predecessor; + TokenId successor; + extractParts(index, object, predecessor, successor); + strStream << "{" << object->getName() << " " << predecessor->toString() << " < " << successor->toString() << "}"; + return strStream.str(); + } - void ThreatDecisionPoint::extractParts(unsigned int index, ObjectId& object, TokenId& predecessor, TokenId& successor) const{ - const std::pair >& choice = m_choices[index]; - object = choice.first; - predecessor = choice.second.first; - successor = choice.second.second; - } + void ThreatDecisionPoint::extractParts(unsigned long index, ObjectId& object, + TokenId& predecessor, TokenId& successor) const{ + const std::pair >& choice = m_choices[index]; + object = choice.first; + predecessor = choice.second.first; + successor = choice.second.second; + } } } diff --git a/src/PLASMA/Solvers/component/ThreatDecisionPoint.hh b/src/PLASMA/Solvers/component/ThreatDecisionPoint.hh index 13ae6b6d8..b359649b5 100644 --- a/src/PLASMA/Solvers/component/ThreatDecisionPoint.hh +++ b/src/PLASMA/Solvers/component/ThreatDecisionPoint.hh @@ -10,50 +10,53 @@ * @date March, 2005 */ namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - /** - * @brief Defines a class for formulation, execution and retraction of token ordering - * decisions as a means to resolve object flaws. - */ - class ThreatDecisionPoint: public DecisionPoint { - public: +/** + * @brief Defines a class for formulation, execution and retraction of token ordering + * decisions as a means to resolve object flaws. + */ +class ThreatDecisionPoint: public DecisionPoint { + public: - ThreatDecisionPoint(const DbClientId& client, const TokenId& tokenToOrder, const TiXmlElement& configData, - const LabelStr& explanation = "unknown"); + ThreatDecisionPoint(const DbClientId client, const TokenId tokenToOrder, + const TiXmlElement& configData, + const std::string& explanation = "unknown"); - /** - * @brief Used to prune entities out which are not active tokens - */ - static bool test(const EntityId& entity); + /** + * @brief Used to prune entities out which are not active tokens + */ + static bool test(const EntityId entity); - const TokenId& getToken() const {return m_tokenToOrder;} + const TokenId getToken() const {return m_tokenToOrder;} - virtual std::string toString() const; - virtual std::string toShortString() const; + virtual std::string toString() const; + virtual std::string toShortString() const; - protected: - virtual void handleInitialize(); + protected: + virtual void handleInitialize(); - void extractParts(unsigned int index, ObjectId& object, TokenId& predecessor, TokenId& successor) const; + void extractParts(unsigned long index, ObjectId& object, TokenId& predecessor, + TokenId& successor) const; - /** Main Interface for the solver **/ - bool hasNext() const; + /** Main Interface for the solver **/ + bool hasNext() const; - const TokenId m_tokenToOrder; /*!< The token that must be ordered */ - std::vector< std::pair > > m_choices; /*!< Choices across all objects */ - unsigned int m_choiceCount; /*!< Stored choice count - size of m_orderingChoices */ - unsigned int m_index; /*!< Current choice position in m_orderingChoices */ + const TokenId m_tokenToOrder; /*!< The token that must be ordered */ + std::vector< std::pair > > m_choices; /*!< Choices across all objects */ + unsigned long m_choiceCount; /*!< Stored choice count - size of m_orderingChoices */ + unsigned long m_index; /*!< Current choice position in m_orderingChoices */ - private: - virtual void handleExecute(); - virtual void handleUndo(); + private: + virtual void handleExecute(); + virtual void handleUndo(); - /** HELPER METHODS **/ - std::string toString(unsigned int index, const std::pair >& choice) const; - }; + /** HELPER METHODS **/ + std::string toString(unsigned long index, + const std::pair >& choice) const; +}; - } +} } #define REGISTER_THREAT_DECISION_FACTORY(MGR,CLASS, NAME)\ diff --git a/src/PLASMA/Solvers/component/ThreatManager.cc b/src/PLASMA/Solvers/component/ThreatManager.cc index 7ec035e15..4445ca9de 100644 --- a/src/PLASMA/Solvers/component/ThreatManager.cc +++ b/src/PLASMA/Solvers/component/ThreatManager.cc @@ -11,10 +11,34 @@ * @date May, 2005 */ namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { +namespace { +class ThreatIterator : public FlawIterator { + public: + ThreatIterator(ThreatManager& manager) + : FlawIterator(manager), + m_it(manager.getPlanDatabase()->getTokensToOrder().begin()), + m_end(manager.getPlanDatabase()->getTokensToOrder().end()){ + advance(); + } + + private: + const EntityId nextCandidate() { + EntityId candidate; + if(m_it != m_end){ + candidate = m_it->second.first; + ++m_it; + } + return candidate; + } + + std::map >::const_iterator m_it; + std::map >::const_iterator m_end; +}; +} - ThreatManager::ThreatManager(const TiXmlElement& configData) - : FlawManager(configData){} +ThreatManager::ThreatManager(const TiXmlElement& configData) + : FlawManager(configData){} ThreatManager::~ThreatManager(){} @@ -23,7 +47,7 @@ namespace EUROPA { /** * Filter out if not a token */ - bool ThreatManager::staticMatch(const EntityId& entity){ + bool ThreatManager::staticMatch(const EntityId entity){ return !TokenId::convertable(entity) || FlawManager::staticMatch(entity); } @@ -31,11 +55,29 @@ namespace EUROPA { * Because we do not process threat candidates until we query the database, we have not yet statically matched * them. Thus we are able to use the dynamic match case in flaw iteration for all types of flaw managers. */ - bool ThreatManager::dynamicMatch(const EntityId& entity){ + bool ThreatManager::dynamicMatch(const EntityId entity){ return staticMatch(entity) || FlawManager::dynamicMatch(entity); } - std::string ThreatManager::toString(const EntityId& entity) const { +bool ThreatManager::noMoreFlaws() { + // const std::map >& flaws = + // getPlanDatabase()->getTokensToOrder(); + + // if(!flaws.empty()) { + // for(std::map >::const_iterator it = + // flaws.begin(); it != flaws.end(); ++it) { + // if(!dynamicMatch(it->second.first)) + // return false; + // } + // } + // return true; + return ThreatIterator(*this).done(); +} + +IteratorId ThreatManager::createIterator() { + return (new ThreatIterator(*this))->getId(); +} + std::string ThreatManager::toString(const EntityId entity) const { checkError(TokenId::convertable(entity), entity->toString()); TokenId token = entity; std::stringstream os; @@ -43,31 +85,5 @@ namespace EUROPA { return os.str(); } - class ThreatIterator : public FlawIterator { - public: - ThreatIterator(ThreatManager& manager) - : FlawIterator(manager), - m_it(manager.getPlanDatabase()->getTokensToOrder().begin()), - m_end(manager.getPlanDatabase()->getTokensToOrder().end()){ - advance(); - } - - private: - const EntityId nextCandidate() { - EntityId candidate; - if(m_it != m_end){ - candidate = m_it->second.first; - ++m_it; - } - return candidate; - } - - std::map >::const_iterator m_it; - std::map >::const_iterator m_end; - }; - - IteratorId ThreatManager::createIterator() { - return (new ThreatIterator(*this))->getId(); - } - } +} } diff --git a/src/PLASMA/Solvers/component/ThreatManager.hh b/src/PLASMA/Solvers/component/ThreatManager.hh index 2d6d4a961..7f419b176 100644 --- a/src/PLASMA/Solvers/component/ThreatManager.hh +++ b/src/PLASMA/Solvers/component/ThreatManager.hh @@ -23,13 +23,15 @@ namespace EUROPA { virtual ~ThreatManager(); - bool staticMatch(const EntityId& entity); + bool staticMatch(const EntityId entity); - bool dynamicMatch(const EntityId& entity); + bool dynamicMatch(const EntityId entity); IteratorId createIterator(); - std::string toString(const EntityId& entity) const; + std::string toString(const EntityId entity) const; + + bool noMoreFlaws(); private: friend class ThreatIterator; diff --git a/src/PLASMA/Solvers/component/UnboundVariableDecisionPoint.cc b/src/PLASMA/Solvers/component/UnboundVariableDecisionPoint.cc index 817ae6463..78ab94c9d 100644 --- a/src/PLASMA/Solvers/component/UnboundVariableDecisionPoint.cc +++ b/src/PLASMA/Solvers/component/UnboundVariableDecisionPoint.cc @@ -4,6 +4,7 @@ #include "Domain.hh" #include "Debug.hh" #include "ValueSource.hh" +#include "tinyxml.h" #include /** @@ -14,14 +15,14 @@ namespace EUROPA { namespace SOLVERS { - bool UnboundVariableDecisionPoint::test(const EntityId& entity){ + bool UnboundVariableDecisionPoint::test(const EntityId entity){ return ConstrainedVariableId::convertable(entity); } - UnboundVariableDecisionPoint::UnboundVariableDecisionPoint(const DbClientId& dbClient, - const ConstrainedVariableId& flawedVariable, + UnboundVariableDecisionPoint::UnboundVariableDecisionPoint(const DbClientId dbClient, + const ConstrainedVariableId flawedVariable, const TiXmlElement& configData, - const LabelStr& explanation) + const std::string& explanation) : DecisionPoint(dbClient, flawedVariable->getKey(), explanation), m_flawedVariable(flawedVariable), m_choices(ValueSource::getSource(dbClient->getSchema(),flawedVariable)){ @@ -37,7 +38,7 @@ namespace EUROPA { delete m_choices; } - const ConstrainedVariableId& UnboundVariableDecisionPoint::getFlawedVariable() const{return m_flawedVariable;} + const ConstrainedVariableId UnboundVariableDecisionPoint::getFlawedVariable() const{return m_flawedVariable;} bool UnboundVariableDecisionPoint::canUndo() const { return DecisionPoint::canUndo() && m_flawedVariable->isSpecified(); @@ -64,15 +65,15 @@ namespace EUROPA { return toString(); } - std::string UnboundVariableDecisionPoint::toString() const{ - std::stringstream strStream; - strStream << "VAR=" <getName().toString() << "(" << m_flawedVariable->getKey() << ")->" - << m_flawedVariable->lastDomain().toString(); - return strStream.str(); - } + std::string UnboundVariableDecisionPoint::toString() const { + std::stringstream strStream; + strStream << "VAR=" <getName() << "(" << m_flawedVariable->getKey() << ")->" + << m_flawedVariable->lastDomain().toString(); + return strStream.str(); + } - MinValue::MinValue(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, const LabelStr& explanation) + MinValue::MinValue(const DbClientId client, const ConstrainedVariableId flawedVariable, const TiXmlElement& configData, const std::string& explanation) : UnboundVariableDecisionPoint(client, flawedVariable, configData, explanation), m_choiceIndex(0){} bool MinValue::hasNext() const {return m_choiceIndex < m_choices->getCount();} @@ -80,21 +81,25 @@ namespace EUROPA { edouble MinValue::getNext(){return m_choices->getValue(m_choiceIndex++);} /** MAX VALUE **/ - MaxValue::MaxValue(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, const LabelStr& explanation) - : UnboundVariableDecisionPoint(client, flawedVariable, configData, explanation), m_choiceIndex(m_choices->getCount()){} + MaxValue::MaxValue(const DbClientId client, const ConstrainedVariableId flawedVariable, const TiXmlElement& configData, const std::string& explanation) + : UnboundVariableDecisionPoint(client, flawedVariable, configData, explanation), + m_choiceIndex(m_choices->getCount()){} bool MaxValue::hasNext() const { return m_choiceIndex > 0; } edouble MaxValue::getNext(){return m_choices->getValue(--m_choiceIndex);} /** RANDOM VALUE **/ - RandomValue::RandomValue(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, const LabelStr& explanation) - : UnboundVariableDecisionPoint(client, flawedVariable, configData, explanation), m_distribution(NORMAL){ + RandomValue::RandomValue(const DbClientId client, + const ConstrainedVariableId flawedVariable, + const TiXmlElement& configData, const std::string& explanation) + : UnboundVariableDecisionPoint(client, flawedVariable, configData, explanation), + m_usedIndices(), m_distribution(NORMAL) { static bool sl_seeded(false); if(!sl_seeded){ - unsigned int seedValue = time(NULL); - srand(seedValue); + long seedValue = time(NULL); + srand(static_cast(seedValue)); sl_seeded = true; debugMsg("RandomValue:RandomValue", "Seeding Random Number Generator with " << seedValue); } @@ -126,19 +131,19 @@ namespace EUROPA { } } - bool RandomValue::hasNext() const{ return m_choices->getCount() > m_usedIndeces.size(); } + bool RandomValue::hasNext() const{ return m_choices->getCount() > m_usedIndices.size(); } edouble RandomValue::getNext(){ unsigned int tryCount = 1; /*!< Number of attempts to get a new selection */ - unsigned int index = rand() % m_choices->getCount(); + unsigned long index = static_cast(rand()) % m_choices->getCount(); - while(m_usedIndeces.find(index) != m_usedIndeces.end()){ - index = rand() % m_choices->getCount(); + while(m_usedIndices.find(index) != m_usedIndices.end()){ + index = static_cast(rand()) % m_choices->getCount(); tryCount++; } // Insert selected index so we do not repeat it - m_usedIndeces.insert(index); + m_usedIndices.insert(index); // Now we should have a selection that indexes into the vector of choices. edouble value = m_choices->getValue(index); diff --git a/src/PLASMA/Solvers/component/UnboundVariableDecisionPoint.hh b/src/PLASMA/Solvers/component/UnboundVariableDecisionPoint.hh index 03a5d3fe8..55f6b4e4a 100644 --- a/src/PLASMA/Solvers/component/UnboundVariableDecisionPoint.hh +++ b/src/PLASMA/Solvers/component/UnboundVariableDecisionPoint.hh @@ -9,8 +9,7 @@ * @author Conor McGann */ namespace EUROPA { - - namespace SOLVERS { +namespace SOLVERS { class ValueSource; @@ -21,73 +20,77 @@ namespace EUROPA { * leaves all details of how choices are stored and how they are iterated through to * derived classes, thus allowing for specialized storage and selection. */ - class UnboundVariableDecisionPoint: public DecisionPoint { - public: +class UnboundVariableDecisionPoint: public DecisionPoint { + public: - /** - * @brief Utility to obtain the next decision point from the set of candidates if it can exceed the - * given best priority. - * @param flawCandidates A set of unbound variables to choose from - * @param guardCache The set of guard variables, each with a reference to the number of guards posted on it. - * @param bestPriority A mutable current best priority. If a new decision point is created, the new - * bestPriority will be updated to the priority of the new decision point. - * @return A noId if no better decision can be found, otherwise a new decision with a better priority. - */ - static DecisionPointId next(const ConstrainedVariableSet& flawCandidates, - const std::map< ConstrainedVariableId, unsigned int>& guardCache, - unsigned int& bestPriority); - - /** - * @brief Used to prune entities out which are not variables - */ - static bool test(const EntityId& entity); - - virtual ~UnboundVariableDecisionPoint(); - - /** - * @brief Dump contents to a String. - */ - virtual std::string toString() const; - virtual std::string toShortString() const; - - const ConstrainedVariableId& getFlawedVariable() const; + /** + * @brief Utility to obtain the next decision point from the set of candidates if it can exceed the + * given best priority. + * @param flawCandidates A set of unbound variables to choose from + * @param guardCache The set of guard variables, each with a reference to the number of guards posted on it. + * @param bestPriority A mutable current best priority. If a new decision point is created, the new + * bestPriority will be updated to the priority of the new decision point. + * @return A noId if no better decision can be found, otherwise a new decision with a better priority. + */ + static DecisionPointId next(const ConstrainedVariableSet& flawCandidates, + const std::map< ConstrainedVariableId, unsigned int>& guardCache, + unsigned int& bestPriority); - protected: + /** + * @brief Used to prune entities out which are not variables + */ + static bool test(const EntityId entity); - UnboundVariableDecisionPoint(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, - const LabelStr& explanation = "unknown"); + virtual ~UnboundVariableDecisionPoint(); - const ConstrainedVariableId m_flawedVariable; /*!< The Flaw to resolve */ + /** + * @brief Dump contents to a String. + */ + virtual std::string toString() const; + virtual std::string toShortString() const; - ValueSource* m_choices; + const ConstrainedVariableId getFlawedVariable() const; - virtual void handleInitialize(); + protected: - virtual void handleExecute(); + UnboundVariableDecisionPoint(const DbClientId client, const ConstrainedVariableId flawedVariable, const TiXmlElement& configData, + const std::string& explanation = "unknown"); - virtual void handleUndo(); + const ConstrainedVariableId m_flawedVariable; /*!< The Flaw to resolve */ - virtual bool canUndo() const; + ValueSource* m_choices; - /** - * @brief Retrieves the next choice to be executed. Implementation will depend - * on the representation of choices in the derived class. - */ - virtual edouble getNext() = 0; - }; + virtual void handleInitialize(); + + virtual void handleExecute(); + + virtual void handleUndo(); + + virtual bool canUndo() const; + + /** + * @brief Retrieves the next choice to be executed. Implementation will depend + * on the representation of choices in the derived class. + */ + virtual edouble getNext() = 0; +private: + UnboundVariableDecisionPoint(const UnboundVariableDecisionPoint&); + UnboundVariableDecisionPoint& operator=(const UnboundVariableDecisionPoint&); +}; /** * @brief Provides for access in ascending order */ class MinValue: public UnboundVariableDecisionPoint { public: - MinValue(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, const LabelStr& explanation = "unknown"); + MinValue(const DbClientId client, const ConstrainedVariableId flawedVariable, + const TiXmlElement& configData, const std::string& explanation = "unknown"); bool hasNext() const; edouble getNext(); private: - unsigned int m_choiceIndex; /*!< The current position in the list of choices. */ + unsigned long m_choiceIndex; /*!< The current position in the list of choices. */ }; /** @@ -95,13 +98,14 @@ namespace EUROPA { */ class MaxValue: public UnboundVariableDecisionPoint { public: - MaxValue(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, const LabelStr& explanation = "unknown"); + MaxValue(const DbClientId client, const ConstrainedVariableId flawedVariable, + const TiXmlElement& configData, const std::string& explanation = "unknown"); bool hasNext() const; edouble getNext(); private: - unsigned int m_choiceIndex; /*!< The current position in the list of choices. */ + unsigned long m_choiceIndex; /*!< The current position in the list of choices. */ }; @@ -112,7 +116,7 @@ namespace EUROPA { */ class RandomValue: public UnboundVariableDecisionPoint { public: - RandomValue(const DbClientId& client, const ConstrainedVariableId& flawedVariable, const TiXmlElement& configData, const LabelStr& explanation = "unknown"); + RandomValue(const DbClientId client, const ConstrainedVariableId flawedVariable, const TiXmlElement& configData, const std::string& explanation = "unknown"); bool hasNext() const; edouble getNext(); @@ -121,7 +125,7 @@ namespace EUROPA { private: - std::set m_usedIndeces; /*!< The set of used choices so far. Each is the index of the choice + std::set m_usedIndices; /*!< The set of used choices so far. Each is the index of the choice in m_choices. */ Distribution m_distribution; /*!< Indicates the distribution used in random number selection. */ }; diff --git a/src/PLASMA/Solvers/component/UnboundVariableManager.cc b/src/PLASMA/Solvers/component/UnboundVariableManager.cc index 5ac164f59..aae4cf30b 100644 --- a/src/PLASMA/Solvers/component/UnboundVariableManager.cc +++ b/src/PLASMA/Solvers/component/UnboundVariableManager.cc @@ -20,14 +20,14 @@ */ namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - /** - * @brief Constructor will evaluate the configuration information and construct assembly from there. - * @see ComponentFactory - */ - UnboundVariableManager::UnboundVariableManager(const TiXmlElement& configData) - : FlawManager(configData) {} +/** + * @brief Constructor will evaluate the configuration information and construct assembly from there. + * @see ComponentFactory + */ +UnboundVariableManager::UnboundVariableManager(const TiXmlElement& configData) + : FlawManager(configData), m_flawCandidates() {} void UnboundVariableManager::handleInitialize(){ @@ -47,20 +47,24 @@ namespace EUROPA { /** * Filter out if not a variable */ - bool UnboundVariableManager::staticMatch(const EntityId& entity){ + bool UnboundVariableManager::staticMatch(const EntityId entity){ return !ConstrainedVariableId::convertable(entity) || FlawManager::staticMatch(entity); } - bool UnboundVariableManager::dynamicMatch(const EntityId& entity){ + bool UnboundVariableManager::dynamicMatch(const EntityId entity){ ConstrainedVariableId var = entity; if (FlawManager::dynamicMatch(entity)) return true; // We also exclude singletons - if(var->lastDomain().isSingleton()){ - debugMsg("UnboundVariableManager:dynamicMatch", "Excluding " << var->getKey() << " as a singleton."); - return true; + // if(var->lastDomain().isSingleton()){ + // debugMsg("UnboundVariableManager:dynamicMatch", "Excluding " << var->getKey() << " as a singleton."); + // return true; + // } + if(var->isSpecified()) { + debugMsg("UnboundVariableManager:dynamicMatch", "Excluding " << var->getKey() << " as already specified."); + return true; } // Finally, we exlude if the bounds are not finite @@ -75,16 +79,15 @@ namespace EUROPA { /** * We may filter based on static information only. */ - void UnboundVariableManager::updateFlaw(const ConstrainedVariableId& var){ + void UnboundVariableManager::updateFlaw(const ConstrainedVariableId var){ debugMsg("UnboundVariableManager:updateFlaw", var->toLongString()); m_flawCandidates.erase(var); - if(variableOfNonActiveToken(var) || !var->canBeSpecified() || var->isSpecified() || var->isSingleton() || staticMatch(var)){ + if(variableOfNonActiveToken(var) || !var->canBeSpecified() || var->isSpecified() || staticMatch(var)){ debugMsg("UnboundVariableManager:updateFlaw", "Excluding " << var->toLongString()); condDebugMsg(variableOfNonActiveToken(var), "UnboundVariableManager:updateFlaw", "Parent is not active."); condDebugMsg(!var->canBeSpecified(), "UnboundVariableManager:updateFlaw", "Variable can't be specified."); condDebugMsg(var->isSpecified(), "UnboundVariableManager:updateFlaw", "Variable is already specified."); - condDebugMsg(var->isSingleton(), "UnboundVariableManager:updateFlaw", "Variable is already singleton."); return; } @@ -94,7 +97,7 @@ namespace EUROPA { m_flawCandidates.insert(var); } - void UnboundVariableManager::removeFlaw(const ConstrainedVariableId& var){ + void UnboundVariableManager::removeFlaw(const ConstrainedVariableId var){ condDebugMsg(m_flawCandidates.find(var) != m_flawCandidates.end(), "UnboundVariableManager:removeFlaw", "Removing " << var->getKey() << ". " << var->toString() << " as a flaw."); @@ -102,7 +105,7 @@ namespace EUROPA { m_flawCandidates.erase(var); } - bool UnboundVariableManager::variableOfNonActiveToken(const ConstrainedVariableId& var){ + bool UnboundVariableManager::variableOfNonActiveToken(const ConstrainedVariableId var){ // If var parent is a token and the state is active, then true. if(TokenId::convertable(var->parent())){ TokenId token(var->parent()); @@ -114,12 +117,12 @@ namespace EUROPA { } - void UnboundVariableManager::notifyRemoved(const ConstrainedVariableId& variable){ + void UnboundVariableManager::notifyRemoved(const ConstrainedVariableId variable){ removeFlaw(variable); FlawManager::notifyRemoved(variable); } - void UnboundVariableManager::notifyChanged(const ConstrainedVariableId& variable, + void UnboundVariableManager::notifyChanged(const ConstrainedVariableId variable, const DomainListener::ChangeType& changeType){ // In the event it is bound to a singleton, we remove it altogether as a flaw. @@ -164,7 +167,7 @@ namespace EUROPA { //reordered FROM guard, key pref TO choice count, guard //re-reordered from choice count, guard TO guard, choice count //completely removed guard - bool UnboundVariableManager::betterThan(const EntityId& a, const EntityId& b, LabelStr& explanation){ + bool UnboundVariableManager::betterThan(const EntityId a, const EntityId b, std::string& explanation){ //we only ever get here because the priority is equal //Added to duplicate behavior from HTX. This may not be the best idea ever. ~MJI const ConstrainedVariableId va = a; @@ -187,7 +190,7 @@ namespace EUROPA { return false; } - std::string UnboundVariableManager::toString(const EntityId& entity) const { + std::string UnboundVariableManager::toString(const EntityId entity) const { checkError(ConstrainedVariableId::convertable(entity), entity->toString()); ConstrainedVariableId var = entity; std::stringstream os; @@ -195,6 +198,10 @@ namespace EUROPA { return os.str(); } + bool UnboundVariableManager::noMoreFlaws() { + return m_flawCandidates.empty(); + } + class UnboundVariableIterator : public FlawIterator { public: UnboundVariableIterator(UnboundVariableManager& manager) diff --git a/src/PLASMA/Solvers/component/UnboundVariableManager.hh b/src/PLASMA/Solvers/component/UnboundVariableManager.hh index f6d1b792a..4cc70073f 100644 --- a/src/PLASMA/Solvers/component/UnboundVariableManager.hh +++ b/src/PLASMA/Solvers/component/UnboundVariableManager.hh @@ -10,40 +10,40 @@ * @author Conor McGann */ namespace EUROPA { - namespace SOLVERS { +namespace SOLVERS { - class UnboundVariableManager: public FlawManager { - public: - UnboundVariableManager(const TiXmlElement& configData); +class UnboundVariableManager: public FlawManager { + public: + UnboundVariableManager(const TiXmlElement& configData); - DecisionPointId nextZeroCommitmentDecision(); + DecisionPointId nextZeroCommitmentDecision(); - bool staticMatch(const EntityId& entity); - bool dynamicMatch(const EntityId& entity); + bool staticMatch(const EntityId entity); + bool dynamicMatch(const EntityId entity); - IteratorId createIterator(); + IteratorId createIterator(); - std::string toString(const EntityId& entity) const; + std::string toString(const EntityId entity) const; + bool noMoreFlaws(); + private: + friend class UnboundVariableIterator; - private: - friend class UnboundVariableIterator; + void notifyRemoved(const ConstrainedVariableId var); + void notifyChanged(const ConstrainedVariableId variable, const DomainListener::ChangeType& changeType); + void handleInitialize(); + void addFlaw(const ConstrainedVariableId var); + void removeFlaw(const ConstrainedVariableId var); + void updateFlaw(const ConstrainedVariableId var); + bool betterThan(const EntityId a, const EntityId b, std::string& explanation); - void notifyRemoved(const ConstrainedVariableId& var); - void notifyChanged(const ConstrainedVariableId& variable, const DomainListener::ChangeType& changeType); - void handleInitialize(); - void addFlaw(const ConstrainedVariableId& var); - void removeFlaw(const ConstrainedVariableId& var); - void updateFlaw(const ConstrainedVariableId& var); - bool betterThan(const EntityId& a, const EntityId& b, LabelStr& explanation); + /** + * @brief Utility to test if the given variable is part of a token that is merged, rejected or inactive. + */ + static bool variableOfNonActiveToken(const ConstrainedVariableId var); - /** - * @brief Utility to test if the given variable is part of a token that is merged, rejected or inactive. - */ - static bool variableOfNonActiveToken(const ConstrainedVariableId& var); - - ConstrainedVariableSet m_flawCandidates; /*!< All variables that have passed the static filter */ - }; - } + ConstrainedVariableSet m_flawCandidates; /*!< All variables that have passed the static filter */ +}; +} } #endif diff --git a/src/PLASMA/Solvers/component/ValueSource.cc b/src/PLASMA/Solvers/component/ValueSource.cc index 79618af02..99f85c073 100644 --- a/src/PLASMA/Solvers/component/ValueSource.cc +++ b/src/PLASMA/Solvers/component/ValueSource.cc @@ -15,7 +15,7 @@ namespace EUROPA { namespace SOLVERS { - ValueSource* ValueSource::getSource(const SchemaId& schema, const ConstrainedVariableId& var, bool externalOrder) { + ValueSource* ValueSource::getSource(const SchemaId schema, const ConstrainedVariableId var, bool externalOrder) { if(externalOrder) return new OrderedValueSource(var->lastDomain()); if(var->lastDomain().isEnumerated()) @@ -32,8 +32,8 @@ namespace EUROPA { Domain::size_type ValueSource::getCount() const { return m_count;} - EnumValueSource::EnumValueSource(const SchemaId& schema, const Domain& dom) - : ValueSource(dom.getSize()) { + EnumValueSource::EnumValueSource(const SchemaId, const Domain& dom) + : ValueSource(dom.getSize()), m_values() { std::list values; dom.getValues(values); //this isn't necessary anymore (I think), since object domains are now entity keys @@ -48,9 +48,11 @@ namespace EUROPA { edouble EnumValueSource::getValue(Domain::size_type index) const { return m_values[index];} - OrderedValueSource::OrderedValueSource(const Domain& dom) : ValueSource(0), m_dom(dom) { - checkError(!m_dom.isEmpty(), "Cannot create a value ordering for empty domain " << m_dom); - } + OrderedValueSource::OrderedValueSource(const Domain& dom) + : ValueSource(0), m_values(), m_dom(dom) { + checkError(!m_dom.isEmpty(), + "Cannot create a value ordering for empty domain " << m_dom); + } void OrderedValueSource::addValue(const edouble value) { if(m_dom.isMember(value)) { @@ -74,7 +76,7 @@ namespace EUROPA { edouble IntervalValueSource::getValue(Domain::size_type index) const {return m_lb + (m_step * index);} Domain::size_type IntervalValueSource::calculateSize(const Domain& dom){ - return cast_int(((dom.getUpperBound() - dom.getLowerBound())/dom.minDelta()) + 1); + return static_cast(cast_int(((dom.getUpperBound() - dom.getLowerBound())/dom.minDelta()) + 1)); } } } diff --git a/src/PLASMA/Solvers/component/ValueSource.hh b/src/PLASMA/Solvers/component/ValueSource.hh index 9286fde61..a084a6398 100644 --- a/src/PLASMA/Solvers/component/ValueSource.hh +++ b/src/PLASMA/Solvers/component/ValueSource.hh @@ -9,54 +9,55 @@ */ #include "SolverDefs.hh" +#include "Domain.hh" namespace EUROPA { - namespace SOLVERS { - class ValueSource { - public: - /** - * @brief Factory method to create appropriate concrete source - */ - static ValueSource* getSource(const SchemaId& schema, const ConstrainedVariableId& var, bool externalOrder = false); +namespace SOLVERS { +class ValueSource { + public: + /** + * @brief Factory method to create appropriate concrete source + */ + static ValueSource* getSource(const SchemaId schema, const ConstrainedVariableId var, bool externalOrder = false); - /** - * @brief Accessor for total number of values available - */ - virtual Domain::size_type getCount() const; + /** + * @brief Accessor for total number of values available + */ + virtual Domain::size_type getCount() const; - /** - * @brief Accessor for the value at position given by index. - */ - virtual edouble getValue(Domain::size_type index) const = 0; + /** + * @brief Accessor for the value at position given by index. + */ + virtual edouble getValue(Domain::size_type index) const = 0; - /** - * @brief Required to allow correct cleanup - */ - virtual ~ValueSource(); + /** + * @brief Required to allow correct cleanup + */ + virtual ~ValueSource(); - protected: - ValueSource(Domain::size_type count); + protected: + ValueSource(Domain::size_type count); - Domain::size_type m_count; - }; + Domain::size_type m_count; +}; - class EnumValueSource : public ValueSource { - public: - EnumValueSource(const SchemaId& schema, const Domain& dom); - edouble getValue(Domain::size_type index) const; - private: - std::vector m_values; - }; +class EnumValueSource : public ValueSource { + public: + EnumValueSource(const SchemaId schema, const Domain& dom); + edouble getValue(Domain::size_type index) const; + private: + std::vector m_values; +}; - class OrderedValueSource : public ValueSource { - public: - OrderedValueSource(const Domain& dom); - edouble getValue(Domain::size_type index) const; - void addValue(const edouble value); - private: - std::vector m_values; - const Domain& m_dom; - }; +class OrderedValueSource : public ValueSource { + public: + OrderedValueSource(const Domain& dom); + edouble getValue(Domain::size_type index) const; + void addValue(const edouble value); + private: + std::vector m_values; + const Domain& m_dom; +}; class IntervalValueSource : public ValueSource { public: diff --git a/src/PLASMA/Solvers/test/SolverTests.xml b/src/PLASMA/Solvers/test/SolverTests.xml index c08ccdecd..5ada368d8 100644 --- a/src/PLASMA/Solvers/test/SolverTests.xml +++ b/src/PLASMA/Solvers/test/SolverTests.xml @@ -25,13 +25,16 @@ + + + + + + - - - @@ -57,4 +60,4 @@ - \ No newline at end of file + diff --git a/src/PLASMA/Solvers/test/module-tests.cc b/src/PLASMA/Solvers/test/module-tests.cc index d84f102f5..826a5f4a0 100644 --- a/src/PLASMA/Solvers/test/module-tests.cc +++ b/src/PLASMA/Solvers/test/module-tests.cc @@ -5,7 +5,7 @@ using namespace EUROPA; CPPUNIT_TEST_SUITE_REGISTRATION( SolversModuleTests ); -int main( int argc, char **argv) +int main( int , char **) { // Init data types so that id counts don't fail VoidDT::instance(); diff --git a/src/PLASMA/Solvers/test/solvers-test-module.cc b/src/PLASMA/Solvers/test/solvers-test-module.cc index c72b3935c..57a629ee1 100644 --- a/src/PLASMA/Solvers/test/solvers-test-module.cc +++ b/src/PLASMA/Solvers/test/solvers-test-module.cc @@ -26,6 +26,9 @@ #include "STNTemporalAdvisor.hh" #include "DbClientTransactionPlayer.hh" #include "TemporalPropagator.hh" +#include "CESchema.hh" +#include "tinyxml.h" +#include "TestUtils.hh" #include "ModuleConstraintEngine.hh" #include "ModulePlanDatabase.hh" @@ -36,6 +39,9 @@ #include +#include +#include + #ifdef near #undef near #endif @@ -53,19 +59,20 @@ using namespace EUROPA; using namespace EUROPA::SOLVERS; using namespace EUROPA::SOLVERS::HSTS; +using namespace boost; -void registerTestElements(EngineId& engine); +void registerTestElements(EngineId engine); class SolversTestEngine : public EngineBase { - public: - SolversTestEngine(); - virtual ~SolversTestEngine(); - - const SchemaId& getSchema() { return ((Schema*)getComponent("Schema"))->getId(); } - const ConstraintEngineId& getConstraintEngine() { return ((ConstraintEngine*)getComponent("ConstraintEngine"))->getId(); } - const PlanDatabaseId& getPlanDatabase() { return ((PlanDatabase*)getComponent("PlanDatabase"))->getId(); } - const RulesEngineId& getRulesEngine() { return ((RulesEngine*)getComponent("RulesEngine"))->getId(); } + public: + SolversTestEngine(); + virtual ~SolversTestEngine(); + + const SchemaId getSchema() { return static_cast(getComponent("Schema"))->getId(); } + const ConstraintEngineId getConstraintEngine() { return static_cast(getComponent("ConstraintEngine"))->getId(); } + const PlanDatabaseId getPlanDatabase() { return static_cast(getComponent("PlanDatabase"))->getId(); } + const RulesEngineId getRulesEngine() { return static_cast(getComponent("RulesEngine"))->getId(); } protected: void createModules(); @@ -121,9 +128,9 @@ class TestEngine : public SolversTestEngine */ class LazyAllDiff: public Constraint { public: - LazyAllDiff(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + LazyAllDiff(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { } @@ -149,9 +156,9 @@ class LazyAllDiff: public Constraint { */ class LazyAlwaysFails: public Constraint { public: - LazyAlwaysFails(const LabelStr& name, - const LabelStr& propagatorName, - const ConstraintEngineId& constraintEngine, + LazyAlwaysFails(const std::string& name, + const std::string& propagatorName, + const ConstraintEngineId constraintEngine, const std::vector& variables) : Constraint(name, propagatorName, constraintEngine, variables) { } @@ -193,14 +200,17 @@ class ComponentFactoryTests{ static bool testBasicAllocation(){ TestEngine testEngine(true); - TiXmlElement* configXml = initXml((getTestLoadLibraryPath() + "/ComponentFactoryTest.xml").c_str()); + TiXmlElement* configXml = + initXml((getTestLoadLibraryPath() + "/ComponentFactoryTest.xml").c_str()); for (TiXmlElement * child = configXml->FirstChildElement(); child != NULL; child = child->NextSiblingElement()) { - ComponentFactoryMgr* cfm = (ComponentFactoryMgr*)testEngine.getComponent("ComponentFactoryMgr"); - TestComponent * testComponent = static_cast(cfm->createInstance(*child)); + ComponentFactoryMgr* cfm = + dynamic_cast(testEngine.getComponent("ComponentFactoryMgr")); + TestComponent * testComponent = + static_cast(cfm->createComponentInstance(*child)); delete testComponent; } @@ -212,8 +222,8 @@ class ComponentFactoryTests{ } }; -void nukeToken(const DbClientId& dbClient,const TokenId& token) -{ +namespace { +void nukeToken(const DbClientId dbClient,const TokenId token) { if (token->isCommitted()) { token->discard(); return; @@ -225,6 +235,7 @@ void nukeToken(const DbClientId& dbClient,const TokenId& token) checkError(token->isInactive(),"Couldn't make inactive:" << token->toLongString()); dbClient->deleteToken(token); } +} class FilterTests { public: @@ -233,10 +244,56 @@ class FilterTests { EUROPA_runTest(testVariableFiltering); EUROPA_runTest(testTokenFiltering); EUROPA_runTest(testThreatFiltering); + EUROPA_runTest(testGuardFilter); return true; } private: + static bool testGuardFilter() { + TestEngine testEngine(true); + DbClientId client = testEngine.getPlanDatabase()->getClient(); + ObjectId obj = client->createObject("BacktrackTest", "filtered"); + TokenId tok = client->createToken("BacktrackTest.pred"); + client->activate(tok); + client->constrain(obj, tok, tok); + CPPUNIT_ASSERT_MESSAGE("Initially inconsistent", client->propagate()); + + const ConstrainedVariableSet& vars = + testEngine.getConstraintEngine()->getVariables(); + std::string filterStr(""); + scoped_ptr filterXml(initXml(filterStr)); + GuardFilter f(*filterXml); + NotGuardFilter g(*filterXml); + bool guardFound = false; + for(ConstrainedVariableSet::const_iterator it = vars.begin(); it != vars.end(); ++it) { + if((*it)->getName() == std::string("b")) { + CPPUNIT_ASSERT_MESSAGE(std::string("Should be a guard: ") + \ + (*it)->getName(), + f.test(*it)); + CPPUNIT_ASSERT_MESSAGE(std::string("Should be a guard: ") + \ + (*it)->getName(), + !g.test(*it)); + guardFound = true; + } + else if(starts_with((*it)->getName(), "implicit") || + starts_with((*it)->getName(), "ExprConstant_PSEUDO_VARIABLE")) { + //these *might* be guards, but might not. can't tell a priori, so skipping the + //test + } + else { + //everything else should be a guard + CPPUNIT_ASSERT_MESSAGE(std::string("Should not be a guard: ") + \ + (*it)->getName(), + !f.test(*it)); + CPPUNIT_ASSERT_MESSAGE(std::string("Should not be a guard: ") + \ + (*it)->getName(), + g.test(*it)); + } + } + CPPUNIT_ASSERT_MESSAGE("Failed to find any guards in the model.", guardFound); + return true; + } + static bool testRuleMatching() { TestEngine testEngine(true); @@ -301,7 +358,7 @@ class FilterTests { // test R3 { - TokenId token = db->getClient()->createToken("D.predicateF", NULL, false); + TokenId token = db->getClient()->createToken("D.predicateF", "", false); std::vector rules; me.getMatches(token, rules); CPPUNIT_ASSERT_MESSAGE(toString(rules.size()), rules.size() == 2); @@ -311,7 +368,7 @@ class FilterTests { // test R4 { - TokenId token = db->getClient()->createToken("D.predicateC", NULL, false); + TokenId token = db->getClient()->createToken("D.predicateC", "", false); std::vector rules; me.getMatches(token->getVariable("arg6"), rules); CPPUNIT_ASSERT_MESSAGE(toString(rules.size()), rules.size() == 2); @@ -321,10 +378,10 @@ class FilterTests { // test R5 & R6 { - TokenId token = db->getClient()->createToken("C.predicateC", NULL, false); + TokenId token = db->getClient()->createToken("C.predicateC", "", false); std::vector rules; me.getMatches(token, rules); - CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getUnqualifiedPredicateName().toString(), rules.size() == 3); + CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getUnqualifiedPredicateName(), rules.size() == 3); CPPUNIT_ASSERT_MESSAGE(rules[1]->toString(), rules[1]->toString() == "[R5]C.predicateC.*.*.*.*"); CPPUNIT_ASSERT_MESSAGE(rules[2]->toString(), rules[2]->toString() == "[R6]C.*.*.*.*.*"); nukeToken(db->getClient(),token); @@ -332,65 +389,70 @@ class FilterTests { // test R6 { - TokenId token = db->getClient()->createToken("C.predicateA", NULL, false); + TokenId token = db->getClient()->createToken("C.predicateA", "", false); std::vector rules; me.getMatches(token, rules); - CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getUnqualifiedPredicateName().toString(), rules.size() == 2); + CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getUnqualifiedPredicateName(), rules.size() == 2); CPPUNIT_ASSERT_MESSAGE(rules[1]->toString(), rules[1]->toString() == "[R6]C.*.*.*.*.*"); nukeToken(db->getClient(),token); } // test R7 { - TokenId token = db->getClient()->createToken("D.predicateF", NULL, false); + TokenId token = db->getClient()->createToken("D.predicateF", "", false); token->activate(); TokenId E_predicateC = *(token->slaves().begin()); std::vector rules; me.getMatches(ConstrainedVariableId(E_predicateC->duration()), rules); - CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getUnqualifiedPredicateName().toString(), rules.size() == 2); + CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getUnqualifiedPredicateName(), rules.size() == 2); CPPUNIT_ASSERT_MESSAGE(rules[1]->toString(), rules[1]->toString() == "[R7]*.*.duration.*.Object.*"); nukeToken(db->getClient(),token); } // test R7a { - TokenId token = db->getClient()->createToken("E.predicateC", NULL, false); + TokenId token = db->getClient()->createToken("E.predicateC", "", false); std::vector rules; me.getMatches(ConstrainedVariableId(token->duration()), rules); - CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getPredicateName().toString(), rules.size() == 2); + CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getPredicateName(), rules.size() == 2); CPPUNIT_ASSERT_MESSAGE(rules[1]->toString(), rules[1]->toString() == "[R7a]*.*.duration.none.*.*"); nukeToken(db->getClient(),token); } // test R8 { - TokenId token = db->getClient()->createToken("B.predicateC", NULL, false); + TokenId token = db->getClient()->createToken("B.predicateC", "", false); token->activate(); TokenId E_predicateC = *(token->slaves().begin()); std::vector rules; me.getMatches(ConstrainedVariableId(E_predicateC->duration()), rules); - CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getPredicateName().toString(), rules.size() == 3); + CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getPredicateName(), rules.size() == 3); CPPUNIT_ASSERT_MESSAGE(rules[1]->toString(), rules[1]->toString() == "[R8]*.*.*.*.B.*"); CPPUNIT_ASSERT_MESSAGE(rules[2]->toString(), rules[2]->toString() == "[R7]*.*.duration.*.Object.*"); nukeToken(db->getClient(),token); } - // test R*, R9 and R10 + // test R8, R9 and R10 { - TokenId token = db->getClient()->createToken("D.predicateG", NULL, false); + TokenId token = db->getClient()->createToken("D.predicateG", "", false); token->activate(); TokenId E_predicateC = *(token->slaves().begin()); - + // Expect to fire R8, R9 and R10 - std::set expectedRules; - expectedRules.insert(LabelStr("[R8]*.*.*.*.B.*")); - expectedRules.insert(LabelStr("[R9]*.*.*.meets.D.predicateG")); - expectedRules.insert(LabelStr("[R10]*.*.*.before.*.*")); + //TODO: Fix this test. It claims to fire R8, but for no apparent reason. + std::set expectedRules; + expectedRules.insert("[R0]*.*.*.*.*.*"); + expectedRules.insert("[R7]*.*.duration.*.Object.*"); + // expectedRules.insert("[R8]*.*.*.*.B.*"); + expectedRules.insert("[R9]*.*.*.meets.D.predicateG"); + expectedRules.insert("[R10]*.*.*.before.*.*"); std::vector rules; me.getMatches(ConstrainedVariableId(E_predicateC->duration()), rules); - CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getPredicateName().toString(), rules.size() == 4); - for(int i=0;i>4; i++) - CPPUNIT_ASSERT_MESSAGE(rules[i]->toString(), expectedRules.find(LabelStr(rules[i]->toString())) != expectedRules.end()); + CPPUNIT_ASSERT_MESSAGE(toString(rules.size()) + " for " + token->getPredicateName(), rules.size() == 4); + for(unsigned long i=0;i<4; i++) {//? { + CPPUNIT_ASSERT_MESSAGE(rules[i]->toString(), + expectedRules.find(rules[i]->toString()) != expectedRules.end()); + } nukeToken(db->getClient(),token); } @@ -405,12 +467,14 @@ class FilterTests { UnboundVariableManager fm(*root); CPPUNIT_ASSERT(testEngine.playTransactions( (getTestLoadLibraryPath() + "/UnboundVariableFiltering.nddl").c_str() )); + // Set the horizon + Context ctx(""); + ctx.put("horizonStart", 0); + ctx.put("horizonEnd", 1000); + // Initialize after filling the database since we are not connected to an event source - fm.initialize(*root,testEngine.getPlanDatabase()); + fm.initialize(*root,testEngine.getPlanDatabase(), ctx.getId()); - // Set the horizon - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); // Simple filter on a variable ConstrainedVariableSet variables = testEngine.getConstraintEngine()->getVariables(); @@ -418,12 +482,12 @@ class FilterTests { ConstrainedVariableId var = *it; // Confirm temporal variables have been excluded - static const LabelStr excludedVariables(":start:end:duration:arg1:arg3:arg4:arg6:arg7:arg8:filterVar:"); - static const LabelStr includedVariables(":arg2:arg5:keepVar:"); - std::string s = ":" + var->getName().toString() + ":"; - if(excludedVariables.contains(s)) + static const std::string excludedVariables(":start:end:duration:arg1:arg3:arg4:arg6:arg7:arg8:filterVar:"); + static const std::string includedVariables(":arg2:arg5:keepVar:"); + std::string s = ":" + var->getName() + ":"; + if(excludedVariables.find(s) != std::string::npos) CPPUNIT_ASSERT_MESSAGE(var->toString(), !fm.inScope(var)); - else if(includedVariables.contains(s)) + else if(includedVariables.find(s) != std::string::npos) CPPUNIT_ASSERT_MESSAGE(var->toString(), fm.inScope(var)); } @@ -432,14 +496,18 @@ class FilterTests { ConstrainedVariableId globalVar1 = testEngine.getPlanDatabase()->getGlobalVariable("globalVariable1"); ConstrainedVariableId globalVar2 = testEngine.getPlanDatabase()->getGlobalVariable("globalVariable2"); ConstrainedVariableId globalVar3 = testEngine.getPlanDatabase()->getGlobalVariable("globalVariable3"); + CPPUNIT_ASSERT(!fm.inScope(globalVar1)); CPPUNIT_ASSERT(fm.inScope(globalVar2)); globalVar2->specify(globalVar2->lastDomain().getLowerBound()); testEngine.getConstraintEngine()->propagate(); + CPPUNIT_ASSERT(!fm.inScope(globalVar2)); - CPPUNIT_ASSERT(!fm.inScope(globalVar1)); // By propagation it will be a singleton, so it will be Excluded + + //CPPUNIT_ASSERT(!fm.inScope(globalVar1)); // By propagation it will be a singleton, so it will be Excluded globalVar2->reset(); testEngine.getConstraintEngine()->propagate(); + CPPUNIT_ASSERT(!fm.inScope(globalVar1)); CPPUNIT_ASSERT(fm.inScope(globalVar2)); @@ -454,19 +522,20 @@ class FilterTests { TestEngine testEngine; OpenConditionManager fm(*root); - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/OpenConditionFiltering.nddl").c_str() )); + Context ctx(""); + ctx.put("horizonStart", 0); + ctx.put("horizonEnd", 1000); // Initialize with data in the database - fm.initialize(*root,testEngine.getPlanDatabase()); + fm.initialize(*root,testEngine.getPlanDatabase(), ctx.getId()); TokenSet tokens = testEngine.getPlanDatabase()->getTokens(); for(TokenSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it){ - static const LabelStr excludedPredicates(":D.predicateA:D.predicateB:D.predicateC:E.predicateC:HorizonFiltered.predicate1:HorizonFiltered.predicate2:HorizonFiltered.predicate5:"); + static const std::string excludedPredicates(":D.predicateA:D.predicateB:D.predicateC:E.predicateC:HorizonFiltered.predicate1:HorizonFiltered.predicate2:HorizonFiltered.predicate5:"); TokenId token = *it; - std::string s = ":" + token->getPredicateName().toString() + ":"; - if(excludedPredicates.contains(s)) + std::string s = ":" + token->getPredicateName() + ":"; + if(excludedPredicates.find(s) != std::string::npos) CPPUNIT_ASSERT_MESSAGE(token->toString() + " is in scope after all.", !fm.inScope(token)); else CPPUNIT_ASSERT_MESSAGE(token->toString() + " is not in scope and not active.", token->isActive() || fm.inScope(token)); @@ -481,20 +550,21 @@ class FilterTests { TestEngine testEngine; ThreatManager fm(*root); - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); + Context ctx(""); + ctx.put("horizonStart", 0); + ctx.put("horizonEnd", 1000); CPPUNIT_ASSERT(testEngine.playTransactions(( getTestLoadLibraryPath() + "/ThreatFiltering.nddl").c_str())); // Initialize with data in the database - fm.initialize(*root,testEngine.getPlanDatabase()); + fm.initialize(*root,testEngine.getPlanDatabase(), ctx.getId()); TokenSet tokens = testEngine.getPlanDatabase()->getTokens(); for(TokenSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it){ - static const LabelStr excludedPredicates(":D.predicateA:D.predicateB:D.predicateC:E.predicateC:HorizonFiltered.predicate1:HorizonFiltered.predicate2:HorizonFiltered.predicate5:"); + static const std::string excludedPredicates(":D.predicateA:D.predicateB:D.predicateC:E.predicateC:HorizonFiltered.predicate1:HorizonFiltered.predicate2:HorizonFiltered.predicate5:"); TokenId token = *it; CPPUNIT_ASSERT_MESSAGE(token->toString() + " is not in scope and not active.", token->isActive() || !fm.inScope(token)); - std::string s = ":" + token->getPredicateName().toString() + ":"; - if(excludedPredicates.contains(s)) + std::string s = ":" + token->getPredicateName() + ":"; + if(excludedPredicates.find(s) != std::string::npos) CPPUNIT_ASSERT_MESSAGE(token->toString() + " is in scope after all.", !fm.inScope(token)); } @@ -565,7 +635,7 @@ class FlawHandlerTests { // test H3 { - TokenId token = db->getClient()->createToken("D.predicateG", NULL, false); + TokenId token = db->getClient()->createToken("D.predicateG", "", false); token->activate(); TokenId E_predicateC = *(token->slaves().begin()); std::vector rules; @@ -594,7 +664,7 @@ class FlawHandlerTests { // test H0 { - TokenId token = db->getClient()->createToken("D.predicateG", NULL, false); + TokenId token = db->getClient()->createToken("D.predicateG", "", false); std::vector rules; me.getMatches(token, rules); CPPUNIT_ASSERT_MESSAGE(toString(rules.size()), rules.size() == 1); @@ -614,7 +684,7 @@ class FlawHandlerTests { // test H1 { - TokenId token = db->getClient()->createToken("C.predicateA", NULL, false); + TokenId token = db->getClient()->createToken("C.predicateA", "", false); std::vector rules; me.getMatches(token, rules); CPPUNIT_ASSERT_MESSAGE(toString(rules.size()), rules.size() == 1); @@ -626,7 +696,7 @@ class FlawHandlerTests { // test H2 { - TokenId token = db->getClient()->createToken("B.predicateC", NULL, false); + TokenId token = db->getClient()->createToken("B.predicateC", "", false); { std::vector rules; me.getMatches(token, rules); @@ -680,7 +750,7 @@ class FlawHandlerTests { // test basic flaw filtering and default handler access { - TokenId token = db->getClient()->createToken("D.predicateG", NULL, false); + TokenId token = db->getClient()->createToken("D.predicateG", "", false); db->getConstraintEngine()->propagate(); // Initially the token is in scope and the variable is not CPPUNIT_ASSERT(solver.inScope(token)); @@ -734,11 +804,11 @@ class FlawHandlerTests { // Now handle a case with increasingly restrictive filters { - TokenId master = db->getClient()->createToken("D.predicateF", NULL, false); + TokenId master = db->getClient()->createToken("D.predicateF", "", false); db->getConstraintEngine()->propagate(); master->activate(); TokenId slave = master->getSlave(1); - CPPUNIT_ASSERT_MESSAGE(slave->getPredicateName().toString(), slave->getPredicateName() == LabelStr("D.predicateC")); + CPPUNIT_ASSERT_MESSAGE(slave->getPredicateName(), slave->getPredicateName() == "D.predicateC"); // With no guards set, we should just get the default priority db->getConstraintEngine()->propagate(); @@ -784,7 +854,8 @@ class FlawHandlerTests { Solver solver(testEngine.getPlanDatabase(), *child); CPPUNIT_ASSERT(solver.solve()); CPPUNIT_ASSERT(solver.getStepCount() == solver.getDepth()); - CPPUNIT_ASSERT_MESSAGE(toString(solver.getStepCount()), solver.getStepCount() == 2); + CPPUNIT_ASSERT_MESSAGE(toString(solver.getStepCount()), solver.getStepCount() == 5); + ConstrainedVariableId v1 = testEngine.getPlanDatabase()->getGlobalVariable("v1"); CPPUNIT_ASSERT_MESSAGE(v1->toString(), v1->lastDomain().getSingletonValue() == 1); ConstrainedVariableId v2 = testEngine.getPlanDatabase()->getGlobalVariable("v2"); @@ -803,7 +874,7 @@ class FlawHandlerTests { Solver solver(testEngine.getPlanDatabase(), *child); CPPUNIT_ASSERT(solver.solve()); CPPUNIT_ASSERT(solver.getStepCount() == solver.getDepth()); - CPPUNIT_ASSERT_MESSAGE(toString(solver.getStepCount()), solver.getStepCount() == 3); + CPPUNIT_ASSERT_MESSAGE(toString(solver.getStepCount()), solver.getStepCount() == 5); ConstrainedVariableId v1 = testEngine.getPlanDatabase()->getGlobalVariable("v1"); CPPUNIT_ASSERT_MESSAGE(v1->toString(), v1->getSpecifiedValue() == 9); ConstrainedVariableId v2 = testEngine.getPlanDatabase()->getGlobalVariable("v2"); @@ -1542,10 +1613,29 @@ class SolverTests { EUROPA_runTest(testDeletedFlaw); EUROPA_runTest(testDeleteAfterCommit); EUROPA_runTest(testSingleonGuardLoop); + EUROPA_runTest(testNoMoreFlawsAfterAddition); return true; } private: + static bool testNoMoreFlawsAfterAddition() { + TestEngine testEngine; + TiXmlElement* root = initXml( (getTestLoadLibraryPath() + "/SolverTests.xml").c_str(), "SingletonLoop"); + TiXmlElement* child = root->FirstChildElement(); + + CPPUNIT_ASSERT(testEngine.playTransactions( (getTestLoadLibraryPath() + "/StaticCSP.nddl").c_str())); + Solver solver(testEngine.getPlanDatabase(), *child); + CPPUNIT_ASSERT(solver.solve()); + CPPUNIT_ASSERT(solver.noMoreFlaws()); + + testEngine.getPlanDatabase()->getClient()->createVariable("int", + IntervalIntDomain(0, 10), + "v5"); + CPPUNIT_ASSERT(!solver.noMoreFlaws()); + + return true; + } + /** * @brief Tests for an infinite loop when binding a singleton guard. @@ -1583,20 +1673,20 @@ class SolverTests { // Run the solver again. CPPUNIT_ASSERT(solver.solve()); - CPPUNIT_ASSERT(solver.getStepCount() == 2); - CPPUNIT_ASSERT(solver.getDepth() == 2); + CPPUNIT_ASSERT(solver.getStepCount() == 5); + CPPUNIT_ASSERT(solver.getDepth() == 5); // Now clear it and run it again solver.reset(); CPPUNIT_ASSERT(solver.solve()); - CPPUNIT_ASSERT(solver.getStepCount() == 2); - CPPUNIT_ASSERT(solver.getDepth() == 2); + CPPUNIT_ASSERT(solver.getStepCount() == 5); + CPPUNIT_ASSERT(solver.getDepth() == 5); // Now partially reset it, and run again solver.reset(1); CPPUNIT_ASSERT(solver.solve()); CPPUNIT_ASSERT_MESSAGE(toString(solver.getStepCount()), solver.getStepCount() == 1); - CPPUNIT_ASSERT_MESSAGE(toString(solver.getDepth()), solver.getDepth() == 2); + CPPUNIT_ASSERT_MESSAGE(toString(solver.getDepth()), solver.getDepth() == 5); // Now we reset one decision, then clear it. Expect the solution and depth to be 1. solver.reset(1); @@ -1634,10 +1724,10 @@ class SolverTests { debugMsg("SolverTests:testExhaustinveSearch", "Step count == " << solver.getStepCount()); const ConstrainedVariableSet& allVars = testEngine.getPlanDatabase()->getGlobalVariables(); - unsigned int stepCount = 0; - unsigned int product = 1; + unsigned long stepCount = 0; + unsigned long product = 1; for(ConstrainedVariableSet::const_iterator it = allVars.begin(); it != allVars.end(); ++it){ - static const unsigned int baseDomainSize = (*it)->baseDomain().getSize(); + static const unsigned long baseDomainSize = (*it)->baseDomain().getSize(); stepCount = stepCount + (product*baseDomainSize); product = product*baseDomainSize; } @@ -1652,10 +1742,12 @@ class SolverTests { TiXmlElement* root = initXml((getTestLoadLibraryPath() + "/SolverTests.xml").c_str(), "SimpleActivationSolver"); TiXmlElement* child = root->FirstChildElement(); { - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/SimpleActivation.nddl").c_str())); Solver solver(testEngine.getPlanDatabase(), *child); + ContextId ctx = solver.getContext(); + ctx->put("horizonStart", 0); + ctx->put("horizonEnd", 1000); + CPPUNIT_ASSERT(solver.solve()); } @@ -1667,12 +1759,15 @@ class SolverTests { TiXmlElement* root = initXml((getTestLoadLibraryPath() + "/SolverTests.xml").c_str(), "SimpleRejectionSolver"); TiXmlElement* child = root->FirstChildElement(); { - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); + CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/SimpleRejection.nddl").c_str())); Solver solver(testEngine.getPlanDatabase(), *child); + ContextId ctx = solver.getContext(); + ctx->put("horizonStart", 0); + ctx->put("horizonEnd", 1000); + CPPUNIT_ASSERT(solver.solve(100, 100)); CPPUNIT_ASSERT_MESSAGE(toString(testEngine.getPlanDatabase()->getTokens().size()), testEngine.getPlanDatabase()->getTokens().size() == 1); } @@ -1747,11 +1842,11 @@ class SolverTests { unsigned int solutionCount = 1; unsigned int timeoutCount = 0; unsigned int iterationCount = 0; - unsigned int backjumpDistance = 1; + unsigned long backjumpDistance = 1; while(iterationCount < solutionLimit && !solver.isExhausted()){ debugMsg("SolverTests:testMultipleSolutionsSearch", "Solving for iteration " << iterationCount); - unsigned int priorDepth = solver.getDepth(); + unsigned long priorDepth = solver.getDepth(); iterationCount++; solver.backjump(backjumpDistance); solver.solve(10); @@ -1806,7 +1901,7 @@ class SolverTests { TiXmlElement* root = initXml(xml); Solver solver(testEngine.getPlanDatabase(), *root); ContextId ctx = solver.getContext(); - CPPUNIT_ASSERT(ctx->getName() == LabelStr(solver.getName().toString() + "Context")); + CPPUNIT_ASSERT(ctx->getName() == solver.getName() + "Context"); ctx->put("foo", 1); CPPUNIT_ASSERT(ctx->get("foo") == 1); CPPUNIT_ASSERT(solver.getContext()->get("foo") == 1); @@ -1853,18 +1948,20 @@ class SolverTests { // iterate over the possibilties with commiting and deleting with four tokens for(int i=1;i<255;i++) { - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 40); + ContextId ctx = solver.getContext(); + ctx->put("horizonStart", 0); + ctx->put("horizonEnd", 40); + TokenId first = db->getClient()->createToken("CommitTest.chaina", "first", false); first->start()->specify(0); solver.solve(100,100); TokenId second = first->getSlave(0); - CPPUNIT_ASSERT_MESSAGE(second->getPredicateName().toString(), second->getPredicateName() == LabelStr("CommitTest.chainb")); + CPPUNIT_ASSERT_MESSAGE(second->getPredicateName(), second->getPredicateName() == "CommitTest.chainb"); TokenId third = second->getSlave(0); - CPPUNIT_ASSERT_MESSAGE(third->getPredicateName().toString(), third->getPredicateName() == LabelStr("CommitTest.chaina")); + CPPUNIT_ASSERT_MESSAGE(third->getPredicateName(), third->getPredicateName() == "CommitTest.chaina"); TokenId fourth = third->getSlave(0); - CPPUNIT_ASSERT_MESSAGE(fourth->getPredicateName().toString(), fourth->getPredicateName() == LabelStr("CommitTest.chainb")); + CPPUNIT_ASSERT_MESSAGE(fourth->getPredicateName(), fourth->getPredicateName() == "CommitTest.chainb"); if(i & (1 << 0)) first->commit(); @@ -1888,7 +1985,10 @@ class SolverTests { CPPUNIT_ASSERT_MESSAGE("Solver must be valid after discards.", solver.isValid()); - horizon = IntervalIntDomain(0, 40); + + ctx = solver.getContext(); + ctx->put("horizonStart", 0); + ctx->put("horizonEnd", 40); solver.solve(100,100); // TODO: this is failing, why? re-enable after understanding causes //CPPUNIT_ASSERT_MESSAGE("Solver must be valid after continuing solving after discards.", solver.isValid()); @@ -1923,16 +2023,18 @@ class FlawIteratorTests { TestEngine testEngine; UnboundVariableManager fm(*root); - fm.initialize(*root,testEngine.getPlanDatabase()); + Context ctx(""); + ctx.put("horizonStart", 0); + ctx.put("horizonEnd", 1000); + fm.initialize(*root,testEngine.getPlanDatabase(), ctx.getId()); CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/UnboundVariableFiltering.nddl").c_str())); - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); ConstrainedVariableSet variables = testEngine.getConstraintEngine()->getVariables(); IteratorId flawIterator = fm.createIterator(); while(!flawIterator->done()) { - const ConstrainedVariableId var = (const ConstrainedVariableId) flawIterator->next(); + // const ConstrainedVariableId var = (const ConstrainedVariableId) flawIterator->next(); + const ConstrainedVariableId var = flawIterator->next(); if(var.isNoId()) continue; CPPUNIT_ASSERT(fm.inScope(var)); @@ -1945,7 +2047,7 @@ class FlawIteratorTests { for(ConstrainedVariableSet::const_iterator it = variables.begin(); it != variables.end(); ++it) CPPUNIT_ASSERT(!fm.inScope(*it)); - delete (Iterator*) flawIterator; + delete static_cast(flawIterator); delete root; return true; } @@ -1955,16 +2057,18 @@ class FlawIteratorTests { TestEngine testEngine; OpenConditionManager fm(*root); - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); - fm.initialize(*root,testEngine.getPlanDatabase()); + Context ctx(""); + ctx.put("horizonStart", 0); + ctx.put("horizonEnd", 1000); + + fm.initialize(*root,testEngine.getPlanDatabase(), ctx.getId()); CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/OpenConditionFiltering.nddl").c_str())); TokenSet tokens = testEngine.getPlanDatabase()->getTokens(); IteratorId flawIterator = fm.createIterator(); while(!flawIterator->done()) { - const TokenId token = (const TokenId) flawIterator->next(); + const TokenId token = flawIterator->next(); if(token.isNoId()) continue; CPPUNIT_ASSERT(fm.inScope(token)); @@ -1977,7 +2081,7 @@ class FlawIteratorTests { for(TokenSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it) CPPUNIT_ASSERT(!fm.inScope(*it)); - delete (Iterator*) flawIterator; + delete static_cast(flawIterator); delete root; return true; @@ -1988,16 +2092,17 @@ class FlawIteratorTests { TestEngine testEngine; ThreatManager fm(*root); - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); - fm.initialize(*root,testEngine.getPlanDatabase()); + Context ctx(""); + ctx.put("horizonStart", 0); + ctx.put("horizonEnd", 1000); + fm.initialize(*root,testEngine.getPlanDatabase(), ctx.getId()); CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/ThreatFiltering.nddl").c_str())); TokenSet tokens = testEngine.getPlanDatabase()->getTokens(); IteratorId flawIterator = fm.createIterator(); while(!flawIterator->done()) { - const TokenId token = (const TokenId) flawIterator->next(); + const TokenId token = flawIterator->next(); if(token.isNoId()) continue; CPPUNIT_ASSERT(fm.inScope(token)); @@ -2010,7 +2115,7 @@ class FlawIteratorTests { for(TokenSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it) CPPUNIT_ASSERT(!fm.inScope(*it)); - delete (Iterator*) flawIterator; + delete static_cast(flawIterator); delete root; return true; } @@ -2023,8 +2128,9 @@ class FlawIteratorTests { UnboundVariableManager uvm(*(root->FirstChildElement("UnboundVariableManager"))); Solver solver(testEngine.getPlanDatabase(), *root); - IntervalIntDomain& horizon = HorizonFilter::getHorizon(); - horizon = IntervalIntDomain(0, 1000); + ContextId ctx = solver.getContext(); + ctx->put("horizonStart", 0); + ctx->put("horizonEnd", 1000); CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/ThreatFiltering.nddl").c_str())); @@ -2041,13 +2147,13 @@ class FlawIteratorTests { if(entity.isNoId()) continue; if(TokenId::convertable(entity)) { - const TokenId tok = (const TokenId) entity; + const TokenId tok = entity; CPPUNIT_ASSERT(tm.inScope(tok) || ocm.inScope(tok)); CPPUNIT_ASSERT(tokens.find(tok) != tokens.end()); tokens.erase(tok); } else if(ConstrainedVariableId::convertable(entity)) { - const ConstrainedVariableId var = (const ConstrainedVariableId) entity; + const ConstrainedVariableId var = entity; CPPUNIT_ASSERT(uvm.inScope(var)); CPPUNIT_ASSERT(vars.find(var) != vars.end()); std::cerr << var->toString() << std::endl; @@ -2065,24 +2171,147 @@ class FlawIteratorTests { CPPUNIT_ASSERT(!uvm.inScope(*it)); } - delete (Iterator*) flawIterator; + delete static_cast(flawIterator); delete root; return true; } }; + +class FlawManagerListener : public ConstraintEngineListener { + public: + FlawManagerListener(const ConstraintEngineId ce, FlawManager& fm) + : ConstraintEngineListener(ce), m_fm(fm) {} + void notifyChanged(const ConstrainedVariableId var, const DomainListener::ChangeType& change) { + m_fm.notifyChanged(var, change); + } + private: + FlawManager& m_fm; +}; + class FlawManagerTests { public: static bool test() { + EUROPA_runTest(testUnboundVariableNoMoreFlaws); + EUROPA_runTest(testThreatNoMoreFlaws); + EUROPA_runTest(testOpenConditionNoMoreFlaws); + return true; + } + static bool testUnboundVariableNoMoreFlaws() { + TestEngine testEngine; + TiXmlElement* root = initXml( (getTestLoadLibraryPath() + "/SolverTests.xml").c_str(), "SingletonLoop"); + TiXmlElement* child = root->FirstChildElement()->FirstChildElement("UnboundVariableManager"); + Context ctx("foo"); + UnboundVariableManager m(*child); + + CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/StaticCSP.nddl").c_str())); + m.initialize(*child, testEngine.getPlanDatabase(), ctx.getId()); + FlawManagerListener listener(testEngine.getConstraintEngine(), m); + + CPPUNIT_ASSERT(!m.noMoreFlaws()); + Priority p = worstCasePriority() + 1; + std::list decisions; + for(DecisionPointId d = m.next(p); d.isValid(); d = m.next(p)) { + d->initialize(); + d->execute(); + CPPUNIT_ASSERT(testEngine.getConstraintEngine()->propagate()); + decisions.push_front(d); + p = worstCasePriority() + 1; + } + CPPUNIT_ASSERT(m.noMoreFlaws()); + + testEngine.getPlanDatabase()->getClient()->createVariable("int", + IntervalIntDomain(0, 10), + "v5"); + CPPUNIT_ASSERT(!m.noMoreFlaws()); + + for(std::list::iterator it = decisions.begin(); + it != decisions.end(); ++it) { + delete static_cast(*it); + } + delete root; + return true; + } + static bool testThreatNoMoreFlaws() { + TestEngine testEngine; + DbClientId client = testEngine.getPlanDatabase()->getClient(); + TiXmlElement* root = + initXml((getTestLoadLibraryPath() + "/SolverTests.xml").c_str(), + "SimpleActivationSolver"); + TiXmlElement* child = + root->FirstChildElement()->FirstChildElement("ThreatManager"); + Context ctx("SimpleTokenSolverContext"); + ctx.put("horizonStart", 0); + ctx.put("horizonEnd", 100); + ThreatManager m(*child); + + CPPUNIT_ASSERT(testEngine.playTransactions((getTestLoadLibraryPath() + "/Model.nddl").c_str())); + ObjectId t = client->createObject("PredicateRoot", "foo"); + TokenId t0 = client->createToken("PredicateRoot.predicateD"); + TokenId t1 = client->createToken("PredicateRoot.predicateD"); + client->activate(t0); + client->activate(t1); + + m.initialize(*child, testEngine.getPlanDatabase(), ctx.getId()); + FlawManagerListener listener(testEngine.getConstraintEngine(), m); + + CPPUNIT_ASSERT(!m.noMoreFlaws()); + + client->constrain(t, t0, t1); + CPPUNIT_ASSERT(m.noMoreFlaws()); + + TokenId t2 = client->createToken("PredicateRoot.predicateD"); + client->activate(t2); + CPPUNIT_ASSERT(!m.noMoreFlaws()); + + delete root; + return true; + } + static bool testOpenConditionNoMoreFlaws() { + TestEngine testEngine; + TiXmlElement* root = initXml( (getTestLoadLibraryPath() + "/SolverTests.xml").c_str(), "GNATS_3196"); + TiXmlElement* child = root->FirstChildElement()->FirstChildElement("OpenConditionManager"); + Context ctx("foo"); + OpenConditionManager m(*child); + + CPPUNIT_ASSERT(testEngine.playTransactions( (getTestLoadLibraryPath() + "/OpenConditionFiltering.nddl").c_str())); + m.initialize(*child, testEngine.getPlanDatabase(), ctx.getId()); + FlawManagerListener listener(testEngine.getConstraintEngine(), m); + + + CPPUNIT_ASSERT(!m.noMoreFlaws()); + Priority p = worstCasePriority() + 1; + std::list decisions; + for(DecisionPointId d = m.next(p); d.isValid(); d = m.next(p)) { + d->initialize(); + d->execute(); + CPPUNIT_ASSERT(testEngine.getConstraintEngine()->propagate()); + decisions.push_front(d); + p = worstCasePriority() + 1; + } + CPPUNIT_ASSERT(m.noMoreFlaws()); + + testEngine.getPlanDatabase()->getClient()->createToken("HorizonFiltered.predicate1", + "testToken", + true, + false); + CPPUNIT_ASSERT(!m.noMoreFlaws()); + + for(std::list::iterator it = decisions.begin(); + it != decisions.end(); ++it) { + delete static_cast(*it); + } + delete root; return true; } }; -void registerTestElements(EngineId& engine) +void registerTestElements(EngineId engine) { - CESchema* ces = (CESchema*)engine->getComponent("CESchema"); - EUROPA::SOLVERS::ComponentFactoryMgr* cfm = (EUROPA::SOLVERS::ComponentFactoryMgr*)engine->getComponent("ComponentFactoryMgr"); + CESchema* ces = reinterpret_cast(engine->getComponent("CESchema")); + EUROPA::SOLVERS::ComponentFactoryMgr* cfm = + reinterpret_cast(engine->getComponent("ComponentFactoryMgr")); // For tests on the matching engine REGISTER_COMPONENT_FACTORY(cfm,MatchingRule, MatchingRule); diff --git a/src/PLASMA/Solvers/test/solvers-test-module.hh b/src/PLASMA/Solvers/test/solvers-test-module.hh index e2088cefd..e71217af0 100644 --- a/src/PLASMA/Solvers/test/solvers-test-module.hh +++ b/src/PLASMA/Solvers/test/solvers-test-module.hh @@ -6,22 +6,22 @@ #include class SolversModuleTests : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(SolversModuleTests); - CPPUNIT_TEST(componentFactoryTests); - CPPUNIT_TEST(filterTests); - CPPUNIT_TEST(flawIteratorTests); - CPPUNIT_TEST(flawManagerTests); - CPPUNIT_TEST(flawHandlerTests); - CPPUNIT_TEST(solverTests); - CPPUNIT_TEST_SUITE_END(); + CPPUNIT_TEST_SUITE(SolversModuleTests); + CPPUNIT_TEST(componentFactoryTests); + CPPUNIT_TEST(filterTests); + CPPUNIT_TEST(flawIteratorTests); + CPPUNIT_TEST(flawManagerTests); + CPPUNIT_TEST(flawHandlerTests); + CPPUNIT_TEST(solverTests); + CPPUNIT_TEST_SUITE_END(); public: - inline void setUp() + inline void setUp() { - cppTests(); - } - - inline void tearDown() + cppTests(); + } + + inline void tearDown() { } @@ -32,7 +32,7 @@ public: void flawManagerTests(); void flawHandlerTests(); void solverTests(); - + }; diff --git a/src/PLASMA/System/CMakeLists.txt b/src/PLASMA/System/CMakeLists.txt index 7a85d0b0e..7cc6f13ed 100644 --- a/src/PLASMA/System/CMakeLists.txt +++ b/src/PLASMA/System/CMakeLists.txt @@ -1,43 +1,128 @@ +#14 -> Yosemite +#13 -> Mavericks +#12 -> Mountain Lion +#11 -> Lion +#10 -> Snow Leopard if(${APPLE}) - set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) + exec_program(uname ARGS -r OUTPUT_VARIABLE DARWIN_VERSION) + + if(DARWIN_VERSION VERSION_EQUAL 14) + message(STATUS "Setting Yosemite include") + set(JNI_INCLUDE_DIRS /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/include) + else(DARWIN_VERSION) + message(STATUS "Setting pre-Yosemite include") + set(JNI_INCLUDE_DIRS /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) + endif(DARWIN_VERSION VERSION_EQUAL 14) else(${APPLE}) find_package(JNI REQUIRED) endif(${APPLE}) +set(ANTLR_FIND_REQUIRED TRUE) +include(FindANTLR) include(EuropaModule) +#Currently, this has to be the whole set of dependencies because of the loop later. +#I'm not sure why it is that System_FULL_DEPENDENCIES isn't visible in this scope set(internal_dependencies NDDL ANML Solvers Resource RulesEngine TemporalNetwork PlanDatabase ConstraintEngine Utils TinyXml) +set(root_sources "") +set(base_sources EuropaEngine.cc PSEngineImpl.cc) +set(component_sources "") +set(test_sources module-tests.cc) + +common_module_prepends("${base_sources}" "${component_sources}" "${test_sources}" base_sources component_sources test_sources) + +declare_module(System "${root_sources}" "${base_sources}" "${component_sources}" "${test_sources}" "${internal_dependencies}" "") + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/base) +#TODO: let the user configure which language or languages to build for find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) set(CMAKE_SWIG_FLAGS "") -#set(CMAKE_SWIG_OUTDIR "${CMAKE_SOURCE_DIR}/src/Java/PSEngine/generated/psengine") -set(CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_SOURCE_DIR}/base") +set(CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/psengine") set_source_files_properties(base/PSEngine.i PROPERTIES CPLUSPLUS ON) -set_source_files_properties(base/PSEngine.i PROPERTIES SWIG_FLAGS "-includeall") -#TEMPORARY +set_source_files_properties(base/PSEngine.i PROPERTIES SWIG_FLAGS "-package;psengine;-includeall") +find_package(Java REQUIRED) +include(UseJava RESULT_VARIABLE java_included) +if(NOT java_included) + message(FATAL_ERROR "Failed to include UseJava") +endif(NOT java_included) -#set(JNI_HOME /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers) -include_directories(${JNI_INCLUDE_DIRS}) -swig_add_module(PSEngine java base/PSEngine.i) -foreach(dep ${internal_dependencies}) - add_common_module_include_dep(PSEngine ${dep}) - target_link_libraries(PSEngine "${dep}${EUROPA_SUFFIX}") -endforeach(dep) -target_link_libraries(PSEngine "System${EUROPA_SUFFIX}") -#swig_link_libraries(PSEngine) +if(NOT EUROPA_ROOT) +message(FATAL_ERROR "EUROPA_ROOT not set") +endif(NOT EUROPA_ROOT) +message(STATUS "EUROPA_ROOT: ${EUROPA_ROOT}") -set(root_sources "") -get_filename_component(swig_generated_source ${swig_generated_file_fullname} NAME) -#set(base_sources EuropaEngine.cc PSEngineImpl.cc ${swig_generated_source}) -set(base_sources EuropaEngine.cc PSEngineImpl.cc) -set(component_sources "") -set(test_sources module-tests.cc) +set(SWIG_GENERATED_JAVA + psengine/PSConstraint.java + psengine/PSConstraintEngineListener.java + psengine/PSConstraintList.java + psengine/PSDataType.java + psengine/PSDataTypeList.java + psengine/PSEngine.java + psengine/PSEngineInterface.java + psengine/PSEngineInterfaceJNI.java + psengine/PSEntity.java + psengine/PSException.java + psengine/PSIntList.java + psengine/PSLanguageException.java + psengine/PSLanguageExceptionList.java + psengine/PSObject.java + psengine/PSObjectList.java + psengine/PSObjectType.java + psengine/PSObjectTypeList.java + psengine/PSPlanDatabaseClient.java + psengine/PSPlanDatabaseListener.java + psengine/PSResource.java + psengine/PSResourceProfile.java + psengine/PSSchema.java + psengine/PSSolver.java + psengine/PSStringList.java + psengine/PSTimePointList.java + psengine/PSToken.java + psengine/PSTokenList.java + psengine/PSTokenState.java + psengine/PSTokenType.java + psengine/PSTokenTypeList.java + psengine/PSValueList.java + psengine/PSVarType.java + psengine/PSVarValue.java + psengine/PSVariable.java + psengine/PSVariableList.java + psengine/StringErrorStream.java + psengine/EngineConfig.java +) -common_module_prepends("${base_sources}" "${component_sources}" "${test_sources}" base_sources component_sources test_sources) +set(SWIG_GENERATED_JAVA_FULL_PATH "") +foreach(f ${SWIG_GENERATED_JAVA}) + list(APPEND SWIG_GENERATED_JAVA_FULL_PATH ${CMAKE_CURRENT_BINARY_DIR}/${f}) +endforeach(f) -declare_module(System "${root_sources}" "${base_sources}" "${component_sources}" "${test_sources}" "${internal_dependencies}" "") +add_jar(PSEngineGenerated + SOURCES ${SWIG_GENERATED_JAVA_FULL_PATH}) + #OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) + +include_directories(${ANTLR_INCLUDE_DIR}) +include_directories(${JNI_INCLUDE_DIRS}) +set(PSEngine_target PSEngine${EUROPA_SUFFIX}) +# file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/base) +swig_add_module(${PSEngine_target} java base/PSEngine.i) +# add_dependencies(${PSEngine_target} ${CMAKE_CURRENT_BINARY_DIR}/base) +#add_custom_command(TARGET ${PSEngine_target} PRE_LINK +# COMMAND mkdir base) + +#add_dependencies(${PSEngine_target} base) +foreach(dep ${internal_dependencies}) + add_common_module_include_dep(${PSEngine_target} ${dep}) + target_link_libraries(${PSEngine_target} "${dep}${EUROPA_SUFFIX}") +endforeach(dep) +add_common_module_include_dep(${PSEngine_target} System) +target_link_libraries(${PSEngine_target} "System${EUROPA_SUFFIX}") +add_dependencies(PSEngineGenerated ${PSEngine_target}) +install(TARGETS ${PSEngine_target} + EXPORT Europa2 + DESTINATION ${EUROPA_ROOT}/dist/europa) add_subdirectory(test) \ No newline at end of file diff --git a/src/PLASMA/System/base/EuropaEngine.cc b/src/PLASMA/System/base/EuropaEngine.cc index 3c8c4c34a..75cfff36c 100644 --- a/src/PLASMA/System/base/EuropaEngine.cc +++ b/src/PLASMA/System/base/EuropaEngine.cc @@ -17,20 +17,22 @@ // Solver Support #include "Solver.hh" +#include "Context.hh" #include "Filters.hh" #include "PlanDatabaseWriter.hh" +#include + namespace EUROPA { //namespace System { //TODO: mcr //Logger &EuropaEngine::LOGGER = Logger::getInstance( "EUROPA::System::EuropaEngine", Logger::DEBUG ); LOGGER_CLASS_INSTANCE_IMPL( EuropaEngine, "EUROPA::System::EuropaEngine", DEBUG ); - EuropaEngine::EuropaEngine() - { - Error::doThrowExceptions(); // throw exceptions! - Error::doDisplayErrors(); - } +EuropaEngine::EuropaEngine() : m_totalNodes(0), m_finalDepth(0) { + Error::doThrowExceptions(); // throw exceptions! + Error::doDisplayErrors(); +} EuropaEngine::~EuropaEngine() { @@ -60,13 +62,13 @@ namespace EUROPA { #endif } - ConstraintEngineId& EuropaEngine::getConstraintEngine() { return (ConstraintEngineId&)((ConstraintEngine*)getComponent("ConstraintEngine"))->getId(); } - PlanDatabaseId& EuropaEngine::getPlanDatabase() { return (PlanDatabaseId&)((PlanDatabase*)getComponent("PlanDatabase"))->getId(); } - RulesEngineId& EuropaEngine::getRulesEngine() { return (RulesEngineId&)((RulesEngine*)getComponent("RulesEngine"))->getId(); } +ConstraintEngineId EuropaEngine::getConstraintEngine() const { return boost::polymorphic_cast(getComponent("ConstraintEngine"))->getId(); } +PlanDatabaseId EuropaEngine::getPlanDatabase() const { return boost::polymorphic_cast(getComponent("PlanDatabase"))->getId(); } +RulesEngineId EuropaEngine::getRulesEngine() const { return boost::polymorphic_cast(getComponent("RulesEngine"))->getId(); } - const ConstraintEngine* EuropaEngine::getConstraintEnginePtr() const { return (const ConstraintEngine*)getComponent("ConstraintEngine"); } - const PlanDatabase* EuropaEngine::getPlanDatabasePtr() const { return (const PlanDatabase*)getComponent("PlanDatabase"); } - const RulesEngine* EuropaEngine::getRulesEnginePtr() const { return (const RulesEngine*)getComponent("RulesEngine"); } +const ConstraintEngine* EuropaEngine::getConstraintEnginePtr() const { return static_cast(getConstraintEngine());} +const PlanDatabase* EuropaEngine::getPlanDatabasePtr() const { return static_cast(getPlanDatabase());} +const RulesEngine* EuropaEngine::getRulesEnginePtr() const { return static_cast(getComponent("RulesEngine")); } // TODO: remains of the old Assemblies, these are only used by test code, should be dropped, eventually. bool EuropaEngine::playTransactions(const char* txSource, const char* language) @@ -130,24 +132,27 @@ namespace EUROPA { eint start = horizonStart->baseDomain().getSingletonValue(); eint end = horizonEnd->baseDomain().getSingletonValue(); - SOLVERS::HorizonFilter::getHorizon() = IntervalDomain(start, end); + solver->getContext()->put("horizonStart", cast_double(start)); + solver->getContext()->put("horizonEnd", cast_double(end)); // Now get planner step max - int steps = cast_int(plannerSteps->baseDomain().getSingletonValue()); - int depth = cast_int(maxDepth->baseDomain().getSingletonValue()); + unsigned int steps = + static_cast(cast_int(plannerSteps->baseDomain().getSingletonValue())); + unsigned int depth = + static_cast(cast_int(maxDepth->baseDomain().getSingletonValue())); bool retval = solver->solve(steps, depth); m_totalNodes = solver->getStepCount(); m_finalDepth = solver->getDepth(); - delete (SOLVERS::Solver*) solver; + delete static_cast(solver); return retval; } - unsigned int EuropaEngine::getTotalNodesSearched() const { return m_totalNodes; } + unsigned long EuropaEngine::getTotalNodesSearched() const { return m_totalNodes; } - unsigned int EuropaEngine::getDepthReached() const { return m_finalDepth; } + unsigned long EuropaEngine::getDepthReached() const { return m_finalDepth; } } diff --git a/src/PLASMA/System/base/EuropaEngine.hh b/src/PLASMA/System/base/EuropaEngine.hh index 1585d83e7..11267eea5 100644 --- a/src/PLASMA/System/base/EuropaEngine.hh +++ b/src/PLASMA/System/base/EuropaEngine.hh @@ -1,5 +1,5 @@ -#ifndef _H_EuropaEngine -#define _H_EuropaEngine +#ifndef H_EuropaEngine +#define H_EuropaEngine #include "Engine.hh" #include "Module.hh" @@ -21,9 +21,9 @@ namespace EUROPA { EuropaEngine(); virtual ~EuropaEngine(); - virtual ConstraintEngineId& getConstraintEngine(); - virtual PlanDatabaseId& getPlanDatabase(); - virtual RulesEngineId& getRulesEngine(); + virtual ConstraintEngineId getConstraintEngine() const; + virtual PlanDatabaseId getPlanDatabase() const; + virtual RulesEngineId getRulesEngine() const; virtual const ConstraintEngine* getConstraintEnginePtr() const; virtual const PlanDatabase* getPlanDatabasePtr() const; @@ -33,16 +33,16 @@ namespace EUROPA { virtual bool playTransactions(const char* txSource, const char* language="nddl-xml-txn"); virtual bool plan(const char* txSource, const char* config, const char* language="nddl-xml-txn"); virtual void write(std::ostream& os) const; - virtual unsigned int getTotalNodesSearched() const; - virtual unsigned int getDepthReached() const; + virtual unsigned long getTotalNodesSearched() const; + virtual unsigned long getDepthReached() const; static const char* TX_LOG(); protected: virtual void initializeModules(); virtual void createModules(); - unsigned int m_totalNodes; - unsigned int m_finalDepth; + unsigned long m_totalNodes; + unsigned long m_finalDepth; }; } diff --git a/src/PLASMA/System/base/PSEngine.hh b/src/PLASMA/System/base/PSEngine.hh index 2f578ab64..92e2bbc21 100644 --- a/src/PLASMA/System/base/PSEngine.hh +++ b/src/PLASMA/System/base/PSEngine.hh @@ -1,5 +1,5 @@ -#ifndef _H_PSEngine -#define _H_PSEngine +#ifndef H_PSEngine +#define H_PSEngine #include "PSConstraintEngine.hh" #include "PSPlanDatabase.hh" diff --git a/src/PLASMA/System/base/PSEngine.i b/src/PLASMA/System/base/PSEngine.i index 1e052a7ed..290f0a716 100644 --- a/src/PLASMA/System/base/PSEngine.i +++ b/src/PLASMA/System/base/PSEngine.i @@ -10,6 +10,7 @@ #include "PSPlanDatabaseListener.hh" #include "PSConstraintEngineListener.hh" #include "NddlInterpreter.hh" + #include "PSVarValue.hh" %} %rename(PSException) Error; // Our Error C++ class is wrapped instead as PSException @@ -194,6 +195,17 @@ namespace EUROPA { void clear(); }; + template + class PSList { + public: + PSList(); + int size() const; + T* get(int idx); + void push_back(T* const value); + void remove(T* const value); + void clear(); + }; + %template(PSObjectList) PSList; %template(PSTokenList) PSList; %template(PSVariableList) PSList; @@ -360,7 +372,7 @@ namespace EUROPA { public: ~PSSchema(); PSList getAllPredicates() const; - PSList getMembers(const std::string& objectType) const; + PSList getObjectMembers(const std::string& objectType) const; bool hasMember(const std::string& parentType, const std::string& memberName) const; PSList getAllPSObjectTypes() const; diff --git a/src/PLASMA/System/base/PSEngineImpl.cc b/src/PLASMA/System/base/PSEngineImpl.cc index a0c892878..e5f717d21 100644 --- a/src/PLASMA/System/base/PSEngineImpl.cc +++ b/src/PLASMA/System/base/PSEngineImpl.cc @@ -4,8 +4,6 @@ */ #include "PSEngineImpl.hh" - -#include "LabelStr.hh" #ifdef _MSC_VER #include "Pdlfcn.hh" #endif @@ -24,9 +22,7 @@ namespace EUROPA { return new PSEngineImpl(); } - PSEngineImpl::PSEngineImpl() - { - } +PSEngineImpl::PSEngineImpl() : m_started(false) {} PSEngineImpl::~PSEngineImpl() { @@ -195,7 +191,7 @@ namespace EUROPA { PSSolver* PSEngineImpl::createSolver(const std::string& configurationFile) { check_runtime_error(isStarted(),"PSEngine has not been started"); - return ((PSSolverManager*)getComponent("PSSolverManager"))->createSolver(configurationFile); + return boost::polymorphic_cast(getComponent("PSSolverManager"))->createSolver(configurationFile); } } diff --git a/src/PLASMA/System/base/PSEngineImpl.hh b/src/PLASMA/System/base/PSEngineImpl.hh index 8e28c9853..979d43e60 100644 --- a/src/PLASMA/System/base/PSEngineImpl.hh +++ b/src/PLASMA/System/base/PSEngineImpl.hh @@ -1,5 +1,5 @@ -#ifndef _H_PSEngineImpl -#define _H_PSEngineImpl +#ifndef H_PSEngineImpl +#define H_PSEngineImpl #include "PSEngine.hh" #include "EuropaEngine.hh" @@ -18,7 +18,9 @@ namespace EUROPA { virtual EngineConfig* getConfig(); virtual void addModule(Module* module); + virtual void addModule(ModuleId module) {addModule(static_cast(module));} virtual void removeModule(Module* module); + virtual void removeModule(ModuleId module) {removeModule(static_cast(module));} virtual void loadModule(const std::string& moduleFileName); virtual std::string executeScript(const std::string& language, const std::string& script, bool isFile); @@ -66,4 +68,4 @@ namespace EUROPA { } -#endif // _H_PSEngineImpl +#endif // H_PSEngineImpl diff --git a/src/PLASMA/System/test/CMakeLists.txt b/src/PLASMA/System/test/CMakeLists.txt index 7d5e68d6c..a4bcd9465 100644 --- a/src/PLASMA/System/test/CMakeLists.txt +++ b/src/PLASMA/System/test/CMakeLists.txt @@ -14,7 +14,8 @@ set(resource_tests better-res resource-backtrack-test resource-backtrack-test-reservoir #Rover-transaction - Rover-transaction-reservoir) + Rover-transaction-reservoir + constraint-to-temporal) set(system_tests backtrack-test merge-with-open-domain @@ -30,36 +31,48 @@ set(system_tests backtrack-test subtype-extension.tx) -function(run_planner_problem model configFile dep) +function(run_planner_problem model configFile compare dep) set(is_nddl FALSE) string(REGEX MATCH ".nddl^" is_nddl ${model}) if(NOT is_nddl) set(model "${model}.nddl") endif(NOT is_nddl) - set(test_target run-nddl-interp-${model}) + set(test_target run-nddl-interp-${model}-${configFile}) add_test(NAME ${test_target} - COMMAND ${exec_plan} ${model} ${configFile} nddl) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} + -Dexec_plan=${CMAKE_CURRENT_BINARY_DIR}/${exec_plan} + -Dmodel=${model} + -DconfigFile=${configFile} + -Dlanguage=nddl + -Doutput_file=${CMAKE_CURRENT_BINARY_DIR}/${test_target}.out + # -Dplan_compare=diff + -Dplan_compare=${CMAKE_CURRENT_SOURCE_DIR}/plan-diff.pl + -Dgold_file=${CMAKE_CURRENT_SOURCE_DIR}/data/${test_target}.out + -Ddiff_file=${CMAKE_CURRENT_BINARY_DIR}/${test_target}.diff + -Dcompare=${compare} + -P ${CMAKE_CURRENT_SOURCE_DIR}/plan-and-compare.cmake) #add_dependencies(${dep} ${test_target}) endfunction(run_planner_problem) foreach(test ${checkin_tests}) - run_planner_problem(${test} ${DEFAULT_PCONFIG} common-tests) + run_planner_problem(${test} ${DEFAULT_PCONFIG} true common-tests) endforeach(test) foreach(test ${resource_tests}) - run_planner_problem(${test} ${DEFAULT_PCONFIG} common-tests) + run_planner_problem(${test} ${DEFAULT_PCONFIG} true common-tests) endforeach(test) foreach(test ${system_tests}) - run_planner_problem(${test} ${DEFAULT_PCONFIG} common-tests) + run_planner_problem(${test} ${DEFAULT_PCONFIG} true common-tests) endforeach(test) -run_planner_problem(HTX.1 HTX.1.solverConfig.xml nddl) +run_planner_problem(HTX.1 HTX.1.solverConfig.xml true other-tests) #TODO: find out why this doesn't get run in the Jamfile #run_planner_problem(HTX.2 HTX.2.solverConfig.xml nddl) -run_planner_problem(HTX.3 HTX.3.solverConfig.xml nddl) -run_planner_problem(reusable-test-transaction ReusableTestConfig.xml nddl) -run_planner_problem(unary-resource-test-transaction ReusableTestConfig.xml nddl) -run_planner_problem(Mini-crew-init.nddl MiniCrewSolverConfig.xml nddl) - +run_planner_problem(HTX.3 HTX.3.solverConfig.xml true other-tests) +run_planner_problem(reusable-test-transaction ReusableTestConfig.xml true other-tests) +run_planner_problem(unary-resource-test-transaction ReusableTestConfig.xml true other-tests) +run_planner_problem(Mini-crew-init MiniCrewSolverConfig.xml true other-tests) +run_planner_problem(basic-model-transaction RandomPlannerConfig.xml false other-tests) file(GLOB models *.nddl) file(COPY ${models} DESTINATION .) diff --git a/src/PLASMA/System/test/DefaultPlannerConfig.xml b/src/PLASMA/System/test/DefaultPlannerConfig.xml index 4a75e61f2..e7463b547 100644 --- a/src/PLASMA/System/test/DefaultPlannerConfig.xml +++ b/src/PLASMA/System/test/DefaultPlannerConfig.xml @@ -15,6 +15,7 @@ + diff --git a/src/PLASMA/System/test/HTX.1.solverConfig.xml b/src/PLASMA/System/test/HTX.1.solverConfig.xml index 0891e1886..dd9b01cf7 100644 --- a/src/PLASMA/System/test/HTX.1.solverConfig.xml +++ b/src/PLASMA/System/test/HTX.1.solverConfig.xml @@ -12,6 +12,7 @@ + diff --git a/src/PLASMA/System/test/Jamfile b/src/PLASMA/System/test/Jamfile index 92099a092..86338a228 100644 --- a/src/PLASMA/System/test/Jamfile +++ b/src/PLASMA/System/test/Jamfile @@ -102,6 +102,7 @@ local testmodels = rejection.nddl rules.0.tx.nddl subtype-extension.tx.nddl + smallerInconsistency-initial-state.nddl ; if ! ( "Resources" in $(NO) ) { diff --git a/src/PLASMA/System/test/Java/RunGcov.java b/src/PLASMA/System/test/Java/RunGcov.java index 64d446af0..9000e1388 100644 --- a/src/PLASMA/System/test/Java/RunGcov.java +++ b/src/PLASMA/System/test/Java/RunGcov.java @@ -8,27 +8,27 @@ public class RunGcov { private static String NO_RESULT = "NORESULT"; public static void runGcov( String outputFileName, String inputDirectory ) { - + System.out.println("Identifying set of source code files"); Vector sourceCodeFiles = getSourceCodeFiles ( new File(inputDirectory) ); System.out.println("Identified " + sourceCodeFiles.size() + " files"); System.out.println(); - + System.out.println("Running gcov on each source code file"); Vector results = applyGcov(inputDirectory, sourceCodeFiles); System.out.println(); - + System.out.println("Writing results table to file"); writeResultsToFile(results, outputFileName); System.out.println("Finished. Results were written to " + outputFileName); } - + private static Vector getSourceCodeFiles (File directory ) { System.out.println("Processing directory " + directory.toString() ); Vector filesInDir = new Vector(); - + FilenameFilter dotCCFilter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".cc"); @@ -44,7 +44,7 @@ public boolean accept(File dir, String name) { String [] dotCCFiles = directory.list( dotCCFilter ); String [] dotHHFiles = directory.list( dotHHFilter ); - // store files into vector. + // store files into vector. for (int i=0; i < dotCCFiles.length; i++) { filesInDir.add ( directory.getPath() + "/" + dotCCFiles[i] ); @@ -58,7 +58,7 @@ public boolean accept(File dir, String name) { // process all sub directories. String [] allFiles = directory.list(); - + for (int i=0; i < allFiles.length; i++) { File theFile = new File ( directory.getPath() + "/" + allFiles[i] ); // only process if it is a directory @@ -67,17 +67,17 @@ public boolean accept(File dir, String name) { Vector v = getSourceCodeFiles( theFile ); filesInDir.addAll(v); } - } + } return filesInDir; - + }; private static Vector applyGcov(String inputDirectory, Vector files) { Vector results = new Vector(); - + Iterator it = files.iterator(); while (it.hasNext()) { String fileName = (String) it.next(); @@ -85,22 +85,22 @@ private static Vector applyGcov(String inputDirectory, Vector files) { if ( blockFileExists(inputDirectory, fileName) ) { String cmd = "gcov -o " + inputDirectory + " " + fileName; String result = runCommand( cmd , fileName ); - - if (! result.equalsIgnoreCase(NO_RESULT)) { + + if (! result.equalsIgnoreCase(NO_RESULT)) { results.add( result ); } } else { results.add (fileName + " has no gcov data"); } } - + return results; } - + private static boolean blockFileExists(String inputDirectory, String fileName) { - - String justFileName = fileName.substring( fileName.lastIndexOf("/") + 1, fileName.lastIndexOf(".") ); + + String justFileName = fileName.substring( fileName.lastIndexOf("/") + 1, fileName.lastIndexOf(".") ); File f = new File (inputDirectory + "/" + justFileName + ".bb"); return f.exists(); @@ -111,7 +111,7 @@ private static boolean blockFileExists(String inputDirectory, String fileName) { private static void writeResultsToFile( Vector results, String outputFileName) { try { BufferedWriter out = new BufferedWriter(new FileWriter( outputFileName)); - + Iterator it = results.iterator(); while (it.hasNext()) { out.write( (String) it.next()); @@ -128,13 +128,13 @@ private static void writeResultsToFile( Vector results, String outputFileName) { private static String runCommand(String command, String fileName) { String result = NO_RESULT; - + try { System.out.println("Executing command " + command); - - + + Process p = Runtime.getRuntime().exec(command); - + String ls_str; DataInputStream ls_in = new DataInputStream( @@ -142,7 +142,7 @@ private static String runCommand(String command, String fileName) { try { while ((ls_str = ls_in.readLine()) != null) { - + if (ls_str.toLowerCase().indexOf( fileName.toLowerCase() ) != -1) { result = ls_str; } @@ -162,15 +162,15 @@ private static String runCommand(String command, String fileName) { // Main program. Check arguments then call processing. - + public static void main(String argv[]) { - + int numArgs = argv.length; if ( numArgs <= 2 ) { - + System.out.println ("EUROPA GCOV script "); System.out.println(); - + String outputFileName = OUTPUT_FILE_NAME_DEFAULT; String inputDirectory = INPUT_DIRECTORY_DEFAULT; @@ -187,28 +187,28 @@ public static void main(String argv[]) { System.out.println ( "Output filse set to default value: " + outputFileName ); System.out.println ( "Input directory set to default value: " + inputDirectory ); } - + // we can only proceed if the input directory exists - + File inputRootFile = new File( inputDirectory ); - + if ( inputRootFile.exists() && inputRootFile.isDirectory() ) { - - runGcov( outputFileName, inputDirectory ); - + + runGcov( outputFileName, inputDirectory ); + } else { - + System.out.println ("Error: input directory " + inputDirectory + " does not exist."); - + } // end if inputRootFile exists and isDirectory. - - + + } else { - + System.out.println ("Usage RunGcov [output file name] [path to gcov files]. Both arguments are optional"); - - } // end if numArgs <= 2 - + + } // end if numArgs <= 2 + } } diff --git a/src/PLASMA/System/test/RandomPlannerConfig.xml b/src/PLASMA/System/test/RandomPlannerConfig.xml new file mode 100644 index 000000000..285da745c --- /dev/null +++ b/src/PLASMA/System/test/RandomPlannerConfig.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PLASMA/System/test/better-res-reservoir.nddl b/src/PLASMA/System/test/better-res-reservoir.nddl index 57005d360..ea4938479 100644 --- a/src/PLASMA/System/test/better-res-reservoir.nddl +++ b/src/PLASMA/System/test/better-res-reservoir.nddl @@ -83,7 +83,7 @@ Rover::Sample{ float qty; //sampleBattery(qty, m_x, m_y); eq(qty, -10.0); - addEq(bc.quantity, qty, 0); + addEq(bc.quantity, qty, 0.0); //sampleDuration( duration, m_x, m_y ); eq(duration, [3 10]); @@ -126,7 +126,7 @@ Rover::Drive{ float intermediateQuantity; mulEq(dist, 4, intermediateQuantity); neg(intermediateQuantity, qty); - addEq(bc.quantity, qty, 0); + addEq(bc.quantity, qty, 0.0); //driveDuration( duration, dist ); mulEq(dist, [1 2], duration); diff --git a/src/PLASMA/System/test/constraint-to-temporal.nddl b/src/PLASMA/System/test/constraint-to-temporal.nddl new file mode 100644 index 000000000..00dc4f9c3 --- /dev/null +++ b/src/PLASMA/System/test/constraint-to-temporal.nddl @@ -0,0 +1,69 @@ +#include "PlannerConfig.nddl" +#include "Resources.nddl" + +class Foo extends Reservoir { + Foo() { + super(50.0, 0.0, 0.0); + } +} + +class Bar extends Object { + Foo m_foo; + Bar() { + m_foo = new Foo(); + } + predicate Stuff { + int reftime1; + int reftime2; + int reftime3; + int reftime4; + } + predicate Axel {} +} + +Bar::Stuff { + contains(object.m_foo.consume f1); + contains(object.m_foo.consume f2); + contains(object.m_foo.consume f3); + contains(object.m_foo.consume f4); + temporalDistance(0, reftime1, f1.time); + eq(f2.time, reftime2); + f3.time == reftime3; + reftime4 == f4.time; +} + +Bar::Axel { + any(object.Stuff f); + f.start <= this.start - 1; + f.end >= this.end - 1; + f.state == ACTIVE; +} +PlannerConfig world = new PlannerConfig(); +Foo foo = new Foo(); +Bar b = new Bar(); +close(); + +goal(foo.consume bar1); +goal(foo.consume bar2); +goal(foo.consume bar3); +goal(foo.consume bar4); + +int reftime1 = 0; +int reftime2 = 10; +int reftime3 = 20; +int reftime4 = 30; + +temporalDistance(0, reftime1, bar1.time); +eq(bar2.time, reftime2); +bar3.time == reftime3; +bar4.time == reftime4; + +goal(b.Stuff bb); +bb.start > world.m_horizonStart; +bb.end < world.m_horizonEnd; +bb.activate(); + +goal(b.Axel a); +a.start > world.m_horizonStart; +a.end < world.m_horizonEnd; +a.activate(); \ No newline at end of file diff --git a/src/PLASMA/System/test/data/run-nddl-interp-DynamicObjTest.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-DynamicObjTest.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..bf1a29d3d --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-DynamicObjTest.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,84 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[20, 20] + world.m_maxPlannerSteps=int:CLOSED[200, 200] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + TestObject:test1************************* + Tokens ************************* + {0} + TestObject.TestPred(foo=Foo:CLOSED{f1(26)}) + Key=32 Master=NONE + {10} + {10} + TestObject.TestPred(foo=Foo:OPEN{f1(26),f2(29)}) + Key=71 Master=NONE + Merged Key=87 ROOT + {20} + End Tokens ********************* + End TestObject:test1************************* + Foo:f1************************* + End Foo:f1************************* + Foo:f2************************* + End Foo:f2************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + test1=TestObject:CLOSED{test1(23)} + f1=Foo:CLOSED{f1(26)} + f2=Foo:CLOSED{f2(29)} +Merged Tokens: ************************* + [10, 19] + TestObject.TestPred(foo=Foo:OPEN{f1(26),f2(29)}) + Key=87 Master=NONE + [11, 20] +Rejected Tokens: ************************* + [0, 9] + TestObject.TestPred(foo=Foo:CLOSED{f2(29)}) + Key=48 Master=NONE + [1, 10] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[20, 20] + world.m_maxPlannerSteps=int:CLOSED[200, 200] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + TestObject:test1************************* + Tokens ************************* + {0} + TestObject.TestPred(foo=Foo:CLOSED{f1(26)}) + Key=32 Master=NONE + {10} + {10} + TestObject.TestPred(foo=Foo:OPEN{f1(26),f2(29)}) + Key=71 Master=NONE + Merged Key=87 ROOT + {20} + End Tokens ********************* + End TestObject:test1************************* + Foo:f1************************* + End Foo:f1************************* + Foo:f2************************* + End Foo:f2************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + test1=TestObject:CLOSED{test1(23)} + f1=Foo:CLOSED{f1(26)} + f2=Foo:CLOSED{f2(29)} +Merged Tokens: ************************* + [10, 19] + TestObject.TestPred(foo=Foo:OPEN{f1(26),f2(29)}) + Key=87 Master=NONE + [11, 20] +Rejected Tokens: ************************* + [0, 9] + TestObject.TestPred(foo=Foo:CLOSED{f2(29)}) + Key=48 Master=NONE + [1, 10] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-HTX.1.nddl-HTX.1.solverConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-HTX.1.nddl-HTX.1.solverConfig.xml.out new file mode 100644 index 000000000..303213be6 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-HTX.1.nddl-HTX.1.solverConfig.xml.out @@ -0,0 +1,40 @@ +Objects ************************* + PlannerTestConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[4, 4] + world.m_maxPlannerDepth=int:CLOSED[2, 2] + End Variables ********************* + End PlannerTestConfig:world************************* + A:a************************* + End A:a************************* +Global Variables************************* + world=PlannerTestConfig:CLOSED{world(18)} + a=A:CLOSED{a(33)} +Rejected Tokens: ************************* + {0} + A.pred() + Key=36 Master=NONE + {10} +Objects ************************* + PlannerTestConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[4, 4] + world.m_maxPlannerDepth=int:CLOSED[2, 2] + End Variables ********************* + End PlannerTestConfig:world************************* + A:a************************* + End A:a************************* +Global Variables************************* + world=PlannerTestConfig:CLOSED{world(18)} + a=A:CLOSED{a(33)} +Rejected Tokens: ************************* + {0} + A.pred() + Key=36 Master=NONE + {10} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-HTX.3.nddl-HTX.3.solverConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-HTX.3.nddl-HTX.3.solverConfig.xml.out new file mode 100644 index 000000000..151df967f --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-HTX.3.nddl-HTX.3.solverConfig.xml.out @@ -0,0 +1,40 @@ +Objects ************************* + PlannerTestConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[6, 6] + world.m_maxPlannerDepth=int:CLOSED[4, 4] + End Variables ********************* + End PlannerTestConfig:world************************* + A:a************************* + End A:a************************* +Global Variables************************* + world=PlannerTestConfig:CLOSED{world(18)} + a=A:CLOSED{a(33)} +Rejected Tokens: ************************* + {0} + A.pred(location=Location:CLOSED{Lander,Rock}) + Key=36 Master=NONE + {5} +Objects ************************* + PlannerTestConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[6, 6] + world.m_maxPlannerDepth=int:CLOSED[4, 4] + End Variables ********************* + End PlannerTestConfig:world************************* + A:a************************* + End A:a************************* +Global Variables************************* + world=PlannerTestConfig:CLOSED{world(18)} + a=A:CLOSED{a(33)} +Rejected Tokens: ************************* + {0} + A.pred(location=Location:CLOSED{Lander,Rock}) + Key=36 Master=NONE + {5} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-Mini-crew-init.nddl-MiniCrewSolverConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-Mini-crew-init.nddl-MiniCrewSolverConfig.xml.out new file mode 100644 index 000000000..97d7a57df --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-Mini-crew-init.nddl-MiniCrewSolverConfig.xml.out @@ -0,0 +1,60 @@ +Objects ************************* + PlannerConfig:plannerConfiguration************************* + Variables ************************* + plannerConfiguration.m_horizonStart=int:CLOSED[0, 0] + plannerConfiguration.m_horizonEnd=int:CLOSED[100, 100] + plannerConfiguration.m_maxPlannerSteps=int:CLOSED[100000, 100000] + plannerConfiguration.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:plannerConfiguration************************* + CrewMember:crew************************* + Tokens ************************* + [0, 98] + CrewMember.Activity(solved=bool:CLOSED[0, 0]) + Key=29 Master=NONE + [1, 99] + [1, 99] + CrewMember.Activity(solved=bool:CLOSED[0, 0]) + Key=45 Master=NONE + [2, 100] + End Tokens ********************* + Variables ************************* + crew.m_claim=CrewMember_Claim:CLOSED{crew.m_claim(25)} + End Variables ********************* + End CrewMember:crew************************* + CrewMember_Claim:crew.m_claim************************* + End CrewMember_Claim:crew.m_claim************************* +Global Variables************************* + plannerConfiguration=PlannerConfig:CLOSED{plannerConfiguration(12)} + crew=CrewMember:CLOSED{crew(23)} +Objects ************************* + PlannerConfig:plannerConfiguration************************* + Variables ************************* + plannerConfiguration.m_horizonStart=int:CLOSED[0, 0] + plannerConfiguration.m_horizonEnd=int:CLOSED[100, 100] + plannerConfiguration.m_maxPlannerSteps=int:CLOSED[100000, 100000] + plannerConfiguration.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:plannerConfiguration************************* + CrewMember:crew************************* + Tokens ************************* + [0, 98] + CrewMember.Activity(solved=bool:CLOSED[0, 0]) + Key=29 Master=NONE + [1, 99] + [1, 99] + CrewMember.Activity(solved=bool:CLOSED[0, 0]) + Key=45 Master=NONE + [2, 100] + End Tokens ********************* + Variables ************************* + crew.m_claim=CrewMember_Claim:CLOSED{crew.m_claim(25)} + End Variables ********************* + End CrewMember:crew************************* + CrewMember_Claim:crew.m_claim************************* + End CrewMember_Claim:crew.m_claim************************* +Global Variables************************* + plannerConfiguration=PlannerConfig:CLOSED{plannerConfiguration(12)} + crew=CrewMember:CLOSED{crew(23)} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-Rover-transaction-reservoir.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-Rover-transaction-reservoir.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..124cfc32b --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-Rover-transaction-reservoir.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,688 @@ +Created node [id_683] initially enabled +Created node [id_684] initially enabled +Maximum flow instance created with source [id_683] and sink [id_684] +Created node [id_683] initially enabled +Created node [id_684] initially enabled +Maximum flow instance created with source [id_683] and sink [id_684] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[100, 100] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Location:lander************************* + Variables ************************* + lander.name=string:CLOSED{LANDER} + lander.x=int:CLOSED[0, 0] + lander.y=int:CLOSED[0, 0] + End Variables ********************* + End Location:lander************************* + Location:rock1************************* + Variables ************************* + rock1.name=string:CLOSED{ROCK1} + rock1.x=int:CLOSED[9, 9] + rock1.y=int:CLOSED[9, 9] + End Variables ********************* + End Location:rock1************************* + Location:rock2************************* + Variables ************************* + rock2.name=string:CLOSED{ROCK2} + rock2.x=int:CLOSED[1, 1] + rock2.y=int:CLOSED[6, 6] + End Variables ********************* + End Location:rock2************************* + Location:rock3************************* + Variables ************************* + rock3.name=string:CLOSED{ROCK3} + rock3.x=int:CLOSED[4, 4] + rock3.y=int:CLOSED[8, 8] + End Variables ********************* + End Location:rock3************************* + Location:rock4************************* + Variables ************************* + rock4.name=string:CLOSED{ROCK4} + rock4.x=int:CLOSED[3, 3] + rock4.y=int:CLOSED[9, 9] + End Variables ********************* + End Location:rock4************************* + Path:p1************************* + Variables ************************* + p1.name=string:CLOSED{Very Long Way} + p1.from=Location:CLOSED{lander(29)} + p1.to=Location:CLOSED{rock4(89)} + p1.cost=float:CLOSED[2000, 2000] + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.name=string:CLOSED{Moderately Long Way} + p2.from=Location:CLOSED{lander(29)} + p2.to=Location:CLOSED{rock4(89)} + p2.cost=float:CLOSED[1500, 1500] + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.name=string:CLOSED{Short Cut} + p3.from=Location:CLOSED{lander(29)} + p3.to=Location:CLOSED{rock4(89)} + p3.cost=float:CLOSED[400, 400] + End Variables ********************* + End Path:p3************************* + Battery:battery************************* + Tokens ************************* + [50, 65] + Battery.consume() + Key=447 Master=299 Instrument.TakeSample(299)[50, 65] --> [60, 75] + [50, 65] + [1, 42] + Battery.consume() + Key=536 Master=362 Instrument.Unstow(362)[1, 42] --> [3, 44] + [1, 42] + [18, 59] + Battery.consume() + Key=665 Master=271 Navigator.Going(271)[18, 59] --> [19, 60] + [18, 59] + [38, 62] + Battery.consume() + Key=757 Master=409 Instrument.Place(409)[38, 62] --> [50, 65] + [38, 62] + [60, 75] + Battery.consume() + Key=849 Master=429 Instrument.Stow(429)[60, 75] --> [62, 81] + [60, 75] + [3, 44] + Battery.consume() + Key=1777 Master=501 Instrument.Place(501)[3, 44] --> [6, 47] + [3, 44] + [32, 60] + Battery.consume() + Key=1901 Master=739 Instrument.Unstow(739)[32, 60] --> [38, 62] + [32, 60] + [6, 47] + Battery.consume() + Key=2063 Master=1739 Instrument.TakeSample(1739)[6, 47] --> [16, 57] + [6, 47] + [16, 57] + Battery.consume() + Key=2239 Master=2045 Instrument.Stow(2045)[16, 57] --> [18, 59] + [16, 57] + [70, 75] + Battery.consume() + Key=2502 Master=2482 Commands.PhoneLander(2482)[70, 75] --> [71, +inf] + [70, 75] + End Tokens ********************* + Variables ************************* + battery.initialCapacity=float:CLOSED[1000, 1000] + battery.levelLimitMin=float:CLOSED[0, 0] + battery.levelLimitMax=float:CLOSED[1000, 1000] + battery.productionRateMax=float:CLOSED[0, 0] + battery.productionMax=float:CLOSED[0, 0] + battery.consumptionRateMax=float:CLOSED[+inf, +inf] + battery.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Battery:battery************************* + Rover:spirit************************* + Variables ************************* + spirit.commands=Commands:CLOSED{spirit.commands(184)} + spirit.navigator=Navigator:CLOSED{spirit.navigator(187)} + spirit.instrument=Instrument:CLOSED{spirit.instrument(190)} + spirit.mainBattery=Battery:CLOSED{battery(159)} + End Variables ********************* + End Rover:spirit************************* + Commands:spirit.commands************************* + Tokens ************************* + {50} + Commands.TakeSample(rock=Location:CLOSED{rock4(89)}) + Key=214 Master=NONE + [70, 75] + [70, 75] + Commands.PhoneLander() + Key=2482 Master=214 sample(214){50} --> [70, 75] + [71, +inf] + End Tokens ********************* + End Commands:spirit.commands************************* + Navigator:spirit.navigator************************* + Tokens ************************* + {0} + Navigator.At(location=Location:CLOSED{lander(29)}) + Key=196 Master=NONE + Merged Key=481 from Instrument.Unstow(362)[1, 42] --> [3, 44] + Merged Key=622 from Navigator.Going(271)[18, 59] --> [19, 60] + Merged Key=1718 from Instrument.Place(501)[3, 44] --> [6, 47] + Merged Key=2004 from Instrument.TakeSample(1739)[6, 47] --> [16, 57] + Merged Key=2184 from Instrument.Stow(2045)[16, 57] --> [18, 59] + [18, 59] + [18, 59] + Navigator.Going(from=Location:CLOSED{lander(29)}to=Location:CLOSED{rock4(89)}) + Key=271 Master=196 initialPosition(196){0} --> [18, 59] + Merged Key=572 from Navigator.At(388)[19, 60] --> [62, +inf] + [19, 60] + [19, 60] + Navigator.At(location=Location:CLOSED{rock4(89)}) + Key=388 Master=299 Instrument.TakeSample(299)[50, 65] --> [60, 75] + Merged Key=640 from Navigator.Going(271)[18, 59] --> [19, 60] + Merged Key=698 from Instrument.Place(409)[38, 62] --> [50, 65] + Merged Key=794 from Instrument.Stow(429)[60, 75] --> [62, 81] + Merged Key=1846 from Instrument.Unstow(739)[32, 60] --> [38, 62] + [62, +inf] + End Tokens ********************* + End Navigator:spirit.navigator************************* + Instrument:spirit.instrument************************* + Tokens ************************* + {0} + Instrument.Stowed() + Key=233 Master=NONE + Merged Key=520 from Instrument.Unstow(362)[1, 42] --> [3, 44] + [1, 42] + [1, 42] + Instrument.Unstow() + Key=362 Master=233 stowed(233){0} --> [1, 42] + Merged Key=1759 from Instrument.Place(501)[3, 44] --> [6, 47] + [3, 44] + [3, 44] + Instrument.Place(rock=Location:CLOSED{lander(29)}) + Key=501 Master=362 Instrument.Unstow(362)[1, 42] --> [3, 44] + Merged Key=2025 from Instrument.TakeSample(1739)[6, 47] --> [16, 57] + [6, 47] + [6, 47] + Instrument.TakeSample(rock=Location:CLOSED{lander(29)}) + Key=1739 Master=501 Instrument.Place(501)[3, 44] --> [6, 47] + Merged Key=2220 from Instrument.Stow(2045)[16, 57] --> [18, 59] + [16, 57] + [16, 57] + Instrument.Stow() + Key=2045 Master=1739 Instrument.TakeSample(1739)[6, 47] --> [16, 57] + Merged Key=2115 from Instrument.Stowed(1885)[18, 59] --> [32, 60] + [18, 59] + [18, 59] + Instrument.Stowed() + Key=1885 Master=739 Instrument.Unstow(739)[32, 60] --> [38, 62] + Merged Key=2204 from Instrument.Stow(2045)[16, 57] --> [18, 59] + [32, 60] + [32, 60] + Instrument.Unstow() + Key=739 Master=409 Instrument.Place(409)[38, 62] --> [50, 65] + Merged Key=2133 from Instrument.Stowed(1885)[18, 59] --> [32, 60] + [38, 62] + [38, 62] + Instrument.Place(rock=Location:CLOSED{rock4(89)}) + Key=409 Master=299 Instrument.TakeSample(299)[50, 65] --> [60, 75] + Merged Key=1866 from Instrument.Unstow(739)[32, 60] --> [38, 62] + [50, 65] + [50, 65] + Instrument.TakeSample(rock=Location:CLOSED{rock4(89)}) + Key=299 Master=214 sample(214){50} --> [70, 75] + Merged Key=719 from Instrument.Place(409)[38, 62] --> [50, 65] + Merged Key=830 from Instrument.Stow(429)[60, 75] --> [62, 81] + [60, 75] + [60, 75] + Instrument.Stow() + Key=429 Master=299 Instrument.TakeSample(299)[50, 65] --> [60, 75] + Merged Key=1945 from Instrument.Stowed(814)[62, 81] --> [63, +inf] + [62, 81] + [62, 81] + Instrument.Stowed() + Key=814 Master=429 Instrument.Stow(429)[60, 75] --> [62, 81] + [63, +inf] + End Tokens ********************* + End Instrument:spirit.instrument************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + lander=Location:CLOSED{lander(29)} + rock1=Location:CLOSED{rock1(44)} + rock2=Location:CLOSED{rock2(59)} + rock3=Location:CLOSED{rock3(74)} + rock4=Location:CLOSED{rock4(89)} + p1=Path:CLOSED{p1(104)} + p2=Path:CLOSED{p2(121)} + p3=Path:CLOSED{p3(138)} + battery=Battery:CLOSED{battery(159)} + spirit=Rover:CLOSED{spirit(181)} +Merged Tokens: ************************* + [-inf, 60] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=481 Master=362 Instrument.Unstow(362)[1, 42] --> [3, 44] + [3, +inf] + [-inf, 56] + Instrument.Stowed() + Key=520 Master=362 Instrument.Unstow(362)[1, 42] --> [3, 44] + [1, 57] + [-inf, 64] + Navigator.Going(from=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74)}to=Location:CLOSED{rock4(89)}) + Key=572 Master=388 Navigator.At(388)[19, 60] --> [62, +inf] + [4, 65] + [-inf, 63] + Navigator.At(location=Location:CLOSED{lander(29)}) + Key=622 Master=271 Navigator.Going(271)[18, 59] --> [19, 60] + [3, 64] + [4, 65] + Navigator.At(location=Location:CLOSED{rock4(89)}) + Key=640 Master=271 Navigator.Going(271)[18, 59] --> [19, 60] + [5, +inf] + [-inf, 62] + Navigator.At(location=Location:CLOSED{rock4(89)}) + Key=698 Master=409 Instrument.Place(409)[38, 62] --> [50, 65] + [50, +inf] + [50, 65] + Instrument.TakeSample(rock=Location:CLOSED{rock4(89)}) + Key=719 Master=409 Instrument.Place(409)[38, 62] --> [50, 65] + [60, +inf] + [-inf, 75] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=794 Master=429 Instrument.Stow(429)[60, 75] --> [62, 81] + [62, +inf] + [-inf, 65] + Instrument.TakeSample(rock=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=830 Master=429 Instrument.Stow(429)[60, 75] --> [62, 81] + [60, 75] + [-inf, 57] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=1718 Master=501 Instrument.Place(501)[3, 44] --> [6, 47] + [6, +inf] + [-3, 45] + Instrument.Unstow() + Key=1759 Master=501 Instrument.Place(501)[3, 44] --> [6, 47] + [3, 47] + [-inf, 60] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=1846 Master=739 Instrument.Unstow(739)[32, 60] --> [38, 62] + [38, +inf] + [38, 62] + Instrument.Place(rock=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=1866 Master=739 Instrument.Unstow(739)[32, 60] --> [38, 62] + [41, 74] + [56, 79] + Instrument.Stow() + Key=1945 Master=814 Instrument.Stowed(814)[62, 81] --> [63, +inf] + [62, 81] + [-inf, 49] + Navigator.At(location=Location:CLOSED{lander(29)}) + Key=2004 Master=1739 Instrument.TakeSample(1739)[6, 47] --> [16, 57] + [16, +inf] + [-6, 46] + Instrument.Place(rock=Location:CLOSED{lander(29)}) + Key=2025 Master=1739 Instrument.TakeSample(1739)[6, 47] --> [16, 57] + [6, 49] + [12, 57] + Instrument.Stow() + Key=2115 Master=1885 Instrument.Stowed(1885)[18, 59] --> [32, 60] + [18, 59] + [32, 60] + Instrument.Unstow() + Key=2133 Master=1885 Instrument.Stowed(1885)[18, 59] --> [32, 60] + [34, 66] + [-inf, 57] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=2184 Master=2045 Instrument.Stow(2045)[16, 57] --> [18, 59] + [18, +inf] + [18, 59] + Instrument.Stowed() + Key=2204 Master=2045 Instrument.Stow(2045)[16, 57] --> [18, 59] + [19, +inf] + [-inf, 47] + Instrument.TakeSample(rock=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=2220 Master=2045 Instrument.Stow(2045)[16, 57] --> [18, 59] + [16, 57] +Inactive Tokens: ************************* + [-inf, -1] + Navigator.Going(from=Location:CLOSED{rock1(44),rock2(59),rock3(74),rock4(89)}to=Location:CLOSED{lander(29)}) + Key=251 Master=196 initialPosition(196){0} --> [18, 59] + {0} + [-6, -2] + Instrument.Stow() + Key=344 Master=233 stowed(233){0} --> [1, 42] + {0} + [62, +inf] + Navigator.Going(from=Location:CLOSED{rock4(89)}to=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74)}) + Key=592 Master=388 Navigator.At(388)[19, 60] --> [62, +inf] + [63, +inf] + [63, +inf] + Instrument.Unstow() + Key=1963 Master=814 Instrument.Stowed(814)[62, 81] --> [63, +inf] + [65, +inf] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[100, 100] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Location:lander************************* + Variables ************************* + lander.name=string:CLOSED{LANDER} + lander.x=int:CLOSED[0, 0] + lander.y=int:CLOSED[0, 0] + End Variables ********************* + End Location:lander************************* + Location:rock1************************* + Variables ************************* + rock1.name=string:CLOSED{ROCK1} + rock1.x=int:CLOSED[9, 9] + rock1.y=int:CLOSED[9, 9] + End Variables ********************* + End Location:rock1************************* + Location:rock2************************* + Variables ************************* + rock2.name=string:CLOSED{ROCK2} + rock2.x=int:CLOSED[1, 1] + rock2.y=int:CLOSED[6, 6] + End Variables ********************* + End Location:rock2************************* + Location:rock3************************* + Variables ************************* + rock3.name=string:CLOSED{ROCK3} + rock3.x=int:CLOSED[4, 4] + rock3.y=int:CLOSED[8, 8] + End Variables ********************* + End Location:rock3************************* + Location:rock4************************* + Variables ************************* + rock4.name=string:CLOSED{ROCK4} + rock4.x=int:CLOSED[3, 3] + rock4.y=int:CLOSED[9, 9] + End Variables ********************* + End Location:rock4************************* + Path:p1************************* + Variables ************************* + p1.name=string:CLOSED{Very Long Way} + p1.from=Location:CLOSED{lander(29)} + p1.to=Location:CLOSED{rock4(89)} + p1.cost=float:CLOSED[2000, 2000] + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.name=string:CLOSED{Moderately Long Way} + p2.from=Location:CLOSED{lander(29)} + p2.to=Location:CLOSED{rock4(89)} + p2.cost=float:CLOSED[1500, 1500] + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.name=string:CLOSED{Short Cut} + p3.from=Location:CLOSED{lander(29)} + p3.to=Location:CLOSED{rock4(89)} + p3.cost=float:CLOSED[400, 400] + End Variables ********************* + End Path:p3************************* + Battery:battery************************* + Tokens ************************* + [50, 65] + Battery.consume() + Key=447 Master=299 Instrument.TakeSample(299)[50, 65] --> [60, 75] + [50, 65] + [1, 42] + Battery.consume() + Key=536 Master=362 Instrument.Unstow(362)[1, 42] --> [3, 44] + [1, 42] + [18, 59] + Battery.consume() + Key=665 Master=271 Navigator.Going(271)[18, 59] --> [19, 60] + [18, 59] + [38, 62] + Battery.consume() + Key=757 Master=409 Instrument.Place(409)[38, 62] --> [50, 65] + [38, 62] + [60, 75] + Battery.consume() + Key=849 Master=429 Instrument.Stow(429)[60, 75] --> [62, 81] + [60, 75] + [3, 44] + Battery.consume() + Key=1777 Master=501 Instrument.Place(501)[3, 44] --> [6, 47] + [3, 44] + [32, 60] + Battery.consume() + Key=1901 Master=739 Instrument.Unstow(739)[32, 60] --> [38, 62] + [32, 60] + [6, 47] + Battery.consume() + Key=2063 Master=1739 Instrument.TakeSample(1739)[6, 47] --> [16, 57] + [6, 47] + [16, 57] + Battery.consume() + Key=2239 Master=2045 Instrument.Stow(2045)[16, 57] --> [18, 59] + [16, 57] + [70, 75] + Battery.consume() + Key=2502 Master=2482 Commands.PhoneLander(2482)[70, 75] --> [71, +inf] + [70, 75] + End Tokens ********************* + Variables ************************* + battery.initialCapacity=float:CLOSED[1000, 1000] + battery.levelLimitMin=float:CLOSED[0, 0] + battery.levelLimitMax=float:CLOSED[1000, 1000] + battery.productionRateMax=float:CLOSED[0, 0] + battery.productionMax=float:CLOSED[0, 0] + battery.consumptionRateMax=float:CLOSED[+inf, +inf] + battery.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Battery:battery************************* + Rover:spirit************************* + Variables ************************* + spirit.commands=Commands:CLOSED{spirit.commands(184)} + spirit.navigator=Navigator:CLOSED{spirit.navigator(187)} + spirit.instrument=Instrument:CLOSED{spirit.instrument(190)} + spirit.mainBattery=Battery:CLOSED{battery(159)} + End Variables ********************* + End Rover:spirit************************* + Commands:spirit.commands************************* + Tokens ************************* + {50} + Commands.TakeSample(rock=Location:CLOSED{rock4(89)}) + Key=214 Master=NONE + [70, 75] + [70, 75] + Commands.PhoneLander() + Key=2482 Master=214 sample(214){50} --> [70, 75] + [71, +inf] + End Tokens ********************* + End Commands:spirit.commands************************* + Navigator:spirit.navigator************************* + Tokens ************************* + {0} + Navigator.At(location=Location:CLOSED{lander(29)}) + Key=196 Master=NONE + Merged Key=481 from Instrument.Unstow(362)[1, 42] --> [3, 44] + Merged Key=622 from Navigator.Going(271)[18, 59] --> [19, 60] + Merged Key=1718 from Instrument.Place(501)[3, 44] --> [6, 47] + Merged Key=2004 from Instrument.TakeSample(1739)[6, 47] --> [16, 57] + Merged Key=2184 from Instrument.Stow(2045)[16, 57] --> [18, 59] + [18, 59] + [18, 59] + Navigator.Going(from=Location:CLOSED{lander(29)}to=Location:CLOSED{rock4(89)}) + Key=271 Master=196 initialPosition(196){0} --> [18, 59] + Merged Key=572 from Navigator.At(388)[19, 60] --> [62, +inf] + [19, 60] + [19, 60] + Navigator.At(location=Location:CLOSED{rock4(89)}) + Key=388 Master=299 Instrument.TakeSample(299)[50, 65] --> [60, 75] + Merged Key=640 from Navigator.Going(271)[18, 59] --> [19, 60] + Merged Key=698 from Instrument.Place(409)[38, 62] --> [50, 65] + Merged Key=794 from Instrument.Stow(429)[60, 75] --> [62, 81] + Merged Key=1846 from Instrument.Unstow(739)[32, 60] --> [38, 62] + [62, +inf] + End Tokens ********************* + End Navigator:spirit.navigator************************* + Instrument:spirit.instrument************************* + Tokens ************************* + {0} + Instrument.Stowed() + Key=233 Master=NONE + Merged Key=520 from Instrument.Unstow(362)[1, 42] --> [3, 44] + [1, 42] + [1, 42] + Instrument.Unstow() + Key=362 Master=233 stowed(233){0} --> [1, 42] + Merged Key=1759 from Instrument.Place(501)[3, 44] --> [6, 47] + [3, 44] + [3, 44] + Instrument.Place(rock=Location:CLOSED{lander(29)}) + Key=501 Master=362 Instrument.Unstow(362)[1, 42] --> [3, 44] + Merged Key=2025 from Instrument.TakeSample(1739)[6, 47] --> [16, 57] + [6, 47] + [6, 47] + Instrument.TakeSample(rock=Location:CLOSED{lander(29)}) + Key=1739 Master=501 Instrument.Place(501)[3, 44] --> [6, 47] + Merged Key=2220 from Instrument.Stow(2045)[16, 57] --> [18, 59] + [16, 57] + [16, 57] + Instrument.Stow() + Key=2045 Master=1739 Instrument.TakeSample(1739)[6, 47] --> [16, 57] + Merged Key=2115 from Instrument.Stowed(1885)[18, 59] --> [32, 60] + [18, 59] + [18, 59] + Instrument.Stowed() + Key=1885 Master=739 Instrument.Unstow(739)[32, 60] --> [38, 62] + Merged Key=2204 from Instrument.Stow(2045)[16, 57] --> [18, 59] + [32, 60] + [32, 60] + Instrument.Unstow() + Key=739 Master=409 Instrument.Place(409)[38, 62] --> [50, 65] + Merged Key=2133 from Instrument.Stowed(1885)[18, 59] --> [32, 60] + [38, 62] + [38, 62] + Instrument.Place(rock=Location:CLOSED{rock4(89)}) + Key=409 Master=299 Instrument.TakeSample(299)[50, 65] --> [60, 75] + Merged Key=1866 from Instrument.Unstow(739)[32, 60] --> [38, 62] + [50, 65] + [50, 65] + Instrument.TakeSample(rock=Location:CLOSED{rock4(89)}) + Key=299 Master=214 sample(214){50} --> [70, 75] + Merged Key=719 from Instrument.Place(409)[38, 62] --> [50, 65] + Merged Key=830 from Instrument.Stow(429)[60, 75] --> [62, 81] + [60, 75] + [60, 75] + Instrument.Stow() + Key=429 Master=299 Instrument.TakeSample(299)[50, 65] --> [60, 75] + Merged Key=1945 from Instrument.Stowed(814)[62, 81] --> [63, +inf] + [62, 81] + [62, 81] + Instrument.Stowed() + Key=814 Master=429 Instrument.Stow(429)[60, 75] --> [62, 81] + [63, +inf] + End Tokens ********************* + End Instrument:spirit.instrument************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + lander=Location:CLOSED{lander(29)} + rock1=Location:CLOSED{rock1(44)} + rock2=Location:CLOSED{rock2(59)} + rock3=Location:CLOSED{rock3(74)} + rock4=Location:CLOSED{rock4(89)} + p1=Path:CLOSED{p1(104)} + p2=Path:CLOSED{p2(121)} + p3=Path:CLOSED{p3(138)} + battery=Battery:CLOSED{battery(159)} + spirit=Rover:CLOSED{spirit(181)} +Merged Tokens: ************************* + [-inf, 60] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=481 Master=362 Instrument.Unstow(362)[1, 42] --> [3, 44] + [3, +inf] + [-inf, 56] + Instrument.Stowed() + Key=520 Master=362 Instrument.Unstow(362)[1, 42] --> [3, 44] + [1, 57] + [-inf, 64] + Navigator.Going(from=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74)}to=Location:CLOSED{rock4(89)}) + Key=572 Master=388 Navigator.At(388)[19, 60] --> [62, +inf] + [4, 65] + [-inf, 63] + Navigator.At(location=Location:CLOSED{lander(29)}) + Key=622 Master=271 Navigator.Going(271)[18, 59] --> [19, 60] + [3, 64] + [4, 65] + Navigator.At(location=Location:CLOSED{rock4(89)}) + Key=640 Master=271 Navigator.Going(271)[18, 59] --> [19, 60] + [5, +inf] + [-inf, 62] + Navigator.At(location=Location:CLOSED{rock4(89)}) + Key=698 Master=409 Instrument.Place(409)[38, 62] --> [50, 65] + [50, +inf] + [50, 65] + Instrument.TakeSample(rock=Location:CLOSED{rock4(89)}) + Key=719 Master=409 Instrument.Place(409)[38, 62] --> [50, 65] + [60, +inf] + [-inf, 75] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=794 Master=429 Instrument.Stow(429)[60, 75] --> [62, 81] + [62, +inf] + [-inf, 65] + Instrument.TakeSample(rock=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=830 Master=429 Instrument.Stow(429)[60, 75] --> [62, 81] + [60, 75] + [-inf, 57] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=1718 Master=501 Instrument.Place(501)[3, 44] --> [6, 47] + [6, +inf] + [-3, 45] + Instrument.Unstow() + Key=1759 Master=501 Instrument.Place(501)[3, 44] --> [6, 47] + [3, 47] + [-inf, 60] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=1846 Master=739 Instrument.Unstow(739)[32, 60] --> [38, 62] + [38, +inf] + [38, 62] + Instrument.Place(rock=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=1866 Master=739 Instrument.Unstow(739)[32, 60] --> [38, 62] + [41, 74] + [56, 79] + Instrument.Stow() + Key=1945 Master=814 Instrument.Stowed(814)[62, 81] --> [63, +inf] + [62, 81] + [-inf, 49] + Navigator.At(location=Location:CLOSED{lander(29)}) + Key=2004 Master=1739 Instrument.TakeSample(1739)[6, 47] --> [16, 57] + [16, +inf] + [-6, 46] + Instrument.Place(rock=Location:CLOSED{lander(29)}) + Key=2025 Master=1739 Instrument.TakeSample(1739)[6, 47] --> [16, 57] + [6, 49] + [12, 57] + Instrument.Stow() + Key=2115 Master=1885 Instrument.Stowed(1885)[18, 59] --> [32, 60] + [18, 59] + [32, 60] + Instrument.Unstow() + Key=2133 Master=1885 Instrument.Stowed(1885)[18, 59] --> [32, 60] + [34, 66] + [-inf, 57] + Navigator.At(location=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=2184 Master=2045 Instrument.Stow(2045)[16, 57] --> [18, 59] + [18, +inf] + [18, 59] + Instrument.Stowed() + Key=2204 Master=2045 Instrument.Stow(2045)[16, 57] --> [18, 59] + [19, +inf] + [-inf, 47] + Instrument.TakeSample(rock=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=2220 Master=2045 Instrument.Stow(2045)[16, 57] --> [18, 59] + [16, 57] +Inactive Tokens: ************************* + [-inf, -1] + Navigator.Going(from=Location:CLOSED{rock1(44),rock2(59),rock3(74),rock4(89)}to=Location:CLOSED{lander(29)}) + Key=251 Master=196 initialPosition(196){0} --> [18, 59] + {0} + [-6, -2] + Instrument.Stow() + Key=344 Master=233 stowed(233){0} --> [1, 42] + {0} + [62, +inf] + Navigator.Going(from=Location:CLOSED{rock4(89)}to=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74)}) + Key=592 Master=388 Navigator.At(388)[19, 60] --> [62, +inf] + [63, +inf] + [63, +inf] + Instrument.Unstow() + Key=1963 Master=814 Instrument.Stowed(814)[62, 81] --> [63, +inf] + [65, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-backtrack-test.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-backtrack-test.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..1fcefe2d1 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-backtrack-test.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,42 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Test:test************************* + Tokens ************************* + {5} + Test.Predicate() + Key=26 Master=NONE + {10} + End Tokens ********************* + End Test:test************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + test=Test:CLOSED{test(23)} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Test:test************************* + Tokens ************************* + {5} + Test.Predicate() + Key=26 Master=NONE + {10} + End Tokens ********************* + End Test:test************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + test=Test:CLOSED{test(23)} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-basic-model-transaction.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-basic-model-transaction.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..9a4ba686b --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-basic-model-transaction.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,1692 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[10, 10] + world.m_horizonEnd=int:CLOSED[101, 101] + world.m_maxPlannerSteps=int:CLOSED[1000, 1000] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {10} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=26 Master=NONE + Merged Key=174 from Rover.Going(68){11} --> {12} + {11} + {11} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=68 Master=26 a(26){10} --> {11} + Merged Key=305 from Rover.At(194){12} --> {13} + {12} + {12} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=194 Master=68 Rover.Going(68){11} --> {12} + Merged Key=400 from Rover.Going(283){13} --> {14} + {13} + {13} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=283 Master=194 Rover.At(194){12} --> {13} + Merged Key=541 from Rover.At(420){14} --> {15} + {14} + {14} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=420 Master=283 Rover.Going(283){13} --> {14} + Merged Key=636 from Rover.Going(519){15} --> {16} + {15} + {15} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=519 Master=420 Rover.At(420){14} --> {15} + Merged Key=777 from Rover.At(656){16} --> {17} + {16} + {16} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=656 Master=519 Rover.Going(519){15} --> {16} + Merged Key=872 from Rover.Going(755){17} --> {18} + {17} + {17} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=755 Master=656 Rover.At(656){16} --> {17} + Merged Key=1013 from Rover.At(892){18} --> {19} + {18} + {18} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=892 Master=755 Rover.Going(755){17} --> {18} + Merged Key=1108 from Rover.Going(991){19} --> {20} + {19} + {19} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=991 Master=892 Rover.At(892){18} --> {19} + Merged Key=1249 from Rover.At(1128){20} --> {21} + {20} + {20} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1128 Master=991 Rover.Going(991){19} --> {20} + Merged Key=1344 from Rover.Going(1227){21} --> {22} + {21} + {21} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=1227 Master=1128 Rover.At(1128){20} --> {21} + Merged Key=1485 from Rover.At(1364){22} --> {23} + {22} + {22} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1364 Master=1227 Rover.Going(1227){21} --> {22} + Merged Key=1580 from Rover.Going(1463){23} --> {24} + {23} + {23} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1463 Master=1364 Rover.At(1364){22} --> {23} + Merged Key=1721 from Rover.At(1600){24} --> {25} + {24} + {24} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1600 Master=1463 Rover.Going(1463){23} --> {24} + Merged Key=1816 from Rover.Going(1699){25} --> {26} + {25} + {25} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=1699 Master=1600 Rover.At(1600){24} --> {25} + Merged Key=1957 from Rover.At(1836){26} --> {27} + {26} + {26} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1836 Master=1699 Rover.Going(1699){25} --> {26} + Merged Key=2052 from Rover.Going(1935){27} --> {28} + {27} + {27} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1935 Master=1836 Rover.At(1836){26} --> {27} + Merged Key=2193 from Rover.At(2072){28} --> {29} + {28} + {28} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2072 Master=1935 Rover.Going(1935){27} --> {28} + Merged Key=2288 from Rover.Going(2171){29} --> {30} + {29} + {29} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2171 Master=2072 Rover.At(2072){28} --> {29} + Merged Key=2429 from Rover.At(2308){30} --> {31} + {30} + {30} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2308 Master=2171 Rover.Going(2171){29} --> {30} + Merged Key=2524 from Rover.Going(2407){31} --> {32} + {31} + {31} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=2407 Master=2308 Rover.At(2308){30} --> {31} + Merged Key=2665 from Rover.At(2544){32} --> {33} + {32} + {32} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2544 Master=2407 Rover.Going(2407){31} --> {32} + Merged Key=2760 from Rover.Going(2643){33} --> {34} + {33} + {33} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2643 Master=2544 Rover.At(2544){32} --> {33} + Merged Key=2901 from Rover.At(2780){34} --> {35} + {34} + {34} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2780 Master=2643 Rover.Going(2643){33} --> {34} + Merged Key=2996 from Rover.Going(2879){35} --> {36} + {35} + {35} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=2879 Master=2780 Rover.At(2780){34} --> {35} + Merged Key=3137 from Rover.At(3016){36} --> {37} + {36} + {36} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3016 Master=2879 Rover.Going(2879){35} --> {36} + Merged Key=3232 from Rover.Going(3115){37} --> {38} + {37} + {37} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3115 Master=3016 Rover.At(3016){36} --> {37} + Merged Key=3373 from Rover.At(3252){38} --> {39} + {38} + {38} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3252 Master=3115 Rover.Going(3115){37} --> {38} + Merged Key=3468 from Rover.Going(3351){39} --> {40} + {39} + {39} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3351 Master=3252 Rover.At(3252){38} --> {39} + Merged Key=3609 from Rover.At(3488){40} --> {41} + {40} + {40} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3488 Master=3351 Rover.Going(3351){39} --> {40} + Merged Key=3704 from Rover.Going(3587){41} --> {42} + {41} + {41} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3587 Master=3488 Rover.At(3488){40} --> {41} + Merged Key=3845 from Rover.At(3724){42} --> {43} + {42} + {42} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3724 Master=3587 Rover.Going(3587){41} --> {42} + Merged Key=3940 from Rover.Going(3823){43} --> {44} + {43} + {43} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3823 Master=3724 Rover.At(3724){42} --> {43} + Merged Key=4081 from Rover.At(3960){44} --> {45} + {44} + {44} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3960 Master=3823 Rover.Going(3823){43} --> {44} + Merged Key=4176 from Rover.Going(4059){45} --> {46} + {45} + {45} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4059 Master=3960 Rover.At(3960){44} --> {45} + Merged Key=4317 from Rover.At(4196){46} --> {47} + {46} + {46} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4196 Master=4059 Rover.Going(4059){45} --> {46} + Merged Key=4412 from Rover.Going(4295){47} --> {48} + {47} + {47} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4295 Master=4196 Rover.At(4196){46} --> {47} + Merged Key=4553 from Rover.At(4432){48} --> {49} + {48} + {48} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4432 Master=4295 Rover.Going(4295){47} --> {48} + Merged Key=4648 from Rover.Going(4531){49} --> {50} + {49} + {49} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4531 Master=4432 Rover.At(4432){48} --> {49} + Merged Key=4789 from Rover.At(4668){50} --> {51} + {50} + {50} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4668 Master=4531 Rover.Going(4531){49} --> {50} + Merged Key=4884 from Rover.Going(4767){51} --> {52} + {51} + {51} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4767 Master=4668 Rover.At(4668){50} --> {51} + Merged Key=5025 from Rover.At(4904){52} --> {53} + {52} + {52} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4904 Master=4767 Rover.Going(4767){51} --> {52} + Merged Key=5120 from Rover.Going(5003){53} --> {54} + {53} + {53} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=5003 Master=4904 Rover.At(4904){52} --> {53} + Merged Key=5261 from Rover.At(5140){54} --> {55} + {54} + {54} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=5140 Master=5003 Rover.Going(5003){53} --> {54} + Merged Key=5356 from Rover.Going(5239){55} --> {56} + {55} + {55} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=5239 Master=5140 Rover.At(5140){54} --> {55} + Merged Key=5317 from Rover.At(5182){56} --> {57} + {56} + {56} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=5182 Master=5081 Rover.Going(5081){57} --> {58} + Merged Key=5376 from Rover.Going(5239){55} --> {56} + {57} + {57} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=5081 Master=4946 Rover.At(4946){58} --> {59} + Merged Key=5295 from Rover.At(5182){56} --> {57} + {58} + {58} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4946 Master=4845 Rover.Going(4845){59} --> {60} + Merged Key=5202 from Rover.Going(5081){57} --> {58} + {59} + {59} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4845 Master=4710 Rover.At(4710){60} --> {61} + Merged Key=5059 from Rover.At(4946){58} --> {59} + {60} + {60} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4710 Master=4609 Rover.Going(4609){61} --> {62} + Merged Key=4966 from Rover.Going(4845){59} --> {60} + {61} + {61} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4609 Master=4474 Rover.At(4474){62} --> {63} + Merged Key=4823 from Rover.At(4710){60} --> {61} + {62} + {62} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4474 Master=4373 Rover.Going(4373){63} --> {64} + Merged Key=4730 from Rover.Going(4609){61} --> {62} + {63} + {63} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4373 Master=4238 Rover.At(4238){64} --> {65} + Merged Key=4587 from Rover.At(4474){62} --> {63} + {64} + {64} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4238 Master=4137 Rover.Going(4137){65} --> {66} + Merged Key=4494 from Rover.Going(4373){63} --> {64} + {65} + {65} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4137 Master=4002 Rover.At(4002){66} --> {67} + Merged Key=4351 from Rover.At(4238){64} --> {65} + {66} + {66} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4002 Master=3901 Rover.Going(3901){67} --> {68} + Merged Key=4258 from Rover.Going(4137){65} --> {66} + {67} + {67} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3901 Master=3766 Rover.At(3766){68} --> {69} + Merged Key=4115 from Rover.At(4002){66} --> {67} + {68} + {68} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3766 Master=3665 Rover.Going(3665){69} --> {70} + Merged Key=4022 from Rover.Going(3901){67} --> {68} + {69} + {69} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3665 Master=3530 Rover.At(3530){70} --> {71} + Merged Key=3879 from Rover.At(3766){68} --> {69} + {70} + {70} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3530 Master=3429 Rover.Going(3429){71} --> {72} + Merged Key=3786 from Rover.Going(3665){69} --> {70} + {71} + {71} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3429 Master=3294 Rover.At(3294){72} --> {73} + Merged Key=3643 from Rover.At(3530){70} --> {71} + {72} + {72} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3294 Master=3193 Rover.Going(3193){73} --> {74} + Merged Key=3550 from Rover.Going(3429){71} --> {72} + {73} + {73} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3193 Master=3058 Rover.At(3058){74} --> {75} + Merged Key=3407 from Rover.At(3294){72} --> {73} + {74} + {74} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3058 Master=2957 Rover.Going(2957){75} --> {76} + Merged Key=3314 from Rover.Going(3193){73} --> {74} + {75} + {75} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2957 Master=2822 Rover.At(2822){76} --> {77} + Merged Key=3171 from Rover.At(3058){74} --> {75} + {76} + {76} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2822 Master=2721 Rover.Going(2721){77} --> {78} + Merged Key=3078 from Rover.Going(2957){75} --> {76} + {77} + {77} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=2721 Master=2586 Rover.At(2586){78} --> {79} + Merged Key=2935 from Rover.At(2822){76} --> {77} + {78} + {78} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2586 Master=2485 Rover.Going(2485){79} --> {80} + Merged Key=2842 from Rover.Going(2721){77} --> {78} + {79} + {79} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2485 Master=2350 Rover.At(2350){80} --> {81} + Merged Key=2699 from Rover.At(2586){78} --> {79} + {80} + {80} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2350 Master=2249 Rover.Going(2249){81} --> {82} + Merged Key=2606 from Rover.Going(2485){79} --> {80} + {81} + {81} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=2249 Master=2114 Rover.At(2114){82} --> {83} + Merged Key=2463 from Rover.At(2350){80} --> {81} + {82} + {82} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2114 Master=2013 Rover.Going(2013){83} --> {84} + Merged Key=2370 from Rover.Going(2249){81} --> {82} + {83} + {83} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2013 Master=1878 Rover.At(1878){84} --> {85} + Merged Key=2227 from Rover.At(2114){82} --> {83} + {84} + {84} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1878 Master=1777 Rover.Going(1777){85} --> {86} + Merged Key=2134 from Rover.Going(2013){83} --> {84} + {85} + {85} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1777 Master=1642 Rover.At(1642){86} --> {87} + Merged Key=1991 from Rover.At(1878){84} --> {85} + {86} + {86} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1642 Master=1541 Rover.Going(1541){87} --> {88} + Merged Key=1898 from Rover.Going(1777){85} --> {86} + {87} + {87} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=1541 Master=1406 Rover.At(1406){88} --> {89} + Merged Key=1755 from Rover.At(1642){86} --> {87} + {88} + {88} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1406 Master=1305 Rover.Going(1305){89} --> {90} + Merged Key=1662 from Rover.Going(1541){87} --> {88} + {89} + {89} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1305 Master=1170 Rover.At(1170){90} --> {91} + Merged Key=1519 from Rover.At(1406){88} --> {89} + {90} + {90} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1170 Master=1069 Rover.Going(1069){91} --> {92} + Merged Key=1426 from Rover.Going(1305){89} --> {90} + {91} + {91} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=1069 Master=934 Rover.At(934){92} --> {93} + Merged Key=1283 from Rover.At(1170){90} --> {91} + {92} + {92} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=934 Master=833 Rover.Going(833){93} --> {94} + Merged Key=1190 from Rover.Going(1069){91} --> {92} + {93} + {93} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=833 Master=698 Rover.At(698){94} --> {95} + Merged Key=1047 from Rover.At(934){92} --> {93} + {94} + {94} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=698 Master=597 Rover.Going(597){95} --> {96} + Merged Key=954 from Rover.Going(833){93} --> {94} + {95} + {95} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=597 Master=462 Rover.At(462){96} --> {97} + Merged Key=811 from Rover.At(698){94} --> {95} + {96} + {96} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=462 Master=361 Rover.Going(361){97} --> {98} + Merged Key=718 from Rover.Going(597){95} --> {96} + {97} + {97} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=361 Master=226 Rover.At(226){98} --> {99} + Merged Key=575 from Rover.At(462){96} --> {97} + {98} + {98} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=226 Master=142 Rover.Going(142){99} --> {100} + Merged Key=482 from Rover.Going(361){97} --> {98} + {99} + {99} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=142 Master=46 b(46){100} --> {101} + Merged Key=339 from Rover.At(226){98} --> {99} + {100} + {100} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=46 Master=NONE + Merged Key=246 from Rover.Going(142){99} --> {100} + {101} + End Tokens ********************* + End Rover:rover************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} +Merged Tokens: ************************* + {10} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=174 Master=68 Rover.Going(68){11} --> {12} + {11} + {100} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=246 Master=142 Rover.Going(142){99} --> {100} + {101} + {11} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Rock}) + Key=305 Master=194 Rover.At(194){12} --> {13} + {12} + {99} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=339 Master=226 Rover.At(226){98} --> {99} + {100} + {12} + Rover.At(m_location=Locations:CLOSED{Hill,Rock}) + Key=400 Master=283 Rover.Going(283){13} --> {14} + {13} + {98} + Rover.At(m_location=Locations:CLOSED{Hill,Lander}) + Key=482 Master=361 Rover.Going(361){97} --> {98} + {99} + {13} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=541 Master=420 Rover.At(420){14} --> {15} + {14} + {97} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=575 Master=462 Rover.At(462){96} --> {97} + {98} + {14} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=636 Master=519 Rover.Going(519){15} --> {16} + {15} + {96} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=718 Master=597 Rover.Going(597){95} --> {96} + {97} + {15} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=777 Master=656 Rover.At(656){16} --> {17} + {16} + {95} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=811 Master=698 Rover.At(698){94} --> {95} + {96} + {16} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=872 Master=755 Rover.Going(755){17} --> {18} + {17} + {94} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=954 Master=833 Rover.Going(833){93} --> {94} + {95} + {17} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1013 Master=892 Rover.At(892){18} --> {19} + {18} + {93} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1047 Master=934 Rover.At(934){92} --> {93} + {94} + {18} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1108 Master=991 Rover.Going(991){19} --> {20} + {19} + {92} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1190 Master=1069 Rover.Going(1069){91} --> {92} + {93} + {19} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1249 Master=1128 Rover.At(1128){20} --> {21} + {20} + {91} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1283 Master=1170 Rover.At(1170){90} --> {91} + {92} + {20} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1344 Master=1227 Rover.Going(1227){21} --> {22} + {21} + {90} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1426 Master=1305 Rover.Going(1305){89} --> {90} + {91} + {21} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1485 Master=1364 Rover.At(1364){22} --> {23} + {22} + {89} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1519 Master=1406 Rover.At(1406){88} --> {89} + {90} + {22} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1580 Master=1463 Rover.Going(1463){23} --> {24} + {23} + {88} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1662 Master=1541 Rover.Going(1541){87} --> {88} + {89} + {23} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1721 Master=1600 Rover.At(1600){24} --> {25} + {24} + {87} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1755 Master=1642 Rover.At(1642){86} --> {87} + {88} + {24} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1816 Master=1699 Rover.Going(1699){25} --> {26} + {25} + {86} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1898 Master=1777 Rover.Going(1777){85} --> {86} + {87} + {25} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1957 Master=1836 Rover.At(1836){26} --> {27} + {26} + {85} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1991 Master=1878 Rover.At(1878){84} --> {85} + {86} + {26} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2052 Master=1935 Rover.Going(1935){27} --> {28} + {27} + {84} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2134 Master=2013 Rover.Going(2013){83} --> {84} + {85} + {27} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2193 Master=2072 Rover.At(2072){28} --> {29} + {28} + {83} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2227 Master=2114 Rover.At(2114){82} --> {83} + {84} + {28} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2288 Master=2171 Rover.Going(2171){29} --> {30} + {29} + {82} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2370 Master=2249 Rover.Going(2249){81} --> {82} + {83} + {29} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2429 Master=2308 Rover.At(2308){30} --> {31} + {30} + {81} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2463 Master=2350 Rover.At(2350){80} --> {81} + {82} + {30} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2524 Master=2407 Rover.Going(2407){31} --> {32} + {31} + {80} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2606 Master=2485 Rover.Going(2485){79} --> {80} + {81} + {31} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2665 Master=2544 Rover.At(2544){32} --> {33} + {32} + {79} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2699 Master=2586 Rover.At(2586){78} --> {79} + {80} + {32} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2760 Master=2643 Rover.Going(2643){33} --> {34} + {33} + {78} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2842 Master=2721 Rover.Going(2721){77} --> {78} + {79} + {33} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2901 Master=2780 Rover.At(2780){34} --> {35} + {34} + {77} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2935 Master=2822 Rover.At(2822){76} --> {77} + {78} + {34} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2996 Master=2879 Rover.Going(2879){35} --> {36} + {35} + {76} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3078 Master=2957 Rover.Going(2957){75} --> {76} + {77} + {35} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3137 Master=3016 Rover.At(3016){36} --> {37} + {36} + {75} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3171 Master=3058 Rover.At(3058){74} --> {75} + {76} + {36} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3232 Master=3115 Rover.Going(3115){37} --> {38} + {37} + {74} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3314 Master=3193 Rover.Going(3193){73} --> {74} + {75} + {37} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3373 Master=3252 Rover.At(3252){38} --> {39} + {38} + {73} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3407 Master=3294 Rover.At(3294){72} --> {73} + {74} + {38} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3468 Master=3351 Rover.Going(3351){39} --> {40} + {39} + {72} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3550 Master=3429 Rover.Going(3429){71} --> {72} + {73} + {39} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3609 Master=3488 Rover.At(3488){40} --> {41} + {40} + {71} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3643 Master=3530 Rover.At(3530){70} --> {71} + {72} + {40} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3704 Master=3587 Rover.Going(3587){41} --> {42} + {41} + {70} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3786 Master=3665 Rover.Going(3665){69} --> {70} + {71} + {41} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3845 Master=3724 Rover.At(3724){42} --> {43} + {42} + {69} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3879 Master=3766 Rover.At(3766){68} --> {69} + {70} + {42} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3940 Master=3823 Rover.Going(3823){43} --> {44} + {43} + {68} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4022 Master=3901 Rover.Going(3901){67} --> {68} + {69} + {43} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4081 Master=3960 Rover.At(3960){44} --> {45} + {44} + {67} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4115 Master=4002 Rover.At(4002){66} --> {67} + {68} + {44} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4176 Master=4059 Rover.Going(4059){45} --> {46} + {45} + {66} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4258 Master=4137 Rover.Going(4137){65} --> {66} + {67} + {45} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4317 Master=4196 Rover.At(4196){46} --> {47} + {46} + {65} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4351 Master=4238 Rover.At(4238){64} --> {65} + {66} + {46} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4412 Master=4295 Rover.Going(4295){47} --> {48} + {47} + {64} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4494 Master=4373 Rover.Going(4373){63} --> {64} + {65} + {47} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4553 Master=4432 Rover.At(4432){48} --> {49} + {48} + {63} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4587 Master=4474 Rover.At(4474){62} --> {63} + {64} + {48} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4648 Master=4531 Rover.Going(4531){49} --> {50} + {49} + {62} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4730 Master=4609 Rover.Going(4609){61} --> {62} + {63} + {49} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4789 Master=4668 Rover.At(4668){50} --> {51} + {50} + {61} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4823 Master=4710 Rover.At(4710){60} --> {61} + {62} + {50} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4884 Master=4767 Rover.Going(4767){51} --> {52} + {51} + {60} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4966 Master=4845 Rover.Going(4845){59} --> {60} + {61} + {51} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5025 Master=4904 Rover.At(4904){52} --> {53} + {52} + {59} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5059 Master=4946 Rover.At(4946){58} --> {59} + {60} + {52} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5120 Master=5003 Rover.Going(5003){53} --> {54} + {53} + {58} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5202 Master=5081 Rover.Going(5081){57} --> {58} + {59} + {53} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5261 Master=5140 Rover.At(5140){54} --> {55} + {54} + {57} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5295 Master=5182 Rover.At(5182){56} --> {57} + {58} + {55} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5317 Master=5182 Rover.At(5182){56} --> {57} + {56} + {54} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5356 Master=5239 Rover.Going(5239){55} --> {56} + {55} + {56} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5376 Master=5239 Rover.Going(5239){55} --> {56} + {57} +Inactive Tokens: ************************* + {9} + Rover.Going(m_from=Locations:CLOSED{Hill,Rock}m_to=Locations:CLOSED{Lander}) + Key=90 Master=26 a(26){10} --> {11} + {10} + {101} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill,Lander}) + Key=120 Master=46 b(46){100} --> {101} + {102} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[10, 10] + world.m_horizonEnd=int:CLOSED[101, 101] + world.m_maxPlannerSteps=int:CLOSED[1000, 1000] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {10} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=26 Master=NONE + Merged Key=174 from Rover.Going(68){11} --> {12} + {11} + {11} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=68 Master=26 a(26){10} --> {11} + Merged Key=305 from Rover.At(194){12} --> {13} + {12} + {12} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=194 Master=68 Rover.Going(68){11} --> {12} + Merged Key=400 from Rover.Going(283){13} --> {14} + {13} + {13} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=283 Master=194 Rover.At(194){12} --> {13} + Merged Key=541 from Rover.At(420){14} --> {15} + {14} + {14} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=420 Master=283 Rover.Going(283){13} --> {14} + Merged Key=636 from Rover.Going(519){15} --> {16} + {15} + {15} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=519 Master=420 Rover.At(420){14} --> {15} + Merged Key=777 from Rover.At(656){16} --> {17} + {16} + {16} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=656 Master=519 Rover.Going(519){15} --> {16} + Merged Key=872 from Rover.Going(755){17} --> {18} + {17} + {17} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=755 Master=656 Rover.At(656){16} --> {17} + Merged Key=1013 from Rover.At(892){18} --> {19} + {18} + {18} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=892 Master=755 Rover.Going(755){17} --> {18} + Merged Key=1108 from Rover.Going(991){19} --> {20} + {19} + {19} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=991 Master=892 Rover.At(892){18} --> {19} + Merged Key=1249 from Rover.At(1128){20} --> {21} + {20} + {20} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1128 Master=991 Rover.Going(991){19} --> {20} + Merged Key=1344 from Rover.Going(1227){21} --> {22} + {21} + {21} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=1227 Master=1128 Rover.At(1128){20} --> {21} + Merged Key=1485 from Rover.At(1364){22} --> {23} + {22} + {22} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1364 Master=1227 Rover.Going(1227){21} --> {22} + Merged Key=1580 from Rover.Going(1463){23} --> {24} + {23} + {23} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1463 Master=1364 Rover.At(1364){22} --> {23} + Merged Key=1721 from Rover.At(1600){24} --> {25} + {24} + {24} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1600 Master=1463 Rover.Going(1463){23} --> {24} + Merged Key=1816 from Rover.Going(1699){25} --> {26} + {25} + {25} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=1699 Master=1600 Rover.At(1600){24} --> {25} + Merged Key=1957 from Rover.At(1836){26} --> {27} + {26} + {26} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1836 Master=1699 Rover.Going(1699){25} --> {26} + Merged Key=2052 from Rover.Going(1935){27} --> {28} + {27} + {27} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1935 Master=1836 Rover.At(1836){26} --> {27} + Merged Key=2193 from Rover.At(2072){28} --> {29} + {28} + {28} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2072 Master=1935 Rover.Going(1935){27} --> {28} + Merged Key=2288 from Rover.Going(2171){29} --> {30} + {29} + {29} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2171 Master=2072 Rover.At(2072){28} --> {29} + Merged Key=2429 from Rover.At(2308){30} --> {31} + {30} + {30} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2308 Master=2171 Rover.Going(2171){29} --> {30} + Merged Key=2524 from Rover.Going(2407){31} --> {32} + {31} + {31} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=2407 Master=2308 Rover.At(2308){30} --> {31} + Merged Key=2665 from Rover.At(2544){32} --> {33} + {32} + {32} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2544 Master=2407 Rover.Going(2407){31} --> {32} + Merged Key=2760 from Rover.Going(2643){33} --> {34} + {33} + {33} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2643 Master=2544 Rover.At(2544){32} --> {33} + Merged Key=2901 from Rover.At(2780){34} --> {35} + {34} + {34} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2780 Master=2643 Rover.Going(2643){33} --> {34} + Merged Key=2996 from Rover.Going(2879){35} --> {36} + {35} + {35} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=2879 Master=2780 Rover.At(2780){34} --> {35} + Merged Key=3137 from Rover.At(3016){36} --> {37} + {36} + {36} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3016 Master=2879 Rover.Going(2879){35} --> {36} + Merged Key=3232 from Rover.Going(3115){37} --> {38} + {37} + {37} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3115 Master=3016 Rover.At(3016){36} --> {37} + Merged Key=3373 from Rover.At(3252){38} --> {39} + {38} + {38} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3252 Master=3115 Rover.Going(3115){37} --> {38} + Merged Key=3468 from Rover.Going(3351){39} --> {40} + {39} + {39} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3351 Master=3252 Rover.At(3252){38} --> {39} + Merged Key=3609 from Rover.At(3488){40} --> {41} + {40} + {40} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3488 Master=3351 Rover.Going(3351){39} --> {40} + Merged Key=3704 from Rover.Going(3587){41} --> {42} + {41} + {41} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3587 Master=3488 Rover.At(3488){40} --> {41} + Merged Key=3845 from Rover.At(3724){42} --> {43} + {42} + {42} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3724 Master=3587 Rover.Going(3587){41} --> {42} + Merged Key=3940 from Rover.Going(3823){43} --> {44} + {43} + {43} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3823 Master=3724 Rover.At(3724){42} --> {43} + Merged Key=4081 from Rover.At(3960){44} --> {45} + {44} + {44} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3960 Master=3823 Rover.Going(3823){43} --> {44} + Merged Key=4176 from Rover.Going(4059){45} --> {46} + {45} + {45} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4059 Master=3960 Rover.At(3960){44} --> {45} + Merged Key=4317 from Rover.At(4196){46} --> {47} + {46} + {46} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4196 Master=4059 Rover.Going(4059){45} --> {46} + Merged Key=4412 from Rover.Going(4295){47} --> {48} + {47} + {47} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4295 Master=4196 Rover.At(4196){46} --> {47} + Merged Key=4553 from Rover.At(4432){48} --> {49} + {48} + {48} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4432 Master=4295 Rover.Going(4295){47} --> {48} + Merged Key=4648 from Rover.Going(4531){49} --> {50} + {49} + {49} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4531 Master=4432 Rover.At(4432){48} --> {49} + Merged Key=4789 from Rover.At(4668){50} --> {51} + {50} + {50} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4668 Master=4531 Rover.Going(4531){49} --> {50} + Merged Key=4884 from Rover.Going(4767){51} --> {52} + {51} + {51} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4767 Master=4668 Rover.At(4668){50} --> {51} + Merged Key=5025 from Rover.At(4904){52} --> {53} + {52} + {52} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4904 Master=4767 Rover.Going(4767){51} --> {52} + Merged Key=5120 from Rover.Going(5003){53} --> {54} + {53} + {53} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=5003 Master=4904 Rover.At(4904){52} --> {53} + Merged Key=5261 from Rover.At(5140){54} --> {55} + {54} + {54} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=5140 Master=5003 Rover.Going(5003){53} --> {54} + Merged Key=5356 from Rover.Going(5239){55} --> {56} + {55} + {55} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=5239 Master=5140 Rover.At(5140){54} --> {55} + Merged Key=5317 from Rover.At(5182){56} --> {57} + {56} + {56} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=5182 Master=5081 Rover.Going(5081){57} --> {58} + Merged Key=5376 from Rover.Going(5239){55} --> {56} + {57} + {57} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=5081 Master=4946 Rover.At(4946){58} --> {59} + Merged Key=5295 from Rover.At(5182){56} --> {57} + {58} + {58} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4946 Master=4845 Rover.Going(4845){59} --> {60} + Merged Key=5202 from Rover.Going(5081){57} --> {58} + {59} + {59} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4845 Master=4710 Rover.At(4710){60} --> {61} + Merged Key=5059 from Rover.At(4946){58} --> {59} + {60} + {60} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4710 Master=4609 Rover.Going(4609){61} --> {62} + Merged Key=4966 from Rover.Going(4845){59} --> {60} + {61} + {61} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4609 Master=4474 Rover.At(4474){62} --> {63} + Merged Key=4823 from Rover.At(4710){60} --> {61} + {62} + {62} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4474 Master=4373 Rover.Going(4373){63} --> {64} + Merged Key=4730 from Rover.Going(4609){61} --> {62} + {63} + {63} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4373 Master=4238 Rover.At(4238){64} --> {65} + Merged Key=4587 from Rover.At(4474){62} --> {63} + {64} + {64} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4238 Master=4137 Rover.Going(4137){65} --> {66} + Merged Key=4494 from Rover.Going(4373){63} --> {64} + {65} + {65} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4137 Master=4002 Rover.At(4002){66} --> {67} + Merged Key=4351 from Rover.At(4238){64} --> {65} + {66} + {66} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4002 Master=3901 Rover.Going(3901){67} --> {68} + Merged Key=4258 from Rover.Going(4137){65} --> {66} + {67} + {67} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3901 Master=3766 Rover.At(3766){68} --> {69} + Merged Key=4115 from Rover.At(4002){66} --> {67} + {68} + {68} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3766 Master=3665 Rover.Going(3665){69} --> {70} + Merged Key=4022 from Rover.Going(3901){67} --> {68} + {69} + {69} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3665 Master=3530 Rover.At(3530){70} --> {71} + Merged Key=3879 from Rover.At(3766){68} --> {69} + {70} + {70} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3530 Master=3429 Rover.Going(3429){71} --> {72} + Merged Key=3786 from Rover.Going(3665){69} --> {70} + {71} + {71} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3429 Master=3294 Rover.At(3294){72} --> {73} + Merged Key=3643 from Rover.At(3530){70} --> {71} + {72} + {72} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3294 Master=3193 Rover.Going(3193){73} --> {74} + Merged Key=3550 from Rover.Going(3429){71} --> {72} + {73} + {73} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3193 Master=3058 Rover.At(3058){74} --> {75} + Merged Key=3407 from Rover.At(3294){72} --> {73} + {74} + {74} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3058 Master=2957 Rover.Going(2957){75} --> {76} + Merged Key=3314 from Rover.Going(3193){73} --> {74} + {75} + {75} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2957 Master=2822 Rover.At(2822){76} --> {77} + Merged Key=3171 from Rover.At(3058){74} --> {75} + {76} + {76} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2822 Master=2721 Rover.Going(2721){77} --> {78} + Merged Key=3078 from Rover.Going(2957){75} --> {76} + {77} + {77} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=2721 Master=2586 Rover.At(2586){78} --> {79} + Merged Key=2935 from Rover.At(2822){76} --> {77} + {78} + {78} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2586 Master=2485 Rover.Going(2485){79} --> {80} + Merged Key=2842 from Rover.Going(2721){77} --> {78} + {79} + {79} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2485 Master=2350 Rover.At(2350){80} --> {81} + Merged Key=2699 from Rover.At(2586){78} --> {79} + {80} + {80} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2350 Master=2249 Rover.Going(2249){81} --> {82} + Merged Key=2606 from Rover.Going(2485){79} --> {80} + {81} + {81} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=2249 Master=2114 Rover.At(2114){82} --> {83} + Merged Key=2463 from Rover.At(2350){80} --> {81} + {82} + {82} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2114 Master=2013 Rover.Going(2013){83} --> {84} + Merged Key=2370 from Rover.Going(2249){81} --> {82} + {83} + {83} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2013 Master=1878 Rover.At(1878){84} --> {85} + Merged Key=2227 from Rover.At(2114){82} --> {83} + {84} + {84} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1878 Master=1777 Rover.Going(1777){85} --> {86} + Merged Key=2134 from Rover.Going(2013){83} --> {84} + {85} + {85} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1777 Master=1642 Rover.At(1642){86} --> {87} + Merged Key=1991 from Rover.At(1878){84} --> {85} + {86} + {86} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1642 Master=1541 Rover.Going(1541){87} --> {88} + Merged Key=1898 from Rover.Going(1777){85} --> {86} + {87} + {87} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=1541 Master=1406 Rover.At(1406){88} --> {89} + Merged Key=1755 from Rover.At(1642){86} --> {87} + {88} + {88} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1406 Master=1305 Rover.Going(1305){89} --> {90} + Merged Key=1662 from Rover.Going(1541){87} --> {88} + {89} + {89} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1305 Master=1170 Rover.At(1170){90} --> {91} + Merged Key=1519 from Rover.At(1406){88} --> {89} + {90} + {90} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1170 Master=1069 Rover.Going(1069){91} --> {92} + Merged Key=1426 from Rover.Going(1305){89} --> {90} + {91} + {91} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=1069 Master=934 Rover.At(934){92} --> {93} + Merged Key=1283 from Rover.At(1170){90} --> {91} + {92} + {92} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=934 Master=833 Rover.Going(833){93} --> {94} + Merged Key=1190 from Rover.Going(1069){91} --> {92} + {93} + {93} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=833 Master=698 Rover.At(698){94} --> {95} + Merged Key=1047 from Rover.At(934){92} --> {93} + {94} + {94} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=698 Master=597 Rover.Going(597){95} --> {96} + Merged Key=954 from Rover.Going(833){93} --> {94} + {95} + {95} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=597 Master=462 Rover.At(462){96} --> {97} + Merged Key=811 from Rover.At(698){94} --> {95} + {96} + {96} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=462 Master=361 Rover.Going(361){97} --> {98} + Merged Key=718 from Rover.Going(597){95} --> {96} + {97} + {97} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=361 Master=226 Rover.At(226){98} --> {99} + Merged Key=575 from Rover.At(462){96} --> {97} + {98} + {98} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=226 Master=142 Rover.Going(142){99} --> {100} + Merged Key=482 from Rover.Going(361){97} --> {98} + {99} + {99} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=142 Master=46 b(46){100} --> {101} + Merged Key=339 from Rover.At(226){98} --> {99} + {100} + {100} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=46 Master=NONE + Merged Key=246 from Rover.Going(142){99} --> {100} + {101} + End Tokens ********************* + End Rover:rover************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} +Merged Tokens: ************************* + {10} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=174 Master=68 Rover.Going(68){11} --> {12} + {11} + {100} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=246 Master=142 Rover.Going(142){99} --> {100} + {101} + {11} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Rock}) + Key=305 Master=194 Rover.At(194){12} --> {13} + {12} + {99} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=339 Master=226 Rover.At(226){98} --> {99} + {100} + {12} + Rover.At(m_location=Locations:CLOSED{Hill,Rock}) + Key=400 Master=283 Rover.Going(283){13} --> {14} + {13} + {98} + Rover.At(m_location=Locations:CLOSED{Hill,Lander}) + Key=482 Master=361 Rover.Going(361){97} --> {98} + {99} + {13} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=541 Master=420 Rover.At(420){14} --> {15} + {14} + {97} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=575 Master=462 Rover.At(462){96} --> {97} + {98} + {14} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=636 Master=519 Rover.Going(519){15} --> {16} + {15} + {96} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=718 Master=597 Rover.Going(597){95} --> {96} + {97} + {15} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=777 Master=656 Rover.At(656){16} --> {17} + {16} + {95} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=811 Master=698 Rover.At(698){94} --> {95} + {96} + {16} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=872 Master=755 Rover.Going(755){17} --> {18} + {17} + {94} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=954 Master=833 Rover.Going(833){93} --> {94} + {95} + {17} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1013 Master=892 Rover.At(892){18} --> {19} + {18} + {93} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1047 Master=934 Rover.At(934){92} --> {93} + {94} + {18} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1108 Master=991 Rover.Going(991){19} --> {20} + {19} + {92} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1190 Master=1069 Rover.Going(1069){91} --> {92} + {93} + {19} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1249 Master=1128 Rover.At(1128){20} --> {21} + {20} + {91} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1283 Master=1170 Rover.At(1170){90} --> {91} + {92} + {20} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1344 Master=1227 Rover.Going(1227){21} --> {22} + {21} + {90} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1426 Master=1305 Rover.Going(1305){89} --> {90} + {91} + {21} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1485 Master=1364 Rover.At(1364){22} --> {23} + {22} + {89} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1519 Master=1406 Rover.At(1406){88} --> {89} + {90} + {22} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1580 Master=1463 Rover.Going(1463){23} --> {24} + {23} + {88} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1662 Master=1541 Rover.Going(1541){87} --> {88} + {89} + {23} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1721 Master=1600 Rover.At(1600){24} --> {25} + {24} + {87} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1755 Master=1642 Rover.At(1642){86} --> {87} + {88} + {24} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1816 Master=1699 Rover.Going(1699){25} --> {26} + {25} + {86} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1898 Master=1777 Rover.Going(1777){85} --> {86} + {87} + {25} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1957 Master=1836 Rover.At(1836){26} --> {27} + {26} + {85} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1991 Master=1878 Rover.At(1878){84} --> {85} + {86} + {26} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2052 Master=1935 Rover.Going(1935){27} --> {28} + {27} + {84} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2134 Master=2013 Rover.Going(2013){83} --> {84} + {85} + {27} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2193 Master=2072 Rover.At(2072){28} --> {29} + {28} + {83} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2227 Master=2114 Rover.At(2114){82} --> {83} + {84} + {28} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2288 Master=2171 Rover.Going(2171){29} --> {30} + {29} + {82} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2370 Master=2249 Rover.Going(2249){81} --> {82} + {83} + {29} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2429 Master=2308 Rover.At(2308){30} --> {31} + {30} + {81} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2463 Master=2350 Rover.At(2350){80} --> {81} + {82} + {30} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2524 Master=2407 Rover.Going(2407){31} --> {32} + {31} + {80} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2606 Master=2485 Rover.Going(2485){79} --> {80} + {81} + {31} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2665 Master=2544 Rover.At(2544){32} --> {33} + {32} + {79} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2699 Master=2586 Rover.At(2586){78} --> {79} + {80} + {32} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2760 Master=2643 Rover.Going(2643){33} --> {34} + {33} + {78} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2842 Master=2721 Rover.Going(2721){77} --> {78} + {79} + {33} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2901 Master=2780 Rover.At(2780){34} --> {35} + {34} + {77} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2935 Master=2822 Rover.At(2822){76} --> {77} + {78} + {34} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2996 Master=2879 Rover.Going(2879){35} --> {36} + {35} + {76} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3078 Master=2957 Rover.Going(2957){75} --> {76} + {77} + {35} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3137 Master=3016 Rover.At(3016){36} --> {37} + {36} + {75} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3171 Master=3058 Rover.At(3058){74} --> {75} + {76} + {36} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3232 Master=3115 Rover.Going(3115){37} --> {38} + {37} + {74} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3314 Master=3193 Rover.Going(3193){73} --> {74} + {75} + {37} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3373 Master=3252 Rover.At(3252){38} --> {39} + {38} + {73} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3407 Master=3294 Rover.At(3294){72} --> {73} + {74} + {38} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3468 Master=3351 Rover.Going(3351){39} --> {40} + {39} + {72} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3550 Master=3429 Rover.Going(3429){71} --> {72} + {73} + {39} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3609 Master=3488 Rover.At(3488){40} --> {41} + {40} + {71} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3643 Master=3530 Rover.At(3530){70} --> {71} + {72} + {40} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3704 Master=3587 Rover.Going(3587){41} --> {42} + {41} + {70} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3786 Master=3665 Rover.Going(3665){69} --> {70} + {71} + {41} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3845 Master=3724 Rover.At(3724){42} --> {43} + {42} + {69} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3879 Master=3766 Rover.At(3766){68} --> {69} + {70} + {42} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3940 Master=3823 Rover.Going(3823){43} --> {44} + {43} + {68} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4022 Master=3901 Rover.Going(3901){67} --> {68} + {69} + {43} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4081 Master=3960 Rover.At(3960){44} --> {45} + {44} + {67} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4115 Master=4002 Rover.At(4002){66} --> {67} + {68} + {44} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4176 Master=4059 Rover.Going(4059){45} --> {46} + {45} + {66} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4258 Master=4137 Rover.Going(4137){65} --> {66} + {67} + {45} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4317 Master=4196 Rover.At(4196){46} --> {47} + {46} + {65} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4351 Master=4238 Rover.At(4238){64} --> {65} + {66} + {46} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4412 Master=4295 Rover.Going(4295){47} --> {48} + {47} + {64} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4494 Master=4373 Rover.Going(4373){63} --> {64} + {65} + {47} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4553 Master=4432 Rover.At(4432){48} --> {49} + {48} + {63} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4587 Master=4474 Rover.At(4474){62} --> {63} + {64} + {48} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4648 Master=4531 Rover.Going(4531){49} --> {50} + {49} + {62} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4730 Master=4609 Rover.Going(4609){61} --> {62} + {63} + {49} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4789 Master=4668 Rover.At(4668){50} --> {51} + {50} + {61} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4823 Master=4710 Rover.At(4710){60} --> {61} + {62} + {50} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4884 Master=4767 Rover.Going(4767){51} --> {52} + {51} + {60} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4966 Master=4845 Rover.Going(4845){59} --> {60} + {61} + {51} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5025 Master=4904 Rover.At(4904){52} --> {53} + {52} + {59} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5059 Master=4946 Rover.At(4946){58} --> {59} + {60} + {52} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5120 Master=5003 Rover.Going(5003){53} --> {54} + {53} + {58} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5202 Master=5081 Rover.Going(5081){57} --> {58} + {59} + {53} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5261 Master=5140 Rover.At(5140){54} --> {55} + {54} + {57} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5295 Master=5182 Rover.At(5182){56} --> {57} + {58} + {55} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5317 Master=5182 Rover.At(5182){56} --> {57} + {56} + {54} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5356 Master=5239 Rover.Going(5239){55} --> {56} + {55} + {56} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5376 Master=5239 Rover.Going(5239){55} --> {56} + {57} +Inactive Tokens: ************************* + {9} + Rover.Going(m_from=Locations:CLOSED{Hill,Rock}m_to=Locations:CLOSED{Lander}) + Key=90 Master=26 a(26){10} --> {11} + {10} + {101} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill,Lander}) + Key=120 Master=46 b(46){100} --> {101} + {102} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-basic-model-transaction.nddl-RandomPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-basic-model-transaction.nddl-RandomPlannerConfig.xml.out new file mode 100644 index 000000000..237b46ea5 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-basic-model-transaction.nddl-RandomPlannerConfig.xml.out @@ -0,0 +1,1692 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[10, 10] + world.m_horizonEnd=int:CLOSED[101, 101] + world.m_maxPlannerSteps=int:CLOSED[1000, 1000] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {10} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=26 Master=NONE + Merged Key=174 from Rover.Going(68){11} --> {12} + {11} + {11} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=68 Master=26 a(26){10} --> {11} + Merged Key=305 from Rover.At(194){12} --> {13} + {12} + {12} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=194 Master=68 Rover.Going(68){11} --> {12} + Merged Key=400 from Rover.Going(283){13} --> {14} + {13} + {13} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=283 Master=194 Rover.At(194){12} --> {13} + Merged Key=541 from Rover.At(420){14} --> {15} + {14} + {14} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=420 Master=283 Rover.Going(283){13} --> {14} + Merged Key=636 from Rover.Going(519){15} --> {16} + {15} + {15} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=519 Master=420 Rover.At(420){14} --> {15} + Merged Key=777 from Rover.At(656){16} --> {17} + {16} + {16} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=656 Master=519 Rover.Going(519){15} --> {16} + Merged Key=872 from Rover.Going(755){17} --> {18} + {17} + {17} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=755 Master=656 Rover.At(656){16} --> {17} + Merged Key=1013 from Rover.At(892){18} --> {19} + {18} + {18} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=892 Master=755 Rover.Going(755){17} --> {18} + Merged Key=1108 from Rover.Going(991){19} --> {20} + {19} + {19} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=991 Master=892 Rover.At(892){18} --> {19} + Merged Key=1249 from Rover.At(1128){20} --> {21} + {20} + {20} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1128 Master=991 Rover.Going(991){19} --> {20} + Merged Key=1344 from Rover.Going(1227){21} --> {22} + {21} + {21} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1227 Master=1128 Rover.At(1128){20} --> {21} + Merged Key=1485 from Rover.At(1364){22} --> {23} + {22} + {22} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1364 Master=1227 Rover.Going(1227){21} --> {22} + Merged Key=1580 from Rover.Going(1463){23} --> {24} + {23} + {23} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=1463 Master=1364 Rover.At(1364){22} --> {23} + Merged Key=1721 from Rover.At(1600){24} --> {25} + {24} + {24} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=1600 Master=1463 Rover.Going(1463){23} --> {24} + Merged Key=1816 from Rover.Going(1699){25} --> {26} + {25} + {25} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=1699 Master=1600 Rover.At(1600){24} --> {25} + Merged Key=1957 from Rover.At(1836){26} --> {27} + {26} + {26} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1836 Master=1699 Rover.Going(1699){25} --> {26} + Merged Key=2052 from Rover.Going(1935){27} --> {28} + {27} + {27} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=1935 Master=1836 Rover.At(1836){26} --> {27} + Merged Key=2193 from Rover.At(2072){28} --> {29} + {28} + {28} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=2072 Master=1935 Rover.Going(1935){27} --> {28} + Merged Key=2288 from Rover.Going(2171){29} --> {30} + {29} + {29} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=2171 Master=2072 Rover.At(2072){28} --> {29} + Merged Key=2429 from Rover.At(2308){30} --> {31} + {30} + {30} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2308 Master=2171 Rover.Going(2171){29} --> {30} + Merged Key=2524 from Rover.Going(2407){31} --> {32} + {31} + {31} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=2407 Master=2308 Rover.At(2308){30} --> {31} + Merged Key=2665 from Rover.At(2544){32} --> {33} + {32} + {32} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=2544 Master=2407 Rover.Going(2407){31} --> {32} + Merged Key=2760 from Rover.Going(2643){33} --> {34} + {33} + {33} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=2643 Master=2544 Rover.At(2544){32} --> {33} + Merged Key=2901 from Rover.At(2780){34} --> {35} + {34} + {34} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2780 Master=2643 Rover.Going(2643){33} --> {34} + Merged Key=2996 from Rover.Going(2879){35} --> {36} + {35} + {35} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=2879 Master=2780 Rover.At(2780){34} --> {35} + Merged Key=3137 from Rover.At(3016){36} --> {37} + {36} + {36} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=3016 Master=2879 Rover.Going(2879){35} --> {36} + Merged Key=3232 from Rover.Going(3115){37} --> {38} + {37} + {37} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=3115 Master=3016 Rover.At(3016){36} --> {37} + Merged Key=3373 from Rover.At(3252){38} --> {39} + {38} + {38} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3252 Master=3115 Rover.Going(3115){37} --> {38} + Merged Key=3468 from Rover.Going(3351){39} --> {40} + {39} + {39} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3351 Master=3252 Rover.At(3252){38} --> {39} + Merged Key=3609 from Rover.At(3488){40} --> {41} + {40} + {40} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3488 Master=3351 Rover.Going(3351){39} --> {40} + Merged Key=3704 from Rover.Going(3587){41} --> {42} + {41} + {41} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=3587 Master=3488 Rover.At(3488){40} --> {41} + Merged Key=3845 from Rover.At(3724){42} --> {43} + {42} + {42} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=3724 Master=3587 Rover.Going(3587){41} --> {42} + Merged Key=3940 from Rover.Going(3823){43} --> {44} + {43} + {43} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=3823 Master=3724 Rover.At(3724){42} --> {43} + Merged Key=4081 from Rover.At(3960){44} --> {45} + {44} + {44} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3960 Master=3823 Rover.Going(3823){43} --> {44} + Merged Key=4176 from Rover.Going(4059){45} --> {46} + {45} + {45} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4059 Master=3960 Rover.At(3960){44} --> {45} + Merged Key=4317 from Rover.At(4196){46} --> {47} + {46} + {46} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4196 Master=4059 Rover.Going(4059){45} --> {46} + Merged Key=4412 from Rover.Going(4295){47} --> {48} + {47} + {47} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=4295 Master=4196 Rover.At(4196){46} --> {47} + Merged Key=4553 from Rover.At(4432){48} --> {49} + {48} + {48} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=4432 Master=4295 Rover.Going(4295){47} --> {48} + Merged Key=4648 from Rover.Going(4531){49} --> {50} + {49} + {49} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=4531 Master=4432 Rover.At(4432){48} --> {49} + Merged Key=4789 from Rover.At(4668){50} --> {51} + {50} + {50} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4668 Master=4531 Rover.Going(4531){49} --> {50} + Merged Key=4884 from Rover.Going(4767){51} --> {52} + {51} + {51} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4767 Master=4668 Rover.At(4668){50} --> {51} + Merged Key=5025 from Rover.At(4904){52} --> {53} + {52} + {52} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4904 Master=4767 Rover.Going(4767){51} --> {52} + Merged Key=5120 from Rover.Going(5003){53} --> {54} + {53} + {53} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=5003 Master=4904 Rover.At(4904){52} --> {53} + Merged Key=5261 from Rover.At(5140){54} --> {55} + {54} + {54} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=5140 Master=5003 Rover.Going(5003){53} --> {54} + Merged Key=5356 from Rover.Going(5239){55} --> {56} + {55} + {55} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=5239 Master=5140 Rover.At(5140){54} --> {55} + Merged Key=5317 from Rover.At(5182){56} --> {57} + {56} + {56} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=5182 Master=5081 Rover.Going(5081){57} --> {58} + Merged Key=5376 from Rover.Going(5239){55} --> {56} + {57} + {57} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=5081 Master=4946 Rover.At(4946){58} --> {59} + Merged Key=5295 from Rover.At(5182){56} --> {57} + {58} + {58} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=4946 Master=4845 Rover.Going(4845){59} --> {60} + Merged Key=5202 from Rover.Going(5081){57} --> {58} + {59} + {59} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=4845 Master=4710 Rover.At(4710){60} --> {61} + Merged Key=5059 from Rover.At(4946){58} --> {59} + {60} + {60} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4710 Master=4609 Rover.Going(4609){61} --> {62} + Merged Key=4966 from Rover.Going(4845){59} --> {60} + {61} + {61} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4609 Master=4474 Rover.At(4474){62} --> {63} + Merged Key=4823 from Rover.At(4710){60} --> {61} + {62} + {62} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4474 Master=4373 Rover.Going(4373){63} --> {64} + Merged Key=4730 from Rover.Going(4609){61} --> {62} + {63} + {63} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4373 Master=4238 Rover.At(4238){64} --> {65} + Merged Key=4587 from Rover.At(4474){62} --> {63} + {64} + {64} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4238 Master=4137 Rover.Going(4137){65} --> {66} + Merged Key=4494 from Rover.Going(4373){63} --> {64} + {65} + {65} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4137 Master=4002 Rover.At(4002){66} --> {67} + Merged Key=4351 from Rover.At(4238){64} --> {65} + {66} + {66} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4002 Master=3901 Rover.Going(3901){67} --> {68} + Merged Key=4258 from Rover.Going(4137){65} --> {66} + {67} + {67} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=3901 Master=3766 Rover.At(3766){68} --> {69} + Merged Key=4115 from Rover.At(4002){66} --> {67} + {68} + {68} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=3766 Master=3665 Rover.Going(3665){69} --> {70} + Merged Key=4022 from Rover.Going(3901){67} --> {68} + {69} + {69} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=3665 Master=3530 Rover.At(3530){70} --> {71} + Merged Key=3879 from Rover.At(3766){68} --> {69} + {70} + {70} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3530 Master=3429 Rover.Going(3429){71} --> {72} + Merged Key=3786 from Rover.Going(3665){69} --> {70} + {71} + {71} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3429 Master=3294 Rover.At(3294){72} --> {73} + Merged Key=3643 from Rover.At(3530){70} --> {71} + {72} + {72} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3294 Master=3193 Rover.Going(3193){73} --> {74} + Merged Key=3550 from Rover.Going(3429){71} --> {72} + {73} + {73} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3193 Master=3058 Rover.At(3058){74} --> {75} + Merged Key=3407 from Rover.At(3294){72} --> {73} + {74} + {74} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3058 Master=2957 Rover.Going(2957){75} --> {76} + Merged Key=3314 from Rover.Going(3193){73} --> {74} + {75} + {75} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=2957 Master=2822 Rover.At(2822){76} --> {77} + Merged Key=3171 from Rover.At(3058){74} --> {75} + {76} + {76} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=2822 Master=2721 Rover.Going(2721){77} --> {78} + Merged Key=3078 from Rover.Going(2957){75} --> {76} + {77} + {77} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=2721 Master=2586 Rover.At(2586){78} --> {79} + Merged Key=2935 from Rover.At(2822){76} --> {77} + {78} + {78} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2586 Master=2485 Rover.Going(2485){79} --> {80} + Merged Key=2842 from Rover.Going(2721){77} --> {78} + {79} + {79} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2485 Master=2350 Rover.At(2350){80} --> {81} + Merged Key=2699 from Rover.At(2586){78} --> {79} + {80} + {80} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2350 Master=2249 Rover.Going(2249){81} --> {82} + Merged Key=2606 from Rover.Going(2485){79} --> {80} + {81} + {81} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=2249 Master=2114 Rover.At(2114){82} --> {83} + Merged Key=2463 from Rover.At(2350){80} --> {81} + {82} + {82} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=2114 Master=2013 Rover.Going(2013){83} --> {84} + Merged Key=2370 from Rover.Going(2249){81} --> {82} + {83} + {83} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=2013 Master=1878 Rover.At(1878){84} --> {85} + Merged Key=2227 from Rover.At(2114){82} --> {83} + {84} + {84} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1878 Master=1777 Rover.Going(1777){85} --> {86} + Merged Key=2134 from Rover.Going(2013){83} --> {84} + {85} + {85} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=1777 Master=1642 Rover.At(1642){86} --> {87} + Merged Key=1991 from Rover.At(1878){84} --> {85} + {86} + {86} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=1642 Master=1541 Rover.Going(1541){87} --> {88} + Merged Key=1898 from Rover.Going(1777){85} --> {86} + {87} + {87} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=1541 Master=1406 Rover.At(1406){88} --> {89} + Merged Key=1755 from Rover.At(1642){86} --> {87} + {88} + {88} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1406 Master=1305 Rover.Going(1305){89} --> {90} + Merged Key=1662 from Rover.Going(1541){87} --> {88} + {89} + {89} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=1305 Master=1170 Rover.At(1170){90} --> {91} + Merged Key=1519 from Rover.At(1406){88} --> {89} + {90} + {90} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=1170 Master=1069 Rover.Going(1069){91} --> {92} + Merged Key=1426 from Rover.Going(1305){89} --> {90} + {91} + {91} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=1069 Master=934 Rover.At(934){92} --> {93} + Merged Key=1283 from Rover.At(1170){90} --> {91} + {92} + {92} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=934 Master=833 Rover.Going(833){93} --> {94} + Merged Key=1190 from Rover.Going(1069){91} --> {92} + {93} + {93} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=833 Master=698 Rover.At(698){94} --> {95} + Merged Key=1047 from Rover.At(934){92} --> {93} + {94} + {94} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=698 Master=597 Rover.Going(597){95} --> {96} + Merged Key=954 from Rover.Going(833){93} --> {94} + {95} + {95} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=597 Master=462 Rover.At(462){96} --> {97} + Merged Key=811 from Rover.At(698){94} --> {95} + {96} + {96} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=462 Master=361 Rover.Going(361){97} --> {98} + Merged Key=718 from Rover.Going(597){95} --> {96} + {97} + {97} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=361 Master=226 Rover.At(226){98} --> {99} + Merged Key=575 from Rover.At(462){96} --> {97} + {98} + {98} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=226 Master=142 Rover.Going(142){99} --> {100} + Merged Key=482 from Rover.Going(361){97} --> {98} + {99} + {99} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=142 Master=46 b(46){100} --> {101} + Merged Key=339 from Rover.At(226){98} --> {99} + {100} + {100} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=46 Master=NONE + Merged Key=246 from Rover.Going(142){99} --> {100} + {101} + End Tokens ********************* + End Rover:rover************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} +Merged Tokens: ************************* + {10} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=174 Master=68 Rover.Going(68){11} --> {12} + {11} + {100} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=246 Master=142 Rover.Going(142){99} --> {100} + {101} + {11} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Rock}) + Key=305 Master=194 Rover.At(194){12} --> {13} + {12} + {99} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=339 Master=226 Rover.At(226){98} --> {99} + {100} + {12} + Rover.At(m_location=Locations:CLOSED{Hill,Rock}) + Key=400 Master=283 Rover.Going(283){13} --> {14} + {13} + {98} + Rover.At(m_location=Locations:CLOSED{Hill,Lander}) + Key=482 Master=361 Rover.Going(361){97} --> {98} + {99} + {13} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=541 Master=420 Rover.At(420){14} --> {15} + {14} + {97} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=575 Master=462 Rover.At(462){96} --> {97} + {98} + {14} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=636 Master=519 Rover.Going(519){15} --> {16} + {15} + {96} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=718 Master=597 Rover.Going(597){95} --> {96} + {97} + {15} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=777 Master=656 Rover.At(656){16} --> {17} + {16} + {95} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=811 Master=698 Rover.At(698){94} --> {95} + {96} + {16} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=872 Master=755 Rover.Going(755){17} --> {18} + {17} + {94} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=954 Master=833 Rover.Going(833){93} --> {94} + {95} + {17} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1013 Master=892 Rover.At(892){18} --> {19} + {18} + {93} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1047 Master=934 Rover.At(934){92} --> {93} + {94} + {18} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1108 Master=991 Rover.Going(991){19} --> {20} + {19} + {92} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1190 Master=1069 Rover.Going(1069){91} --> {92} + {93} + {19} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1249 Master=1128 Rover.At(1128){20} --> {21} + {20} + {91} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1283 Master=1170 Rover.At(1170){90} --> {91} + {92} + {20} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1344 Master=1227 Rover.Going(1227){21} --> {22} + {21} + {90} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1426 Master=1305 Rover.Going(1305){89} --> {90} + {91} + {21} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1485 Master=1364 Rover.At(1364){22} --> {23} + {22} + {89} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1519 Master=1406 Rover.At(1406){88} --> {89} + {90} + {22} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1580 Master=1463 Rover.Going(1463){23} --> {24} + {23} + {88} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1662 Master=1541 Rover.Going(1541){87} --> {88} + {89} + {23} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1721 Master=1600 Rover.At(1600){24} --> {25} + {24} + {87} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1755 Master=1642 Rover.At(1642){86} --> {87} + {88} + {24} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1816 Master=1699 Rover.Going(1699){25} --> {26} + {25} + {86} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1898 Master=1777 Rover.Going(1777){85} --> {86} + {87} + {25} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1957 Master=1836 Rover.At(1836){26} --> {27} + {26} + {85} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1991 Master=1878 Rover.At(1878){84} --> {85} + {86} + {26} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2052 Master=1935 Rover.Going(1935){27} --> {28} + {27} + {84} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2134 Master=2013 Rover.Going(2013){83} --> {84} + {85} + {27} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2193 Master=2072 Rover.At(2072){28} --> {29} + {28} + {83} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2227 Master=2114 Rover.At(2114){82} --> {83} + {84} + {28} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2288 Master=2171 Rover.Going(2171){29} --> {30} + {29} + {82} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2370 Master=2249 Rover.Going(2249){81} --> {82} + {83} + {29} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2429 Master=2308 Rover.At(2308){30} --> {31} + {30} + {81} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2463 Master=2350 Rover.At(2350){80} --> {81} + {82} + {30} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2524 Master=2407 Rover.Going(2407){31} --> {32} + {31} + {80} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2606 Master=2485 Rover.Going(2485){79} --> {80} + {81} + {31} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2665 Master=2544 Rover.At(2544){32} --> {33} + {32} + {79} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2699 Master=2586 Rover.At(2586){78} --> {79} + {80} + {32} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2760 Master=2643 Rover.Going(2643){33} --> {34} + {33} + {78} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2842 Master=2721 Rover.Going(2721){77} --> {78} + {79} + {33} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2901 Master=2780 Rover.At(2780){34} --> {35} + {34} + {77} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2935 Master=2822 Rover.At(2822){76} --> {77} + {78} + {34} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2996 Master=2879 Rover.Going(2879){35} --> {36} + {35} + {76} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3078 Master=2957 Rover.Going(2957){75} --> {76} + {77} + {35} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3137 Master=3016 Rover.At(3016){36} --> {37} + {36} + {75} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3171 Master=3058 Rover.At(3058){74} --> {75} + {76} + {36} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3232 Master=3115 Rover.Going(3115){37} --> {38} + {37} + {74} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3314 Master=3193 Rover.Going(3193){73} --> {74} + {75} + {37} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3373 Master=3252 Rover.At(3252){38} --> {39} + {38} + {73} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3407 Master=3294 Rover.At(3294){72} --> {73} + {74} + {38} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3468 Master=3351 Rover.Going(3351){39} --> {40} + {39} + {72} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3550 Master=3429 Rover.Going(3429){71} --> {72} + {73} + {39} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3609 Master=3488 Rover.At(3488){40} --> {41} + {40} + {71} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3643 Master=3530 Rover.At(3530){70} --> {71} + {72} + {40} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3704 Master=3587 Rover.Going(3587){41} --> {42} + {41} + {70} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3786 Master=3665 Rover.Going(3665){69} --> {70} + {71} + {41} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3845 Master=3724 Rover.At(3724){42} --> {43} + {42} + {69} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3879 Master=3766 Rover.At(3766){68} --> {69} + {70} + {42} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3940 Master=3823 Rover.Going(3823){43} --> {44} + {43} + {68} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4022 Master=3901 Rover.Going(3901){67} --> {68} + {69} + {43} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4081 Master=3960 Rover.At(3960){44} --> {45} + {44} + {67} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4115 Master=4002 Rover.At(4002){66} --> {67} + {68} + {44} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4176 Master=4059 Rover.Going(4059){45} --> {46} + {45} + {66} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4258 Master=4137 Rover.Going(4137){65} --> {66} + {67} + {45} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4317 Master=4196 Rover.At(4196){46} --> {47} + {46} + {65} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4351 Master=4238 Rover.At(4238){64} --> {65} + {66} + {46} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4412 Master=4295 Rover.Going(4295){47} --> {48} + {47} + {64} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4494 Master=4373 Rover.Going(4373){63} --> {64} + {65} + {47} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4553 Master=4432 Rover.At(4432){48} --> {49} + {48} + {63} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4587 Master=4474 Rover.At(4474){62} --> {63} + {64} + {48} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4648 Master=4531 Rover.Going(4531){49} --> {50} + {49} + {62} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4730 Master=4609 Rover.Going(4609){61} --> {62} + {63} + {49} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4789 Master=4668 Rover.At(4668){50} --> {51} + {50} + {61} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4823 Master=4710 Rover.At(4710){60} --> {61} + {62} + {50} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4884 Master=4767 Rover.Going(4767){51} --> {52} + {51} + {60} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4966 Master=4845 Rover.Going(4845){59} --> {60} + {61} + {51} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5025 Master=4904 Rover.At(4904){52} --> {53} + {52} + {59} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5059 Master=4946 Rover.At(4946){58} --> {59} + {60} + {52} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5120 Master=5003 Rover.Going(5003){53} --> {54} + {53} + {58} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5202 Master=5081 Rover.Going(5081){57} --> {58} + {59} + {53} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5261 Master=5140 Rover.At(5140){54} --> {55} + {54} + {57} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5295 Master=5182 Rover.At(5182){56} --> {57} + {58} + {55} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5317 Master=5182 Rover.At(5182){56} --> {57} + {56} + {54} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5356 Master=5239 Rover.Going(5239){55} --> {56} + {55} + {56} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5376 Master=5239 Rover.Going(5239){55} --> {56} + {57} +Inactive Tokens: ************************* + {9} + Rover.Going(m_from=Locations:CLOSED{Hill,Rock}m_to=Locations:CLOSED{Lander}) + Key=90 Master=26 a(26){10} --> {11} + {10} + {101} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill,Lander}) + Key=120 Master=46 b(46){100} --> {101} + {102} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[10, 10] + world.m_horizonEnd=int:CLOSED[101, 101] + world.m_maxPlannerSteps=int:CLOSED[1000, 1000] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {10} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=26 Master=NONE + Merged Key=174 from Rover.Going(68){11} --> {12} + {11} + {11} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=68 Master=26 a(26){10} --> {11} + Merged Key=305 from Rover.At(194){12} --> {13} + {12} + {12} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=194 Master=68 Rover.Going(68){11} --> {12} + Merged Key=400 from Rover.Going(283){13} --> {14} + {13} + {13} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=283 Master=194 Rover.At(194){12} --> {13} + Merged Key=541 from Rover.At(420){14} --> {15} + {14} + {14} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=420 Master=283 Rover.Going(283){13} --> {14} + Merged Key=636 from Rover.Going(519){15} --> {16} + {15} + {15} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=519 Master=420 Rover.At(420){14} --> {15} + Merged Key=777 from Rover.At(656){16} --> {17} + {16} + {16} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=656 Master=519 Rover.Going(519){15} --> {16} + Merged Key=872 from Rover.Going(755){17} --> {18} + {17} + {17} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=755 Master=656 Rover.At(656){16} --> {17} + Merged Key=1013 from Rover.At(892){18} --> {19} + {18} + {18} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=892 Master=755 Rover.Going(755){17} --> {18} + Merged Key=1108 from Rover.Going(991){19} --> {20} + {19} + {19} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=991 Master=892 Rover.At(892){18} --> {19} + Merged Key=1249 from Rover.At(1128){20} --> {21} + {20} + {20} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1128 Master=991 Rover.Going(991){19} --> {20} + Merged Key=1344 from Rover.Going(1227){21} --> {22} + {21} + {21} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=1227 Master=1128 Rover.At(1128){20} --> {21} + Merged Key=1485 from Rover.At(1364){22} --> {23} + {22} + {22} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1364 Master=1227 Rover.Going(1227){21} --> {22} + Merged Key=1580 from Rover.Going(1463){23} --> {24} + {23} + {23} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=1463 Master=1364 Rover.At(1364){22} --> {23} + Merged Key=1721 from Rover.At(1600){24} --> {25} + {24} + {24} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=1600 Master=1463 Rover.Going(1463){23} --> {24} + Merged Key=1816 from Rover.Going(1699){25} --> {26} + {25} + {25} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=1699 Master=1600 Rover.At(1600){24} --> {25} + Merged Key=1957 from Rover.At(1836){26} --> {27} + {26} + {26} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1836 Master=1699 Rover.Going(1699){25} --> {26} + Merged Key=2052 from Rover.Going(1935){27} --> {28} + {27} + {27} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=1935 Master=1836 Rover.At(1836){26} --> {27} + Merged Key=2193 from Rover.At(2072){28} --> {29} + {28} + {28} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=2072 Master=1935 Rover.Going(1935){27} --> {28} + Merged Key=2288 from Rover.Going(2171){29} --> {30} + {29} + {29} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=2171 Master=2072 Rover.At(2072){28} --> {29} + Merged Key=2429 from Rover.At(2308){30} --> {31} + {30} + {30} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2308 Master=2171 Rover.Going(2171){29} --> {30} + Merged Key=2524 from Rover.Going(2407){31} --> {32} + {31} + {31} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=2407 Master=2308 Rover.At(2308){30} --> {31} + Merged Key=2665 from Rover.At(2544){32} --> {33} + {32} + {32} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=2544 Master=2407 Rover.Going(2407){31} --> {32} + Merged Key=2760 from Rover.Going(2643){33} --> {34} + {33} + {33} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=2643 Master=2544 Rover.At(2544){32} --> {33} + Merged Key=2901 from Rover.At(2780){34} --> {35} + {34} + {34} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2780 Master=2643 Rover.Going(2643){33} --> {34} + Merged Key=2996 from Rover.Going(2879){35} --> {36} + {35} + {35} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=2879 Master=2780 Rover.At(2780){34} --> {35} + Merged Key=3137 from Rover.At(3016){36} --> {37} + {36} + {36} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=3016 Master=2879 Rover.Going(2879){35} --> {36} + Merged Key=3232 from Rover.Going(3115){37} --> {38} + {37} + {37} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=3115 Master=3016 Rover.At(3016){36} --> {37} + Merged Key=3373 from Rover.At(3252){38} --> {39} + {38} + {38} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3252 Master=3115 Rover.Going(3115){37} --> {38} + Merged Key=3468 from Rover.Going(3351){39} --> {40} + {39} + {39} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3351 Master=3252 Rover.At(3252){38} --> {39} + Merged Key=3609 from Rover.At(3488){40} --> {41} + {40} + {40} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3488 Master=3351 Rover.Going(3351){39} --> {40} + Merged Key=3704 from Rover.Going(3587){41} --> {42} + {41} + {41} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=3587 Master=3488 Rover.At(3488){40} --> {41} + Merged Key=3845 from Rover.At(3724){42} --> {43} + {42} + {42} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=3724 Master=3587 Rover.Going(3587){41} --> {42} + Merged Key=3940 from Rover.Going(3823){43} --> {44} + {43} + {43} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=3823 Master=3724 Rover.At(3724){42} --> {43} + Merged Key=4081 from Rover.At(3960){44} --> {45} + {44} + {44} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3960 Master=3823 Rover.Going(3823){43} --> {44} + Merged Key=4176 from Rover.Going(4059){45} --> {46} + {45} + {45} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4059 Master=3960 Rover.At(3960){44} --> {45} + Merged Key=4317 from Rover.At(4196){46} --> {47} + {46} + {46} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4196 Master=4059 Rover.Going(4059){45} --> {46} + Merged Key=4412 from Rover.Going(4295){47} --> {48} + {47} + {47} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=4295 Master=4196 Rover.At(4196){46} --> {47} + Merged Key=4553 from Rover.At(4432){48} --> {49} + {48} + {48} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=4432 Master=4295 Rover.Going(4295){47} --> {48} + Merged Key=4648 from Rover.Going(4531){49} --> {50} + {49} + {49} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=4531 Master=4432 Rover.At(4432){48} --> {49} + Merged Key=4789 from Rover.At(4668){50} --> {51} + {50} + {50} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4668 Master=4531 Rover.Going(4531){49} --> {50} + Merged Key=4884 from Rover.Going(4767){51} --> {52} + {51} + {51} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4767 Master=4668 Rover.At(4668){50} --> {51} + Merged Key=5025 from Rover.At(4904){52} --> {53} + {52} + {52} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4904 Master=4767 Rover.Going(4767){51} --> {52} + Merged Key=5120 from Rover.Going(5003){53} --> {54} + {53} + {53} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=5003 Master=4904 Rover.At(4904){52} --> {53} + Merged Key=5261 from Rover.At(5140){54} --> {55} + {54} + {54} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=5140 Master=5003 Rover.Going(5003){53} --> {54} + Merged Key=5356 from Rover.Going(5239){55} --> {56} + {55} + {55} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=5239 Master=5140 Rover.At(5140){54} --> {55} + Merged Key=5317 from Rover.At(5182){56} --> {57} + {56} + {56} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=5182 Master=5081 Rover.Going(5081){57} --> {58} + Merged Key=5376 from Rover.Going(5239){55} --> {56} + {57} + {57} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=5081 Master=4946 Rover.At(4946){58} --> {59} + Merged Key=5295 from Rover.At(5182){56} --> {57} + {58} + {58} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=4946 Master=4845 Rover.Going(4845){59} --> {60} + Merged Key=5202 from Rover.Going(5081){57} --> {58} + {59} + {59} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=4845 Master=4710 Rover.At(4710){60} --> {61} + Merged Key=5059 from Rover.At(4946){58} --> {59} + {60} + {60} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4710 Master=4609 Rover.Going(4609){61} --> {62} + Merged Key=4966 from Rover.Going(4845){59} --> {60} + {61} + {61} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4609 Master=4474 Rover.At(4474){62} --> {63} + Merged Key=4823 from Rover.At(4710){60} --> {61} + {62} + {62} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4474 Master=4373 Rover.Going(4373){63} --> {64} + Merged Key=4730 from Rover.Going(4609){61} --> {62} + {63} + {63} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=4373 Master=4238 Rover.At(4238){64} --> {65} + Merged Key=4587 from Rover.At(4474){62} --> {63} + {64} + {64} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=4238 Master=4137 Rover.Going(4137){65} --> {66} + Merged Key=4494 from Rover.Going(4373){63} --> {64} + {65} + {65} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=4137 Master=4002 Rover.At(4002){66} --> {67} + Merged Key=4351 from Rover.At(4238){64} --> {65} + {66} + {66} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=4002 Master=3901 Rover.Going(3901){67} --> {68} + Merged Key=4258 from Rover.Going(4137){65} --> {66} + {67} + {67} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=3901 Master=3766 Rover.At(3766){68} --> {69} + Merged Key=4115 from Rover.At(4002){66} --> {67} + {68} + {68} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=3766 Master=3665 Rover.Going(3665){69} --> {70} + Merged Key=4022 from Rover.Going(3901){67} --> {68} + {69} + {69} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=3665 Master=3530 Rover.At(3530){70} --> {71} + Merged Key=3879 from Rover.At(3766){68} --> {69} + {70} + {70} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3530 Master=3429 Rover.Going(3429){71} --> {72} + Merged Key=3786 from Rover.Going(3665){69} --> {70} + {71} + {71} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=3429 Master=3294 Rover.At(3294){72} --> {73} + Merged Key=3643 from Rover.At(3530){70} --> {71} + {72} + {72} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=3294 Master=3193 Rover.Going(3193){73} --> {74} + Merged Key=3550 from Rover.Going(3429){71} --> {72} + {73} + {73} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill}) + Key=3193 Master=3058 Rover.At(3058){74} --> {75} + Merged Key=3407 from Rover.At(3294){72} --> {73} + {74} + {74} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=3058 Master=2957 Rover.Going(2957){75} --> {76} + Merged Key=3314 from Rover.Going(3193){73} --> {74} + {75} + {75} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=2957 Master=2822 Rover.At(2822){76} --> {77} + Merged Key=3171 from Rover.At(3058){74} --> {75} + {76} + {76} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=2822 Master=2721 Rover.Going(2721){77} --> {78} + Merged Key=3078 from Rover.Going(2957){75} --> {76} + {77} + {77} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=2721 Master=2586 Rover.At(2586){78} --> {79} + Merged Key=2935 from Rover.At(2822){76} --> {77} + {78} + {78} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=2586 Master=2485 Rover.Going(2485){79} --> {80} + Merged Key=2842 from Rover.Going(2721){77} --> {78} + {79} + {79} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=2485 Master=2350 Rover.At(2350){80} --> {81} + Merged Key=2699 from Rover.At(2586){78} --> {79} + {80} + {80} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=2350 Master=2249 Rover.Going(2249){81} --> {82} + Merged Key=2606 from Rover.Going(2485){79} --> {80} + {81} + {81} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=2249 Master=2114 Rover.At(2114){82} --> {83} + Merged Key=2463 from Rover.At(2350){80} --> {81} + {82} + {82} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=2114 Master=2013 Rover.Going(2013){83} --> {84} + Merged Key=2370 from Rover.Going(2249){81} --> {82} + {83} + {83} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Rock}) + Key=2013 Master=1878 Rover.At(1878){84} --> {85} + Merged Key=2227 from Rover.At(2114){82} --> {83} + {84} + {84} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=1878 Master=1777 Rover.Going(1777){85} --> {86} + Merged Key=2134 from Rover.Going(2013){83} --> {84} + {85} + {85} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=1777 Master=1642 Rover.At(1642){86} --> {87} + Merged Key=1991 from Rover.At(1878){84} --> {85} + {86} + {86} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=1642 Master=1541 Rover.Going(1541){87} --> {88} + Merged Key=1898 from Rover.Going(1777){85} --> {86} + {87} + {87} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=1541 Master=1406 Rover.At(1406){88} --> {89} + Merged Key=1755 from Rover.At(1642){86} --> {87} + {88} + {88} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=1406 Master=1305 Rover.Going(1305){89} --> {90} + Merged Key=1662 from Rover.Going(1541){87} --> {88} + {89} + {89} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Lander}) + Key=1305 Master=1170 Rover.At(1170){90} --> {91} + Merged Key=1519 from Rover.At(1406){88} --> {89} + {90} + {90} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=1170 Master=1069 Rover.Going(1069){91} --> {92} + Merged Key=1426 from Rover.Going(1305){89} --> {90} + {91} + {91} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=1069 Master=934 Rover.At(934){92} --> {93} + Merged Key=1283 from Rover.At(1170){90} --> {91} + {92} + {92} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=934 Master=833 Rover.Going(833){93} --> {94} + Merged Key=1190 from Rover.Going(1069){91} --> {92} + {93} + {93} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=833 Master=698 Rover.At(698){94} --> {95} + Merged Key=1047 from Rover.At(934){92} --> {93} + {94} + {94} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=698 Master=597 Rover.Going(597){95} --> {96} + Merged Key=954 from Rover.Going(833){93} --> {94} + {95} + {95} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Lander}) + Key=597 Master=462 Rover.At(462){96} --> {97} + Merged Key=811 from Rover.At(698){94} --> {95} + {96} + {96} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=462 Master=361 Rover.Going(361){97} --> {98} + Merged Key=718 from Rover.Going(597){95} --> {96} + {97} + {97} + Rover.Going(m_from=Locations:CLOSED{Lander}m_to=Locations:CLOSED{Hill}) + Key=361 Master=226 Rover.At(226){98} --> {99} + Merged Key=575 from Rover.At(462){96} --> {97} + {98} + {98} + Rover.At(m_location=Locations:CLOSED{Hill}) + Key=226 Master=142 Rover.Going(142){99} --> {100} + Merged Key=482 from Rover.Going(361){97} --> {98} + {99} + {99} + Rover.Going(m_from=Locations:CLOSED{Hill}m_to=Locations:CLOSED{Rock}) + Key=142 Master=46 b(46){100} --> {101} + Merged Key=339 from Rover.At(226){98} --> {99} + {100} + {100} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=46 Master=NONE + Merged Key=246 from Rover.Going(142){99} --> {100} + {101} + End Tokens ********************* + End Rover:rover************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} +Merged Tokens: ************************* + {10} + Rover.At(m_location=Locations:CLOSED{Lander}) + Key=174 Master=68 Rover.Going(68){11} --> {12} + {11} + {100} + Rover.At(m_location=Locations:CLOSED{Rock}) + Key=246 Master=142 Rover.Going(142){99} --> {100} + {101} + {11} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Rock}) + Key=305 Master=194 Rover.At(194){12} --> {13} + {12} + {99} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=339 Master=226 Rover.At(226){98} --> {99} + {100} + {12} + Rover.At(m_location=Locations:CLOSED{Hill,Rock}) + Key=400 Master=283 Rover.Going(283){13} --> {14} + {13} + {98} + Rover.At(m_location=Locations:CLOSED{Hill,Lander}) + Key=482 Master=361 Rover.Going(361){97} --> {98} + {99} + {13} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=541 Master=420 Rover.At(420){14} --> {15} + {14} + {97} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=575 Master=462 Rover.At(462){96} --> {97} + {98} + {14} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=636 Master=519 Rover.Going(519){15} --> {16} + {15} + {96} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=718 Master=597 Rover.Going(597){95} --> {96} + {97} + {15} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=777 Master=656 Rover.At(656){16} --> {17} + {16} + {95} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=811 Master=698 Rover.At(698){94} --> {95} + {96} + {16} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=872 Master=755 Rover.Going(755){17} --> {18} + {17} + {94} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=954 Master=833 Rover.Going(833){93} --> {94} + {95} + {17} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1013 Master=892 Rover.At(892){18} --> {19} + {18} + {93} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1047 Master=934 Rover.At(934){92} --> {93} + {94} + {18} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1108 Master=991 Rover.Going(991){19} --> {20} + {19} + {92} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1190 Master=1069 Rover.Going(1069){91} --> {92} + {93} + {19} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1249 Master=1128 Rover.At(1128){20} --> {21} + {20} + {91} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1283 Master=1170 Rover.At(1170){90} --> {91} + {92} + {20} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1344 Master=1227 Rover.Going(1227){21} --> {22} + {21} + {90} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1426 Master=1305 Rover.Going(1305){89} --> {90} + {91} + {21} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1485 Master=1364 Rover.At(1364){22} --> {23} + {22} + {89} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1519 Master=1406 Rover.At(1406){88} --> {89} + {90} + {22} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1580 Master=1463 Rover.Going(1463){23} --> {24} + {23} + {88} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1662 Master=1541 Rover.Going(1541){87} --> {88} + {89} + {23} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1721 Master=1600 Rover.At(1600){24} --> {25} + {24} + {87} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1755 Master=1642 Rover.At(1642){86} --> {87} + {88} + {24} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1816 Master=1699 Rover.Going(1699){25} --> {26} + {25} + {86} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=1898 Master=1777 Rover.Going(1777){85} --> {86} + {87} + {25} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1957 Master=1836 Rover.At(1836){26} --> {27} + {26} + {85} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=1991 Master=1878 Rover.At(1878){84} --> {85} + {86} + {26} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2052 Master=1935 Rover.Going(1935){27} --> {28} + {27} + {84} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2134 Master=2013 Rover.Going(2013){83} --> {84} + {85} + {27} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2193 Master=2072 Rover.At(2072){28} --> {29} + {28} + {83} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2227 Master=2114 Rover.At(2114){82} --> {83} + {84} + {28} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2288 Master=2171 Rover.Going(2171){29} --> {30} + {29} + {82} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2370 Master=2249 Rover.Going(2249){81} --> {82} + {83} + {29} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2429 Master=2308 Rover.At(2308){30} --> {31} + {30} + {81} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2463 Master=2350 Rover.At(2350){80} --> {81} + {82} + {30} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2524 Master=2407 Rover.Going(2407){31} --> {32} + {31} + {80} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2606 Master=2485 Rover.Going(2485){79} --> {80} + {81} + {31} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2665 Master=2544 Rover.At(2544){32} --> {33} + {32} + {79} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2699 Master=2586 Rover.At(2586){78} --> {79} + {80} + {32} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2760 Master=2643 Rover.Going(2643){33} --> {34} + {33} + {78} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2842 Master=2721 Rover.Going(2721){77} --> {78} + {79} + {33} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2901 Master=2780 Rover.At(2780){34} --> {35} + {34} + {77} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=2935 Master=2822 Rover.At(2822){76} --> {77} + {78} + {34} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=2996 Master=2879 Rover.Going(2879){35} --> {36} + {35} + {76} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3078 Master=2957 Rover.Going(2957){75} --> {76} + {77} + {35} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3137 Master=3016 Rover.At(3016){36} --> {37} + {36} + {75} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3171 Master=3058 Rover.At(3058){74} --> {75} + {76} + {36} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3232 Master=3115 Rover.Going(3115){37} --> {38} + {37} + {74} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3314 Master=3193 Rover.Going(3193){73} --> {74} + {75} + {37} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3373 Master=3252 Rover.At(3252){38} --> {39} + {38} + {73} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3407 Master=3294 Rover.At(3294){72} --> {73} + {74} + {38} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3468 Master=3351 Rover.Going(3351){39} --> {40} + {39} + {72} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3550 Master=3429 Rover.Going(3429){71} --> {72} + {73} + {39} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3609 Master=3488 Rover.At(3488){40} --> {41} + {40} + {71} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3643 Master=3530 Rover.At(3530){70} --> {71} + {72} + {40} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3704 Master=3587 Rover.Going(3587){41} --> {42} + {41} + {70} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3786 Master=3665 Rover.Going(3665){69} --> {70} + {71} + {41} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3845 Master=3724 Rover.At(3724){42} --> {43} + {42} + {69} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=3879 Master=3766 Rover.At(3766){68} --> {69} + {70} + {42} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=3940 Master=3823 Rover.Going(3823){43} --> {44} + {43} + {68} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4022 Master=3901 Rover.Going(3901){67} --> {68} + {69} + {43} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4081 Master=3960 Rover.At(3960){44} --> {45} + {44} + {67} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4115 Master=4002 Rover.At(4002){66} --> {67} + {68} + {44} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4176 Master=4059 Rover.Going(4059){45} --> {46} + {45} + {66} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4258 Master=4137 Rover.Going(4137){65} --> {66} + {67} + {45} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4317 Master=4196 Rover.At(4196){46} --> {47} + {46} + {65} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4351 Master=4238 Rover.At(4238){64} --> {65} + {66} + {46} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4412 Master=4295 Rover.Going(4295){47} --> {48} + {47} + {64} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4494 Master=4373 Rover.Going(4373){63} --> {64} + {65} + {47} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4553 Master=4432 Rover.At(4432){48} --> {49} + {48} + {63} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4587 Master=4474 Rover.At(4474){62} --> {63} + {64} + {48} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4648 Master=4531 Rover.Going(4531){49} --> {50} + {49} + {62} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4730 Master=4609 Rover.Going(4609){61} --> {62} + {63} + {49} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4789 Master=4668 Rover.At(4668){50} --> {51} + {50} + {61} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=4823 Master=4710 Rover.At(4710){60} --> {61} + {62} + {50} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4884 Master=4767 Rover.Going(4767){51} --> {52} + {51} + {60} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=4966 Master=4845 Rover.Going(4845){59} --> {60} + {61} + {51} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5025 Master=4904 Rover.At(4904){52} --> {53} + {52} + {59} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5059 Master=4946 Rover.At(4946){58} --> {59} + {60} + {52} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5120 Master=5003 Rover.Going(5003){53} --> {54} + {53} + {58} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5202 Master=5081 Rover.Going(5081){57} --> {58} + {59} + {53} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5261 Master=5140 Rover.At(5140){54} --> {55} + {54} + {57} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5295 Master=5182 Rover.At(5182){56} --> {57} + {58} + {55} + Rover.Going(m_from=Locations:CLOSED{Hill,Lander,Rock}m_to=Locations:CLOSED{Hill,Lander,Rock}) + Key=5317 Master=5182 Rover.At(5182){56} --> {57} + {56} + {54} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5356 Master=5239 Rover.Going(5239){55} --> {56} + {55} + {56} + Rover.At(m_location=Locations:CLOSED{Hill,Lander,Rock}) + Key=5376 Master=5239 Rover.Going(5239){55} --> {56} + {57} +Inactive Tokens: ************************* + {9} + Rover.Going(m_from=Locations:CLOSED{Hill,Rock}m_to=Locations:CLOSED{Lander}) + Key=90 Master=26 a(26){10} --> {11} + {10} + {101} + Rover.Going(m_from=Locations:CLOSED{Rock}m_to=Locations:CLOSED{Hill,Lander}) + Key=120 Master=46 b(46){100} --> {101} + {102} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-basic-types.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-basic-types.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..683fe6c0b --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-basic-types.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,128 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[100, 100] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + A:a1************************* + Variables ************************* + a1.m_f=Fruit:CLOSED{apple} + End Variables ********************* + End A:a1************************* + A:a2************************* + Variables ************************* + a2.m_f=Fruit:CLOSED{apple} + End Variables ********************* + End A:a2************************* + B:b3************************* + Variables ************************* + b3.m_c=Color:CLOSED{purple} + End Variables ********************* + End B:b3************************* + B:b4************************* + Variables ************************* + b4.m_c=Color:CLOSED{purple} + End Variables ********************* + End B:b4************************* +Global Variables************************* + w=bool:CLOSED[0, 0] + w1=bool:CLOSED[1, 1] + w2=bool:CLOSED[0, 0] + x=int:CLOSED[-inf, +inf] + x1=int:CLOSED[3, 3] + x2=int:CLOSED[3, 3] + x3=int:CLOSED[-inf, 5] + x4=int:CLOSED[3, +inf] + y=float:CLOSED[-inf, +inf] + y1=float:CLOSED[3.5, 3.5] + y2=float:CLOSED[3.5, 4.5] + y3=float:CLOSED[3.5, 4] + y4=float:CLOSED[3, 4.5] + y5=float:CLOSED[3, 4] + y6=float:CLOSED[3, +inf] + y7=float:CLOSED[-inf, 3] + z=string:OPEN{} + z1=string:CLOSED{hi} + f=Fruit:CLOSED{apple} + f0=Fruit:CLOSED{apple} + f1=Fruit:CLOSED{apple} + f2=Fruit:CLOSED{orange} + f3=Fruit:CLOSED{orange} + f4=Fruit:CLOSED{orange} + c=Color:CLOSED{red} + c2=Color:CLOSED{purple} + c3=Color:CLOSED{purple} + c5=Color:CLOSED{red} + world=PlannerConfig:CLOSED{world(68)} + a1=A:CLOSED{a1(81)} + a2=A:CLOSED{a2(88)} + b3=B:CLOSED{b3(95)} + b4=B:CLOSED{b4(102)} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[100, 100] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + A:a1************************* + Variables ************************* + a1.m_f=Fruit:CLOSED{apple} + End Variables ********************* + End A:a1************************* + A:a2************************* + Variables ************************* + a2.m_f=Fruit:CLOSED{apple} + End Variables ********************* + End A:a2************************* + B:b3************************* + Variables ************************* + b3.m_c=Color:CLOSED{purple} + End Variables ********************* + End B:b3************************* + B:b4************************* + Variables ************************* + b4.m_c=Color:CLOSED{purple} + End Variables ********************* + End B:b4************************* +Global Variables************************* + w=bool:CLOSED[0, 0] + w1=bool:CLOSED[1, 1] + w2=bool:CLOSED[0, 0] + x=int:CLOSED[-inf, +inf] + x1=int:CLOSED[3, 3] + x2=int:CLOSED[3, 3] + x3=int:CLOSED[-inf, 5] + x4=int:CLOSED[3, +inf] + y=float:CLOSED[-inf, +inf] + y1=float:CLOSED[3.5, 3.5] + y2=float:CLOSED[3.5, 4.5] + y3=float:CLOSED[3.5, 4] + y4=float:CLOSED[3, 4.5] + y5=float:CLOSED[3, 4] + y6=float:CLOSED[3, +inf] + y7=float:CLOSED[-inf, 3] + z=string:OPEN{} + z1=string:CLOSED{hi} + f=Fruit:CLOSED{apple} + f0=Fruit:CLOSED{apple} + f1=Fruit:CLOSED{apple} + f2=Fruit:CLOSED{orange} + f3=Fruit:CLOSED{orange} + f4=Fruit:CLOSED{orange} + c=Color:CLOSED{red} + c2=Color:CLOSED{purple} + c3=Color:CLOSED{purple} + c5=Color:CLOSED{red} + world=PlannerConfig:CLOSED{world(68)} + a1=A:CLOSED{a1(81)} + a2=A:CLOSED{a2(88)} + b3=B:CLOSED{b3(95)} + b4=B:CLOSED{b4(102)} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-better-res-reservoir.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-better-res-reservoir.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..69ccc92e1 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-better-res-reservoir.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,292 @@ +Created node [id_434] initially enabled +Created node [id_435] initially enabled +Maximum flow instance created with source [id_434] and sink [id_435] +Created node [id_434] initially enabled +Created node [id_435] initially enabled +Maximum flow instance created with source [id_434] and sink [id_435] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[10, 10] + world.m_horizonEnd=int:CLOSED[101, 101] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {10} + Rover.Standby(m_x=int:CLOSED[0, 0]m_y=int:CLOSED[0, 0]) + Key=71 Master=NONE + [11, 87] + [11, 87] + Rover.Drive(m_from_x=int:CLOSED[0, 0]m_from_y=int:CLOSED[0, 0]m_to_x=int:CLOSED[3, 3]m_to_y=int:CLOSED[0, 0]) + Key=489 Master=71 roverInit(71){10} --> [11, 87] + [14, 90] + [14, 90] + Rover.Sample(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[0, 0]) + Key=315 Master=169 goal1(169)[10, 90] --> [17, 97] + Merged Key=748 from Rover.Drive(489)[11, 87] --> [14, 90] + [17, 93] + [17, 93] + Rover.Drive(m_from_x=int:CLOSED[3, 3]m_from_y=int:CLOSED[0, 0]m_to_x=int:CLOSED[3, 3]m_to_y=int:CLOSED[4, 4]) + Key=579 Master=315 Rover.Sample(315)[14, 90] --> [17, 93] + [21, 97] + [21, 97] + Rover.Sample(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[4, 4]) + Key=345 Master=190 goal2(190)[17, 97] --> [24, 100] + Merged Key=789 from Rover.Drive(579)[17, 93] --> [21, 97] + [24, 100] + [24, 100] + Rover.Drive(m_from_x=int:CLOSED[3, 3]m_from_y=int:CLOSED[4, 4]m_to_x=int:CLOSED[-inf, +inf]m_to_y=int:CLOSED[-inf, +inf]) + Key=666 Master=345 Rover.Sample(345)[21, 97] --> [24, 100] + [25, 125] + End Tokens ********************* + Variables ************************* + rover.m_battery=Battery:CLOSED{rover.m_battery(45)} + End Variables ********************* + End Rover:rover************************* + Battery:rover.m_battery************************* + Tokens ************************* + {20} + Battery.produce() + Key=233 Master=93 w1(93){10} --> {20} + {20} + {30} + Battery.produce() + Key=252 Master=112 w2(112){20} --> {30} + {30} + {40} + Battery.produce() + Key=273 Master=131 w3(131){30} --> {40} + {40} + {50} + Battery.produce() + Key=294 Master=150 w4(150){40} --> {50} + {50} + [15, 92] + Battery.consume() + Key=392 Master=315 Rover.Sample(315)[14, 90] --> [17, 93] + [15, 92] + [22, 99] + Battery.consume() + Key=441 Master=345 Rover.Sample(345)[21, 97] --> [24, 100] + [22, 99] + [11, 87] + Battery.consume() + Key=515 Master=489 Rover.Drive(489)[11, 87] --> [14, 90] + [11, 87] + [17, 93] + Battery.consume() + Key=605 Master=579 Rover.Drive(579)[17, 93] --> [21, 97] + [17, 93] + [24, 100] + Battery.consume() + Key=692 Master=666 Rover.Drive(666)[24, 100] --> [25, 125] + [24, 100] + End Tokens ********************* + Variables ************************* + rover.m_battery.initialCapacity=float:CLOSED[0, 0] + rover.m_battery.levelLimitMin=float:CLOSED[0, 0] + rover.m_battery.levelLimitMax=float:CLOSED[100, 100] + rover.m_battery.productionRateMax=float:CLOSED[70, 70] + rover.m_battery.productionMax=float:CLOSED[70, 70] + rover.m_battery.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.m_battery.consumptionMax=float:CLOSED[70, 70] + End Variables ********************* + End Battery:rover.m_battery************************* + Wind:wind************************* + Tokens ************************* + {10} + Wind.Velocity(m_velocity=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=93 Master=NONE + {20} + {20} + Wind.Velocity(m_velocity=float:CLOSED[10.000000000000000, 10.000000000000000]) + Key=112 Master=NONE + {30} + {30} + Wind.Velocity(m_velocity=float:CLOSED[20.000000000000000, 20.000000000000000]) + Key=131 Master=NONE + {40} + {40} + Wind.Velocity(m_velocity=float:CLOSED[40.000000000000000, 40.000000000000000]) + Key=150 Master=NONE + {50} + End Tokens ********************* + End Wind:wind************************* + Mission:mission************************* + Tokens ************************* + [10, 90] + Mission.SampleCycle(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[0, 0]) + Key=169 Master=NONE + [17, 97] + [17, 97] + Mission.SampleCycle(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[4, 4]) + Key=190 Master=NONE + [24, 100] + End Tokens ********************* + End Mission:mission************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(33)} + wind=Wind:CLOSED{wind(65)} + mission=Mission:CLOSED{mission(68)} +Merged Tokens: ************************* + [12, 93] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=748 Master=489 Rover.Drive(489)[11, 87] --> [14, 90] + [13, +inf] + [18, 97] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=789 Master=579 Rover.Drive(579)[17, 93] --> [21, 97] + [19, +inf] +Inactive Tokens: ************************* + [25, 125] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=832 Master=666 Rover.Drive(666)[24, 100] --> [25, 125] + [26, +inf] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[10, 10] + world.m_horizonEnd=int:CLOSED[101, 101] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {10} + Rover.Standby(m_x=int:CLOSED[0, 0]m_y=int:CLOSED[0, 0]) + Key=71 Master=NONE + [11, 87] + [11, 87] + Rover.Drive(m_from_x=int:CLOSED[0, 0]m_from_y=int:CLOSED[0, 0]m_to_x=int:CLOSED[3, 3]m_to_y=int:CLOSED[0, 0]) + Key=489 Master=71 roverInit(71){10} --> [11, 87] + [14, 90] + [14, 90] + Rover.Sample(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[0, 0]) + Key=315 Master=169 goal1(169)[10, 90] --> [17, 97] + Merged Key=748 from Rover.Drive(489)[11, 87] --> [14, 90] + [17, 93] + [17, 93] + Rover.Drive(m_from_x=int:CLOSED[3, 3]m_from_y=int:CLOSED[0, 0]m_to_x=int:CLOSED[3, 3]m_to_y=int:CLOSED[4, 4]) + Key=579 Master=315 Rover.Sample(315)[14, 90] --> [17, 93] + [21, 97] + [21, 97] + Rover.Sample(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[4, 4]) + Key=345 Master=190 goal2(190)[17, 97] --> [24, 100] + Merged Key=789 from Rover.Drive(579)[17, 93] --> [21, 97] + [24, 100] + [24, 100] + Rover.Drive(m_from_x=int:CLOSED[3, 3]m_from_y=int:CLOSED[4, 4]m_to_x=int:CLOSED[-inf, +inf]m_to_y=int:CLOSED[-inf, +inf]) + Key=666 Master=345 Rover.Sample(345)[21, 97] --> [24, 100] + [25, 125] + End Tokens ********************* + Variables ************************* + rover.m_battery=Battery:CLOSED{rover.m_battery(45)} + End Variables ********************* + End Rover:rover************************* + Battery:rover.m_battery************************* + Tokens ************************* + {20} + Battery.produce() + Key=233 Master=93 w1(93){10} --> {20} + {20} + {30} + Battery.produce() + Key=252 Master=112 w2(112){20} --> {30} + {30} + {40} + Battery.produce() + Key=273 Master=131 w3(131){30} --> {40} + {40} + {50} + Battery.produce() + Key=294 Master=150 w4(150){40} --> {50} + {50} + [15, 92] + Battery.consume() + Key=392 Master=315 Rover.Sample(315)[14, 90] --> [17, 93] + [15, 92] + [22, 99] + Battery.consume() + Key=441 Master=345 Rover.Sample(345)[21, 97] --> [24, 100] + [22, 99] + [11, 87] + Battery.consume() + Key=515 Master=489 Rover.Drive(489)[11, 87] --> [14, 90] + [11, 87] + [17, 93] + Battery.consume() + Key=605 Master=579 Rover.Drive(579)[17, 93] --> [21, 97] + [17, 93] + [24, 100] + Battery.consume() + Key=692 Master=666 Rover.Drive(666)[24, 100] --> [25, 125] + [24, 100] + End Tokens ********************* + Variables ************************* + rover.m_battery.initialCapacity=float:CLOSED[0, 0] + rover.m_battery.levelLimitMin=float:CLOSED[0, 0] + rover.m_battery.levelLimitMax=float:CLOSED[100, 100] + rover.m_battery.productionRateMax=float:CLOSED[70, 70] + rover.m_battery.productionMax=float:CLOSED[70, 70] + rover.m_battery.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.m_battery.consumptionMax=float:CLOSED[70, 70] + End Variables ********************* + End Battery:rover.m_battery************************* + Wind:wind************************* + Tokens ************************* + {10} + Wind.Velocity(m_velocity=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=93 Master=NONE + {20} + {20} + Wind.Velocity(m_velocity=float:CLOSED[10.000000000000000, 10.000000000000000]) + Key=112 Master=NONE + {30} + {30} + Wind.Velocity(m_velocity=float:CLOSED[20.000000000000000, 20.000000000000000]) + Key=131 Master=NONE + {40} + {40} + Wind.Velocity(m_velocity=float:CLOSED[40.000000000000000, 40.000000000000000]) + Key=150 Master=NONE + {50} + End Tokens ********************* + End Wind:wind************************* + Mission:mission************************* + Tokens ************************* + [10, 90] + Mission.SampleCycle(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[0, 0]) + Key=169 Master=NONE + [17, 97] + [17, 97] + Mission.SampleCycle(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[4, 4]) + Key=190 Master=NONE + [24, 100] + End Tokens ********************* + End Mission:mission************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(33)} + wind=Wind:CLOSED{wind(65)} + mission=Mission:CLOSED{mission(68)} +Merged Tokens: ************************* + [12, 93] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=748 Master=489 Rover.Drive(489)[11, 87] --> [14, 90] + [13, +inf] + [18, 97] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=789 Master=579 Rover.Drive(579)[17, 93] --> [21, 97] + [19, +inf] +Inactive Tokens: ************************* + [25, 125] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=832 Master=666 Rover.Drive(666)[24, 100] --> [25, 125] + [26, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-better-res.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-better-res.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..741e08390 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-better-res.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,292 @@ +Created node [id_434] initially enabled +Created node [id_435] initially enabled +Maximum flow instance created with source [id_434] and sink [id_435] +Created node [id_434] initially enabled +Created node [id_435] initially enabled +Maximum flow instance created with source [id_434] and sink [id_435] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[10, 10] + world.m_horizonEnd=int:CLOSED[101, 101] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {10} + Rover.Standby(m_x=int:CLOSED[0, 0]m_y=int:CLOSED[0, 0]) + Key=71 Master=NONE + [11, 87] + [11, 87] + Rover.Drive(m_from_x=int:CLOSED[0, 0]m_from_y=int:CLOSED[0, 0]m_to_x=int:CLOSED[3, 3]m_to_y=int:CLOSED[0, 0]) + Key=483 Master=71 roverInit(71){10} --> [11, 87] + [14, 90] + [14, 90] + Rover.Sample(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[0, 0]) + Key=315 Master=169 goal1(169)[10, 90] --> [17, 97] + Merged Key=731 from Rover.Drive(483)[11, 87] --> [14, 90] + [17, 93] + [17, 93] + Rover.Drive(m_from_x=int:CLOSED[3, 3]m_from_y=int:CLOSED[0, 0]m_to_x=int:CLOSED[3, 3]m_to_y=int:CLOSED[4, 4]) + Key=569 Master=315 Rover.Sample(315)[14, 90] --> [17, 93] + [21, 97] + [21, 97] + Rover.Sample(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[4, 4]) + Key=345 Master=190 goal2(190)[17, 97] --> [24, 100] + Merged Key=771 from Rover.Drive(569)[17, 93] --> [21, 97] + [24, 100] + [24, 100] + Rover.Drive(m_from_x=int:CLOSED[3, 3]m_from_y=int:CLOSED[4, 4]m_to_x=int:CLOSED[-inf, +inf]m_to_y=int:CLOSED[-inf, +inf]) + Key=652 Master=345 Rover.Sample(345)[21, 97] --> [24, 100] + [25, 125] + End Tokens ********************* + Variables ************************* + rover.m_battery=Battery:CLOSED{rover.m_battery(45)} + End Variables ********************* + End Rover:rover************************* + Battery:rover.m_battery************************* + Tokens ************************* + {20} + Battery.produce() + Key=233 Master=93 w1(93){10} --> {20} + {20} + {30} + Battery.produce() + Key=252 Master=112 w2(112){20} --> {30} + {30} + {40} + Battery.produce() + Key=273 Master=131 w3(131){30} --> {40} + {40} + {50} + Battery.produce() + Key=294 Master=150 w4(150){40} --> {50} + {50} + [15, 92] + Battery.consume() + Key=392 Master=315 Rover.Sample(315)[14, 90] --> [17, 93] + [15, 92] + [22, 99] + Battery.consume() + Key=438 Master=345 Rover.Sample(345)[21, 97] --> [24, 100] + [22, 99] + [11, 87] + Battery.consume() + Key=509 Master=483 Rover.Drive(483)[11, 87] --> [14, 90] + [11, 87] + [17, 93] + Battery.consume() + Key=595 Master=569 Rover.Drive(569)[17, 93] --> [21, 97] + [17, 93] + [24, 100] + Battery.consume() + Key=678 Master=652 Rover.Drive(652)[24, 100] --> [25, 125] + [24, 100] + End Tokens ********************* + Variables ************************* + rover.m_battery.initialCapacity=float:CLOSED[0, 0] + rover.m_battery.levelLimitMin=float:CLOSED[0, 0] + rover.m_battery.levelLimitMax=float:CLOSED[100, 100] + rover.m_battery.productionRateMax=float:CLOSED[70, 70] + rover.m_battery.productionMax=float:CLOSED[70, 70] + rover.m_battery.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.m_battery.consumptionMax=float:CLOSED[70, 70] + End Variables ********************* + End Battery:rover.m_battery************************* + Wind:wind************************* + Tokens ************************* + {10} + Wind.Velocity(m_velocity=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=93 Master=NONE + {20} + {20} + Wind.Velocity(m_velocity=float:CLOSED[10.000000000000000, 10.000000000000000]) + Key=112 Master=NONE + {30} + {30} + Wind.Velocity(m_velocity=float:CLOSED[20.000000000000000, 20.000000000000000]) + Key=131 Master=NONE + {40} + {40} + Wind.Velocity(m_velocity=float:CLOSED[40.000000000000000, 40.000000000000000]) + Key=150 Master=NONE + {50} + End Tokens ********************* + End Wind:wind************************* + Mission:mission************************* + Tokens ************************* + [10, 90] + Mission.SampleCycle(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[0, 0]) + Key=169 Master=NONE + [17, 97] + [17, 97] + Mission.SampleCycle(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[4, 4]) + Key=190 Master=NONE + [24, 100] + End Tokens ********************* + End Mission:mission************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(33)} + wind=Wind:CLOSED{wind(65)} + mission=Mission:CLOSED{mission(68)} +Merged Tokens: ************************* + [12, 93] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=731 Master=483 Rover.Drive(483)[11, 87] --> [14, 90] + [13, +inf] + [18, 97] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=771 Master=569 Rover.Drive(569)[17, 93] --> [21, 97] + [19, +inf] +Inactive Tokens: ************************* + [25, 125] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=813 Master=652 Rover.Drive(652)[24, 100] --> [25, 125] + [26, +inf] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[10, 10] + world.m_horizonEnd=int:CLOSED[101, 101] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {10} + Rover.Standby(m_x=int:CLOSED[0, 0]m_y=int:CLOSED[0, 0]) + Key=71 Master=NONE + [11, 87] + [11, 87] + Rover.Drive(m_from_x=int:CLOSED[0, 0]m_from_y=int:CLOSED[0, 0]m_to_x=int:CLOSED[3, 3]m_to_y=int:CLOSED[0, 0]) + Key=483 Master=71 roverInit(71){10} --> [11, 87] + [14, 90] + [14, 90] + Rover.Sample(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[0, 0]) + Key=315 Master=169 goal1(169)[10, 90] --> [17, 97] + Merged Key=731 from Rover.Drive(483)[11, 87] --> [14, 90] + [17, 93] + [17, 93] + Rover.Drive(m_from_x=int:CLOSED[3, 3]m_from_y=int:CLOSED[0, 0]m_to_x=int:CLOSED[3, 3]m_to_y=int:CLOSED[4, 4]) + Key=569 Master=315 Rover.Sample(315)[14, 90] --> [17, 93] + [21, 97] + [21, 97] + Rover.Sample(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[4, 4]) + Key=345 Master=190 goal2(190)[17, 97] --> [24, 100] + Merged Key=771 from Rover.Drive(569)[17, 93] --> [21, 97] + [24, 100] + [24, 100] + Rover.Drive(m_from_x=int:CLOSED[3, 3]m_from_y=int:CLOSED[4, 4]m_to_x=int:CLOSED[-inf, +inf]m_to_y=int:CLOSED[-inf, +inf]) + Key=652 Master=345 Rover.Sample(345)[21, 97] --> [24, 100] + [25, 125] + End Tokens ********************* + Variables ************************* + rover.m_battery=Battery:CLOSED{rover.m_battery(45)} + End Variables ********************* + End Rover:rover************************* + Battery:rover.m_battery************************* + Tokens ************************* + {20} + Battery.produce() + Key=233 Master=93 w1(93){10} --> {20} + {20} + {30} + Battery.produce() + Key=252 Master=112 w2(112){20} --> {30} + {30} + {40} + Battery.produce() + Key=273 Master=131 w3(131){30} --> {40} + {40} + {50} + Battery.produce() + Key=294 Master=150 w4(150){40} --> {50} + {50} + [15, 92] + Battery.consume() + Key=392 Master=315 Rover.Sample(315)[14, 90] --> [17, 93] + [15, 92] + [22, 99] + Battery.consume() + Key=438 Master=345 Rover.Sample(345)[21, 97] --> [24, 100] + [22, 99] + [11, 87] + Battery.consume() + Key=509 Master=483 Rover.Drive(483)[11, 87] --> [14, 90] + [11, 87] + [17, 93] + Battery.consume() + Key=595 Master=569 Rover.Drive(569)[17, 93] --> [21, 97] + [17, 93] + [24, 100] + Battery.consume() + Key=678 Master=652 Rover.Drive(652)[24, 100] --> [25, 125] + [24, 100] + End Tokens ********************* + Variables ************************* + rover.m_battery.initialCapacity=float:CLOSED[0, 0] + rover.m_battery.levelLimitMin=float:CLOSED[0, 0] + rover.m_battery.levelLimitMax=float:CLOSED[100, 100] + rover.m_battery.productionRateMax=float:CLOSED[70, 70] + rover.m_battery.productionMax=float:CLOSED[70, 70] + rover.m_battery.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.m_battery.consumptionMax=float:CLOSED[70, 70] + End Variables ********************* + End Battery:rover.m_battery************************* + Wind:wind************************* + Tokens ************************* + {10} + Wind.Velocity(m_velocity=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=93 Master=NONE + {20} + {20} + Wind.Velocity(m_velocity=float:CLOSED[10.000000000000000, 10.000000000000000]) + Key=112 Master=NONE + {30} + {30} + Wind.Velocity(m_velocity=float:CLOSED[20.000000000000000, 20.000000000000000]) + Key=131 Master=NONE + {40} + {40} + Wind.Velocity(m_velocity=float:CLOSED[40.000000000000000, 40.000000000000000]) + Key=150 Master=NONE + {50} + End Tokens ********************* + End Wind:wind************************* + Mission:mission************************* + Tokens ************************* + [10, 90] + Mission.SampleCycle(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[0, 0]) + Key=169 Master=NONE + [17, 97] + [17, 97] + Mission.SampleCycle(m_x=int:CLOSED[3, 3]m_y=int:CLOSED[4, 4]) + Key=190 Master=NONE + [24, 100] + End Tokens ********************* + End Mission:mission************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(33)} + wind=Wind:CLOSED{wind(65)} + mission=Mission:CLOSED{mission(68)} +Merged Tokens: ************************* + [12, 93] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=731 Master=483 Rover.Drive(483)[11, 87] --> [14, 90] + [13, +inf] + [18, 97] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=771 Master=569 Rover.Drive(569)[17, 93] --> [21, 97] + [19, +inf] +Inactive Tokens: ************************* + [25, 125] + Rover.Sample(m_x=int:CLOSED[-inf, +inf]m_y=int:CLOSED[-inf, +inf]) + Key=813 Master=652 Rover.Drive(652)[24, 100] --> [25, 125] + [26, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-constrain-transaction.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-constrain-transaction.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..f97dfda12 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-constrain-transaction.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,56 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[5, 5] + world.m_maxPlannerSteps=int:CLOSED[10, 10] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Foo:f1************************* + End Foo:f1************************* + Foo:f2************************* + Tokens ************************* + [-inf, +inf] + Foo.baz() + Key=44 Master=NONE + [-inf, +inf] + [-inf, +inf] + Foo.bar() + Key=29 Master=NONE + [-inf, +inf] + End Tokens ********************* + End Foo:f2************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + f1=Foo:CLOSED{f1(23)} + f2=Foo:CLOSED{f2(26)} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[5, 5] + world.m_maxPlannerSteps=int:CLOSED[10, 10] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Foo:f1************************* + End Foo:f1************************* + Foo:f2************************* + Tokens ************************* + [-inf, +inf] + Foo.baz() + Key=44 Master=NONE + [-inf, +inf] + [-inf, +inf] + Foo.bar() + Key=29 Master=NONE + [-inf, +inf] + End Tokens ********************* + End Foo:f2************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + f1=Foo:CLOSED{f1(23)} + f2=Foo:CLOSED{f2(26)} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-constraint-to-temporal.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-constraint-to-temporal.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..2235921e5 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-constraint-to-temporal.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,234 @@ +Created node [id_363] initially enabled +Created node [id_364] initially enabled +Maximum flow instance created with source [id_363] and sink [id_364] +Created node [id_363] initially enabled +Created node [id_364] initially enabled +Maximum flow instance created with source [id_363] and sink [id_364] +Created node [id_413] initially enabled +Created node [id_414] initially enabled +Maximum flow instance created with source [id_413] and sink [id_414] +Created node [id_413] initially enabled +Created node [id_414] initially enabled +Maximum flow instance created with source [id_413] and sink [id_414] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[200, 200] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Foo:foo************************* + Tokens ************************* + {0} + Foo.consume() + Key=60 Master=NONE + {0} + {10} + Foo.consume() + Key=72 Master=NONE + {10} + {20} + Foo.consume() + Key=82 Master=NONE + {20} + {30} + Foo.consume() + Key=92 Master=NONE + {30} + End Tokens ********************* + Variables ************************* + foo.initialCapacity=float:CLOSED[50, 50] + foo.levelLimitMin=float:CLOSED[0, 0] + foo.levelLimitMax=float:CLOSED[0, 0] + foo.productionRateMax=float:CLOSED[+inf, +inf] + foo.productionMax=float:CLOSED[+inf, +inf] + foo.consumptionRateMax=float:CLOSED[+inf, +inf] + foo.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Foo:foo************************* + Bar:b************************* + Tokens ************************* + {1} + Bar.Stuff(reftime1=int:CLOSED[-inf, +inf]reftime2=int:CLOSED[1, 1]reftime3=int:CLOSED[1, 1]reftime4=int:CLOSED[1, 1]) + Key=126 Master=NONE + [2, 99] + [1, 98] + Bar.Axel() + Key=251 Master=NONE + [2, 99] + [-inf, 97] + Bar.Stuff(reftime1=int:CLOSED[-inf, +inf]reftime2=int:CLOSED[-inf, +inf]reftime3=int:CLOSED[-inf, +inf]reftime4=int:CLOSED[-inf, +inf]) + Key=269 Master=251 a(251)[1, 98] --> [2, 99] + [1, +inf] + End Tokens ********************* + Variables ************************* + b.m_foo=Foo:CLOSED{b.m_foo(42)} + End Variables ********************* + End Bar:b************************* + Foo:b.m_foo************************* + Tokens ************************* + [1, 99] + Foo.consume() + Key=148 Master=126 bb(126){1} --> [2, 99] + [1, 99] + {1} + Foo.consume() + Key=173 Master=126 bb(126){1} --> [2, 99] + {1} + {1} + Foo.consume() + Key=196 Master=126 bb(126){1} --> [2, 99] + {1} + {1} + Foo.consume() + Key=219 Master=126 bb(126){1} --> [2, 99] + {1} + [-inf, +inf] + Foo.consume() + Key=309 Master=269 Bar.Stuff(269)[-inf, 97] --> [1, +inf] + [-inf, +inf] + [-inf, +inf] + Foo.consume() + Key=326 Master=269 Bar.Stuff(269)[-inf, 97] --> [1, +inf] + [-inf, +inf] + [-inf, +inf] + Foo.consume() + Key=343 Master=269 Bar.Stuff(269)[-inf, 97] --> [1, +inf] + [-inf, +inf] + [-inf, +inf] + Foo.consume() + Key=360 Master=269 Bar.Stuff(269)[-inf, 97] --> [1, +inf] + [-inf, +inf] + End Tokens ********************* + Variables ************************* + b.m_foo.initialCapacity=float:CLOSED[50, 50] + b.m_foo.levelLimitMin=float:CLOSED[0, 0] + b.m_foo.levelLimitMax=float:CLOSED[0, 0] + b.m_foo.productionRateMax=float:CLOSED[+inf, +inf] + b.m_foo.productionMax=float:CLOSED[+inf, +inf] + b.m_foo.consumptionRateMax=float:CLOSED[+inf, +inf] + b.m_foo.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Foo:b.m_foo************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(6)} + foo=Foo:CLOSED{foo(20)} + b=Bar:CLOSED{b(37)} + reftime1=int:CLOSED[0, 0] + reftime2=int:CLOSED[10, 10] + reftime3=int:CLOSED[20, 20] + reftime4=int:CLOSED[30, 30] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[200, 200] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Foo:foo************************* + Tokens ************************* + {0} + Foo.consume() + Key=60 Master=NONE + {0} + {10} + Foo.consume() + Key=72 Master=NONE + {10} + {20} + Foo.consume() + Key=82 Master=NONE + {20} + {30} + Foo.consume() + Key=92 Master=NONE + {30} + End Tokens ********************* + Variables ************************* + foo.initialCapacity=float:CLOSED[50, 50] + foo.levelLimitMin=float:CLOSED[0, 0] + foo.levelLimitMax=float:CLOSED[0, 0] + foo.productionRateMax=float:CLOSED[+inf, +inf] + foo.productionMax=float:CLOSED[+inf, +inf] + foo.consumptionRateMax=float:CLOSED[+inf, +inf] + foo.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Foo:foo************************* + Bar:b************************* + Tokens ************************* + {1} + Bar.Stuff(reftime1=int:CLOSED[-inf, +inf]reftime2=int:CLOSED[1, 1]reftime3=int:CLOSED[1, 1]reftime4=int:CLOSED[1, 1]) + Key=126 Master=NONE + [2, 99] + [1, 98] + Bar.Axel() + Key=251 Master=NONE + [2, 99] + [-inf, 97] + Bar.Stuff(reftime1=int:CLOSED[-inf, +inf]reftime2=int:CLOSED[-inf, +inf]reftime3=int:CLOSED[-inf, +inf]reftime4=int:CLOSED[-inf, +inf]) + Key=269 Master=251 a(251)[1, 98] --> [2, 99] + [1, +inf] + End Tokens ********************* + Variables ************************* + b.m_foo=Foo:CLOSED{b.m_foo(42)} + End Variables ********************* + End Bar:b************************* + Foo:b.m_foo************************* + Tokens ************************* + [1, 99] + Foo.consume() + Key=148 Master=126 bb(126){1} --> [2, 99] + [1, 99] + {1} + Foo.consume() + Key=173 Master=126 bb(126){1} --> [2, 99] + {1} + {1} + Foo.consume() + Key=196 Master=126 bb(126){1} --> [2, 99] + {1} + {1} + Foo.consume() + Key=219 Master=126 bb(126){1} --> [2, 99] + {1} + [-inf, +inf] + Foo.consume() + Key=309 Master=269 Bar.Stuff(269)[-inf, 97] --> [1, +inf] + [-inf, +inf] + [-inf, +inf] + Foo.consume() + Key=326 Master=269 Bar.Stuff(269)[-inf, 97] --> [1, +inf] + [-inf, +inf] + [-inf, +inf] + Foo.consume() + Key=343 Master=269 Bar.Stuff(269)[-inf, 97] --> [1, +inf] + [-inf, +inf] + [-inf, +inf] + Foo.consume() + Key=360 Master=269 Bar.Stuff(269)[-inf, 97] --> [1, +inf] + [-inf, +inf] + End Tokens ********************* + Variables ************************* + b.m_foo.initialCapacity=float:CLOSED[50, 50] + b.m_foo.levelLimitMin=float:CLOSED[0, 0] + b.m_foo.levelLimitMax=float:CLOSED[0, 0] + b.m_foo.productionRateMax=float:CLOSED[+inf, +inf] + b.m_foo.productionMax=float:CLOSED[+inf, +inf] + b.m_foo.consumptionRateMax=float:CLOSED[+inf, +inf] + b.m_foo.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Foo:b.m_foo************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(6)} + foo=Foo:CLOSED{foo(20)} + b=Bar:CLOSED{b(37)} + reftime1=int:CLOSED[0, 0] + reftime2=int:CLOSED[10, 10] + reftime3=int:CLOSED[20, 20] + reftime4=int:CLOSED[30, 30] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-force-object-distribution.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-force-object-distribution.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..b898bbe8e --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-force-object-distribution.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,134 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {0} + Rover.Drive() + Key=38 Master=NONE + {10} + {10} + Rover.Drive() + Key=56 Master=NONE + {20} + {20} + Rover.Drive() + Key=74 Master=NONE + {30} + {30} + Rover.Drive() + Key=92 Master=NONE + {40} + End Tokens ********************* + End Rover:rover************************* + Battery:b1************************* + Tokens ************************* + {0} + Battery.uses() + Key=112 Master=38 d1(38){0} --> {10} + {30} + {30} + Battery.uses() + Key=182 Master=92 d4(92){30} --> {40} + {60} + End Tokens ********************* + End Battery:b1************************* + Battery:b2************************* + Tokens ************************* + {10} + Battery.uses() + Key=134 Master=56 d2(56){10} --> {20} + {40} + End Tokens ********************* + End Battery:b2************************* + Battery:b3************************* + Tokens ************************* + {20} + Battery.uses() + Key=158 Master=74 d3(74){20} --> {30} + {50} + End Tokens ********************* + End Battery:b3************************* + Battery:b4************************* + End Battery:b4************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} + b1=Battery:CLOSED{b1(26)} + b2=Battery:CLOSED{b2(29)} + b3=Battery:CLOSED{b3(32)} + b4=Battery:CLOSED{b4(35)} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Tokens ************************* + {0} + Rover.Drive() + Key=38 Master=NONE + {10} + {10} + Rover.Drive() + Key=56 Master=NONE + {20} + {20} + Rover.Drive() + Key=74 Master=NONE + {30} + {30} + Rover.Drive() + Key=92 Master=NONE + {40} + End Tokens ********************* + End Rover:rover************************* + Battery:b1************************* + Tokens ************************* + {0} + Battery.uses() + Key=112 Master=38 d1(38){0} --> {10} + {30} + {30} + Battery.uses() + Key=182 Master=92 d4(92){30} --> {40} + {60} + End Tokens ********************* + End Battery:b1************************* + Battery:b2************************* + Tokens ************************* + {10} + Battery.uses() + Key=134 Master=56 d2(56){10} --> {20} + {40} + End Tokens ********************* + End Battery:b2************************* + Battery:b3************************* + Tokens ************************* + {20} + Battery.uses() + Key=158 Master=74 d3(74){20} --> {30} + {50} + End Tokens ********************* + End Battery:b3************************* + Battery:b4************************* + End Battery:b4************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} + b1=Battery:CLOSED{b1(26)} + b2=Battery:CLOSED{b2(29)} + b3=Battery:CLOSED{b3(32)} + b4=Battery:CLOSED{b4(35)} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-foreach-transaction.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-foreach-transaction.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..fde48fa74 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-foreach-transaction.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,252 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Location:Hill************************* + Variables ************************* + Hill.description=string:CLOSED{Hill} + End Variables ********************* + End Location:Hill************************* + Location:Rock************************* + Variables ************************* + Rock.description=string:CLOSED{Rock} + End Variables ********************* + End Location:Rock************************* + Location:Lander************************* + Variables ************************* + Lander.description=string:CLOSED{Lander} + End Variables ********************* + End Location:Lander************************* + Path:p1************************* + Variables ************************* + p1.from=Location:CLOSED{Rock(32)} + p1.to=Location:CLOSED{Hill(25)} + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.from=Location:CLOSED{Lander(39)} + p2.to=Location:CLOSED{Hill(25)} + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.from=Location:CLOSED{Hill(25)} + p3.to=Location:CLOSED{Lander(39)} + End Variables ********************* + End Path:p3************************* + Target:t1************************* + End Target:t1************************* + Target:t2************************* + End Target:t2************************* + Target:t3************************* + End Target:t3************************* + Target:t4************************* + End Target:t4************************* + Target:t5************************* + End Target:t5************************* + Target:t6************************* + End Target:t6************************* + Trackable:tr1************************* + Variables ************************* + tr1.path=Path:CLOSED{p1(46)} + tr1.target=Target:CLOSED{t1(71)} + End Variables ********************* + End Trackable:tr1************************* + Trackable:tr2************************* + Variables ************************* + tr2.path=Path:CLOSED{p1(46)} + tr2.target=Target:CLOSED{t2(74)} + End Variables ********************* + End Trackable:tr2************************* + Trackable:tr3************************* + Variables ************************* + tr3.path=Path:CLOSED{p2(55)} + tr3.target=Target:CLOSED{t3(77)} + End Variables ********************* + End Trackable:tr3************************* + Trackable:tr4************************* + Variables ************************* + tr4.path=Path:CLOSED{p2(55)} + tr4.target=Target:CLOSED{t4(80)} + End Variables ********************* + End Trackable:tr4************************* + Trackable:tr5************************* + Variables ************************* + tr5.path=Path:CLOSED{p3(64)} + tr5.target=Target:CLOSED{t5(83)} + End Variables ********************* + End Trackable:tr5************************* + Trackable:tr6************************* + Variables ************************* + tr6.path=Path:CLOSED{p3(64)} + tr6.target=Target:CLOSED{t6(86)} + End Variables ********************* + End Trackable:tr6************************* + NotTrackable:nt1************************* + Variables ************************* + nt1.path=Path:CLOSED{p3(64)} + nt1.target=Target:CLOSED{t6(86)} + End Variables ********************* + End NotTrackable:nt1************************* + Rover:rover************************* + End Rover:rover************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + Hill=Location:CLOSED{Hill(25)} + Rock=Location:CLOSED{Rock(32)} + Lander=Location:CLOSED{Lander(39)} + p1=Path:CLOSED{p1(46)} + p2=Path:CLOSED{p2(55)} + p3=Path:CLOSED{p3(64)} + t1=Target:CLOSED{t1(71)} + t2=Target:CLOSED{t2(74)} + t3=Target:CLOSED{t3(77)} + t4=Target:CLOSED{t4(80)} + t5=Target:CLOSED{t5(83)} + t6=Target:CLOSED{t6(86)} + tr1=Trackable:CLOSED{tr1(91)} + tr2=Trackable:CLOSED{tr2(100)} + tr3=Trackable:CLOSED{tr3(109)} + tr4=Trackable:CLOSED{tr4(118)} + tr5=Trackable:CLOSED{tr5(127)} + tr6=Trackable:CLOSED{tr6(136)} + nt1=NotTrackable:CLOSED{nt1(147)} + rover=Rover:CLOSED{rover(156)} +Rejected Tokens: ************************* + {0} + Rover.Navigate(path=Path:CLOSED{p1(46),p2(55),p3(64)}from=Location:CLOSED{Lander(39)}to=Location:CLOSED{Hill(25)}) + Key=159 Master=NONE + {100} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Location:Hill************************* + Variables ************************* + Hill.description=string:CLOSED{Hill} + End Variables ********************* + End Location:Hill************************* + Location:Rock************************* + Variables ************************* + Rock.description=string:CLOSED{Rock} + End Variables ********************* + End Location:Rock************************* + Location:Lander************************* + Variables ************************* + Lander.description=string:CLOSED{Lander} + End Variables ********************* + End Location:Lander************************* + Path:p1************************* + Variables ************************* + p1.from=Location:CLOSED{Rock(32)} + p1.to=Location:CLOSED{Hill(25)} + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.from=Location:CLOSED{Lander(39)} + p2.to=Location:CLOSED{Hill(25)} + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.from=Location:CLOSED{Hill(25)} + p3.to=Location:CLOSED{Lander(39)} + End Variables ********************* + End Path:p3************************* + Target:t1************************* + End Target:t1************************* + Target:t2************************* + End Target:t2************************* + Target:t3************************* + End Target:t3************************* + Target:t4************************* + End Target:t4************************* + Target:t5************************* + End Target:t5************************* + Target:t6************************* + End Target:t6************************* + Trackable:tr1************************* + Variables ************************* + tr1.path=Path:CLOSED{p1(46)} + tr1.target=Target:CLOSED{t1(71)} + End Variables ********************* + End Trackable:tr1************************* + Trackable:tr2************************* + Variables ************************* + tr2.path=Path:CLOSED{p1(46)} + tr2.target=Target:CLOSED{t2(74)} + End Variables ********************* + End Trackable:tr2************************* + Trackable:tr3************************* + Variables ************************* + tr3.path=Path:CLOSED{p2(55)} + tr3.target=Target:CLOSED{t3(77)} + End Variables ********************* + End Trackable:tr3************************* + Trackable:tr4************************* + Variables ************************* + tr4.path=Path:CLOSED{p2(55)} + tr4.target=Target:CLOSED{t4(80)} + End Variables ********************* + End Trackable:tr4************************* + Trackable:tr5************************* + Variables ************************* + tr5.path=Path:CLOSED{p3(64)} + tr5.target=Target:CLOSED{t5(83)} + End Variables ********************* + End Trackable:tr5************************* + Trackable:tr6************************* + Variables ************************* + tr6.path=Path:CLOSED{p3(64)} + tr6.target=Target:CLOSED{t6(86)} + End Variables ********************* + End Trackable:tr6************************* + NotTrackable:nt1************************* + Variables ************************* + nt1.path=Path:CLOSED{p3(64)} + nt1.target=Target:CLOSED{t6(86)} + End Variables ********************* + End NotTrackable:nt1************************* + Rover:rover************************* + End Rover:rover************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + Hill=Location:CLOSED{Hill(25)} + Rock=Location:CLOSED{Rock(32)} + Lander=Location:CLOSED{Lander(39)} + p1=Path:CLOSED{p1(46)} + p2=Path:CLOSED{p2(55)} + p3=Path:CLOSED{p3(64)} + t1=Target:CLOSED{t1(71)} + t2=Target:CLOSED{t2(74)} + t3=Target:CLOSED{t3(77)} + t4=Target:CLOSED{t4(80)} + t5=Target:CLOSED{t5(83)} + t6=Target:CLOSED{t6(86)} + tr1=Trackable:CLOSED{tr1(91)} + tr2=Trackable:CLOSED{tr2(100)} + tr3=Trackable:CLOSED{tr3(109)} + tr4=Trackable:CLOSED{tr4(118)} + tr5=Trackable:CLOSED{tr5(127)} + tr6=Trackable:CLOSED{tr6(136)} + nt1=NotTrackable:CLOSED{nt1(147)} + rover=Rover:CLOSED{rover(156)} +Rejected Tokens: ************************* + {0} + Rover.Navigate(path=Path:CLOSED{p1(46),p2(55),p3(64)}from=Location:CLOSED{Lander(39)}to=Location:CLOSED{Hill(25)}) + Key=159 Master=NONE + {100} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-gnats_2572_interval-tx.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-gnats_2572_interval-tx.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..953513728 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-gnats_2572_interval-tx.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,302 @@ +Objects ************************* + PlannerConfig:plannerConfiguration************************* + Variables ************************* + plannerConfiguration.m_horizonStart=int:CLOSED[0, 0] + plannerConfiguration.m_horizonEnd=int:CLOSED[1000, 1000] + plannerConfiguration.m_maxPlannerSteps=int:CLOSED[500, 500] + plannerConfiguration.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:plannerConfiguration************************* + Location:lander************************* + Variables ************************* + lander.x=int:CLOSED[0, 0] + lander.y=int:CLOSED[0, 0] + lander.label=string:CLOSED{lander} + End Variables ********************* + End Location:lander************************* + Location:rock1************************* + Variables ************************* + rock1.x=int:CLOSED[9, 9] + rock1.y=int:CLOSED[9, 9] + rock1.label=string:CLOSED{rock1} + End Variables ********************* + End Location:rock1************************* + Location:rock2************************* + Variables ************************* + rock2.x=int:CLOSED[1, 1] + rock2.y=int:CLOSED[6, 6] + rock2.label=string:CLOSED{rock2} + End Variables ********************* + End Location:rock2************************* + Location:rock3************************* + Variables ************************* + rock3.x=int:CLOSED[4, 4] + rock3.y=int:CLOSED[8, 8] + rock3.label=string:CLOSED{rock3} + End Variables ********************* + End Location:rock3************************* + Location:rock4************************* + Variables ************************* + rock4.x=int:CLOSED[3, 3] + rock4.y=int:CLOSED[9, 9] + rock4.label=string:CLOSED{rock4} + End Variables ********************* + End Location:rock4************************* + Rover:spirit************************* + Variables ************************* + spirit.antenna=Instrument:CLOSED{spirit.antenna(100)} + spirit.rat=Stowable_Instrument:CLOSED{spirit.rat(107)} + End Variables ********************* + End Rover:spirit************************* + Instrument:spirit.antenna************************* + End Instrument:spirit.antenna************************* + Stowable_Instrument:spirit.rat************************* + Tokens ************************* + {0} + Stowable_Instrument.Stowed() + Key=132 Master=NONE + Merged Key=332 from Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + [1, 81] + [1, 81] + Stowable_Instrument.StandBy() + Key=213 Master=132 stowed(132){0} --> [1, 81] + Merged Key=497 from Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [2, 82] + [2, 82] + Stowable_Instrument.Unstow() + Key=348 Master=213 Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + Merged Key=381 from Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [17, 97] + [17, 97] + Stowable_Instrument.Unstowed() + Key=258 Master=152 Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + Merged Key=481 from Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [18, 98] + [18, 98] + Stowable_Instrument.Position(destination=Location:CLOSED{rock4(89)}position_speed=int:CLOSED[1, 1]) + Key=152 Master=115 experiment(115)[19, 99] --> [99, 100] + Merged Key=397 from Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [19, 99] + [19, 99] + Stowable_Instrument.Positioned(destination=Location:CLOSED{rock4(89)}) + Key=115 Master=NONE + Merged Key=239 from Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + Merged Key=305 from Stowable_Instrument.Stow(173)[99, 100] --> [109, 110] + [99, 100] + [99, 100] + Stowable_Instrument.Stow() + Key=173 Master=115 experiment(115)[19, 99] --> [99, 100] + Merged Key=428 from Stowable_Instrument.Stowed(289)[109, 110] --> [110, +inf] + [109, 110] + [109, 110] + Stowable_Instrument.Stowed() + Key=289 Master=173 Stowable_Instrument.Stow(173)[99, 100] --> [109, 110] + [110, +inf] + End Tokens ********************* + Variables ************************* + spirit.rat.stow_speed=int:CLOSED[10, 10] + spirit.rat.unstow_speed=int:CLOSED[15, 15] + End Variables ********************* + End Stowable_Instrument:spirit.rat************************* +Global Variables************************* + plannerConfiguration=PlannerConfig:CLOSED{plannerConfiguration(12)} + lander=Location:CLOSED{lander(29)} + rock1=Location:CLOSED{rock1(44)} + rock2=Location:CLOSED{rock2(59)} + rock3=Location:CLOSED{rock3(74)} + rock4=Location:CLOSED{rock4(89)} + spirit=Rover:CLOSED{spirit(98)} +Merged Tokens: ************************* + [3, 99] + Stowable_Instrument.Positioned(destination=Location:CLOSED{rock4(89)}) + Key=239 Master=152 Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + [4, +inf] + [-inf, 99] + Instrument.Positioned(destination=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=305 Master=173 Stowable_Instrument.Stow(173)[99, 100] --> [109, 110] + [99, 100] + [-inf, 95] + Stowable_Instrument.Stowed() + Key=332 Master=213 Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + [1, 96] + [-inf, 96] + Stowable_Instrument.Unstow() + Key=381 Master=258 Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [17, 97] + [18, 98] + Instrument.Position(destination=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}position_speed=int:CLOSED[1, +inf]) + Key=397 Master=258 Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [19, +inf] + [-inf, 109] + Stowable_Instrument.Stow() + Key=428 Master=289 Stowable_Instrument.Stowed(289)[109, 110] --> [110, +inf] + [109, 110] + [17, 97] + Stowable_Instrument.Unstowed() + Key=481 Master=348 Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [18, +inf] + [-inf, 81] + Stowable_Instrument.StandBy() + Key=497 Master=348 Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [2, 82] +Inactive Tokens: ************************* + [-inf, -1] + Stowable_Instrument.Stow() + Key=197 Master=132 stowed(132){0} --> [1, 81] + {0} + [110, +inf] + Stowable_Instrument.StandBy() + Key=444 Master=289 Stowable_Instrument.Stowed(289)[109, 110] --> [110, +inf] + [111, +inf] +Objects ************************* + PlannerConfig:plannerConfiguration************************* + Variables ************************* + plannerConfiguration.m_horizonStart=int:CLOSED[0, 0] + plannerConfiguration.m_horizonEnd=int:CLOSED[1000, 1000] + plannerConfiguration.m_maxPlannerSteps=int:CLOSED[500, 500] + plannerConfiguration.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:plannerConfiguration************************* + Location:lander************************* + Variables ************************* + lander.x=int:CLOSED[0, 0] + lander.y=int:CLOSED[0, 0] + lander.label=string:CLOSED{lander} + End Variables ********************* + End Location:lander************************* + Location:rock1************************* + Variables ************************* + rock1.x=int:CLOSED[9, 9] + rock1.y=int:CLOSED[9, 9] + rock1.label=string:CLOSED{rock1} + End Variables ********************* + End Location:rock1************************* + Location:rock2************************* + Variables ************************* + rock2.x=int:CLOSED[1, 1] + rock2.y=int:CLOSED[6, 6] + rock2.label=string:CLOSED{rock2} + End Variables ********************* + End Location:rock2************************* + Location:rock3************************* + Variables ************************* + rock3.x=int:CLOSED[4, 4] + rock3.y=int:CLOSED[8, 8] + rock3.label=string:CLOSED{rock3} + End Variables ********************* + End Location:rock3************************* + Location:rock4************************* + Variables ************************* + rock4.x=int:CLOSED[3, 3] + rock4.y=int:CLOSED[9, 9] + rock4.label=string:CLOSED{rock4} + End Variables ********************* + End Location:rock4************************* + Rover:spirit************************* + Variables ************************* + spirit.antenna=Instrument:CLOSED{spirit.antenna(100)} + spirit.rat=Stowable_Instrument:CLOSED{spirit.rat(107)} + End Variables ********************* + End Rover:spirit************************* + Instrument:spirit.antenna************************* + End Instrument:spirit.antenna************************* + Stowable_Instrument:spirit.rat************************* + Tokens ************************* + {0} + Stowable_Instrument.Stowed() + Key=132 Master=NONE + Merged Key=332 from Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + [1, 81] + [1, 81] + Stowable_Instrument.StandBy() + Key=213 Master=132 stowed(132){0} --> [1, 81] + Merged Key=497 from Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [2, 82] + [2, 82] + Stowable_Instrument.Unstow() + Key=348 Master=213 Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + Merged Key=381 from Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [17, 97] + [17, 97] + Stowable_Instrument.Unstowed() + Key=258 Master=152 Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + Merged Key=481 from Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [18, 98] + [18, 98] + Stowable_Instrument.Position(destination=Location:CLOSED{rock4(89)}position_speed=int:CLOSED[1, 1]) + Key=152 Master=115 experiment(115)[19, 99] --> [99, 100] + Merged Key=397 from Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [19, 99] + [19, 99] + Stowable_Instrument.Positioned(destination=Location:CLOSED{rock4(89)}) + Key=115 Master=NONE + Merged Key=239 from Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + Merged Key=305 from Stowable_Instrument.Stow(173)[99, 100] --> [109, 110] + [99, 100] + [99, 100] + Stowable_Instrument.Stow() + Key=173 Master=115 experiment(115)[19, 99] --> [99, 100] + Merged Key=428 from Stowable_Instrument.Stowed(289)[109, 110] --> [110, +inf] + [109, 110] + [109, 110] + Stowable_Instrument.Stowed() + Key=289 Master=173 Stowable_Instrument.Stow(173)[99, 100] --> [109, 110] + [110, +inf] + End Tokens ********************* + Variables ************************* + spirit.rat.stow_speed=int:CLOSED[10, 10] + spirit.rat.unstow_speed=int:CLOSED[15, 15] + End Variables ********************* + End Stowable_Instrument:spirit.rat************************* +Global Variables************************* + plannerConfiguration=PlannerConfig:CLOSED{plannerConfiguration(12)} + lander=Location:CLOSED{lander(29)} + rock1=Location:CLOSED{rock1(44)} + rock2=Location:CLOSED{rock2(59)} + rock3=Location:CLOSED{rock3(74)} + rock4=Location:CLOSED{rock4(89)} + spirit=Rover:CLOSED{spirit(98)} +Merged Tokens: ************************* + [3, 99] + Stowable_Instrument.Positioned(destination=Location:CLOSED{rock4(89)}) + Key=239 Master=152 Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + [4, +inf] + [-inf, 99] + Instrument.Positioned(destination=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=305 Master=173 Stowable_Instrument.Stow(173)[99, 100] --> [109, 110] + [99, 100] + [-inf, 95] + Stowable_Instrument.Stowed() + Key=332 Master=213 Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + [1, 96] + [-inf, 96] + Stowable_Instrument.Unstow() + Key=381 Master=258 Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [17, 97] + [18, 98] + Instrument.Position(destination=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}position_speed=int:CLOSED[1, +inf]) + Key=397 Master=258 Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [19, +inf] + [-inf, 109] + Stowable_Instrument.Stow() + Key=428 Master=289 Stowable_Instrument.Stowed(289)[109, 110] --> [110, +inf] + [109, 110] + [17, 97] + Stowable_Instrument.Unstowed() + Key=481 Master=348 Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [18, +inf] + [-inf, 81] + Stowable_Instrument.StandBy() + Key=497 Master=348 Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [2, 82] +Inactive Tokens: ************************* + [-inf, -1] + Stowable_Instrument.Stow() + Key=197 Master=132 stowed(132){0} --> [1, 81] + {0} + [110, +inf] + Stowable_Instrument.StandBy() + Key=444 Master=289 Stowable_Instrument.Stowed(289)[109, 110] --> [110, +inf] + [111, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-gnats_2837-tx.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-gnats_2837-tx.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..f7e8422e2 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-gnats_2837-tx.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,302 @@ +Objects ************************* + PlannerConfig:plannerConfiguration************************* + Variables ************************* + plannerConfiguration.m_horizonStart=int:CLOSED[0, 0] + plannerConfiguration.m_horizonEnd=int:CLOSED[1000, 1000] + plannerConfiguration.m_maxPlannerSteps=int:CLOSED[500, 500] + plannerConfiguration.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:plannerConfiguration************************* + Location:lander************************* + Variables ************************* + lander.x=int:CLOSED[0, 0] + lander.y=int:CLOSED[0, 0] + lander.label=string:CLOSED{lander} + End Variables ********************* + End Location:lander************************* + Location:rock1************************* + Variables ************************* + rock1.x=int:CLOSED[9, 9] + rock1.y=int:CLOSED[9, 9] + rock1.label=string:CLOSED{rock1} + End Variables ********************* + End Location:rock1************************* + Location:rock2************************* + Variables ************************* + rock2.x=int:CLOSED[1, 1] + rock2.y=int:CLOSED[6, 6] + rock2.label=string:CLOSED{rock2} + End Variables ********************* + End Location:rock2************************* + Location:rock3************************* + Variables ************************* + rock3.x=int:CLOSED[4, 4] + rock3.y=int:CLOSED[8, 8] + rock3.label=string:CLOSED{rock3} + End Variables ********************* + End Location:rock3************************* + Location:rock4************************* + Variables ************************* + rock4.x=int:CLOSED[3, 3] + rock4.y=int:CLOSED[9, 9] + rock4.label=string:CLOSED{rock4} + End Variables ********************* + End Location:rock4************************* + Rover:spirit************************* + Variables ************************* + spirit.antenna=Instrument:CLOSED{spirit.antenna(100)} + spirit.rat=Stowable_Instrument:CLOSED{spirit.rat(107)} + End Variables ********************* + End Rover:spirit************************* + Instrument:spirit.antenna************************* + End Instrument:spirit.antenna************************* + Stowable_Instrument:spirit.rat************************* + Tokens ************************* + {0} + Stowable_Instrument.Stowed() + Key=133 Master=NONE + Merged Key=332 from Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + [1, 81] + [1, 81] + Stowable_Instrument.StandBy() + Key=213 Master=133 stowed(133){0} --> [1, 81] + Merged Key=497 from Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [2, 82] + [2, 82] + Stowable_Instrument.Unstow() + Key=348 Master=213 Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + Merged Key=381 from Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [17, 97] + [17, 97] + Stowable_Instrument.Unstowed() + Key=258 Master=152 Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + Merged Key=481 from Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [18, 98] + [18, 98] + Stowable_Instrument.Position(destination=Location:CLOSED{rock4(89)}position_speed=int:CLOSED[1, 1]) + Key=152 Master=115 experiment(115)[19, 99] --> {100} + Merged Key=397 from Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [19, 99] + [19, 99] + Stowable_Instrument.Positioned(destination=Location:CLOSED{rock4(89)}) + Key=115 Master=NONE + Merged Key=239 from Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + Merged Key=305 from Stowable_Instrument.Stow(173){100} --> {110} + {100} + {100} + Stowable_Instrument.Stow() + Key=173 Master=115 experiment(115)[19, 99] --> {100} + Merged Key=428 from Stowable_Instrument.Stowed(289){110} --> [111, +inf] + {110} + {110} + Stowable_Instrument.Stowed() + Key=289 Master=173 Stowable_Instrument.Stow(173){100} --> {110} + [111, +inf] + End Tokens ********************* + Variables ************************* + spirit.rat.stow_speed=int:CLOSED[10, 10] + spirit.rat.unstow_speed=int:CLOSED[15, 15] + End Variables ********************* + End Stowable_Instrument:spirit.rat************************* +Global Variables************************* + plannerConfiguration=PlannerConfig:CLOSED{plannerConfiguration(12)} + lander=Location:CLOSED{lander(29)} + rock1=Location:CLOSED{rock1(44)} + rock2=Location:CLOSED{rock2(59)} + rock3=Location:CLOSED{rock3(74)} + rock4=Location:CLOSED{rock4(89)} + spirit=Rover:CLOSED{spirit(98)} +Merged Tokens: ************************* + [3, 99] + Stowable_Instrument.Positioned(destination=Location:CLOSED{rock4(89)}) + Key=239 Master=152 Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + [4, +inf] + [-inf, 99] + Instrument.Positioned(destination=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=305 Master=173 Stowable_Instrument.Stow(173){100} --> {110} + {100} + [-inf, 95] + Stowable_Instrument.Stowed() + Key=332 Master=213 Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + [1, 96] + [-inf, 96] + Stowable_Instrument.Unstow() + Key=381 Master=258 Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [17, 97] + [18, 98] + Instrument.Position(destination=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}position_speed=int:CLOSED[1, +inf]) + Key=397 Master=258 Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [19, +inf] + [-inf, 109] + Stowable_Instrument.Stow() + Key=428 Master=289 Stowable_Instrument.Stowed(289){110} --> [111, +inf] + {110} + [17, 97] + Stowable_Instrument.Unstowed() + Key=481 Master=348 Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [18, +inf] + [-inf, 81] + Stowable_Instrument.StandBy() + Key=497 Master=348 Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [2, 82] +Inactive Tokens: ************************* + [-inf, -1] + Stowable_Instrument.Stow() + Key=197 Master=133 stowed(133){0} --> [1, 81] + {0} + [111, +inf] + Stowable_Instrument.StandBy() + Key=444 Master=289 Stowable_Instrument.Stowed(289){110} --> [111, +inf] + [112, +inf] +Objects ************************* + PlannerConfig:plannerConfiguration************************* + Variables ************************* + plannerConfiguration.m_horizonStart=int:CLOSED[0, 0] + plannerConfiguration.m_horizonEnd=int:CLOSED[1000, 1000] + plannerConfiguration.m_maxPlannerSteps=int:CLOSED[500, 500] + plannerConfiguration.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:plannerConfiguration************************* + Location:lander************************* + Variables ************************* + lander.x=int:CLOSED[0, 0] + lander.y=int:CLOSED[0, 0] + lander.label=string:CLOSED{lander} + End Variables ********************* + End Location:lander************************* + Location:rock1************************* + Variables ************************* + rock1.x=int:CLOSED[9, 9] + rock1.y=int:CLOSED[9, 9] + rock1.label=string:CLOSED{rock1} + End Variables ********************* + End Location:rock1************************* + Location:rock2************************* + Variables ************************* + rock2.x=int:CLOSED[1, 1] + rock2.y=int:CLOSED[6, 6] + rock2.label=string:CLOSED{rock2} + End Variables ********************* + End Location:rock2************************* + Location:rock3************************* + Variables ************************* + rock3.x=int:CLOSED[4, 4] + rock3.y=int:CLOSED[8, 8] + rock3.label=string:CLOSED{rock3} + End Variables ********************* + End Location:rock3************************* + Location:rock4************************* + Variables ************************* + rock4.x=int:CLOSED[3, 3] + rock4.y=int:CLOSED[9, 9] + rock4.label=string:CLOSED{rock4} + End Variables ********************* + End Location:rock4************************* + Rover:spirit************************* + Variables ************************* + spirit.antenna=Instrument:CLOSED{spirit.antenna(100)} + spirit.rat=Stowable_Instrument:CLOSED{spirit.rat(107)} + End Variables ********************* + End Rover:spirit************************* + Instrument:spirit.antenna************************* + End Instrument:spirit.antenna************************* + Stowable_Instrument:spirit.rat************************* + Tokens ************************* + {0} + Stowable_Instrument.Stowed() + Key=133 Master=NONE + Merged Key=332 from Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + [1, 81] + [1, 81] + Stowable_Instrument.StandBy() + Key=213 Master=133 stowed(133){0} --> [1, 81] + Merged Key=497 from Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [2, 82] + [2, 82] + Stowable_Instrument.Unstow() + Key=348 Master=213 Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + Merged Key=381 from Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [17, 97] + [17, 97] + Stowable_Instrument.Unstowed() + Key=258 Master=152 Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + Merged Key=481 from Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [18, 98] + [18, 98] + Stowable_Instrument.Position(destination=Location:CLOSED{rock4(89)}position_speed=int:CLOSED[1, 1]) + Key=152 Master=115 experiment(115)[19, 99] --> {100} + Merged Key=397 from Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [19, 99] + [19, 99] + Stowable_Instrument.Positioned(destination=Location:CLOSED{rock4(89)}) + Key=115 Master=NONE + Merged Key=239 from Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + Merged Key=305 from Stowable_Instrument.Stow(173){100} --> {110} + {100} + {100} + Stowable_Instrument.Stow() + Key=173 Master=115 experiment(115)[19, 99] --> {100} + Merged Key=428 from Stowable_Instrument.Stowed(289){110} --> [111, +inf] + {110} + {110} + Stowable_Instrument.Stowed() + Key=289 Master=173 Stowable_Instrument.Stow(173){100} --> {110} + [111, +inf] + End Tokens ********************* + Variables ************************* + spirit.rat.stow_speed=int:CLOSED[10, 10] + spirit.rat.unstow_speed=int:CLOSED[15, 15] + End Variables ********************* + End Stowable_Instrument:spirit.rat************************* +Global Variables************************* + plannerConfiguration=PlannerConfig:CLOSED{plannerConfiguration(12)} + lander=Location:CLOSED{lander(29)} + rock1=Location:CLOSED{rock1(44)} + rock2=Location:CLOSED{rock2(59)} + rock3=Location:CLOSED{rock3(74)} + rock4=Location:CLOSED{rock4(89)} + spirit=Rover:CLOSED{spirit(98)} +Merged Tokens: ************************* + [3, 99] + Stowable_Instrument.Positioned(destination=Location:CLOSED{rock4(89)}) + Key=239 Master=152 Stowable_Instrument.Position(152)[18, 98] --> [19, 99] + [4, +inf] + [-inf, 99] + Instrument.Positioned(destination=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}) + Key=305 Master=173 Stowable_Instrument.Stow(173){100} --> {110} + {100} + [-inf, 95] + Stowable_Instrument.Stowed() + Key=332 Master=213 Stowable_Instrument.StandBy(213)[1, 81] --> [2, 82] + [1, 96] + [-inf, 96] + Stowable_Instrument.Unstow() + Key=381 Master=258 Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [17, 97] + [18, 98] + Instrument.Position(destination=Location:CLOSED{lander(29),rock1(44),rock2(59),rock3(74),rock4(89)}position_speed=int:CLOSED[1, +inf]) + Key=397 Master=258 Stowable_Instrument.Unstowed(258)[17, 97] --> [18, 98] + [19, +inf] + [-inf, 109] + Stowable_Instrument.Stow() + Key=428 Master=289 Stowable_Instrument.Stowed(289){110} --> [111, +inf] + {110} + [17, 97] + Stowable_Instrument.Unstowed() + Key=481 Master=348 Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [18, +inf] + [-inf, 81] + Stowable_Instrument.StandBy() + Key=497 Master=348 Stowable_Instrument.Unstow(348)[2, 82] --> [17, 97] + [2, 82] +Inactive Tokens: ************************* + [-inf, -1] + Stowable_Instrument.Stow() + Key=197 Master=133 stowed(133){0} --> [1, 81] + {0} + [111, +inf] + Stowable_Instrument.StandBy() + Key=444 Master=289 Stowable_Instrument.Stowed(289){110} --> [111, +inf] + [112, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-gnats_3161.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-gnats_3161.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..12e415e60 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-gnats_3161.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,82 @@ +Objects ************************* + Foo:x************************* + Variables ************************* + x.b=bool:CLOSED[1, 1] + End Variables ********************* + End Foo:x************************* + Foo:y************************* + Variables ************************* + y.b=bool:CLOSED[0, 0] + End Variables ********************* + End Foo:y************************* + Bar:b************************* + Tokens ************************* + {0} + Bar.somePred(arg=bool:CLOSED[1, 1]) + Key=25 Master=NONE + {1} + End Tokens ********************* + Variables ************************* + b.b=bool:CLOSED[1, 1] + End Variables ********************* + End Bar:b************************* + PlannerTestConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[4, 4] + world.m_maxPlannerDepth=int:CLOSED[2, 2] + End Variables ********************* + End PlannerTestConfig:world************************* +Global Variables************************* + x=Foo:CLOSED{x(8)} + y=Foo:CLOSED{y(15)} + b=Bar:CLOSED{b(20)} + world=PlannerTestConfig:CLOSED{world(80)} +Rejected Tokens: ************************* + {0} + Bar.otherPred() + Key=53 Master=NONE + {1} +Objects ************************* + Foo:x************************* + Variables ************************* + x.b=bool:CLOSED[1, 1] + End Variables ********************* + End Foo:x************************* + Foo:y************************* + Variables ************************* + y.b=bool:CLOSED[0, 0] + End Variables ********************* + End Foo:y************************* + Bar:b************************* + Tokens ************************* + {0} + Bar.somePred(arg=bool:CLOSED[1, 1]) + Key=25 Master=NONE + {1} + End Tokens ********************* + Variables ************************* + b.b=bool:CLOSED[1, 1] + End Variables ********************* + End Bar:b************************* + PlannerTestConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[4, 4] + world.m_maxPlannerDepth=int:CLOSED[2, 2] + End Variables ********************* + End PlannerTestConfig:world************************* +Global Variables************************* + x=Foo:CLOSED{x(8)} + y=Foo:CLOSED{y(15)} + b=Bar:CLOSED{b(20)} + world=PlannerTestConfig:CLOSED{world(80)} +Rejected Tokens: ************************* + {0} + Bar.otherPred() + Key=53 Master=NONE + {1} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-k9-initial.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-k9-initial.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..775468977 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-k9-initial.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,230 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Variables ************************* + rover.m_position=Position:CLOSED{rover.m_position(25)} + rover.m_tracker=Tracker:CLOSED{rover.m_tracker(28)} + rover.m_oppsci=OpportunisticScience:CLOSED{rover.m_oppsci(31)} + rover.m_champ=CHAMP:CLOSED{rover.m_champ(34)} + End Variables ********************* + End Rover:rover************************* + Position:rover.m_position************************* + End Position:rover.m_position************************* + Tracker:rover.m_tracker************************* + End Tracker:rover.m_tracker************************* + OpportunisticScience:rover.m_oppsci************************* + End OpportunisticScience:rover.m_oppsci************************* + CHAMP:rover.m_champ************************* + End CHAMP:rover.m_champ************************* + Location:l1************************* + End Location:l1************************* + Location:l2************************* + End Location:l2************************* + Location:l3************************* + End Location:l3************************* + Location:l4************************* + End Location:l4************************* + Location:l5************************* + End Location:l5************************* + Location:l6************************* + End Location:l6************************* + Path:p1************************* + Variables ************************* + p1.m_from=Location:CLOSED{l1(38)} + p1.m_to=Location:CLOSED{l2(41)} + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.m_from=Location:CLOSED{l1(38)} + p2.m_to=Location:CLOSED{l3(44)} + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.m_from=Location:CLOSED{l2(41)} + p3.m_to=Location:CLOSED{l5(50)} + End Variables ********************* + End Path:p3************************* + Path:p4************************* + Variables ************************* + p4.m_from=Location:CLOSED{l5(50)} + p4.m_to=Location:CLOSED{l6(53)} + End Variables ********************* + End Path:p4************************* + Path:p5************************* + Variables ************************* + p5.m_from=Location:CLOSED{l3(44)} + p5.m_to=Location:CLOSED{l6(53)} + End Variables ********************* + End Path:p5************************* + Path:p6************************* + Variables ************************* + p6.m_from=Location:CLOSED{l2(41)} + p6.m_to=Location:CLOSED{l3(44)} + End Variables ********************* + End Path:p6************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} + l1=Location:CLOSED{l1(38)} + l2=Location:CLOSED{l2(41)} + l3=Location:CLOSED{l3(44)} + l4=Location:CLOSED{l4(47)} + l5=Location:CLOSED{l5(50)} + l6=Location:CLOSED{l6(53)} + p1=Path:CLOSED{p1(58)} + p2=Path:CLOSED{p2(67)} + p3=Path:CLOSED{p3(76)} + p4=Path:CLOSED{p4(85)} + p5=Path:CLOSED{p5(94)} + p6=Path:CLOSED{p6(103)} +Active Tokens: ************************* + [0, +inf] + Position.At(location=Location:CLOSED{l1(38)}) + Key=110 Master=NONE + [100, +inf] + [100, +inf] + Position.At(location=Location:CLOSED{l5(50)}) + Key=175 Master=NONE + [101, +inf] +Inactive Tokens: ************************* + [100, +inf] + Position.navigate(from=Location:CLOSED{l1(38)}to=Location:CLOSED{l2(41),l3(44),l4(47),l5(50),l6(53)}) + Key=127 Master=110 a(110)[0, +inf] --> [100, +inf] + [101, +inf] + [-1, +inf] + Position.navigate(from=Location:CLOSED{l2(41),l3(44),l4(47),l5(50),l6(53)}to=Location:CLOSED{l1(38)}) + Key=151 Master=110 a(110)[0, +inf] --> [100, +inf] + [0, +inf] + [101, +inf] + Position.navigate(from=Location:CLOSED{l5(50)}to=Location:CLOSED{l1(38),l2(41),l3(44),l4(47),l6(53)}) + Key=192 Master=175 b(175)[100, +inf] --> [101, +inf] + [102, +inf] + [99, +inf] + Position.navigate(from=Location:CLOSED{l1(38),l2(41),l3(44),l4(47),l6(53)}to=Location:CLOSED{l5(50)}) + Key=216 Master=175 b(175)[100, +inf] --> [101, +inf] + [100, +inf] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Variables ************************* + rover.m_position=Position:CLOSED{rover.m_position(25)} + rover.m_tracker=Tracker:CLOSED{rover.m_tracker(28)} + rover.m_oppsci=OpportunisticScience:CLOSED{rover.m_oppsci(31)} + rover.m_champ=CHAMP:CLOSED{rover.m_champ(34)} + End Variables ********************* + End Rover:rover************************* + Position:rover.m_position************************* + End Position:rover.m_position************************* + Tracker:rover.m_tracker************************* + End Tracker:rover.m_tracker************************* + OpportunisticScience:rover.m_oppsci************************* + End OpportunisticScience:rover.m_oppsci************************* + CHAMP:rover.m_champ************************* + End CHAMP:rover.m_champ************************* + Location:l1************************* + End Location:l1************************* + Location:l2************************* + End Location:l2************************* + Location:l3************************* + End Location:l3************************* + Location:l4************************* + End Location:l4************************* + Location:l5************************* + End Location:l5************************* + Location:l6************************* + End Location:l6************************* + Path:p1************************* + Variables ************************* + p1.m_from=Location:CLOSED{l1(38)} + p1.m_to=Location:CLOSED{l2(41)} + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.m_from=Location:CLOSED{l1(38)} + p2.m_to=Location:CLOSED{l3(44)} + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.m_from=Location:CLOSED{l2(41)} + p3.m_to=Location:CLOSED{l5(50)} + End Variables ********************* + End Path:p3************************* + Path:p4************************* + Variables ************************* + p4.m_from=Location:CLOSED{l5(50)} + p4.m_to=Location:CLOSED{l6(53)} + End Variables ********************* + End Path:p4************************* + Path:p5************************* + Variables ************************* + p5.m_from=Location:CLOSED{l3(44)} + p5.m_to=Location:CLOSED{l6(53)} + End Variables ********************* + End Path:p5************************* + Path:p6************************* + Variables ************************* + p6.m_from=Location:CLOSED{l2(41)} + p6.m_to=Location:CLOSED{l3(44)} + End Variables ********************* + End Path:p6************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} + l1=Location:CLOSED{l1(38)} + l2=Location:CLOSED{l2(41)} + l3=Location:CLOSED{l3(44)} + l4=Location:CLOSED{l4(47)} + l5=Location:CLOSED{l5(50)} + l6=Location:CLOSED{l6(53)} + p1=Path:CLOSED{p1(58)} + p2=Path:CLOSED{p2(67)} + p3=Path:CLOSED{p3(76)} + p4=Path:CLOSED{p4(85)} + p5=Path:CLOSED{p5(94)} + p6=Path:CLOSED{p6(103)} +Active Tokens: ************************* + [0, +inf] + Position.At(location=Location:CLOSED{l1(38)}) + Key=110 Master=NONE + [100, +inf] + [100, +inf] + Position.At(location=Location:CLOSED{l5(50)}) + Key=175 Master=NONE + [101, +inf] +Inactive Tokens: ************************* + [100, +inf] + Position.navigate(from=Location:CLOSED{l1(38)}to=Location:CLOSED{l2(41),l3(44),l4(47),l5(50),l6(53)}) + Key=127 Master=110 a(110)[0, +inf] --> [100, +inf] + [101, +inf] + [-1, +inf] + Position.navigate(from=Location:CLOSED{l2(41),l3(44),l4(47),l5(50),l6(53)}to=Location:CLOSED{l1(38)}) + Key=151 Master=110 a(110)[0, +inf] --> [100, +inf] + [0, +inf] + [101, +inf] + Position.navigate(from=Location:CLOSED{l5(50)}to=Location:CLOSED{l1(38),l2(41),l3(44),l4(47),l6(53)}) + Key=192 Master=175 b(175)[100, +inf] --> [101, +inf] + [102, +inf] + [99, +inf] + Position.navigate(from=Location:CLOSED{l1(38),l2(41),l3(44),l4(47),l6(53)}to=Location:CLOSED{l5(50)}) + Key=216 Master=175 b(175)[100, +inf] --> [101, +inf] + [100, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-k9-transaction.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-k9-transaction.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..854c90ea5 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-k9-transaction.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,292 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Variables ************************* + rover.m_position=Position:CLOSED{rover.m_position(25)} + rover.m_tracker=Tracker:CLOSED{rover.m_tracker(28)} + rover.m_oppsci=OpportunisticScience:CLOSED{rover.m_oppsci(31)} + rover.m_champ=CHAMP:CLOSED{rover.m_champ(34)} + End Variables ********************* + End Rover:rover************************* + Position:rover.m_position************************* + Tokens ************************* + [0, 95] + Position.At(location=Location:CLOSED{l1(38)}) + Key=110 Master=NONE + Merged Key=295 from Position.navigate(127)[1, 96] --> [2, 97] + [1, 96] + [1, 96] + Position.navigate(from=Location:CLOSED{l1(38)}to=Location:CLOSED{l2(41)}) + Key=127 Master=110 a(110)[0, 95] --> [1, 96] + Merged Key=402 from Position.At(277)[2, 97] --> [3, 98] + [2, 97] + [2, 97] + Position.At(location=Location:CLOSED{l2(41)}) + Key=277 Master=127 Position.navigate(127)[1, 96] --> [2, 97] + Merged Key=350 from Position.navigate(216)[3, 98] --> [4, 99] + [3, 98] + [3, 98] + Position.navigate(from=Location:CLOSED{l2(41)}to=Location:CLOSED{l5(50)}) + Key=216 Master=175 b(175)[4, 99] --> [5, 100] + Merged Key=380 from Position.At(277)[2, 97] --> [3, 98] + [4, 99] + [4, 99] + Position.At(location=Location:CLOSED{l5(50)}) + Key=175 Master=NONE + Merged Key=332 from Position.navigate(216)[3, 98] --> [4, 99] + [5, 100] + End Tokens ********************* + End Position:rover.m_position************************* + Tracker:rover.m_tracker************************* + End Tracker:rover.m_tracker************************* + OpportunisticScience:rover.m_oppsci************************* + End OpportunisticScience:rover.m_oppsci************************* + CHAMP:rover.m_champ************************* + End CHAMP:rover.m_champ************************* + Location:l1************************* + End Location:l1************************* + Location:l2************************* + End Location:l2************************* + Location:l3************************* + End Location:l3************************* + Location:l4************************* + End Location:l4************************* + Location:l5************************* + End Location:l5************************* + Location:l6************************* + End Location:l6************************* + Path:p1************************* + Variables ************************* + p1.m_from=Location:CLOSED{l1(38)} + p1.m_to=Location:CLOSED{l2(41)} + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.m_from=Location:CLOSED{l1(38)} + p2.m_to=Location:CLOSED{l3(44)} + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.m_from=Location:CLOSED{l2(41)} + p3.m_to=Location:CLOSED{l5(50)} + End Variables ********************* + End Path:p3************************* + Path:p4************************* + Variables ************************* + p4.m_from=Location:CLOSED{l5(50)} + p4.m_to=Location:CLOSED{l6(53)} + End Variables ********************* + End Path:p4************************* + Path:p5************************* + Variables ************************* + p5.m_from=Location:CLOSED{l3(44)} + p5.m_to=Location:CLOSED{l6(53)} + End Variables ********************* + End Path:p5************************* + Path:p6************************* + Variables ************************* + p6.m_from=Location:CLOSED{l2(41)} + p6.m_to=Location:CLOSED{l3(44)} + End Variables ********************* + End Path:p6************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} + l1=Location:CLOSED{l1(38)} + l2=Location:CLOSED{l2(41)} + l3=Location:CLOSED{l3(44)} + l4=Location:CLOSED{l4(47)} + l5=Location:CLOSED{l5(50)} + l6=Location:CLOSED{l6(53)} + p1=Path:CLOSED{p1(58)} + p2=Path:CLOSED{p2(67)} + p3=Path:CLOSED{p3(76)} + p4=Path:CLOSED{p4(85)} + p5=Path:CLOSED{p5(94)} + p6=Path:CLOSED{p6(103)} +Merged Tokens: ************************* + [-inf, 95] + Position.At(location=Location:CLOSED{l1(38)}) + Key=295 Master=127 Position.navigate(127)[1, 96] --> [2, 97] + [1, 96] + [4, 99] + Position.At(location=Location:CLOSED{l5(50)}) + Key=332 Master=216 Position.navigate(216)[3, 98] --> [4, 99] + [5, +inf] + [-inf, 97] + Position.At(location=Location:CLOSED{l2(41)}) + Key=350 Master=216 Position.navigate(216)[3, 98] --> [4, 99] + [3, 98] + [3, 98] + Position.navigate(from=Location:CLOSED{l2(41)}to=Location:CLOSED{l1(38),l3(44),l4(47),l5(50),l6(53)}) + Key=380 Master=277 Position.At(277)[2, 97] --> [3, 98] + [4, 99] + [1, 96] + Position.navigate(from=Location:CLOSED{l1(38),l3(44),l4(47),l5(50),l6(53)}to=Location:CLOSED{l2(41)}) + Key=402 Master=277 Position.At(277)[2, 97] --> [3, 98] + [2, 97] +Inactive Tokens: ************************* + [-1, 94] + Position.navigate(from=Location:CLOSED{l2(41),l3(44),l4(47),l5(50),l6(53)}to=Location:CLOSED{l1(38)}) + Key=151 Master=110 a(110)[0, 95] --> [1, 96] + [0, 95] + [5, 100] + Position.navigate(from=Location:CLOSED{l5(50)}to=Location:CLOSED{l1(38),l2(41),l3(44),l4(47),l6(53)}) + Key=192 Master=175 b(175)[4, 99] --> [5, 100] + [6, 101] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Variables ************************* + rover.m_position=Position:CLOSED{rover.m_position(25)} + rover.m_tracker=Tracker:CLOSED{rover.m_tracker(28)} + rover.m_oppsci=OpportunisticScience:CLOSED{rover.m_oppsci(31)} + rover.m_champ=CHAMP:CLOSED{rover.m_champ(34)} + End Variables ********************* + End Rover:rover************************* + Position:rover.m_position************************* + Tokens ************************* + [0, 95] + Position.At(location=Location:CLOSED{l1(38)}) + Key=110 Master=NONE + Merged Key=295 from Position.navigate(127)[1, 96] --> [2, 97] + [1, 96] + [1, 96] + Position.navigate(from=Location:CLOSED{l1(38)}to=Location:CLOSED{l2(41)}) + Key=127 Master=110 a(110)[0, 95] --> [1, 96] + Merged Key=402 from Position.At(277)[2, 97] --> [3, 98] + [2, 97] + [2, 97] + Position.At(location=Location:CLOSED{l2(41)}) + Key=277 Master=127 Position.navigate(127)[1, 96] --> [2, 97] + Merged Key=350 from Position.navigate(216)[3, 98] --> [4, 99] + [3, 98] + [3, 98] + Position.navigate(from=Location:CLOSED{l2(41)}to=Location:CLOSED{l5(50)}) + Key=216 Master=175 b(175)[4, 99] --> [5, 100] + Merged Key=380 from Position.At(277)[2, 97] --> [3, 98] + [4, 99] + [4, 99] + Position.At(location=Location:CLOSED{l5(50)}) + Key=175 Master=NONE + Merged Key=332 from Position.navigate(216)[3, 98] --> [4, 99] + [5, 100] + End Tokens ********************* + End Position:rover.m_position************************* + Tracker:rover.m_tracker************************* + End Tracker:rover.m_tracker************************* + OpportunisticScience:rover.m_oppsci************************* + End OpportunisticScience:rover.m_oppsci************************* + CHAMP:rover.m_champ************************* + End CHAMP:rover.m_champ************************* + Location:l1************************* + End Location:l1************************* + Location:l2************************* + End Location:l2************************* + Location:l3************************* + End Location:l3************************* + Location:l4************************* + End Location:l4************************* + Location:l5************************* + End Location:l5************************* + Location:l6************************* + End Location:l6************************* + Path:p1************************* + Variables ************************* + p1.m_from=Location:CLOSED{l1(38)} + p1.m_to=Location:CLOSED{l2(41)} + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.m_from=Location:CLOSED{l1(38)} + p2.m_to=Location:CLOSED{l3(44)} + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.m_from=Location:CLOSED{l2(41)} + p3.m_to=Location:CLOSED{l5(50)} + End Variables ********************* + End Path:p3************************* + Path:p4************************* + Variables ************************* + p4.m_from=Location:CLOSED{l5(50)} + p4.m_to=Location:CLOSED{l6(53)} + End Variables ********************* + End Path:p4************************* + Path:p5************************* + Variables ************************* + p5.m_from=Location:CLOSED{l3(44)} + p5.m_to=Location:CLOSED{l6(53)} + End Variables ********************* + End Path:p5************************* + Path:p6************************* + Variables ************************* + p6.m_from=Location:CLOSED{l2(41)} + p6.m_to=Location:CLOSED{l3(44)} + End Variables ********************* + End Path:p6************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(23)} + l1=Location:CLOSED{l1(38)} + l2=Location:CLOSED{l2(41)} + l3=Location:CLOSED{l3(44)} + l4=Location:CLOSED{l4(47)} + l5=Location:CLOSED{l5(50)} + l6=Location:CLOSED{l6(53)} + p1=Path:CLOSED{p1(58)} + p2=Path:CLOSED{p2(67)} + p3=Path:CLOSED{p3(76)} + p4=Path:CLOSED{p4(85)} + p5=Path:CLOSED{p5(94)} + p6=Path:CLOSED{p6(103)} +Merged Tokens: ************************* + [-inf, 95] + Position.At(location=Location:CLOSED{l1(38)}) + Key=295 Master=127 Position.navigate(127)[1, 96] --> [2, 97] + [1, 96] + [4, 99] + Position.At(location=Location:CLOSED{l5(50)}) + Key=332 Master=216 Position.navigate(216)[3, 98] --> [4, 99] + [5, +inf] + [-inf, 97] + Position.At(location=Location:CLOSED{l2(41)}) + Key=350 Master=216 Position.navigate(216)[3, 98] --> [4, 99] + [3, 98] + [3, 98] + Position.navigate(from=Location:CLOSED{l2(41)}to=Location:CLOSED{l1(38),l3(44),l4(47),l5(50),l6(53)}) + Key=380 Master=277 Position.At(277)[2, 97] --> [3, 98] + [4, 99] + [1, 96] + Position.navigate(from=Location:CLOSED{l1(38),l3(44),l4(47),l5(50),l6(53)}to=Location:CLOSED{l2(41)}) + Key=402 Master=277 Position.At(277)[2, 97] --> [3, 98] + [2, 97] +Inactive Tokens: ************************* + [-1, 94] + Position.navigate(from=Location:CLOSED{l2(41),l3(44),l4(47),l5(50),l6(53)}to=Location:CLOSED{l1(38)}) + Key=151 Master=110 a(110)[0, 95] --> [1, 96] + [0, 95] + [5, 100] + Position.navigate(from=Location:CLOSED{l5(50)}to=Location:CLOSED{l1(38),l2(41),l3(44),l4(47),l6(53)}) + Key=192 Master=175 b(175)[4, 99] --> [5, 100] + [6, 101] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-k9.backtrack.moderate-transaction-reservoir.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-k9.backtrack.moderate-transaction-reservoir.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..ef9e68e7c --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-k9.backtrack.moderate-transaction-reservoir.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,1502 @@ +Created node [id_538] initially enabled +Created node [id_539] initially enabled +Maximum flow instance created with source [id_538] and sink [id_539] +Created node [id_538] initially enabled +Created node [id_539] initially enabled +Maximum flow instance created with source [id_538] and sink [id_539] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[500, 500] + world.m_maxPlannerSteps=int:CLOSED[1000, 1000] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Variables ************************* + rover.BATTERY_MIN=float:CLOSED[0, 0] + rover.BATTERY_MAX=float:CLOSED[518400, 518400] + rover.m_position=Position:CLOSED{rover.m_position(33)} + rover.m_tracker=Tracker:CLOSED{rover.m_tracker(39)} + rover.m_oppsci=OpportunisticScience:CLOSED{rover.m_oppsci(45)} + rover.m_champ=CHAMP:CLOSED{rover.m_champ(51)} + rover.m_energy=Energy:CLOSED{rover.m_energy(61)} + End Variables ********************* + End Rover:rover************************* + Position:rover.m_position************************* + Tokens ************************* + {0} + Position.At(location=Location:CLOSED{start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=517 Master=NONE + Merged Key=1421 from Position.navigate(766)[4, 492] --> [5, 493] + [4, 492] + [4, 492] + Position.navigate(from=Location:CLOSED{start(103)}to=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=766 Master=517 a(517){0} --> [4, 492] + Merged Key=1768 from Position.At(917)[5, 493] --> [12, +inf] + [5, 493] + [5, 493] + Position.At(location=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{FLUENT}) + Key=917 Master=541 ipg(541)[11, 499] --> [12, 500] + Merged Key=1400 from Position.navigate(766)[4, 492] --> [5, 493] + Merged Key=2072 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2502 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2783 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [12, +inf] + End Tokens ********************* + Variables ************************* + rover.m_position.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End Position:rover.m_position************************* + Tracker:rover.m_tracker************************* + Tokens ************************* + {0} + Tracker.TrackingOff(TYPE=Types:CLOSED{FLUENT}) + Key=578 Master=NONE + Merged Key=1839 from Tracker.trackloadgroup(978)[1, 489] --> [2, 490] + [1, 489] + [1, 489] + Tracker.trackloadgroup(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=978 Master=578 toff(578){0} --> [1, 489] + Merged Key=2152 from Tracker.LandmarksDefined(1820)[2, 490] --> [3, 491] + [2, 490] + [2, 490] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=1820 Master=978 Tracker.trackloadgroup(978)[1, 489] --> [2, 490] + Merged Key=1912 from Target.trackstart(1319)[2, 490] --> [3, 491] + Merged Key=2358 from Tracker.StartTracking(2183)[3, 491] --> [4, 492] + [3, 491] + [3, 491] + Tracker.StartTracking(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2183 Master=1820 Tracker.LandmarksDefined(1820)[2, 490] --> [3, 491] + Merged Key=3150 from Tracker.TrackingOn(896)[4, 492] --> [12, +inf] + [4, 492] + [4, 492] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=896 Master=541 ipg(541)[11, 499] --> [12, 500] + Merged Key=1443 from Position.navigate(766)[4, 492] --> [5, 493] + Merged Key=2051 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2377 from Tracker.StartTracking(2183)[3, 491] --> [4, 492] + Merged Key=2481 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2762 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [12, +inf] + End Tokens ********************* + Variables ************************* + rover.m_tracker.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End Tracker:rover.m_tracker************************* + OpportunisticScience:rover.m_oppsci************************* + Tokens ************************* + {0} + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=600 Master=NONE + Merged Key=939 from ipg(541)[11, 499] --> [12, 500] + Merged Key=1464 from Position.navigate(766)[4, 492] --> [5, 493] + Merged Key=2094 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2524 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2805 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [12, 500] + End Tokens ********************* + Variables ************************* + rover.m_oppsci.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End OpportunisticScience:rover.m_oppsci************************* + CHAMP:rover.m_champ************************* + Tokens ************************* + {0} + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=622 Master=NONE + Merged Key=1485 from Position.navigate(766)[4, 492] --> [5, 493] + Merged Key=2691 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [5, 493] + [5, 493] + CHAMP.ipgetname(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2581 Master=2408 CHAMP.IPHaveName(2408)[6, 494] --> [7, 495] + [6, 494] + [6, 494] + CHAMP.IPHaveName(target=Target:CLOSED{L0_target(106)}at_loc=Location:CLOSED{D14(79)}TYPE=Types:CLOSED{FLUENT}) + Key=2408 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2710 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [7, 495] + [7, 495] + CHAMP.ipsettarget(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2244 Master=1978 CHAMP.IPTargetSet(1978)[8, 496] --> [9, 497] + Merged Key=2614 from CHAMP.IPHaveName(2408)[6, 494] --> [7, 495] + [8, 496] + [8, 496] + CHAMP.IPTargetSet(target=Target:CLOSED{L0_target(106)}at_loc=Location:CLOSED{D14(79)}TYPE=Types:CLOSED{FLUENT}) + Key=1978 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2429 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [9, 497] + [9, 497] + CHAMP.ipplaceinstrument(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1525 Master=844 CHAMP.IPDonePlaceInstrument(844)[10, 498] --> [11, 499] + Merged Key=2277 from CHAMP.IPTargetSet(1978)[8, 496] --> [9, 497] + [10, 498] + [10, 498] + CHAMP.IPDonePlaceInstrument(target=Target:CLOSED{L0_target(106)}at_loc=Location:CLOSED{D14(79)}TYPE=Types:CLOSED{FLUENT}) + Key=844 Master=541 ipg(541)[11, 499] --> [12, 500] + Merged Key=1999 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [11, 499] + [11, 499] + CHAMP.ipgetstatus(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=541 Master=NONE + Merged Key=1558 from CHAMP.IPDonePlaceInstrument(844)[10, 498] --> [11, 499] + [12, 500] + End Tokens ********************* + Variables ************************* + rover.m_champ.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End CHAMP:rover.m_champ************************* + Energy:rover.m_energy************************* + Variables ************************* + rover.m_energy.initialCapacity=float:CLOSED[1000, 1000] + rover.m_energy.levelLimitMin=float:CLOSED[0, 0] + rover.m_energy.levelLimitMax=float:CLOSED[518400, 518400] + rover.m_energy.productionRateMax=float:CLOSED[+inf, +inf] + rover.m_energy.productionMax=float:CLOSED[+inf, +inf] + rover.m_energy.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.m_energy.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Energy:rover.m_energy************************* + Location:D14************************* + End Location:D14************************* + Location:D13************************* + End Location:D13************************* + Location:C1************************* + End Location:C1************************* + Location:L4************************* + End Location:L4************************* + Location:L3************************* + End Location:L3************************* + Location:L2************************* + End Location:L2************************* + Location:L1************************* + End Location:L1************************* + Location:L0************************* + End Location:L0************************* + Location:start************************* + End Location:start************************* + Target:L0_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{FLUENT}) + Key=644 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L0_target************************* + CHAMP_Accessable:ch_L0_target************************* + Variables ************************* + ch_L0_target.m_from=Location:CLOSED{L0(100)} + ch_L0_target.m_to=Target:CLOSED{L0_target(106)} + End Variables ********************* + End CHAMP_Accessable:ch_L0_target************************* + OppSci_Accessable:op_L0_target************************* + Variables ************************* + op_L0_target.m_from=Location:CLOSED{L0(100)} + op_L0_target.m_to=Target:CLOSED{L0_target(106)} + End Variables ********************* + End OppSci_Accessable:op_L0_target************************* + Target:L1_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{FLUENT}) + Key=668 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L1_target************************* + CHAMP_Accessable:ch_L1_target************************* + Variables ************************* + ch_L1_target.m_from=Location:CLOSED{L1(97)} + ch_L1_target.m_to=Target:CLOSED{L1_target(127)} + End Variables ********************* + End CHAMP_Accessable:ch_L1_target************************* + OppSci_Accessable:op_L1_target************************* + Variables ************************* + op_L1_target.m_from=Location:CLOSED{L1(97)} + op_L1_target.m_to=Target:CLOSED{L1_target(127)} + End Variables ********************* + End OppSci_Accessable:op_L1_target************************* + Target:L2_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{FLUENT}) + Key=692 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L2_target************************* + CHAMP_Accessable:ch_L2_target************************* + Variables ************************* + ch_L2_target.m_from=Location:CLOSED{L2(94)} + ch_L2_target.m_to=Target:CLOSED{L2_target(148)} + End Variables ********************* + End CHAMP_Accessable:ch_L2_target************************* + OppSci_Accessable:op_L2_target************************* + Variables ************************* + op_L2_target.m_from=Location:CLOSED{L2(94)} + op_L2_target.m_to=Target:CLOSED{L2_target(148)} + End Variables ********************* + End OppSci_Accessable:op_L2_target************************* + Target:L3_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{FLUENT}) + Key=716 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L3_target************************* + CHAMP_Accessable:ch_L3_target************************* + Variables ************************* + ch_L3_target.m_from=Location:CLOSED{L3(91)} + ch_L3_target.m_to=Target:CLOSED{L3_target(169)} + End Variables ********************* + End CHAMP_Accessable:ch_L3_target************************* + OppSci_Accessable:op_L3_target************************* + Variables ************************* + op_L3_target.m_from=Location:CLOSED{L3(91)} + op_L3_target.m_to=Target:CLOSED{L3_target(169)} + End Variables ********************* + End OppSci_Accessable:op_L3_target************************* + Target:L4_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=740 Master=NONE + Merged Key=1891 from Target.trackstart(1319)[2, 490] --> [3, 491] + [2, 490] + [2, 490] + Target.trackstart(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1319 Master=740 nt_L4_target(740){0} --> [2, 490] + Merged Key=1636 from Target.Tracked(865)[3, 491] --> [12, +inf] + [3, 491] + [3, 491] + Target.Tracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=865 Master=541 ipg(541)[11, 499] --> [12, 500] + Merged Key=1870 from Target.trackstart(1319)[2, 490] --> [3, 491] + Merged Key=2020 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2450 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2731 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [12, +inf] + End Tokens ********************* + End Target:L4_target************************* + CHAMP_Accessable:ch_L4_target************************* + Variables ************************* + ch_L4_target.m_from=Location:CLOSED{L4(88)} + ch_L4_target.m_to=Target:CLOSED{L4_target(190)} + End Variables ********************* + End CHAMP_Accessable:ch_L4_target************************* + OppSci_Accessable:op_L4_target************************* + Variables ************************* + op_L4_target.m_from=Location:CLOSED{L4(88)} + op_L4_target.m_to=Target:CLOSED{L4_target(190)} + End Variables ********************* + End OppSci_Accessable:op_L4_target************************* + Path:L4D14************************* + Variables ************************* + L4D14.m_from=Location:CLOSED{L4(88)} + L4D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L4D14************************* + Path:D14L4************************* + Variables ************************* + D14L4.m_from=Location:CLOSED{D14(79)} + D14L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:D14L4************************* + Path:L2D13************************* + Variables ************************* + L2D13.m_from=Location:CLOSED{L2(94)} + L2D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L2D13************************* + Path:D13L2************************* + Variables ************************* + D13L2.m_from=Location:CLOSED{D13(82)} + D13L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:D13L2************************* + Path:C1D14************************* + Variables ************************* + C1D14.m_from=Location:CLOSED{C1(85)} + C1D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:C1D14************************* + Path:D14C1************************* + Variables ************************* + D14C1.m_from=Location:CLOSED{D14(79)} + D14C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:D14C1************************* + Path:L3D14************************* + Variables ************************* + L3D14.m_from=Location:CLOSED{L3(91)} + L3D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L3D14************************* + Path:D14L3************************* + Variables ************************* + D14L3.m_from=Location:CLOSED{D14(79)} + D14L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:D14L3************************* + Path:D14L1************************* + Variables ************************* + D14L1.m_from=Location:CLOSED{D14(79)} + D14L1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:D14L1************************* + Path:L1D14************************* + Variables ************************* + L1D14.m_from=Location:CLOSED{L1(97)} + L1D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L1D14************************* + Path:C1D13************************* + Variables ************************* + C1D13.m_from=Location:CLOSED{C1(85)} + C1D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:C1D13************************* + Path:D13C1************************* + Variables ************************* + D13C1.m_from=Location:CLOSED{D13(82)} + D13C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:D13C1************************* + Path:L4D13************************* + Variables ************************* + L4D13.m_from=Location:CLOSED{L4(88)} + L4D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L4D13************************* + Path:D13L4************************* + Variables ************************* + D13L4.m_from=Location:CLOSED{D13(82)} + D13L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:D13L4************************* + Path:D13L0************************* + Variables ************************* + D13L0.m_from=Location:CLOSED{D13(82)} + D13L0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:D13L0************************* + Path:L0D13************************* + Variables ************************* + L0D13.m_from=Location:CLOSED{L0(100)} + L0D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L0D13************************* + Path:L4C1************************* + Variables ************************* + L4C1.m_from=Location:CLOSED{L4(88)} + L4C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L4C1************************* + Path:C1L3************************* + Variables ************************* + C1L3.m_from=Location:CLOSED{C1(85)} + C1L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:C1L3************************* + Path:L3C1************************* + Variables ************************* + L3C1.m_from=Location:CLOSED{L3(91)} + L3C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L3C1************************* + Path:C1L4************************* + Variables ************************* + C1L4.m_from=Location:CLOSED{C1(85)} + C1L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:C1L4************************* + Path:C1L2************************* + Variables ************************* + C1L2.m_from=Location:CLOSED{C1(85)} + C1L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:C1L2************************* + Path:L2C1************************* + Variables ************************* + L2C1.m_from=Location:CLOSED{L2(94)} + L2C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L2C1************************* + Path:L4L1************************* + Variables ************************* + L4L1.m_from=Location:CLOSED{L4(88)} + L4L1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:L4L1************************* + Path:L1L4************************* + Variables ************************* + L1L4.m_from=Location:CLOSED{L1(97)} + L1L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:L1L4************************* + Path:L4start************************* + Variables ************************* + L4start.m_from=Location:CLOSED{L4(88)} + L4start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L4start************************* + Path:startL4************************* + Variables ************************* + startL4.m_from=Location:CLOSED{start(103)} + startL4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:startL4************************* + Path:L3L2************************* + Variables ************************* + L3L2.m_from=Location:CLOSED{L3(91)} + L3L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:L3L2************************* + Path:L2L3************************* + Variables ************************* + L2L3.m_from=Location:CLOSED{L2(94)} + L2L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:L2L3************************* + Path:L2L0************************* + Variables ************************* + L2L0.m_from=Location:CLOSED{L2(94)} + L2L0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:L2L0************************* + Path:L0L2************************* + Variables ************************* + L0L2.m_from=Location:CLOSED{L0(100)} + L0L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:L0L2************************* + Path:L1start************************* + Variables ************************* + L1start.m_from=Location:CLOSED{L1(97)} + L1start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L1start************************* + Path:startL1************************* + Variables ************************* + startL1.m_from=Location:CLOSED{start(103)} + startL1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:startL1************************* + Path:L0start************************* + Variables ************************* + L0start.m_from=Location:CLOSED{L0(100)} + L0start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L0start************************* + Path:startL0************************* + Variables ************************* + startL0.m_from=Location:CLOSED{start(103)} + startL0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:startL0************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(25)} + D14=Location:CLOSED{D14(79)} + D13=Location:CLOSED{D13(82)} + C1=Location:CLOSED{C1(85)} + L4=Location:CLOSED{L4(88)} + L3=Location:CLOSED{L3(91)} + L2=Location:CLOSED{L2(94)} + L1=Location:CLOSED{L1(97)} + L0=Location:CLOSED{L0(100)} + start=Location:CLOSED{start(103)} + L0_target=Target:CLOSED{L0_target(106)} + ch_L0_target=CHAMP_Accessable:CLOSED{ch_L0_target(111)} + op_L0_target=OppSci_Accessable:CLOSED{op_L0_target(120)} + L1_target=Target:CLOSED{L1_target(127)} + ch_L1_target=CHAMP_Accessable:CLOSED{ch_L1_target(132)} + op_L1_target=OppSci_Accessable:CLOSED{op_L1_target(141)} + L2_target=Target:CLOSED{L2_target(148)} + ch_L2_target=CHAMP_Accessable:CLOSED{ch_L2_target(153)} + op_L2_target=OppSci_Accessable:CLOSED{op_L2_target(162)} + L3_target=Target:CLOSED{L3_target(169)} + ch_L3_target=CHAMP_Accessable:CLOSED{ch_L3_target(174)} + op_L3_target=OppSci_Accessable:CLOSED{op_L3_target(183)} + L4_target=Target:CLOSED{L4_target(190)} + ch_L4_target=CHAMP_Accessable:CLOSED{ch_L4_target(195)} + op_L4_target=OppSci_Accessable:CLOSED{op_L4_target(204)} + L4D14=Path:CLOSED{L4D14(213)} + D14L4=Path:CLOSED{D14L4(222)} + L2D13=Path:CLOSED{L2D13(231)} + D13L2=Path:CLOSED{D13L2(240)} + C1D14=Path:CLOSED{C1D14(249)} + D14C1=Path:CLOSED{D14C1(258)} + L3D14=Path:CLOSED{L3D14(267)} + D14L3=Path:CLOSED{D14L3(276)} + D14L1=Path:CLOSED{D14L1(285)} + L1D14=Path:CLOSED{L1D14(294)} + C1D13=Path:CLOSED{C1D13(303)} + D13C1=Path:CLOSED{D13C1(312)} + L4D13=Path:CLOSED{L4D13(321)} + D13L4=Path:CLOSED{D13L4(330)} + D13L0=Path:CLOSED{D13L0(339)} + L0D13=Path:CLOSED{L0D13(348)} + L4C1=Path:CLOSED{L4C1(357)} + C1L3=Path:CLOSED{C1L3(366)} + L3C1=Path:CLOSED{L3C1(375)} + C1L4=Path:CLOSED{C1L4(384)} + C1L2=Path:CLOSED{C1L2(393)} + L2C1=Path:CLOSED{L2C1(402)} + L4L1=Path:CLOSED{L4L1(411)} + L1L4=Path:CLOSED{L1L4(420)} + L4start=Path:CLOSED{L4start(429)} + startL4=Path:CLOSED{startL4(438)} + L3L2=Path:CLOSED{L3L2(447)} + L2L3=Path:CLOSED{L2L3(456)} + L2L0=Path:CLOSED{L2L0(465)} + L0L2=Path:CLOSED{L0L2(474)} + L1start=Path:CLOSED{L1start(483)} + startL1=Path:CLOSED{startL1(492)} + L0start=Path:CLOSED{L0start(501)} + startL0=Path:CLOSED{startL0(510)} +Merged Tokens: ************************* + [-inf, 499] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=939 Master=541 ipg(541)[11, 499] --> [12, 500] + [3, +inf] + [2, 499] + Position.At(location=Location:CLOSED{L0(100),L1(97),L4(88)}TYPE=Types:CLOSED{FLUENT}) + Key=1400 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [3, +inf] + [-inf, 497] + Position.At(location=Location:CLOSED{start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=1421 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [1, 498] + [-inf, 498] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=1443 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [2, +inf] + [-inf, 498] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=1464 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [3, +inf] + [-inf, 498] + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=1485 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [3, +inf] + [5, 499] + CHAMP.ipgetstatus(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1558 Master=844 CHAMP.IPDonePlaceInstrument(844)[10, 498] --> [11, 499] + [6, +inf] + [-inf, 498] + Target.trackstart(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1636 Master=865 Target.Tracked(865)[3, 491] --> [12, +inf] + [2, 499] + [-inf, 496] + Position.navigate(from=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}to=Location:CLOSED{L0(100),L1(97),L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=1768 Master=917 Position.At(917)[5, 493] --> [12, +inf] + [3, 497] + [-inf, 493] + Tracker.TrackingOff(TYPE=Types:CLOSED{FLUENT}) + Key=1839 Master=978 Tracker.trackloadgroup(978)[1, 489] --> [2, 490] + [1, 494] + [2, 499] + Target.Tracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=1870 Master=1319 Target.trackstart(1319)[2, 490] --> [3, 491] + [3, +inf] + [-inf, 497] + Target.NotTracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=1891 Master=1319 Target.trackstart(1319)[2, 490] --> [3, 491] + [1, 498] + [-inf, 498] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=1912 Master=1319 Target.trackstart(1319)[2, 490] --> [3, 491] + [2, +inf] + [6, 498] + CHAMP.IPDonePlaceInstrument(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=1999 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [7, +inf] + [-inf, 497] + Target.Tracked(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=2020 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [6, +inf] + [-inf, 497] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2051 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [6, +inf] + [-inf, 497] + Position.At(location=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2072 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [6, +inf] + [-inf, 497] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=2094 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [6, +inf] + [-inf, 493] + Tracker.trackloadgroup(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2152 Master=1820 Tracker.LandmarksDefined(1820)[2, 490] --> [3, 491] + [2, 494] + [7, 497] + CHAMP.ipplaceinstrument(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2277 Master=1978 CHAMP.IPTargetSet(1978)[8, 496] --> [9, 497] + [8, +inf] + [-inf, 492] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=2358 Master=2183 Tracker.StartTracking(2183)[3, 491] --> [4, 492] + [3, 493] + [4, 494] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2377 Master=2183 Tracker.StartTracking(2183)[3, 491] --> [4, 492] + [5, +inf] + [7, 496] + CHAMP.IPTargetSet(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2429 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [8, +inf] + [-inf, 495] + Target.Tracked(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=2450 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [7, +inf] + [-inf, 495] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2481 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [7, +inf] + [-inf, 495] + Position.At(location=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2502 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [7, +inf] + [-inf, 495] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=2524 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [7, +inf] + [7, 495] + CHAMP.ipsettarget(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2614 Master=2408 CHAMP.IPHaveName(2408)[6, 494] --> [7, 495] + [8, +inf] + [-inf, 492] + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=2691 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [5, 493] + [6, 494] + CHAMP.IPHaveName(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2710 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [7, +inf] + [-inf, 493] + Target.Tracked(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=2731 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [6, +inf] + [-inf, 493] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2762 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [6, +inf] + [-inf, 493] + Position.At(location=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2783 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [6, +inf] + [-inf, 493] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=2805 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [6, +inf] + [-inf, 491] + Tracker.StartTracking(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=3150 Master=896 Tracker.TrackingOn(896)[4, 492] --> [12, +inf] + [4, 492] +Inactive Tokens: ************************* + [-inf, -1] + Position.navigate(from=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88)}to=Location:CLOSED{start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=801 Master=517 a(517){0} --> [4, 492] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1023 Master=644 nt_L0_target(644){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1056 Master=644 nt_L0_target(644){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1097 Master=668 nt_L1_target(668){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1130 Master=668 nt_L1_target(668){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1171 Master=692 nt_L2_target(692){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1204 Master=692 nt_L2_target(692){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1245 Master=716 nt_L3_target(716){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1278 Master=716 nt_L3_target(716){0} --> [1, 500] + {0} + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1352 Master=740 nt_L4_target(740){0} --> [2, 490] + {0} + [12, +inf] + Target.trackstop(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1603 Master=865 Target.Tracked(865)[3, 491] --> [12, +inf] + [13, +inf] + [12, +inf] + Tracker.trackfreeze(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1679 Master=896 Tracker.TrackingOn(896)[4, 492] --> [12, +inf] + [13, +inf] + [12, +inf] + Position.navigate(from=Location:CLOSED{L4(88)}to=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=1733 Master=917 Position.At(917)[5, 493] --> [12, +inf] + [13, +inf] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[500, 500] + world.m_maxPlannerSteps=int:CLOSED[1000, 1000] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Variables ************************* + rover.BATTERY_MIN=float:CLOSED[0, 0] + rover.BATTERY_MAX=float:CLOSED[518400, 518400] + rover.m_position=Position:CLOSED{rover.m_position(33)} + rover.m_tracker=Tracker:CLOSED{rover.m_tracker(39)} + rover.m_oppsci=OpportunisticScience:CLOSED{rover.m_oppsci(45)} + rover.m_champ=CHAMP:CLOSED{rover.m_champ(51)} + rover.m_energy=Energy:CLOSED{rover.m_energy(61)} + End Variables ********************* + End Rover:rover************************* + Position:rover.m_position************************* + Tokens ************************* + {0} + Position.At(location=Location:CLOSED{start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=517 Master=NONE + Merged Key=1421 from Position.navigate(766)[4, 492] --> [5, 493] + [4, 492] + [4, 492] + Position.navigate(from=Location:CLOSED{start(103)}to=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=766 Master=517 a(517){0} --> [4, 492] + Merged Key=1768 from Position.At(917)[5, 493] --> [12, +inf] + [5, 493] + [5, 493] + Position.At(location=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{FLUENT}) + Key=917 Master=541 ipg(541)[11, 499] --> [12, 500] + Merged Key=1400 from Position.navigate(766)[4, 492] --> [5, 493] + Merged Key=2072 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2502 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2783 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [12, +inf] + End Tokens ********************* + Variables ************************* + rover.m_position.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End Position:rover.m_position************************* + Tracker:rover.m_tracker************************* + Tokens ************************* + {0} + Tracker.TrackingOff(TYPE=Types:CLOSED{FLUENT}) + Key=578 Master=NONE + Merged Key=1839 from Tracker.trackloadgroup(978)[1, 489] --> [2, 490] + [1, 489] + [1, 489] + Tracker.trackloadgroup(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=978 Master=578 toff(578){0} --> [1, 489] + Merged Key=2152 from Tracker.LandmarksDefined(1820)[2, 490] --> [3, 491] + [2, 490] + [2, 490] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=1820 Master=978 Tracker.trackloadgroup(978)[1, 489] --> [2, 490] + Merged Key=1912 from Target.trackstart(1319)[2, 490] --> [3, 491] + Merged Key=2358 from Tracker.StartTracking(2183)[3, 491] --> [4, 492] + [3, 491] + [3, 491] + Tracker.StartTracking(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2183 Master=1820 Tracker.LandmarksDefined(1820)[2, 490] --> [3, 491] + Merged Key=3150 from Tracker.TrackingOn(896)[4, 492] --> [12, +inf] + [4, 492] + [4, 492] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=896 Master=541 ipg(541)[11, 499] --> [12, 500] + Merged Key=1443 from Position.navigate(766)[4, 492] --> [5, 493] + Merged Key=2051 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2377 from Tracker.StartTracking(2183)[3, 491] --> [4, 492] + Merged Key=2481 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2762 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [12, +inf] + End Tokens ********************* + Variables ************************* + rover.m_tracker.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End Tracker:rover.m_tracker************************* + OpportunisticScience:rover.m_oppsci************************* + Tokens ************************* + {0} + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=600 Master=NONE + Merged Key=939 from ipg(541)[11, 499] --> [12, 500] + Merged Key=1464 from Position.navigate(766)[4, 492] --> [5, 493] + Merged Key=2094 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2524 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2805 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [12, 500] + End Tokens ********************* + Variables ************************* + rover.m_oppsci.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End OpportunisticScience:rover.m_oppsci************************* + CHAMP:rover.m_champ************************* + Tokens ************************* + {0} + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=622 Master=NONE + Merged Key=1485 from Position.navigate(766)[4, 492] --> [5, 493] + Merged Key=2691 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [5, 493] + [5, 493] + CHAMP.ipgetname(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2581 Master=2408 CHAMP.IPHaveName(2408)[6, 494] --> [7, 495] + [6, 494] + [6, 494] + CHAMP.IPHaveName(target=Target:CLOSED{L0_target(106)}at_loc=Location:CLOSED{D14(79)}TYPE=Types:CLOSED{FLUENT}) + Key=2408 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2710 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [7, 495] + [7, 495] + CHAMP.ipsettarget(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2244 Master=1978 CHAMP.IPTargetSet(1978)[8, 496] --> [9, 497] + Merged Key=2614 from CHAMP.IPHaveName(2408)[6, 494] --> [7, 495] + [8, 496] + [8, 496] + CHAMP.IPTargetSet(target=Target:CLOSED{L0_target(106)}at_loc=Location:CLOSED{D14(79)}TYPE=Types:CLOSED{FLUENT}) + Key=1978 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2429 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [9, 497] + [9, 497] + CHAMP.ipplaceinstrument(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1525 Master=844 CHAMP.IPDonePlaceInstrument(844)[10, 498] --> [11, 499] + Merged Key=2277 from CHAMP.IPTargetSet(1978)[8, 496] --> [9, 497] + [10, 498] + [10, 498] + CHAMP.IPDonePlaceInstrument(target=Target:CLOSED{L0_target(106)}at_loc=Location:CLOSED{D14(79)}TYPE=Types:CLOSED{FLUENT}) + Key=844 Master=541 ipg(541)[11, 499] --> [12, 500] + Merged Key=1999 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [11, 499] + [11, 499] + CHAMP.ipgetstatus(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=541 Master=NONE + Merged Key=1558 from CHAMP.IPDonePlaceInstrument(844)[10, 498] --> [11, 499] + [12, 500] + End Tokens ********************* + Variables ************************* + rover.m_champ.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End CHAMP:rover.m_champ************************* + Energy:rover.m_energy************************* + Variables ************************* + rover.m_energy.initialCapacity=float:CLOSED[1000, 1000] + rover.m_energy.levelLimitMin=float:CLOSED[0, 0] + rover.m_energy.levelLimitMax=float:CLOSED[518400, 518400] + rover.m_energy.productionRateMax=float:CLOSED[+inf, +inf] + rover.m_energy.productionMax=float:CLOSED[+inf, +inf] + rover.m_energy.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.m_energy.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Energy:rover.m_energy************************* + Location:D14************************* + End Location:D14************************* + Location:D13************************* + End Location:D13************************* + Location:C1************************* + End Location:C1************************* + Location:L4************************* + End Location:L4************************* + Location:L3************************* + End Location:L3************************* + Location:L2************************* + End Location:L2************************* + Location:L1************************* + End Location:L1************************* + Location:L0************************* + End Location:L0************************* + Location:start************************* + End Location:start************************* + Target:L0_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{FLUENT}) + Key=644 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L0_target************************* + CHAMP_Accessable:ch_L0_target************************* + Variables ************************* + ch_L0_target.m_from=Location:CLOSED{L0(100)} + ch_L0_target.m_to=Target:CLOSED{L0_target(106)} + End Variables ********************* + End CHAMP_Accessable:ch_L0_target************************* + OppSci_Accessable:op_L0_target************************* + Variables ************************* + op_L0_target.m_from=Location:CLOSED{L0(100)} + op_L0_target.m_to=Target:CLOSED{L0_target(106)} + End Variables ********************* + End OppSci_Accessable:op_L0_target************************* + Target:L1_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{FLUENT}) + Key=668 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L1_target************************* + CHAMP_Accessable:ch_L1_target************************* + Variables ************************* + ch_L1_target.m_from=Location:CLOSED{L1(97)} + ch_L1_target.m_to=Target:CLOSED{L1_target(127)} + End Variables ********************* + End CHAMP_Accessable:ch_L1_target************************* + OppSci_Accessable:op_L1_target************************* + Variables ************************* + op_L1_target.m_from=Location:CLOSED{L1(97)} + op_L1_target.m_to=Target:CLOSED{L1_target(127)} + End Variables ********************* + End OppSci_Accessable:op_L1_target************************* + Target:L2_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{FLUENT}) + Key=692 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L2_target************************* + CHAMP_Accessable:ch_L2_target************************* + Variables ************************* + ch_L2_target.m_from=Location:CLOSED{L2(94)} + ch_L2_target.m_to=Target:CLOSED{L2_target(148)} + End Variables ********************* + End CHAMP_Accessable:ch_L2_target************************* + OppSci_Accessable:op_L2_target************************* + Variables ************************* + op_L2_target.m_from=Location:CLOSED{L2(94)} + op_L2_target.m_to=Target:CLOSED{L2_target(148)} + End Variables ********************* + End OppSci_Accessable:op_L2_target************************* + Target:L3_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{FLUENT}) + Key=716 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L3_target************************* + CHAMP_Accessable:ch_L3_target************************* + Variables ************************* + ch_L3_target.m_from=Location:CLOSED{L3(91)} + ch_L3_target.m_to=Target:CLOSED{L3_target(169)} + End Variables ********************* + End CHAMP_Accessable:ch_L3_target************************* + OppSci_Accessable:op_L3_target************************* + Variables ************************* + op_L3_target.m_from=Location:CLOSED{L3(91)} + op_L3_target.m_to=Target:CLOSED{L3_target(169)} + End Variables ********************* + End OppSci_Accessable:op_L3_target************************* + Target:L4_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=740 Master=NONE + Merged Key=1891 from Target.trackstart(1319)[2, 490] --> [3, 491] + [2, 490] + [2, 490] + Target.trackstart(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1319 Master=740 nt_L4_target(740){0} --> [2, 490] + Merged Key=1636 from Target.Tracked(865)[3, 491] --> [12, +inf] + [3, 491] + [3, 491] + Target.Tracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=865 Master=541 ipg(541)[11, 499] --> [12, 500] + Merged Key=1870 from Target.trackstart(1319)[2, 490] --> [3, 491] + Merged Key=2020 from CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + Merged Key=2450 from CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + Merged Key=2731 from CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [12, +inf] + End Tokens ********************* + End Target:L4_target************************* + CHAMP_Accessable:ch_L4_target************************* + Variables ************************* + ch_L4_target.m_from=Location:CLOSED{L4(88)} + ch_L4_target.m_to=Target:CLOSED{L4_target(190)} + End Variables ********************* + End CHAMP_Accessable:ch_L4_target************************* + OppSci_Accessable:op_L4_target************************* + Variables ************************* + op_L4_target.m_from=Location:CLOSED{L4(88)} + op_L4_target.m_to=Target:CLOSED{L4_target(190)} + End Variables ********************* + End OppSci_Accessable:op_L4_target************************* + Path:L4D14************************* + Variables ************************* + L4D14.m_from=Location:CLOSED{L4(88)} + L4D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L4D14************************* + Path:D14L4************************* + Variables ************************* + D14L4.m_from=Location:CLOSED{D14(79)} + D14L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:D14L4************************* + Path:L2D13************************* + Variables ************************* + L2D13.m_from=Location:CLOSED{L2(94)} + L2D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L2D13************************* + Path:D13L2************************* + Variables ************************* + D13L2.m_from=Location:CLOSED{D13(82)} + D13L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:D13L2************************* + Path:C1D14************************* + Variables ************************* + C1D14.m_from=Location:CLOSED{C1(85)} + C1D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:C1D14************************* + Path:D14C1************************* + Variables ************************* + D14C1.m_from=Location:CLOSED{D14(79)} + D14C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:D14C1************************* + Path:L3D14************************* + Variables ************************* + L3D14.m_from=Location:CLOSED{L3(91)} + L3D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L3D14************************* + Path:D14L3************************* + Variables ************************* + D14L3.m_from=Location:CLOSED{D14(79)} + D14L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:D14L3************************* + Path:D14L1************************* + Variables ************************* + D14L1.m_from=Location:CLOSED{D14(79)} + D14L1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:D14L1************************* + Path:L1D14************************* + Variables ************************* + L1D14.m_from=Location:CLOSED{L1(97)} + L1D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L1D14************************* + Path:C1D13************************* + Variables ************************* + C1D13.m_from=Location:CLOSED{C1(85)} + C1D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:C1D13************************* + Path:D13C1************************* + Variables ************************* + D13C1.m_from=Location:CLOSED{D13(82)} + D13C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:D13C1************************* + Path:L4D13************************* + Variables ************************* + L4D13.m_from=Location:CLOSED{L4(88)} + L4D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L4D13************************* + Path:D13L4************************* + Variables ************************* + D13L4.m_from=Location:CLOSED{D13(82)} + D13L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:D13L4************************* + Path:D13L0************************* + Variables ************************* + D13L0.m_from=Location:CLOSED{D13(82)} + D13L0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:D13L0************************* + Path:L0D13************************* + Variables ************************* + L0D13.m_from=Location:CLOSED{L0(100)} + L0D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L0D13************************* + Path:L4C1************************* + Variables ************************* + L4C1.m_from=Location:CLOSED{L4(88)} + L4C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L4C1************************* + Path:C1L3************************* + Variables ************************* + C1L3.m_from=Location:CLOSED{C1(85)} + C1L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:C1L3************************* + Path:L3C1************************* + Variables ************************* + L3C1.m_from=Location:CLOSED{L3(91)} + L3C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L3C1************************* + Path:C1L4************************* + Variables ************************* + C1L4.m_from=Location:CLOSED{C1(85)} + C1L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:C1L4************************* + Path:C1L2************************* + Variables ************************* + C1L2.m_from=Location:CLOSED{C1(85)} + C1L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:C1L2************************* + Path:L2C1************************* + Variables ************************* + L2C1.m_from=Location:CLOSED{L2(94)} + L2C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L2C1************************* + Path:L4L1************************* + Variables ************************* + L4L1.m_from=Location:CLOSED{L4(88)} + L4L1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:L4L1************************* + Path:L1L4************************* + Variables ************************* + L1L4.m_from=Location:CLOSED{L1(97)} + L1L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:L1L4************************* + Path:L4start************************* + Variables ************************* + L4start.m_from=Location:CLOSED{L4(88)} + L4start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L4start************************* + Path:startL4************************* + Variables ************************* + startL4.m_from=Location:CLOSED{start(103)} + startL4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:startL4************************* + Path:L3L2************************* + Variables ************************* + L3L2.m_from=Location:CLOSED{L3(91)} + L3L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:L3L2************************* + Path:L2L3************************* + Variables ************************* + L2L3.m_from=Location:CLOSED{L2(94)} + L2L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:L2L3************************* + Path:L2L0************************* + Variables ************************* + L2L0.m_from=Location:CLOSED{L2(94)} + L2L0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:L2L0************************* + Path:L0L2************************* + Variables ************************* + L0L2.m_from=Location:CLOSED{L0(100)} + L0L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:L0L2************************* + Path:L1start************************* + Variables ************************* + L1start.m_from=Location:CLOSED{L1(97)} + L1start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L1start************************* + Path:startL1************************* + Variables ************************* + startL1.m_from=Location:CLOSED{start(103)} + startL1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:startL1************************* + Path:L0start************************* + Variables ************************* + L0start.m_from=Location:CLOSED{L0(100)} + L0start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L0start************************* + Path:startL0************************* + Variables ************************* + startL0.m_from=Location:CLOSED{start(103)} + startL0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:startL0************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(25)} + D14=Location:CLOSED{D14(79)} + D13=Location:CLOSED{D13(82)} + C1=Location:CLOSED{C1(85)} + L4=Location:CLOSED{L4(88)} + L3=Location:CLOSED{L3(91)} + L2=Location:CLOSED{L2(94)} + L1=Location:CLOSED{L1(97)} + L0=Location:CLOSED{L0(100)} + start=Location:CLOSED{start(103)} + L0_target=Target:CLOSED{L0_target(106)} + ch_L0_target=CHAMP_Accessable:CLOSED{ch_L0_target(111)} + op_L0_target=OppSci_Accessable:CLOSED{op_L0_target(120)} + L1_target=Target:CLOSED{L1_target(127)} + ch_L1_target=CHAMP_Accessable:CLOSED{ch_L1_target(132)} + op_L1_target=OppSci_Accessable:CLOSED{op_L1_target(141)} + L2_target=Target:CLOSED{L2_target(148)} + ch_L2_target=CHAMP_Accessable:CLOSED{ch_L2_target(153)} + op_L2_target=OppSci_Accessable:CLOSED{op_L2_target(162)} + L3_target=Target:CLOSED{L3_target(169)} + ch_L3_target=CHAMP_Accessable:CLOSED{ch_L3_target(174)} + op_L3_target=OppSci_Accessable:CLOSED{op_L3_target(183)} + L4_target=Target:CLOSED{L4_target(190)} + ch_L4_target=CHAMP_Accessable:CLOSED{ch_L4_target(195)} + op_L4_target=OppSci_Accessable:CLOSED{op_L4_target(204)} + L4D14=Path:CLOSED{L4D14(213)} + D14L4=Path:CLOSED{D14L4(222)} + L2D13=Path:CLOSED{L2D13(231)} + D13L2=Path:CLOSED{D13L2(240)} + C1D14=Path:CLOSED{C1D14(249)} + D14C1=Path:CLOSED{D14C1(258)} + L3D14=Path:CLOSED{L3D14(267)} + D14L3=Path:CLOSED{D14L3(276)} + D14L1=Path:CLOSED{D14L1(285)} + L1D14=Path:CLOSED{L1D14(294)} + C1D13=Path:CLOSED{C1D13(303)} + D13C1=Path:CLOSED{D13C1(312)} + L4D13=Path:CLOSED{L4D13(321)} + D13L4=Path:CLOSED{D13L4(330)} + D13L0=Path:CLOSED{D13L0(339)} + L0D13=Path:CLOSED{L0D13(348)} + L4C1=Path:CLOSED{L4C1(357)} + C1L3=Path:CLOSED{C1L3(366)} + L3C1=Path:CLOSED{L3C1(375)} + C1L4=Path:CLOSED{C1L4(384)} + C1L2=Path:CLOSED{C1L2(393)} + L2C1=Path:CLOSED{L2C1(402)} + L4L1=Path:CLOSED{L4L1(411)} + L1L4=Path:CLOSED{L1L4(420)} + L4start=Path:CLOSED{L4start(429)} + startL4=Path:CLOSED{startL4(438)} + L3L2=Path:CLOSED{L3L2(447)} + L2L3=Path:CLOSED{L2L3(456)} + L2L0=Path:CLOSED{L2L0(465)} + L0L2=Path:CLOSED{L0L2(474)} + L1start=Path:CLOSED{L1start(483)} + startL1=Path:CLOSED{startL1(492)} + L0start=Path:CLOSED{L0start(501)} + startL0=Path:CLOSED{startL0(510)} +Merged Tokens: ************************* + [-inf, 499] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=939 Master=541 ipg(541)[11, 499] --> [12, 500] + [3, +inf] + [2, 499] + Position.At(location=Location:CLOSED{L0(100),L1(97),L4(88)}TYPE=Types:CLOSED{FLUENT}) + Key=1400 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [3, +inf] + [-inf, 497] + Position.At(location=Location:CLOSED{start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=1421 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [1, 498] + [-inf, 498] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=1443 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [2, +inf] + [-inf, 498] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=1464 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [3, +inf] + [-inf, 498] + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=1485 Master=766 Position.navigate(766)[4, 492] --> [5, 493] + [3, +inf] + [5, 499] + CHAMP.ipgetstatus(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1558 Master=844 CHAMP.IPDonePlaceInstrument(844)[10, 498] --> [11, 499] + [6, +inf] + [-inf, 498] + Target.trackstart(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1636 Master=865 Target.Tracked(865)[3, 491] --> [12, +inf] + [2, 499] + [-inf, 496] + Position.navigate(from=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}to=Location:CLOSED{L0(100),L1(97),L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=1768 Master=917 Position.At(917)[5, 493] --> [12, +inf] + [3, 497] + [-inf, 493] + Tracker.TrackingOff(TYPE=Types:CLOSED{FLUENT}) + Key=1839 Master=978 Tracker.trackloadgroup(978)[1, 489] --> [2, 490] + [1, 494] + [2, 499] + Target.Tracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=1870 Master=1319 Target.trackstart(1319)[2, 490] --> [3, 491] + [3, +inf] + [-inf, 497] + Target.NotTracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=1891 Master=1319 Target.trackstart(1319)[2, 490] --> [3, 491] + [1, 498] + [-inf, 498] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=1912 Master=1319 Target.trackstart(1319)[2, 490] --> [3, 491] + [2, +inf] + [6, 498] + CHAMP.IPDonePlaceInstrument(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=1999 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [7, +inf] + [-inf, 497] + Target.Tracked(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=2020 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [6, +inf] + [-inf, 497] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2051 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [6, +inf] + [-inf, 497] + Position.At(location=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2072 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [6, +inf] + [-inf, 497] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=2094 Master=1525 CHAMP.ipplaceinstrument(1525)[9, 497] --> [10, 498] + [6, +inf] + [-inf, 493] + Tracker.trackloadgroup(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2152 Master=1820 Tracker.LandmarksDefined(1820)[2, 490] --> [3, 491] + [2, 494] + [7, 497] + CHAMP.ipplaceinstrument(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2277 Master=1978 CHAMP.IPTargetSet(1978)[8, 496] --> [9, 497] + [8, +inf] + [-inf, 492] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=2358 Master=2183 Tracker.StartTracking(2183)[3, 491] --> [4, 492] + [3, 493] + [4, 494] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2377 Master=2183 Tracker.StartTracking(2183)[3, 491] --> [4, 492] + [5, +inf] + [7, 496] + CHAMP.IPTargetSet(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2429 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [8, +inf] + [-inf, 495] + Target.Tracked(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=2450 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [7, +inf] + [-inf, 495] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2481 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [7, +inf] + [-inf, 495] + Position.At(location=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2502 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [7, +inf] + [-inf, 495] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=2524 Master=2244 CHAMP.ipsettarget(2244)[7, 495] --> [8, 496] + [7, +inf] + [7, 495] + CHAMP.ipsettarget(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2614 Master=2408 CHAMP.IPHaveName(2408)[6, 494] --> [7, 495] + [8, +inf] + [-inf, 492] + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=2691 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [5, 493] + [6, 494] + CHAMP.IPHaveName(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2710 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [7, +inf] + [-inf, 493] + Target.Tracked(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=2731 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [6, +inf] + [-inf, 493] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2762 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [6, +inf] + [-inf, 493] + Position.At(location=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=2783 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [6, +inf] + [-inf, 493] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=2805 Master=2581 CHAMP.ipgetname(2581)[5, 493] --> [6, 494] + [6, +inf] + [-inf, 491] + Tracker.StartTracking(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=3150 Master=896 Tracker.TrackingOn(896)[4, 492] --> [12, +inf] + [4, 492] +Inactive Tokens: ************************* + [-inf, -1] + Position.navigate(from=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88)}to=Location:CLOSED{start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=801 Master=517 a(517){0} --> [4, 492] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1023 Master=644 nt_L0_target(644){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1056 Master=644 nt_L0_target(644){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1097 Master=668 nt_L1_target(668){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1130 Master=668 nt_L1_target(668){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1171 Master=692 nt_L2_target(692){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1204 Master=692 nt_L2_target(692){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1245 Master=716 nt_L3_target(716){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1278 Master=716 nt_L3_target(716){0} --> [1, 500] + {0} + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1352 Master=740 nt_L4_target(740){0} --> [2, 490] + {0} + [12, +inf] + Target.trackstop(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1603 Master=865 Target.Tracked(865)[3, 491] --> [12, +inf] + [13, +inf] + [12, +inf] + Tracker.trackfreeze(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1679 Master=896 Tracker.TrackingOn(896)[4, 492] --> [12, +inf] + [13, +inf] + [12, +inf] + Position.navigate(from=Location:CLOSED{L4(88)}to=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=1733 Master=917 Position.At(917)[5, 493] --> [12, +inf] + [13, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-k9.backtrack.moderate-transaction.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-k9.backtrack.moderate-transaction.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..e056f34c8 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-k9.backtrack.moderate-transaction.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,1290 @@ +Created node [id_538] initially enabled +Created node [id_539] initially enabled +Maximum flow instance created with source [id_538] and sink [id_539] +Created node [id_538] initially enabled +Created node [id_539] initially enabled +Maximum flow instance created with source [id_538] and sink [id_539] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[500, 500] + world.m_maxPlannerSteps=int:CLOSED[1000, 1000] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Variables ************************* + rover.BATTERY_MIN=float:CLOSED[0, 0] + rover.BATTERY_MAX=float:CLOSED[518400, 518400] + rover.m_position=Position:CLOSED{rover.m_position(33)} + rover.m_tracker=Tracker:CLOSED{rover.m_tracker(39)} + rover.m_oppsci=OpportunisticScience:CLOSED{rover.m_oppsci(45)} + rover.m_champ=CHAMP:CLOSED{rover.m_champ(51)} + rover.m_energy=Energy:CLOSED{rover.m_energy(61)} + End Variables ********************* + End Rover:rover************************* + Position:rover.m_position************************* + Tokens ************************* + {0} + Position.At(location=Location:CLOSED{start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=517 Master=NONE + Merged Key=1413 from Position.navigate(766)[4, 498] --> [5, 499] + [4, 498] + [4, 498] + Position.navigate(from=Location:CLOSED{start(103)}to=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=766 Master=517 a(517){0} --> [4, 498] + Merged Key=1754 from Position.At(917)[5, 499] --> [6, +inf] + [5, 499] + [5, 499] + Position.At(location=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{FLUENT}) + Key=917 Master=541 ipg(541)[5, 499] --> [6, 500] + Merged Key=1392 from Position.navigate(766)[4, 498] --> [5, 499] + [6, +inf] + End Tokens ********************* + Variables ************************* + rover.m_position.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End Position:rover.m_position************************* + Tracker:rover.m_tracker************************* + Tokens ************************* + {0} + Tracker.TrackingOff(TYPE=Types:CLOSED{FLUENT}) + Key=578 Master=NONE + Merged Key=1825 from Tracker.trackloadgroup(976)[1, 495] --> [2, 496] + [1, 495] + [1, 495] + Tracker.trackloadgroup(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=976 Master=578 toff(578){0} --> [1, 495] + Merged Key=1977 from Tracker.LandmarksDefined(1806)[2, 496] --> [3, 497] + [2, 496] + [2, 496] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=1806 Master=976 Tracker.trackloadgroup(976)[1, 495] --> [2, 496] + Merged Key=1898 from Target.trackstart(1311)[2, 496] --> [3, 497] + Merged Key=2073 from Tracker.StartTracking(2008)[3, 497] --> [4, 498] + [3, 497] + [3, 497] + Tracker.StartTracking(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2008 Master=1806 Tracker.LandmarksDefined(1806)[2, 496] --> [3, 497] + Merged Key=2356 from Tracker.TrackingOn(896)[4, 498] --> [6, +inf] + [4, 498] + [4, 498] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=896 Master=541 ipg(541)[5, 499] --> [6, 500] + Merged Key=1435 from Position.navigate(766)[4, 498] --> [5, 499] + Merged Key=2092 from Tracker.StartTracking(2008)[3, 497] --> [4, 498] + [6, +inf] + End Tokens ********************* + Variables ************************* + rover.m_tracker.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End Tracker:rover.m_tracker************************* + OpportunisticScience:rover.m_oppsci************************* + Tokens ************************* + {0} + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=600 Master=NONE + Merged Key=939 from ipg(541)[5, 499] --> [6, 500] + Merged Key=1456 from Position.navigate(766)[4, 498] --> [5, 499] + [6, 500] + End Tokens ********************* + Variables ************************* + rover.m_oppsci.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End OpportunisticScience:rover.m_oppsci************************* + CHAMP:rover.m_champ************************* + Tokens ************************* + [5, 499] + CHAMP.ipgetstatus(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=541 Master=NONE + Merged Key=1550 from CHAMP.IPDonePlaceInstrument(844)[-inf, 498] --> [5, 499] + [6, 500] + {0} + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=622 Master=NONE + Merged Key=1477 from Position.navigate(766)[4, 498] --> [5, 499] + [5, 500] + [-inf, 498] + CHAMP.IPDonePlaceInstrument(target=Target:CLOSED{L0_target(106)}at_loc=Location:CLOSED{D14(79)}TYPE=Types:CLOSED{FLUENT}) + Key=844 Master=541 ipg(541)[5, 499] --> [6, 500] + [5, 499] + End Tokens ********************* + Variables ************************* + rover.m_champ.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End CHAMP:rover.m_champ************************* + Energy:rover.m_energy************************* + Variables ************************* + rover.m_energy.initialCapacity=float:CLOSED[1000, 1000] + rover.m_energy.levelLimitMin=float:CLOSED[0, 0] + rover.m_energy.levelLimitMax=float:CLOSED[518400, 518400] + rover.m_energy.productionRateMax=float:CLOSED[+inf, +inf] + rover.m_energy.productionMax=float:CLOSED[+inf, +inf] + rover.m_energy.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.m_energy.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Energy:rover.m_energy************************* + Location:D14************************* + End Location:D14************************* + Location:D13************************* + End Location:D13************************* + Location:C1************************* + End Location:C1************************* + Location:L4************************* + End Location:L4************************* + Location:L3************************* + End Location:L3************************* + Location:L2************************* + End Location:L2************************* + Location:L1************************* + End Location:L1************************* + Location:L0************************* + End Location:L0************************* + Location:start************************* + End Location:start************************* + Target:L0_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{FLUENT}) + Key=644 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L0_target************************* + CHAMP_Accessable:ch_L0_target************************* + Variables ************************* + ch_L0_target.m_from=Location:CLOSED{L0(100)} + ch_L0_target.m_to=Target:CLOSED{L0_target(106)} + End Variables ********************* + End CHAMP_Accessable:ch_L0_target************************* + OppSci_Accessable:op_L0_target************************* + Variables ************************* + op_L0_target.m_from=Location:CLOSED{L0(100)} + op_L0_target.m_to=Target:CLOSED{L0_target(106)} + End Variables ********************* + End OppSci_Accessable:op_L0_target************************* + Target:L1_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{FLUENT}) + Key=668 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L1_target************************* + CHAMP_Accessable:ch_L1_target************************* + Variables ************************* + ch_L1_target.m_from=Location:CLOSED{L1(97)} + ch_L1_target.m_to=Target:CLOSED{L1_target(127)} + End Variables ********************* + End CHAMP_Accessable:ch_L1_target************************* + OppSci_Accessable:op_L1_target************************* + Variables ************************* + op_L1_target.m_from=Location:CLOSED{L1(97)} + op_L1_target.m_to=Target:CLOSED{L1_target(127)} + End Variables ********************* + End OppSci_Accessable:op_L1_target************************* + Target:L2_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{FLUENT}) + Key=692 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L2_target************************* + CHAMP_Accessable:ch_L2_target************************* + Variables ************************* + ch_L2_target.m_from=Location:CLOSED{L2(94)} + ch_L2_target.m_to=Target:CLOSED{L2_target(148)} + End Variables ********************* + End CHAMP_Accessable:ch_L2_target************************* + OppSci_Accessable:op_L2_target************************* + Variables ************************* + op_L2_target.m_from=Location:CLOSED{L2(94)} + op_L2_target.m_to=Target:CLOSED{L2_target(148)} + End Variables ********************* + End OppSci_Accessable:op_L2_target************************* + Target:L3_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{FLUENT}) + Key=716 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L3_target************************* + CHAMP_Accessable:ch_L3_target************************* + Variables ************************* + ch_L3_target.m_from=Location:CLOSED{L3(91)} + ch_L3_target.m_to=Target:CLOSED{L3_target(169)} + End Variables ********************* + End CHAMP_Accessable:ch_L3_target************************* + OppSci_Accessable:op_L3_target************************* + Variables ************************* + op_L3_target.m_from=Location:CLOSED{L3(91)} + op_L3_target.m_to=Target:CLOSED{L3_target(169)} + End Variables ********************* + End OppSci_Accessable:op_L3_target************************* + Target:L4_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=740 Master=NONE + Merged Key=1877 from Target.trackstart(1311)[2, 496] --> [3, 497] + [2, 496] + [2, 496] + Target.trackstart(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1311 Master=740 nt_L4_target(740){0} --> [2, 496] + Merged Key=1622 from Target.Tracked(865)[3, 497] --> [6, +inf] + [3, 497] + [3, 497] + Target.Tracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=865 Master=541 ipg(541)[5, 499] --> [6, 500] + Merged Key=1856 from Target.trackstart(1311)[2, 496] --> [3, 497] + [6, +inf] + End Tokens ********************* + End Target:L4_target************************* + CHAMP_Accessable:ch_L4_target************************* + Variables ************************* + ch_L4_target.m_from=Location:CLOSED{L4(88)} + ch_L4_target.m_to=Target:CLOSED{L4_target(190)} + End Variables ********************* + End CHAMP_Accessable:ch_L4_target************************* + OppSci_Accessable:op_L4_target************************* + Variables ************************* + op_L4_target.m_from=Location:CLOSED{L4(88)} + op_L4_target.m_to=Target:CLOSED{L4_target(190)} + End Variables ********************* + End OppSci_Accessable:op_L4_target************************* + Path:L4D14************************* + Variables ************************* + L4D14.m_from=Location:CLOSED{L4(88)} + L4D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L4D14************************* + Path:D14L4************************* + Variables ************************* + D14L4.m_from=Location:CLOSED{D14(79)} + D14L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:D14L4************************* + Path:L2D13************************* + Variables ************************* + L2D13.m_from=Location:CLOSED{L2(94)} + L2D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L2D13************************* + Path:D13L2************************* + Variables ************************* + D13L2.m_from=Location:CLOSED{D13(82)} + D13L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:D13L2************************* + Path:C1D14************************* + Variables ************************* + C1D14.m_from=Location:CLOSED{C1(85)} + C1D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:C1D14************************* + Path:D14C1************************* + Variables ************************* + D14C1.m_from=Location:CLOSED{D14(79)} + D14C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:D14C1************************* + Path:L3D14************************* + Variables ************************* + L3D14.m_from=Location:CLOSED{L3(91)} + L3D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L3D14************************* + Path:D14L3************************* + Variables ************************* + D14L3.m_from=Location:CLOSED{D14(79)} + D14L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:D14L3************************* + Path:D14L1************************* + Variables ************************* + D14L1.m_from=Location:CLOSED{D14(79)} + D14L1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:D14L1************************* + Path:L1D14************************* + Variables ************************* + L1D14.m_from=Location:CLOSED{L1(97)} + L1D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L1D14************************* + Path:C1D13************************* + Variables ************************* + C1D13.m_from=Location:CLOSED{C1(85)} + C1D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:C1D13************************* + Path:D13C1************************* + Variables ************************* + D13C1.m_from=Location:CLOSED{D13(82)} + D13C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:D13C1************************* + Path:L4D13************************* + Variables ************************* + L4D13.m_from=Location:CLOSED{L4(88)} + L4D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L4D13************************* + Path:D13L4************************* + Variables ************************* + D13L4.m_from=Location:CLOSED{D13(82)} + D13L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:D13L4************************* + Path:D13L0************************* + Variables ************************* + D13L0.m_from=Location:CLOSED{D13(82)} + D13L0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:D13L0************************* + Path:L0D13************************* + Variables ************************* + L0D13.m_from=Location:CLOSED{L0(100)} + L0D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L0D13************************* + Path:L4C1************************* + Variables ************************* + L4C1.m_from=Location:CLOSED{L4(88)} + L4C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L4C1************************* + Path:C1L3************************* + Variables ************************* + C1L3.m_from=Location:CLOSED{C1(85)} + C1L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:C1L3************************* + Path:L3C1************************* + Variables ************************* + L3C1.m_from=Location:CLOSED{L3(91)} + L3C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L3C1************************* + Path:C1L4************************* + Variables ************************* + C1L4.m_from=Location:CLOSED{C1(85)} + C1L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:C1L4************************* + Path:C1L2************************* + Variables ************************* + C1L2.m_from=Location:CLOSED{C1(85)} + C1L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:C1L2************************* + Path:L2C1************************* + Variables ************************* + L2C1.m_from=Location:CLOSED{L2(94)} + L2C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L2C1************************* + Path:L4L1************************* + Variables ************************* + L4L1.m_from=Location:CLOSED{L4(88)} + L4L1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:L4L1************************* + Path:L1L4************************* + Variables ************************* + L1L4.m_from=Location:CLOSED{L1(97)} + L1L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:L1L4************************* + Path:L4start************************* + Variables ************************* + L4start.m_from=Location:CLOSED{L4(88)} + L4start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L4start************************* + Path:startL4************************* + Variables ************************* + startL4.m_from=Location:CLOSED{start(103)} + startL4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:startL4************************* + Path:L3L2************************* + Variables ************************* + L3L2.m_from=Location:CLOSED{L3(91)} + L3L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:L3L2************************* + Path:L2L3************************* + Variables ************************* + L2L3.m_from=Location:CLOSED{L2(94)} + L2L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:L2L3************************* + Path:L2L0************************* + Variables ************************* + L2L0.m_from=Location:CLOSED{L2(94)} + L2L0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:L2L0************************* + Path:L0L2************************* + Variables ************************* + L0L2.m_from=Location:CLOSED{L0(100)} + L0L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:L0L2************************* + Path:L1start************************* + Variables ************************* + L1start.m_from=Location:CLOSED{L1(97)} + L1start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L1start************************* + Path:startL1************************* + Variables ************************* + startL1.m_from=Location:CLOSED{start(103)} + startL1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:startL1************************* + Path:L0start************************* + Variables ************************* + L0start.m_from=Location:CLOSED{L0(100)} + L0start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L0start************************* + Path:startL0************************* + Variables ************************* + startL0.m_from=Location:CLOSED{start(103)} + startL0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:startL0************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(25)} + D14=Location:CLOSED{D14(79)} + D13=Location:CLOSED{D13(82)} + C1=Location:CLOSED{C1(85)} + L4=Location:CLOSED{L4(88)} + L3=Location:CLOSED{L3(91)} + L2=Location:CLOSED{L2(94)} + L1=Location:CLOSED{L1(97)} + L0=Location:CLOSED{L0(100)} + start=Location:CLOSED{start(103)} + L0_target=Target:CLOSED{L0_target(106)} + ch_L0_target=CHAMP_Accessable:CLOSED{ch_L0_target(111)} + op_L0_target=OppSci_Accessable:CLOSED{op_L0_target(120)} + L1_target=Target:CLOSED{L1_target(127)} + ch_L1_target=CHAMP_Accessable:CLOSED{ch_L1_target(132)} + op_L1_target=OppSci_Accessable:CLOSED{op_L1_target(141)} + L2_target=Target:CLOSED{L2_target(148)} + ch_L2_target=CHAMP_Accessable:CLOSED{ch_L2_target(153)} + op_L2_target=OppSci_Accessable:CLOSED{op_L2_target(162)} + L3_target=Target:CLOSED{L3_target(169)} + ch_L3_target=CHAMP_Accessable:CLOSED{ch_L3_target(174)} + op_L3_target=OppSci_Accessable:CLOSED{op_L3_target(183)} + L4_target=Target:CLOSED{L4_target(190)} + ch_L4_target=CHAMP_Accessable:CLOSED{ch_L4_target(195)} + op_L4_target=OppSci_Accessable:CLOSED{op_L4_target(204)} + L4D14=Path:CLOSED{L4D14(213)} + D14L4=Path:CLOSED{D14L4(222)} + L2D13=Path:CLOSED{L2D13(231)} + D13L2=Path:CLOSED{D13L2(240)} + C1D14=Path:CLOSED{C1D14(249)} + D14C1=Path:CLOSED{D14C1(258)} + L3D14=Path:CLOSED{L3D14(267)} + D14L3=Path:CLOSED{D14L3(276)} + D14L1=Path:CLOSED{D14L1(285)} + L1D14=Path:CLOSED{L1D14(294)} + C1D13=Path:CLOSED{C1D13(303)} + D13C1=Path:CLOSED{D13C1(312)} + L4D13=Path:CLOSED{L4D13(321)} + D13L4=Path:CLOSED{D13L4(330)} + D13L0=Path:CLOSED{D13L0(339)} + L0D13=Path:CLOSED{L0D13(348)} + L4C1=Path:CLOSED{L4C1(357)} + C1L3=Path:CLOSED{C1L3(366)} + L3C1=Path:CLOSED{L3C1(375)} + C1L4=Path:CLOSED{C1L4(384)} + C1L2=Path:CLOSED{C1L2(393)} + L2C1=Path:CLOSED{L2C1(402)} + L4L1=Path:CLOSED{L4L1(411)} + L1L4=Path:CLOSED{L1L4(420)} + L4start=Path:CLOSED{L4start(429)} + startL4=Path:CLOSED{startL4(438)} + L3L2=Path:CLOSED{L3L2(447)} + L2L3=Path:CLOSED{L2L3(456)} + L2L0=Path:CLOSED{L2L0(465)} + L0L2=Path:CLOSED{L0L2(474)} + L1start=Path:CLOSED{L1start(483)} + startL1=Path:CLOSED{startL1(492)} + L0start=Path:CLOSED{L0start(501)} + startL0=Path:CLOSED{startL0(510)} +Merged Tokens: ************************* + [-inf, 499] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=939 Master=541 ipg(541)[5, 499] --> [6, 500] + [3, +inf] + [2, 499] + Position.At(location=Location:CLOSED{L0(100),L1(97),L4(88)}TYPE=Types:CLOSED{FLUENT}) + Key=1392 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [3, +inf] + [-inf, 497] + Position.At(location=Location:CLOSED{start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=1413 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [1, 498] + [-inf, 498] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=1435 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [2, +inf] + [-inf, 498] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=1456 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [3, +inf] + [-inf, 498] + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=1477 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [3, +inf] + [3, 499] + CHAMP.ipgetstatus(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1550 Master=844 CHAMP.IPDonePlaceInstrument(844)[-inf, 498] --> [5, 499] + [4, +inf] + [-inf, 498] + Target.trackstart(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1622 Master=865 Target.Tracked(865)[3, 497] --> [6, +inf] + [2, 499] + [-inf, 498] + Position.navigate(from=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}to=Location:CLOSED{L0(100),L1(97),L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=1754 Master=917 Position.At(917)[5, 499] --> [6, +inf] + [3, 499] + [-inf, 495] + Tracker.TrackingOff(TYPE=Types:CLOSED{FLUENT}) + Key=1825 Master=976 Tracker.trackloadgroup(976)[1, 495] --> [2, 496] + [1, 496] + [2, 499] + Target.Tracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=1856 Master=1311 Target.trackstart(1311)[2, 496] --> [3, 497] + [3, +inf] + [-inf, 497] + Target.NotTracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=1877 Master=1311 Target.trackstart(1311)[2, 496] --> [3, 497] + [1, 498] + [-inf, 498] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=1898 Master=1311 Target.trackstart(1311)[2, 496] --> [3, 497] + [2, +inf] + [-inf, 496] + Tracker.trackloadgroup(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1977 Master=1806 Tracker.LandmarksDefined(1806)[2, 496] --> [3, 497] + [2, 497] + [-inf, 496] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=2073 Master=2008 Tracker.StartTracking(2008)[3, 497] --> [4, 498] + [3, 497] + [4, 498] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2092 Master=2008 Tracker.StartTracking(2008)[3, 497] --> [4, 498] + [5, +inf] + [-inf, 497] + Tracker.StartTracking(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2356 Master=896 Tracker.TrackingOn(896)[4, 498] --> [6, +inf] + [4, 498] +Inactive Tokens: ************************* + [-inf, -1] + Position.navigate(from=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88)}to=Location:CLOSED{start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=801 Master=517 a(517){0} --> [4, 498] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1015 Master=644 nt_L0_target(644){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1048 Master=644 nt_L0_target(644){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1089 Master=668 nt_L1_target(668){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1122 Master=668 nt_L1_target(668){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1163 Master=692 nt_L2_target(692){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1196 Master=692 nt_L2_target(692){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1237 Master=716 nt_L3_target(716){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1270 Master=716 nt_L3_target(716){0} --> [1, 500] + {0} + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1344 Master=740 nt_L4_target(740){0} --> [2, 496] + {0} + [-inf, 497] + CHAMP.ipplaceinstrument(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1517 Master=844 CHAMP.IPDonePlaceInstrument(844)[-inf, 498] --> [5, 499] + [-inf, 498] + [6, +inf] + Target.trackstop(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1589 Master=865 Target.Tracked(865)[3, 497] --> [6, +inf] + [7, +inf] + [6, +inf] + Tracker.trackfreeze(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1665 Master=896 Tracker.TrackingOn(896)[4, 498] --> [6, +inf] + [7, +inf] + [6, +inf] + Position.navigate(from=Location:CLOSED{L4(88)}to=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=1719 Master=917 Position.At(917)[5, 499] --> [6, +inf] + [7, +inf] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[500, 500] + world.m_maxPlannerSteps=int:CLOSED[1000, 1000] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Rover:rover************************* + Variables ************************* + rover.BATTERY_MIN=float:CLOSED[0, 0] + rover.BATTERY_MAX=float:CLOSED[518400, 518400] + rover.m_position=Position:CLOSED{rover.m_position(33)} + rover.m_tracker=Tracker:CLOSED{rover.m_tracker(39)} + rover.m_oppsci=OpportunisticScience:CLOSED{rover.m_oppsci(45)} + rover.m_champ=CHAMP:CLOSED{rover.m_champ(51)} + rover.m_energy=Energy:CLOSED{rover.m_energy(61)} + End Variables ********************* + End Rover:rover************************* + Position:rover.m_position************************* + Tokens ************************* + {0} + Position.At(location=Location:CLOSED{start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=517 Master=NONE + Merged Key=1413 from Position.navigate(766)[4, 498] --> [5, 499] + [4, 498] + [4, 498] + Position.navigate(from=Location:CLOSED{start(103)}to=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=766 Master=517 a(517){0} --> [4, 498] + Merged Key=1754 from Position.At(917)[5, 499] --> [6, +inf] + [5, 499] + [5, 499] + Position.At(location=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{FLUENT}) + Key=917 Master=541 ipg(541)[5, 499] --> [6, 500] + Merged Key=1392 from Position.navigate(766)[4, 498] --> [5, 499] + [6, +inf] + End Tokens ********************* + Variables ************************* + rover.m_position.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End Position:rover.m_position************************* + Tracker:rover.m_tracker************************* + Tokens ************************* + {0} + Tracker.TrackingOff(TYPE=Types:CLOSED{FLUENT}) + Key=578 Master=NONE + Merged Key=1825 from Tracker.trackloadgroup(976)[1, 495] --> [2, 496] + [1, 495] + [1, 495] + Tracker.trackloadgroup(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=976 Master=578 toff(578){0} --> [1, 495] + Merged Key=1977 from Tracker.LandmarksDefined(1806)[2, 496] --> [3, 497] + [2, 496] + [2, 496] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=1806 Master=976 Tracker.trackloadgroup(976)[1, 495] --> [2, 496] + Merged Key=1898 from Target.trackstart(1311)[2, 496] --> [3, 497] + Merged Key=2073 from Tracker.StartTracking(2008)[3, 497] --> [4, 498] + [3, 497] + [3, 497] + Tracker.StartTracking(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2008 Master=1806 Tracker.LandmarksDefined(1806)[2, 496] --> [3, 497] + Merged Key=2356 from Tracker.TrackingOn(896)[4, 498] --> [6, +inf] + [4, 498] + [4, 498] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=896 Master=541 ipg(541)[5, 499] --> [6, 500] + Merged Key=1435 from Position.navigate(766)[4, 498] --> [5, 499] + Merged Key=2092 from Tracker.StartTracking(2008)[3, 497] --> [4, 498] + [6, +inf] + End Tokens ********************* + Variables ************************* + rover.m_tracker.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End Tracker:rover.m_tracker************************* + OpportunisticScience:rover.m_oppsci************************* + Tokens ************************* + {0} + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=600 Master=NONE + Merged Key=939 from ipg(541)[5, 499] --> [6, 500] + Merged Key=1456 from Position.navigate(766)[4, 498] --> [5, 499] + [6, 500] + End Tokens ********************* + Variables ************************* + rover.m_oppsci.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End OpportunisticScience:rover.m_oppsci************************* + CHAMP:rover.m_champ************************* + Tokens ************************* + [5, 499] + CHAMP.ipgetstatus(target=Target:CLOSED{L4_target(190)}at_loc=Location:CLOSED{L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=541 Master=NONE + Merged Key=1550 from CHAMP.IPDonePlaceInstrument(844)[-inf, 498] --> [5, 499] + [6, 500] + {0} + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=622 Master=NONE + Merged Key=1477 from Position.navigate(766)[4, 498] --> [5, 499] + [5, 500] + [-inf, 498] + CHAMP.IPDonePlaceInstrument(target=Target:CLOSED{L0_target(106)}at_loc=Location:CLOSED{D14(79)}TYPE=Types:CLOSED{FLUENT}) + Key=844 Master=541 ipg(541)[5, 499] --> [6, 500] + [5, 499] + End Tokens ********************* + Variables ************************* + rover.m_champ.m_rover=Rover:CLOSED{rover(25)} + End Variables ********************* + End CHAMP:rover.m_champ************************* + Energy:rover.m_energy************************* + Variables ************************* + rover.m_energy.initialCapacity=float:CLOSED[1000, 1000] + rover.m_energy.levelLimitMin=float:CLOSED[0, 0] + rover.m_energy.levelLimitMax=float:CLOSED[518400, 518400] + rover.m_energy.productionRateMax=float:CLOSED[+inf, +inf] + rover.m_energy.productionMax=float:CLOSED[+inf, +inf] + rover.m_energy.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.m_energy.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Energy:rover.m_energy************************* + Location:D14************************* + End Location:D14************************* + Location:D13************************* + End Location:D13************************* + Location:C1************************* + End Location:C1************************* + Location:L4************************* + End Location:L4************************* + Location:L3************************* + End Location:L3************************* + Location:L2************************* + End Location:L2************************* + Location:L1************************* + End Location:L1************************* + Location:L0************************* + End Location:L0************************* + Location:start************************* + End Location:start************************* + Target:L0_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{FLUENT}) + Key=644 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L0_target************************* + CHAMP_Accessable:ch_L0_target************************* + Variables ************************* + ch_L0_target.m_from=Location:CLOSED{L0(100)} + ch_L0_target.m_to=Target:CLOSED{L0_target(106)} + End Variables ********************* + End CHAMP_Accessable:ch_L0_target************************* + OppSci_Accessable:op_L0_target************************* + Variables ************************* + op_L0_target.m_from=Location:CLOSED{L0(100)} + op_L0_target.m_to=Target:CLOSED{L0_target(106)} + End Variables ********************* + End OppSci_Accessable:op_L0_target************************* + Target:L1_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{FLUENT}) + Key=668 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L1_target************************* + CHAMP_Accessable:ch_L1_target************************* + Variables ************************* + ch_L1_target.m_from=Location:CLOSED{L1(97)} + ch_L1_target.m_to=Target:CLOSED{L1_target(127)} + End Variables ********************* + End CHAMP_Accessable:ch_L1_target************************* + OppSci_Accessable:op_L1_target************************* + Variables ************************* + op_L1_target.m_from=Location:CLOSED{L1(97)} + op_L1_target.m_to=Target:CLOSED{L1_target(127)} + End Variables ********************* + End OppSci_Accessable:op_L1_target************************* + Target:L2_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{FLUENT}) + Key=692 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L2_target************************* + CHAMP_Accessable:ch_L2_target************************* + Variables ************************* + ch_L2_target.m_from=Location:CLOSED{L2(94)} + ch_L2_target.m_to=Target:CLOSED{L2_target(148)} + End Variables ********************* + End CHAMP_Accessable:ch_L2_target************************* + OppSci_Accessable:op_L2_target************************* + Variables ************************* + op_L2_target.m_from=Location:CLOSED{L2(94)} + op_L2_target.m_to=Target:CLOSED{L2_target(148)} + End Variables ********************* + End OppSci_Accessable:op_L2_target************************* + Target:L3_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{FLUENT}) + Key=716 Master=NONE + [1, 500] + End Tokens ********************* + End Target:L3_target************************* + CHAMP_Accessable:ch_L3_target************************* + Variables ************************* + ch_L3_target.m_from=Location:CLOSED{L3(91)} + ch_L3_target.m_to=Target:CLOSED{L3_target(169)} + End Variables ********************* + End CHAMP_Accessable:ch_L3_target************************* + OppSci_Accessable:op_L3_target************************* + Variables ************************* + op_L3_target.m_from=Location:CLOSED{L3(91)} + op_L3_target.m_to=Target:CLOSED{L3_target(169)} + End Variables ********************* + End OppSci_Accessable:op_L3_target************************* + Target:L4_target************************* + Tokens ************************* + {0} + Target.NotTracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=740 Master=NONE + Merged Key=1877 from Target.trackstart(1311)[2, 496] --> [3, 497] + [2, 496] + [2, 496] + Target.trackstart(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1311 Master=740 nt_L4_target(740){0} --> [2, 496] + Merged Key=1622 from Target.Tracked(865)[3, 497] --> [6, +inf] + [3, 497] + [3, 497] + Target.Tracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=865 Master=541 ipg(541)[5, 499] --> [6, 500] + Merged Key=1856 from Target.trackstart(1311)[2, 496] --> [3, 497] + [6, +inf] + End Tokens ********************* + End Target:L4_target************************* + CHAMP_Accessable:ch_L4_target************************* + Variables ************************* + ch_L4_target.m_from=Location:CLOSED{L4(88)} + ch_L4_target.m_to=Target:CLOSED{L4_target(190)} + End Variables ********************* + End CHAMP_Accessable:ch_L4_target************************* + OppSci_Accessable:op_L4_target************************* + Variables ************************* + op_L4_target.m_from=Location:CLOSED{L4(88)} + op_L4_target.m_to=Target:CLOSED{L4_target(190)} + End Variables ********************* + End OppSci_Accessable:op_L4_target************************* + Path:L4D14************************* + Variables ************************* + L4D14.m_from=Location:CLOSED{L4(88)} + L4D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L4D14************************* + Path:D14L4************************* + Variables ************************* + D14L4.m_from=Location:CLOSED{D14(79)} + D14L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:D14L4************************* + Path:L2D13************************* + Variables ************************* + L2D13.m_from=Location:CLOSED{L2(94)} + L2D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L2D13************************* + Path:D13L2************************* + Variables ************************* + D13L2.m_from=Location:CLOSED{D13(82)} + D13L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:D13L2************************* + Path:C1D14************************* + Variables ************************* + C1D14.m_from=Location:CLOSED{C1(85)} + C1D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:C1D14************************* + Path:D14C1************************* + Variables ************************* + D14C1.m_from=Location:CLOSED{D14(79)} + D14C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:D14C1************************* + Path:L3D14************************* + Variables ************************* + L3D14.m_from=Location:CLOSED{L3(91)} + L3D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L3D14************************* + Path:D14L3************************* + Variables ************************* + D14L3.m_from=Location:CLOSED{D14(79)} + D14L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:D14L3************************* + Path:D14L1************************* + Variables ************************* + D14L1.m_from=Location:CLOSED{D14(79)} + D14L1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:D14L1************************* + Path:L1D14************************* + Variables ************************* + L1D14.m_from=Location:CLOSED{L1(97)} + L1D14.m_to=Location:CLOSED{D14(79)} + End Variables ********************* + End Path:L1D14************************* + Path:C1D13************************* + Variables ************************* + C1D13.m_from=Location:CLOSED{C1(85)} + C1D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:C1D13************************* + Path:D13C1************************* + Variables ************************* + D13C1.m_from=Location:CLOSED{D13(82)} + D13C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:D13C1************************* + Path:L4D13************************* + Variables ************************* + L4D13.m_from=Location:CLOSED{L4(88)} + L4D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L4D13************************* + Path:D13L4************************* + Variables ************************* + D13L4.m_from=Location:CLOSED{D13(82)} + D13L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:D13L4************************* + Path:D13L0************************* + Variables ************************* + D13L0.m_from=Location:CLOSED{D13(82)} + D13L0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:D13L0************************* + Path:L0D13************************* + Variables ************************* + L0D13.m_from=Location:CLOSED{L0(100)} + L0D13.m_to=Location:CLOSED{D13(82)} + End Variables ********************* + End Path:L0D13************************* + Path:L4C1************************* + Variables ************************* + L4C1.m_from=Location:CLOSED{L4(88)} + L4C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L4C1************************* + Path:C1L3************************* + Variables ************************* + C1L3.m_from=Location:CLOSED{C1(85)} + C1L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:C1L3************************* + Path:L3C1************************* + Variables ************************* + L3C1.m_from=Location:CLOSED{L3(91)} + L3C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L3C1************************* + Path:C1L4************************* + Variables ************************* + C1L4.m_from=Location:CLOSED{C1(85)} + C1L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:C1L4************************* + Path:C1L2************************* + Variables ************************* + C1L2.m_from=Location:CLOSED{C1(85)} + C1L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:C1L2************************* + Path:L2C1************************* + Variables ************************* + L2C1.m_from=Location:CLOSED{L2(94)} + L2C1.m_to=Location:CLOSED{C1(85)} + End Variables ********************* + End Path:L2C1************************* + Path:L4L1************************* + Variables ************************* + L4L1.m_from=Location:CLOSED{L4(88)} + L4L1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:L4L1************************* + Path:L1L4************************* + Variables ************************* + L1L4.m_from=Location:CLOSED{L1(97)} + L1L4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:L1L4************************* + Path:L4start************************* + Variables ************************* + L4start.m_from=Location:CLOSED{L4(88)} + L4start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L4start************************* + Path:startL4************************* + Variables ************************* + startL4.m_from=Location:CLOSED{start(103)} + startL4.m_to=Location:CLOSED{L4(88)} + End Variables ********************* + End Path:startL4************************* + Path:L3L2************************* + Variables ************************* + L3L2.m_from=Location:CLOSED{L3(91)} + L3L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:L3L2************************* + Path:L2L3************************* + Variables ************************* + L2L3.m_from=Location:CLOSED{L2(94)} + L2L3.m_to=Location:CLOSED{L3(91)} + End Variables ********************* + End Path:L2L3************************* + Path:L2L0************************* + Variables ************************* + L2L0.m_from=Location:CLOSED{L2(94)} + L2L0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:L2L0************************* + Path:L0L2************************* + Variables ************************* + L0L2.m_from=Location:CLOSED{L0(100)} + L0L2.m_to=Location:CLOSED{L2(94)} + End Variables ********************* + End Path:L0L2************************* + Path:L1start************************* + Variables ************************* + L1start.m_from=Location:CLOSED{L1(97)} + L1start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L1start************************* + Path:startL1************************* + Variables ************************* + startL1.m_from=Location:CLOSED{start(103)} + startL1.m_to=Location:CLOSED{L1(97)} + End Variables ********************* + End Path:startL1************************* + Path:L0start************************* + Variables ************************* + L0start.m_from=Location:CLOSED{L0(100)} + L0start.m_to=Location:CLOSED{start(103)} + End Variables ********************* + End Path:L0start************************* + Path:startL0************************* + Variables ************************* + startL0.m_from=Location:CLOSED{start(103)} + startL0.m_to=Location:CLOSED{L0(100)} + End Variables ********************* + End Path:startL0************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + rover=Rover:CLOSED{rover(25)} + D14=Location:CLOSED{D14(79)} + D13=Location:CLOSED{D13(82)} + C1=Location:CLOSED{C1(85)} + L4=Location:CLOSED{L4(88)} + L3=Location:CLOSED{L3(91)} + L2=Location:CLOSED{L2(94)} + L1=Location:CLOSED{L1(97)} + L0=Location:CLOSED{L0(100)} + start=Location:CLOSED{start(103)} + L0_target=Target:CLOSED{L0_target(106)} + ch_L0_target=CHAMP_Accessable:CLOSED{ch_L0_target(111)} + op_L0_target=OppSci_Accessable:CLOSED{op_L0_target(120)} + L1_target=Target:CLOSED{L1_target(127)} + ch_L1_target=CHAMP_Accessable:CLOSED{ch_L1_target(132)} + op_L1_target=OppSci_Accessable:CLOSED{op_L1_target(141)} + L2_target=Target:CLOSED{L2_target(148)} + ch_L2_target=CHAMP_Accessable:CLOSED{ch_L2_target(153)} + op_L2_target=OppSci_Accessable:CLOSED{op_L2_target(162)} + L3_target=Target:CLOSED{L3_target(169)} + ch_L3_target=CHAMP_Accessable:CLOSED{ch_L3_target(174)} + op_L3_target=OppSci_Accessable:CLOSED{op_L3_target(183)} + L4_target=Target:CLOSED{L4_target(190)} + ch_L4_target=CHAMP_Accessable:CLOSED{ch_L4_target(195)} + op_L4_target=OppSci_Accessable:CLOSED{op_L4_target(204)} + L4D14=Path:CLOSED{L4D14(213)} + D14L4=Path:CLOSED{D14L4(222)} + L2D13=Path:CLOSED{L2D13(231)} + D13L2=Path:CLOSED{D13L2(240)} + C1D14=Path:CLOSED{C1D14(249)} + D14C1=Path:CLOSED{D14C1(258)} + L3D14=Path:CLOSED{L3D14(267)} + D14L3=Path:CLOSED{D14L3(276)} + D14L1=Path:CLOSED{D14L1(285)} + L1D14=Path:CLOSED{L1D14(294)} + C1D13=Path:CLOSED{C1D13(303)} + D13C1=Path:CLOSED{D13C1(312)} + L4D13=Path:CLOSED{L4D13(321)} + D13L4=Path:CLOSED{D13L4(330)} + D13L0=Path:CLOSED{D13L0(339)} + L0D13=Path:CLOSED{L0D13(348)} + L4C1=Path:CLOSED{L4C1(357)} + C1L3=Path:CLOSED{C1L3(366)} + L3C1=Path:CLOSED{L3C1(375)} + C1L4=Path:CLOSED{C1L4(384)} + C1L2=Path:CLOSED{C1L2(393)} + L2C1=Path:CLOSED{L2C1(402)} + L4L1=Path:CLOSED{L4L1(411)} + L1L4=Path:CLOSED{L1L4(420)} + L4start=Path:CLOSED{L4start(429)} + startL4=Path:CLOSED{startL4(438)} + L3L2=Path:CLOSED{L3L2(447)} + L2L3=Path:CLOSED{L2L3(456)} + L2L0=Path:CLOSED{L2L0(465)} + L0L2=Path:CLOSED{L0L2(474)} + L1start=Path:CLOSED{L1start(483)} + startL1=Path:CLOSED{startL1(492)} + L0start=Path:CLOSED{L0start(501)} + startL0=Path:CLOSED{startL0(510)} +Merged Tokens: ************************* + [-inf, 499] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=939 Master=541 ipg(541)[5, 499] --> [6, 500] + [3, +inf] + [2, 499] + Position.At(location=Location:CLOSED{L0(100),L1(97),L4(88)}TYPE=Types:CLOSED{FLUENT}) + Key=1392 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [3, +inf] + [-inf, 497] + Position.At(location=Location:CLOSED{start(103)}TYPE=Types:CLOSED{FLUENT}) + Key=1413 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [1, 498] + [-inf, 498] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=1435 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [2, +inf] + [-inf, 498] + OpportunisticScience.OppSciIdle(TYPE=Types:CLOSED{FLUENT}) + Key=1456 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [3, +inf] + [-inf, 498] + CHAMP.IPIdle(TYPE=Types:CLOSED{FLUENT}) + Key=1477 Master=766 Position.navigate(766)[4, 498] --> [5, 499] + [3, +inf] + [3, 499] + CHAMP.ipgetstatus(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1550 Master=844 CHAMP.IPDonePlaceInstrument(844)[-inf, 498] --> [5, 499] + [4, +inf] + [-inf, 498] + Target.trackstart(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1622 Master=865 Target.Tracked(865)[3, 497] --> [6, +inf] + [2, 499] + [-inf, 498] + Position.navigate(from=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}to=Location:CLOSED{L0(100),L1(97),L4(88)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=1754 Master=917 Position.At(917)[5, 499] --> [6, +inf] + [3, 499] + [-inf, 495] + Tracker.TrackingOff(TYPE=Types:CLOSED{FLUENT}) + Key=1825 Master=976 Tracker.trackloadgroup(976)[1, 495] --> [2, 496] + [1, 496] + [2, 499] + Target.Tracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=1856 Master=1311 Target.trackstart(1311)[2, 496] --> [3, 497] + [3, +inf] + [-inf, 497] + Target.NotTracked(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{FLUENT}) + Key=1877 Master=1311 Target.trackstart(1311)[2, 496] --> [3, 497] + [1, 498] + [-inf, 498] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=1898 Master=1311 Target.trackstart(1311)[2, 496] --> [3, 497] + [2, +inf] + [-inf, 496] + Tracker.trackloadgroup(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1977 Master=1806 Tracker.LandmarksDefined(1806)[2, 496] --> [3, 497] + [2, 497] + [-inf, 496] + Tracker.LandmarksDefined(TYPE=Types:CLOSED{FLUENT}) + Key=2073 Master=2008 Tracker.StartTracking(2008)[3, 497] --> [4, 498] + [3, 497] + [4, 498] + Tracker.TrackingOn(TYPE=Types:CLOSED{FLUENT}) + Key=2092 Master=2008 Tracker.StartTracking(2008)[3, 497] --> [4, 498] + [5, +inf] + [-inf, 497] + Tracker.StartTracking(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=2356 Master=896 Tracker.TrackingOn(896)[4, 498] --> [6, +inf] + [4, 498] +Inactive Tokens: ************************* + [-inf, -1] + Position.navigate(from=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88)}to=Location:CLOSED{start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=801 Master=517 a(517){0} --> [4, 498] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1015 Master=644 nt_L0_target(644){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L0_target(106)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1048 Master=644 nt_L0_target(644){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1089 Master=668 nt_L1_target(668){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L1_target(127)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1122 Master=668 nt_L1_target(668){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1163 Master=692 nt_L2_target(692){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L2_target(148)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1196 Master=692 nt_L2_target(692){0} --> [1, 500] + {0} + [1, 500] + Target.trackstart(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1237 Master=716 nt_L3_target(716){0} --> [1, 500] + [2, +inf] + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L3_target(169)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1270 Master=716 nt_L3_target(716){0} --> [1, 500] + {0} + [-inf, -1] + Target.trackstop(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1344 Master=740 nt_L4_target(740){0} --> [2, 496] + {0} + [-inf, 497] + CHAMP.ipplaceinstrument(target=Target:CLOSED{L0_target(106),L1_target(127),L2_target(148),L3_target(169),L4_target(190)}at_loc=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),L4(88),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1517 Master=844 CHAMP.IPDonePlaceInstrument(844)[-inf, 498] --> [5, 499] + [-inf, 498] + [6, +inf] + Target.trackstop(target=Target:CLOSED{L4_target(190)}TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1589 Master=865 Target.Tracked(865)[3, 497] --> [6, +inf] + [7, +inf] + [6, +inf] + Tracker.trackfreeze(TYPE=Types:CLOSED{ACTION}m_duration_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std=float:CLOSED[0.000000000000000, 0.000000000000000]m_energy_mean=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std=float:CLOSED[0.000000000000000, 0.000000000000000]) + Key=1665 Master=896 Tracker.TrackingOn(896)[4, 498] --> [6, +inf] + [7, +inf] + [6, +inf] + Position.navigate(from=Location:CLOSED{L4(88)}to=Location:CLOSED{C1(85),D13(82),D14(79),L0(100),L1(97),L2(94),L3(91),start(103)}TYPE=Types:CLOSED{ACTION}m_duration_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_duration_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_mean_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]m_energy_std_multiplier=float:CLOSED[1.000000000000000, 1.000000000000000]) + Key=1719 Master=917 Position.At(917)[5, 499] --> [6, +inf] + [7, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-merge-with-open-domain.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-merge-with-open-domain.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..100ec7313 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-merge-with-open-domain.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,52 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Test:test************************* + Tokens ************************* + {0} + Test.Predicate(parameter=string:CLOSED{foo}first=bool:CLOSED[0, 0]qforce_backtrack=int:CLOSED[2, 2]) + Key=26 Master=NONE + {50} + End Tokens ********************* + End Test:test************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + test=Test:CLOSED{test(23)} +Inactive Tokens: ************************* + [-inf, -1] + Test.Predicate(parameter=string:CLOSED{foo}first=bool:CLOSED[0, 1]qforce_backtrack=int:CLOSED[3, 3]) + Key=60 Master=26 p(26){0} --> {50} + [-inf, 0] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Test:test************************* + Tokens ************************* + {0} + Test.Predicate(parameter=string:CLOSED{foo}first=bool:CLOSED[0, 0]qforce_backtrack=int:CLOSED[2, 2]) + Key=26 Master=NONE + {50} + End Tokens ********************* + End Test:test************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + test=Test:CLOSED{test(23)} +Inactive Tokens: ************************* + [-inf, -1] + Test.Predicate(parameter=string:CLOSED{foo}first=bool:CLOSED[0, 1]qforce_backtrack=int:CLOSED[3, 3]) + Key=60 Master=26 p(26){0} --> {50} + [-inf, 0] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-monkey1monkey-transaction.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-monkey1monkey-transaction.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..1329b8b76 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-monkey1monkey-transaction.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,286 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[200, 200] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Monkey_Class:Monkey1************************* + Variables ************************* + Monkey1.Location_SV=Monkey_Class___Location_SV:CLOSED{Monkey1.Location_SV(26)} + Monkey1.Altitude_SV=Monkey_Class___Altitude_SV:CLOSED{Monkey1.Altitude_SV(32)} + Monkey1.Banana_SV=Monkey_Class___Banana_SV:CLOSED{Monkey1.Banana_SV(38)} + End Variables ********************* + End Monkey_Class:Monkey1************************* + Monkey_Class___Location_SV:Monkey1.Location_SV************************* + Tokens ************************* + {0} + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Rock}) + Key=44 Master=NONE + Merged Key=2680 from Monkey_Class___Location_SV.Going(2185)[1, 177] --> [6, 182] + [1, 177] + [1, 177] + Monkey_Class___Location_SV.Going(From_Loc=Location_Label:CLOSED{Rock}To_Loc=Location_Label:CLOSED{Tree}) + Key=2185 Master=1530 Monkey_Class___Location_SV.At(1530)[6, 182] --> [18, 194] + [6, 182] + [6, 182] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Tree}) + Key=1530 Master=693 Monkey_Class___Location_SV.Going(693)[18, 194] --> [23, 199] + Merged Key=1625 from Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + Merged Key=2915 from Monkey_Class___Altitude_SV.CLIMBING(2634)[6, 182] --> [16, 192] + [18, 194] + [18, 194] + Monkey_Class___Location_SV.Going(From_Loc=Location_Label:CLOSED{Tree}To_Loc=Location_Label:CLOSED{Rock}) + Key=693 Master=65 finalLocation(65)[23, 199] --> {200} + [23, 199] + [23, 199] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Rock}) + Key=65 Master=NONE + {200} + End Tokens ********************* + Variables ************************* + Monkey1.Location_SV.__DDL__object=Monkey_Class:CLOSED{Monkey1(23)} + End Variables ********************* + End Monkey_Class___Location_SV:Monkey1.Location_SV************************* + Monkey_Class___Altitude_SV:Monkey1.Altitude_SV************************* + Tokens ************************* + {0} + Monkey_Class___Altitude_SV.LOW() + Key=86 Master=NONE + Merged Key=2699 from Monkey_Class___Location_SV.Going(2185)[1, 177] --> [6, 182] + Merged Key=2731 from Monkey_Class___Altitude_SV.CLIMBING(2634)[6, 182] --> [16, 192] + [6, 182] + [6, 182] + Monkey_Class___Altitude_SV.CLIMBING(_0_anon_OR_tag_1=int:CLOSED[2, 2]) + Key=2634 Master=1581 Monkey_Class___Altitude_SV.HIGH(1581)[16, 192] --> [17, 193] + [16, 192] + [16, 192] + Monkey_Class___Altitude_SV.HIGH() + Key=1581 Master=1476 Monkey_Class___Altitude_SV.CLIMBING_DOWN(1476)[17, 193] --> [18, 194] + Merged Key=1647 from Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [17, 193] + [17, 193] + Monkey_Class___Altitude_SV.CLIMBING_DOWN() + Key=1476 Master=104 finalHeight(104)[18, 194] --> {200} + [18, 194] + [18, 194] + Monkey_Class___Altitude_SV.LOW() + Key=104 Master=NONE + Merged Key=1549 from Monkey_Class___Location_SV.Going(693)[18, 194] --> [23, 199] + {200} + End Tokens ********************* + Variables ************************* + Monkey1.Altitude_SV.__DDL__object=Monkey_Class:CLOSED{Monkey1(23)} + End Variables ********************* + End Monkey_Class___Altitude_SV:Monkey1.Altitude_SV************************* + Monkey_Class___Banana_SV:Monkey1.Banana_SV************************* + Tokens ************************* + {0} + Monkey_Class___Banana_SV.NOT_HAVE_BANANA() + Key=122 Master=NONE + Merged Key=1608 from Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [16, 192] + [16, 192] + Monkey_Class___Banana_SV.GRABBING_BANANA() + Key=1505 Master=140 hasBanana(140)[17, 193] --> {200} + [17, 193] + [17, 193] + Monkey_Class___Banana_SV.HAVE_BANANA(Who=Monkey_Class:CLOSED{Monkey1(23)}) + Key=140 Master=NONE + {200} + End Tokens ********************* + Variables ************************* + Monkey1.Banana_SV.__DDL__object=Monkey_Class:CLOSED{Monkey1(23)} + End Variables ********************* + End Monkey_Class___Banana_SV:Monkey1.Banana_SV************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + Monkey1=Monkey_Class:CLOSED{Monkey1(23)} +Merged Tokens: ************************* + [-inf, 194] + Monkey_Class___Altitude_SV.LOW() + Key=1549 Master=693 Monkey_Class___Location_SV.Going(693)[18, 194] --> [23, 199] + [7, +inf] + [-inf, 197] + Monkey_Class___Banana_SV.NOT_HAVE_BANANA() + Key=1608 Master=1505 Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [1, 198] + [-inf, 198] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Tree}) + Key=1625 Master=1505 Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [2, +inf] + [-inf, 193] + Monkey_Class___Altitude_SV.HIGH() + Key=1647 Master=1505 Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [2, +inf] + [-inf, 186] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Rock,Tree}) + Key=2680 Master=2185 Monkey_Class___Location_SV.Going(2185)[1, 177] --> [6, 182] + [1, 187] + [-inf, 187] + Monkey_Class___Altitude_SV.LOW() + Key=2699 Master=2185 Monkey_Class___Location_SV.Going(2185)[1, 177] --> [6, 182] + [6, +inf] + [-inf, 181] + Monkey_Class___Altitude_SV.LOW() + Key=2731 Master=2634 Monkey_Class___Altitude_SV.CLIMBING(2634)[6, 182] --> [16, 192] + [6, 182] + [-inf, 182] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Tree}) + Key=2915 Master=2634 Monkey_Class___Altitude_SV.CLIMBING(2634)[6, 182] --> [16, 192] + [16, +inf] +Inactive Tokens: ************************* + [-inf, -5] + Monkey_Class___Location_SV.Going(From_Loc=Location_Label:CLOSED{Rock,Tree}To_Loc=Location_Label:CLOSED{Rock}) + Key=161 Master=44 initialLocation(44){0} --> [1, 177] + {0} + [-inf, -1] + Monkey_Class___Altitude_SV.CLIMBING_DOWN() + Key=721 Master=86 initialHeight(86){0} --> [6, 182] + {0} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[200, 200] + world.m_maxPlannerSteps=int:CLOSED[500, 500] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Monkey_Class:Monkey1************************* + Variables ************************* + Monkey1.Location_SV=Monkey_Class___Location_SV:CLOSED{Monkey1.Location_SV(26)} + Monkey1.Altitude_SV=Monkey_Class___Altitude_SV:CLOSED{Monkey1.Altitude_SV(32)} + Monkey1.Banana_SV=Monkey_Class___Banana_SV:CLOSED{Monkey1.Banana_SV(38)} + End Variables ********************* + End Monkey_Class:Monkey1************************* + Monkey_Class___Location_SV:Monkey1.Location_SV************************* + Tokens ************************* + {0} + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Rock}) + Key=44 Master=NONE + Merged Key=2680 from Monkey_Class___Location_SV.Going(2185)[1, 177] --> [6, 182] + [1, 177] + [1, 177] + Monkey_Class___Location_SV.Going(From_Loc=Location_Label:CLOSED{Rock}To_Loc=Location_Label:CLOSED{Tree}) + Key=2185 Master=1530 Monkey_Class___Location_SV.At(1530)[6, 182] --> [18, 194] + [6, 182] + [6, 182] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Tree}) + Key=1530 Master=693 Monkey_Class___Location_SV.Going(693)[18, 194] --> [23, 199] + Merged Key=1625 from Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + Merged Key=2915 from Monkey_Class___Altitude_SV.CLIMBING(2634)[6, 182] --> [16, 192] + [18, 194] + [18, 194] + Monkey_Class___Location_SV.Going(From_Loc=Location_Label:CLOSED{Tree}To_Loc=Location_Label:CLOSED{Rock}) + Key=693 Master=65 finalLocation(65)[23, 199] --> {200} + [23, 199] + [23, 199] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Rock}) + Key=65 Master=NONE + {200} + End Tokens ********************* + Variables ************************* + Monkey1.Location_SV.__DDL__object=Monkey_Class:CLOSED{Monkey1(23)} + End Variables ********************* + End Monkey_Class___Location_SV:Monkey1.Location_SV************************* + Monkey_Class___Altitude_SV:Monkey1.Altitude_SV************************* + Tokens ************************* + {0} + Monkey_Class___Altitude_SV.LOW() + Key=86 Master=NONE + Merged Key=2699 from Monkey_Class___Location_SV.Going(2185)[1, 177] --> [6, 182] + Merged Key=2731 from Monkey_Class___Altitude_SV.CLIMBING(2634)[6, 182] --> [16, 192] + [6, 182] + [6, 182] + Monkey_Class___Altitude_SV.CLIMBING(_0_anon_OR_tag_1=int:CLOSED[2, 2]) + Key=2634 Master=1581 Monkey_Class___Altitude_SV.HIGH(1581)[16, 192] --> [17, 193] + [16, 192] + [16, 192] + Monkey_Class___Altitude_SV.HIGH() + Key=1581 Master=1476 Monkey_Class___Altitude_SV.CLIMBING_DOWN(1476)[17, 193] --> [18, 194] + Merged Key=1647 from Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [17, 193] + [17, 193] + Monkey_Class___Altitude_SV.CLIMBING_DOWN() + Key=1476 Master=104 finalHeight(104)[18, 194] --> {200} + [18, 194] + [18, 194] + Monkey_Class___Altitude_SV.LOW() + Key=104 Master=NONE + Merged Key=1549 from Monkey_Class___Location_SV.Going(693)[18, 194] --> [23, 199] + {200} + End Tokens ********************* + Variables ************************* + Monkey1.Altitude_SV.__DDL__object=Monkey_Class:CLOSED{Monkey1(23)} + End Variables ********************* + End Monkey_Class___Altitude_SV:Monkey1.Altitude_SV************************* + Monkey_Class___Banana_SV:Monkey1.Banana_SV************************* + Tokens ************************* + {0} + Monkey_Class___Banana_SV.NOT_HAVE_BANANA() + Key=122 Master=NONE + Merged Key=1608 from Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [16, 192] + [16, 192] + Monkey_Class___Banana_SV.GRABBING_BANANA() + Key=1505 Master=140 hasBanana(140)[17, 193] --> {200} + [17, 193] + [17, 193] + Monkey_Class___Banana_SV.HAVE_BANANA(Who=Monkey_Class:CLOSED{Monkey1(23)}) + Key=140 Master=NONE + {200} + End Tokens ********************* + Variables ************************* + Monkey1.Banana_SV.__DDL__object=Monkey_Class:CLOSED{Monkey1(23)} + End Variables ********************* + End Monkey_Class___Banana_SV:Monkey1.Banana_SV************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + Monkey1=Monkey_Class:CLOSED{Monkey1(23)} +Merged Tokens: ************************* + [-inf, 194] + Monkey_Class___Altitude_SV.LOW() + Key=1549 Master=693 Monkey_Class___Location_SV.Going(693)[18, 194] --> [23, 199] + [7, +inf] + [-inf, 197] + Monkey_Class___Banana_SV.NOT_HAVE_BANANA() + Key=1608 Master=1505 Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [1, 198] + [-inf, 198] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Tree}) + Key=1625 Master=1505 Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [2, +inf] + [-inf, 193] + Monkey_Class___Altitude_SV.HIGH() + Key=1647 Master=1505 Monkey_Class___Banana_SV.GRABBING_BANANA(1505)[16, 192] --> [17, 193] + [2, +inf] + [-inf, 186] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Rock,Tree}) + Key=2680 Master=2185 Monkey_Class___Location_SV.Going(2185)[1, 177] --> [6, 182] + [1, 187] + [-inf, 187] + Monkey_Class___Altitude_SV.LOW() + Key=2699 Master=2185 Monkey_Class___Location_SV.Going(2185)[1, 177] --> [6, 182] + [6, +inf] + [-inf, 181] + Monkey_Class___Altitude_SV.LOW() + Key=2731 Master=2634 Monkey_Class___Altitude_SV.CLIMBING(2634)[6, 182] --> [16, 192] + [6, 182] + [-inf, 182] + Monkey_Class___Location_SV.At(Loc_Label=Location_Label:CLOSED{Tree}) + Key=2915 Master=2634 Monkey_Class___Altitude_SV.CLIMBING(2634)[6, 182] --> [16, 192] + [16, +inf] +Inactive Tokens: ************************* + [-inf, -5] + Monkey_Class___Location_SV.Going(From_Loc=Location_Label:CLOSED{Rock,Tree}To_Loc=Location_Label:CLOSED{Rock}) + Key=161 Master=44 initialLocation(44){0} --> [1, 177] + {0} + [-inf, -1] + Monkey_Class___Altitude_SV.CLIMBING_DOWN() + Key=721 Master=86 initialHeight(86){0} --> [6, 182] + {0} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-path-filter-transaction.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-path-filter-transaction.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..70eb2b1f7 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-path-filter-transaction.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,158 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[200, 200] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Location:rock************************* + Variables ************************* + rock.name=string:CLOSED{ROCK} + End Variables ********************* + End Location:rock************************* + Location:hill************************* + Variables ************************* + hill.name=string:CLOSED{HILL} + End Variables ********************* + End Location:hill************************* + Location:lander************************* + Variables ************************* + lander.name=string:CLOSED{LANDER} + End Variables ********************* + End Location:lander************************* + Location:martianCity************************* + Variables ************************* + martianCity.name=string:CLOSED{MARTIAN_CITY} + End Variables ********************* + End Location:martianCity************************* + Location:crater************************* + Variables ************************* + crater.name=string:CLOSED{CRATER} + End Variables ********************* + End Location:crater************************* + Path:p1************************* + Variables ************************* + p1.from=Location:CLOSED{rock(19)} + p1.to=Location:CLOSED{hill(26)} + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.from=Location:CLOSED{lander(33)} + p2.to=Location:CLOSED{hill(26)} + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.from=Location:CLOSED{martianCity(40)} + p3.to=Location:CLOSED{hill(26)} + End Variables ********************* + End Path:p3************************* + Path:p4************************* + Variables ************************* + p4.from=Location:CLOSED{hill(26)} + p4.to=Location:CLOSED{lander(33)} + End Variables ********************* + End Path:p4************************* + Rover:rover************************* + Tokens ************************* + {0} + Rover.Going(from=Location:CLOSED{hill(26)}to=Location:CLOSED{lander(33)}) + Key=91 Master=NONE + {100} + End Tokens ********************* + End Rover:rover************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(6)} + rock=Location:CLOSED{rock(19)} + hill=Location:CLOSED{hill(26)} + lander=Location:CLOSED{lander(33)} + martianCity=Location:CLOSED{martianCity(40)} + crater=Location:CLOSED{crater(47)} + p1=Path:CLOSED{p1(54)} + p2=Path:CLOSED{p2(63)} + p3=Path:CLOSED{p3(72)} + p4=Path:CLOSED{p4(81)} + rover=Rover:CLOSED{rover(88)} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[200, 200] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Location:rock************************* + Variables ************************* + rock.name=string:CLOSED{ROCK} + End Variables ********************* + End Location:rock************************* + Location:hill************************* + Variables ************************* + hill.name=string:CLOSED{HILL} + End Variables ********************* + End Location:hill************************* + Location:lander************************* + Variables ************************* + lander.name=string:CLOSED{LANDER} + End Variables ********************* + End Location:lander************************* + Location:martianCity************************* + Variables ************************* + martianCity.name=string:CLOSED{MARTIAN_CITY} + End Variables ********************* + End Location:martianCity************************* + Location:crater************************* + Variables ************************* + crater.name=string:CLOSED{CRATER} + End Variables ********************* + End Location:crater************************* + Path:p1************************* + Variables ************************* + p1.from=Location:CLOSED{rock(19)} + p1.to=Location:CLOSED{hill(26)} + End Variables ********************* + End Path:p1************************* + Path:p2************************* + Variables ************************* + p2.from=Location:CLOSED{lander(33)} + p2.to=Location:CLOSED{hill(26)} + End Variables ********************* + End Path:p2************************* + Path:p3************************* + Variables ************************* + p3.from=Location:CLOSED{martianCity(40)} + p3.to=Location:CLOSED{hill(26)} + End Variables ********************* + End Path:p3************************* + Path:p4************************* + Variables ************************* + p4.from=Location:CLOSED{hill(26)} + p4.to=Location:CLOSED{lander(33)} + End Variables ********************* + End Path:p4************************* + Rover:rover************************* + Tokens ************************* + {0} + Rover.Going(from=Location:CLOSED{hill(26)}to=Location:CLOSED{lander(33)}) + Key=91 Master=NONE + {100} + End Tokens ********************* + End Rover:rover************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(6)} + rock=Location:CLOSED{rock(19)} + hill=Location:CLOSED{hill(26)} + lander=Location:CLOSED{lander(33)} + martianCity=Location:CLOSED{martianCity(40)} + crater=Location:CLOSED{crater(47)} + p1=Path:CLOSED{p1(54)} + p2=Path:CLOSED{p2(63)} + p3=Path:CLOSED{p3(72)} + p4=Path:CLOSED{p4(81)} + rover=Rover:CLOSED{rover(88)} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-rejection.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-rejection.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..31c1f6af9 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-rejection.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,40 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[100, 100] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + rejection:r************************* + End rejection:r************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + r=rejection:CLOSED{r(23)} +Rejected Tokens: ************************* + {2} + rejection.unsatisfiable() + Key=26 Master=NONE + [3, +inf] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[10, 10] + world.m_maxPlannerSteps=int:CLOSED[100, 100] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + rejection:r************************* + End rejection:r************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + r=rejection:CLOSED{r(23)} +Rejected Tokens: ************************* + {2} + rejection.unsatisfiable() + Key=26 Master=NONE + [3, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-resource-backtrack-test-reservoir.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-resource-backtrack-test-reservoir.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..57d75d63e --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-resource-backtrack-test-reservoir.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,138 @@ +Created node [id_411] initially enabled +Created node [id_412] initially enabled +Maximum flow instance created with source [id_411] and sink [id_412] +Created node [id_411] initially enabled +Created node [id_412] initially enabled +Maximum flow instance created with source [id_411] and sink [id_412] +Created node [id_460] initially enabled +Created node [id_461] initially enabled +Maximum flow instance created with source [id_460] and sink [id_461] +Created node [id_460] initially enabled +Created node [id_461] initially enabled +Maximum flow instance created with source [id_460] and sink [id_461] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Battery:mainBattery************************* + Tokens ************************* + {0} + Battery.consume() + Key=175 Master=154 DriveSubsystem.Stroll(154){0} --> {100} + {0} + End Tokens ********************* + Variables ************************* + mainBattery.initialCapacity=float:CLOSED[30, 30] + mainBattery.levelLimitMin=float:CLOSED[0, 0] + mainBattery.levelLimitMax=float:CLOSED[50, 50] + mainBattery.productionRateMax=float:CLOSED[0, 0] + mainBattery.productionMax=float:CLOSED[0, 0] + mainBattery.consumptionRateMax=float:CLOSED[+inf, +inf] + mainBattery.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Battery:mainBattery************************* + Rover:rover************************* + Tokens ************************* + {0} + Rover.Move() + Key=77 Master=NONE + {100} + End Tokens ********************* + Variables ************************* + rover.dss=DriveSubsystem:CLOSED{rover.dss(58)} + rover.battery=Battery:CLOSED{mainBattery(33)} + rover.disk=Disk:CLOSED{rover.disk(62)} + End Variables ********************* + End Rover:rover************************* + DriveSubsystem:rover.dss************************* + Tokens ************************* + {0} + DriveSubsystem.Stroll() + Key=154 Master=77 goal1(77){0} --> {100} + {100} + End Tokens ********************* + End DriveSubsystem:rover.dss************************* + Disk:rover.disk************************* + Variables ************************* + rover.disk.initialCapacity=float:CLOSED[0, 0] + rover.disk.levelLimitMin=float:CLOSED[-inf, -inf] + rover.disk.levelLimitMax=float:CLOSED[+inf, +inf] + rover.disk.productionRateMax=float:CLOSED[+inf, +inf] + rover.disk.productionMax=float:CLOSED[+inf, +inf] + rover.disk.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.disk.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Disk:rover.disk************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + mainBattery=Battery:CLOSED{mainBattery(33)} + rover=Rover:CLOSED{rover(55)} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Battery:mainBattery************************* + Tokens ************************* + {0} + Battery.consume() + Key=175 Master=154 DriveSubsystem.Stroll(154){0} --> {100} + {0} + End Tokens ********************* + Variables ************************* + mainBattery.initialCapacity=float:CLOSED[30, 30] + mainBattery.levelLimitMin=float:CLOSED[0, 0] + mainBattery.levelLimitMax=float:CLOSED[50, 50] + mainBattery.productionRateMax=float:CLOSED[0, 0] + mainBattery.productionMax=float:CLOSED[0, 0] + mainBattery.consumptionRateMax=float:CLOSED[+inf, +inf] + mainBattery.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Battery:mainBattery************************* + Rover:rover************************* + Tokens ************************* + {0} + Rover.Move() + Key=77 Master=NONE + {100} + End Tokens ********************* + Variables ************************* + rover.dss=DriveSubsystem:CLOSED{rover.dss(58)} + rover.battery=Battery:CLOSED{mainBattery(33)} + rover.disk=Disk:CLOSED{rover.disk(62)} + End Variables ********************* + End Rover:rover************************* + DriveSubsystem:rover.dss************************* + Tokens ************************* + {0} + DriveSubsystem.Stroll() + Key=154 Master=77 goal1(77){0} --> {100} + {100} + End Tokens ********************* + End DriveSubsystem:rover.dss************************* + Disk:rover.disk************************* + Variables ************************* + rover.disk.initialCapacity=float:CLOSED[0, 0] + rover.disk.levelLimitMin=float:CLOSED[-inf, -inf] + rover.disk.levelLimitMax=float:CLOSED[+inf, +inf] + rover.disk.productionRateMax=float:CLOSED[+inf, +inf] + rover.disk.productionMax=float:CLOSED[+inf, +inf] + rover.disk.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.disk.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Disk:rover.disk************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + mainBattery=Battery:CLOSED{mainBattery(33)} + rover=Rover:CLOSED{rover(55)} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-resource-backtrack-test.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-resource-backtrack-test.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..57d75d63e --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-resource-backtrack-test.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,138 @@ +Created node [id_411] initially enabled +Created node [id_412] initially enabled +Maximum flow instance created with source [id_411] and sink [id_412] +Created node [id_411] initially enabled +Created node [id_412] initially enabled +Maximum flow instance created with source [id_411] and sink [id_412] +Created node [id_460] initially enabled +Created node [id_461] initially enabled +Maximum flow instance created with source [id_460] and sink [id_461] +Created node [id_460] initially enabled +Created node [id_461] initially enabled +Maximum flow instance created with source [id_460] and sink [id_461] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Battery:mainBattery************************* + Tokens ************************* + {0} + Battery.consume() + Key=175 Master=154 DriveSubsystem.Stroll(154){0} --> {100} + {0} + End Tokens ********************* + Variables ************************* + mainBattery.initialCapacity=float:CLOSED[30, 30] + mainBattery.levelLimitMin=float:CLOSED[0, 0] + mainBattery.levelLimitMax=float:CLOSED[50, 50] + mainBattery.productionRateMax=float:CLOSED[0, 0] + mainBattery.productionMax=float:CLOSED[0, 0] + mainBattery.consumptionRateMax=float:CLOSED[+inf, +inf] + mainBattery.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Battery:mainBattery************************* + Rover:rover************************* + Tokens ************************* + {0} + Rover.Move() + Key=77 Master=NONE + {100} + End Tokens ********************* + Variables ************************* + rover.dss=DriveSubsystem:CLOSED{rover.dss(58)} + rover.battery=Battery:CLOSED{mainBattery(33)} + rover.disk=Disk:CLOSED{rover.disk(62)} + End Variables ********************* + End Rover:rover************************* + DriveSubsystem:rover.dss************************* + Tokens ************************* + {0} + DriveSubsystem.Stroll() + Key=154 Master=77 goal1(77){0} --> {100} + {100} + End Tokens ********************* + End DriveSubsystem:rover.dss************************* + Disk:rover.disk************************* + Variables ************************* + rover.disk.initialCapacity=float:CLOSED[0, 0] + rover.disk.levelLimitMin=float:CLOSED[-inf, -inf] + rover.disk.levelLimitMax=float:CLOSED[+inf, +inf] + rover.disk.productionRateMax=float:CLOSED[+inf, +inf] + rover.disk.productionMax=float:CLOSED[+inf, +inf] + rover.disk.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.disk.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Disk:rover.disk************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + mainBattery=Battery:CLOSED{mainBattery(33)} + rover=Rover:CLOSED{rover(55)} +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[350, 350] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Battery:mainBattery************************* + Tokens ************************* + {0} + Battery.consume() + Key=175 Master=154 DriveSubsystem.Stroll(154){0} --> {100} + {0} + End Tokens ********************* + Variables ************************* + mainBattery.initialCapacity=float:CLOSED[30, 30] + mainBattery.levelLimitMin=float:CLOSED[0, 0] + mainBattery.levelLimitMax=float:CLOSED[50, 50] + mainBattery.productionRateMax=float:CLOSED[0, 0] + mainBattery.productionMax=float:CLOSED[0, 0] + mainBattery.consumptionRateMax=float:CLOSED[+inf, +inf] + mainBattery.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Battery:mainBattery************************* + Rover:rover************************* + Tokens ************************* + {0} + Rover.Move() + Key=77 Master=NONE + {100} + End Tokens ********************* + Variables ************************* + rover.dss=DriveSubsystem:CLOSED{rover.dss(58)} + rover.battery=Battery:CLOSED{mainBattery(33)} + rover.disk=Disk:CLOSED{rover.disk(62)} + End Variables ********************* + End Rover:rover************************* + DriveSubsystem:rover.dss************************* + Tokens ************************* + {0} + DriveSubsystem.Stroll() + Key=154 Master=77 goal1(77){0} --> {100} + {100} + End Tokens ********************* + End DriveSubsystem:rover.dss************************* + Disk:rover.disk************************* + Variables ************************* + rover.disk.initialCapacity=float:CLOSED[0, 0] + rover.disk.levelLimitMin=float:CLOSED[-inf, -inf] + rover.disk.levelLimitMax=float:CLOSED[+inf, +inf] + rover.disk.productionRateMax=float:CLOSED[+inf, +inf] + rover.disk.productionMax=float:CLOSED[+inf, +inf] + rover.disk.consumptionRateMax=float:CLOSED[+inf, +inf] + rover.disk.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End Disk:rover.disk************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + mainBattery=Battery:CLOSED{mainBattery(33)} + rover=Rover:CLOSED{rover(55)} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-reusable-test-transaction.nddl-ReusableTestConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-reusable-test-transaction.nddl-ReusableTestConfig.xml.out new file mode 100644 index 000000000..1be8c4abc --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-reusable-test-transaction.nddl-ReusableTestConfig.xml.out @@ -0,0 +1,130 @@ +Created node [id_371] initially enabled +Created node [id_372] initially enabled +Maximum flow instance created with source [id_371] and sink [id_372] +Created node [id_371] initially enabled +Created node [id_372] initially enabled +Maximum flow instance created with source [id_371] and sink [id_372] +Objects ************************* + PlannerConfig:config************************* + Variables ************************* + config.m_horizonStart=int:CLOSED[0, 0] + config.m_horizonEnd=int:CLOSED[100, 100] + config.m_maxPlannerSteps=int:CLOSED[100, 100] + config.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:config************************* + IntermediateReusable:programmerPool************************* + Tokens ************************* + {0} + IntermediateReusable.uses() + Key=129 Master=46 task11(46){0} --> {10} + {10} + {10} + IntermediateReusable.uses() + Key=159 Master=66 task12(66){10} --> {100} + {100} + [10, 99] + IntermediateReusable.uses() + Key=188 Master=87 task21(87)[10, 99] --> [11, 100] + [11, 100] + End Tokens ********************* + Variables ************************* + programmerPool.capacity=float:CLOSED[5, 5] + programmerPool.levelLimitMin=float:CLOSED[0, 0] + programmerPool.consumptionRateMax=float:CLOSED[+inf, +inf] + programmerPool.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End IntermediateReusable:programmerPool************************* + Project:proj1************************* + Tokens ************************* + {0} + Project.task(numProgrammers=float:CLOSED[3.000000000000000, 3.000000000000000]) + Key=46 Master=NONE + {10} + {10} + Project.task(numProgrammers=float:CLOSED[2.000000000000000, 2.000000000000000]) + Key=66 Master=NONE + {100} + End Tokens ********************* + End Project:proj1************************* + Project:proj2************************* + Tokens ************************* + [10, 99] + Project.task(numProgrammers=float:CLOSED[3.000000000000000, 3.000000000000000]) + Key=87 Master=NONE + [11, 100] + End Tokens ********************* + End Project:proj2************************* +Global Variables************************* + config=PlannerConfig:CLOSED{config(12)} + programmerPool=IntermediateReusable:CLOSED{programmerPool(27)} + proj1=Project:CLOSED{proj1(40)} + proj2=Project:CLOSED{proj2(43)} +Rejected Tokens: ************************* + [0, 99] + Project.task(numProgrammers=float:CLOSED[9.000000000000000, 9.000000000000000]) + Key=107 Master=NONE + {100} +Objects ************************* + PlannerConfig:config************************* + Variables ************************* + config.m_horizonStart=int:CLOSED[0, 0] + config.m_horizonEnd=int:CLOSED[100, 100] + config.m_maxPlannerSteps=int:CLOSED[100, 100] + config.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:config************************* + IntermediateReusable:programmerPool************************* + Tokens ************************* + {0} + IntermediateReusable.uses() + Key=129 Master=46 task11(46){0} --> {10} + {10} + {10} + IntermediateReusable.uses() + Key=159 Master=66 task12(66){10} --> {100} + {100} + [10, 99] + IntermediateReusable.uses() + Key=188 Master=87 task21(87)[10, 99] --> [11, 100] + [11, 100] + End Tokens ********************* + Variables ************************* + programmerPool.capacity=float:CLOSED[5, 5] + programmerPool.levelLimitMin=float:CLOSED[0, 0] + programmerPool.consumptionRateMax=float:CLOSED[+inf, +inf] + programmerPool.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End IntermediateReusable:programmerPool************************* + Project:proj1************************* + Tokens ************************* + {0} + Project.task(numProgrammers=float:CLOSED[3.000000000000000, 3.000000000000000]) + Key=46 Master=NONE + {10} + {10} + Project.task(numProgrammers=float:CLOSED[2.000000000000000, 2.000000000000000]) + Key=66 Master=NONE + {100} + End Tokens ********************* + End Project:proj1************************* + Project:proj2************************* + Tokens ************************* + [10, 99] + Project.task(numProgrammers=float:CLOSED[3.000000000000000, 3.000000000000000]) + Key=87 Master=NONE + [11, 100] + End Tokens ********************* + End Project:proj2************************* +Global Variables************************* + config=PlannerConfig:CLOSED{config(12)} + programmerPool=IntermediateReusable:CLOSED{programmerPool(27)} + proj1=Project:CLOSED{proj1(40)} + proj2=Project:CLOSED{proj2(43)} +Rejected Tokens: ************************* + [0, 99] + Project.task(numProgrammers=float:CLOSED[9.000000000000000, 9.000000000000000]) + Key=107 Master=NONE + {100} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-rules.0.tx.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-rules.0.tx.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..cb2714173 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-rules.0.tx.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,104 @@ +Objects ************************* + Location:Hill************************* + Variables ************************* + Hill.name=string:CLOSED{Hill} + End Variables ********************* + End Location:Hill************************* + Location:Rock************************* + Variables ************************* + Rock.name=string:CLOSED{Rock} + End Variables ********************* + End Location:Rock************************* + Location:Lander************************* + Variables ************************* + Lander.name=string:CLOSED{Lander} + End Variables ********************* + End Location:Lander************************* + Navigator:nav1************************* + Tokens ************************* + {0} + Navigator.At(location=Location:CLOSED{Lander(22)}) + Key=41 Master=NONE + [1, 100] + End Tokens ********************* + End Navigator:nav1************************* + PlannerConfig:config************************* + Variables ************************* + config.m_horizonStart=int:CLOSED[0, 0] + config.m_horizonEnd=int:CLOSED[100, 100] + config.m_maxPlannerSteps=int:CLOSED[200, 200] + config.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:config************************* +Global Variables************************* + Hill=Location:CLOSED{Hill(8)} + Rock=Location:CLOSED{Rock(15)} + Lander=Location:CLOSED{Lander(22)} + nav1=Navigator:CLOSED{nav1(27)} + config=PlannerConfig:CLOSED{config(30)} +Inactive Tokens: ************************* + [1, 100] + Navigator.At(location=Location:CLOSED{Rock(15)}) + Key=57 Master=NONE + [2, +inf] + [1, 100] + Navigator.Going(from=Location:CLOSED{Lander(22)}to=Location:CLOSED{Hill(8),Rock(15)}) + Key=82 Master=41 initialPosition(41){0} --> [1, 100] + [2, +inf] + [-inf, -1] + Navigator.Going(from=Location:CLOSED{Hill(8),Rock(15)}to=Location:CLOSED{Lander(22)}) + Key=102 Master=41 initialPosition(41){0} --> [1, 100] + {0} +Objects ************************* + Location:Hill************************* + Variables ************************* + Hill.name=string:CLOSED{Hill} + End Variables ********************* + End Location:Hill************************* + Location:Rock************************* + Variables ************************* + Rock.name=string:CLOSED{Rock} + End Variables ********************* + End Location:Rock************************* + Location:Lander************************* + Variables ************************* + Lander.name=string:CLOSED{Lander} + End Variables ********************* + End Location:Lander************************* + Navigator:nav1************************* + Tokens ************************* + {0} + Navigator.At(location=Location:CLOSED{Lander(22)}) + Key=41 Master=NONE + [1, 100] + End Tokens ********************* + End Navigator:nav1************************* + PlannerConfig:config************************* + Variables ************************* + config.m_horizonStart=int:CLOSED[0, 0] + config.m_horizonEnd=int:CLOSED[100, 100] + config.m_maxPlannerSteps=int:CLOSED[200, 200] + config.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:config************************* +Global Variables************************* + Hill=Location:CLOSED{Hill(8)} + Rock=Location:CLOSED{Rock(15)} + Lander=Location:CLOSED{Lander(22)} + nav1=Navigator:CLOSED{nav1(27)} + config=PlannerConfig:CLOSED{config(30)} +Inactive Tokens: ************************* + [1, 100] + Navigator.At(location=Location:CLOSED{Rock(15)}) + Key=57 Master=NONE + [2, +inf] + [1, 100] + Navigator.Going(from=Location:CLOSED{Lander(22)}to=Location:CLOSED{Hill(8),Rock(15)}) + Key=82 Master=41 initialPosition(41){0} --> [1, 100] + [2, +inf] + [-inf, -1] + Navigator.Going(from=Location:CLOSED{Hill(8),Rock(15)}to=Location:CLOSED{Lander(22)}) + Key=102 Master=41 initialPosition(41){0} --> [1, 100] + {0} + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-subtype-extension.tx.nddl-DefaultPlannerConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-subtype-extension.tx.nddl-DefaultPlannerConfig.xml.out new file mode 100644 index 000000000..fd8cee1c2 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-subtype-extension.tx.nddl-DefaultPlannerConfig.xml.out @@ -0,0 +1,224 @@ +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[100, 100] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Derived:d************************* + Tokens ************************* + {0} + Derived.P(x=int:CLOSED[8, 8]i=int:CLOSED[-inf, +inf]) + Key=26 Master=NONE + Merged Key=93 from Derived.P(65){10} --> {20} + {10} + {10} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=65 Master=26 g0(26){0} --> {10} + Merged Key=145 from Derived.P(111){20} --> {30} + {20} + {20} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=111 Master=65 Derived.P(65){10} --> {20} + Merged Key=197 from Derived.P(163){30} --> {40} + {30} + {30} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=163 Master=111 Derived.P(111){20} --> {30} + Merged Key=249 from Derived.P(215){40} --> {50} + {40} + {40} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=215 Master=163 Derived.P(163){30} --> {40} + Merged Key=301 from Derived.P(267){50} --> {60} + {50} + {50} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=267 Master=215 Derived.P(215){40} --> {50} + Merged Key=353 from Derived.P(319){60} --> {70} + {60} + {60} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=319 Master=267 Derived.P(267){50} --> {60} + Merged Key=405 from Derived.P(371){70} --> {80} + {70} + {70} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=371 Master=319 Derived.P(319){60} --> {70} + Merged Key=457 from Derived.P(423){80} --> {90} + {80} + {80} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=423 Master=371 Derived.P(371){70} --> {80} + Merged Key=509 from Derived.P(475){90} --> {100} + {90} + {90} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=475 Master=423 Derived.P(423){80} --> {90} + {100} + End Tokens ********************* + End Derived:d************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + d=Derived:CLOSED{d(23)} +Merged Tokens: ************************* + [-inf, 9] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=93 Master=65 Derived.P(65){10} --> {20} + {10} + [-inf, 19] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=145 Master=111 Derived.P(111){20} --> {30} + {20} + [-inf, 29] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=197 Master=163 Derived.P(163){30} --> {40} + {30} + [-inf, 39] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=249 Master=215 Derived.P(215){40} --> {50} + {40} + [-inf, 49] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=301 Master=267 Derived.P(267){50} --> {60} + {50} + [-inf, 59] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=353 Master=319 Derived.P(319){60} --> {70} + {60} + [-inf, 69] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=405 Master=371 Derived.P(371){70} --> {80} + {70} + [-inf, 79] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=457 Master=423 Derived.P(423){80} --> {90} + {80} + [-inf, 89] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=509 Master=475 Derived.P(475){90} --> {100} + {90} +Inactive Tokens: ************************* + [-inf, -1] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=47 Master=26 g0(26){0} --> {10} + {0} + {100} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=527 Master=475 Derived.P(475){90} --> {100} + [101, +inf] +Objects ************************* + PlannerConfig:world************************* + Variables ************************* + world.m_horizonStart=int:CLOSED[0, 0] + world.m_horizonEnd=int:CLOSED[100, 100] + world.m_maxPlannerSteps=int:CLOSED[100, 100] + world.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:world************************* + Derived:d************************* + Tokens ************************* + {0} + Derived.P(x=int:CLOSED[8, 8]i=int:CLOSED[-inf, +inf]) + Key=26 Master=NONE + Merged Key=93 from Derived.P(65){10} --> {20} + {10} + {10} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=65 Master=26 g0(26){0} --> {10} + Merged Key=145 from Derived.P(111){20} --> {30} + {20} + {20} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=111 Master=65 Derived.P(65){10} --> {20} + Merged Key=197 from Derived.P(163){30} --> {40} + {30} + {30} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=163 Master=111 Derived.P(111){20} --> {30} + Merged Key=249 from Derived.P(215){40} --> {50} + {40} + {40} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=215 Master=163 Derived.P(163){30} --> {40} + Merged Key=301 from Derived.P(267){50} --> {60} + {50} + {50} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=267 Master=215 Derived.P(215){40} --> {50} + Merged Key=353 from Derived.P(319){60} --> {70} + {60} + {60} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=319 Master=267 Derived.P(267){50} --> {60} + Merged Key=405 from Derived.P(371){70} --> {80} + {70} + {70} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=371 Master=319 Derived.P(319){60} --> {70} + Merged Key=457 from Derived.P(423){80} --> {90} + {80} + {80} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=423 Master=371 Derived.P(371){70} --> {80} + Merged Key=509 from Derived.P(475){90} --> {100} + {90} + {90} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=475 Master=423 Derived.P(423){80} --> {90} + {100} + End Tokens ********************* + End Derived:d************************* +Global Variables************************* + world=PlannerConfig:CLOSED{world(12)} + d=Derived:CLOSED{d(23)} +Merged Tokens: ************************* + [-inf, 9] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=93 Master=65 Derived.P(65){10} --> {20} + {10} + [-inf, 19] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=145 Master=111 Derived.P(111){20} --> {30} + {20} + [-inf, 29] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=197 Master=163 Derived.P(163){30} --> {40} + {30} + [-inf, 39] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=249 Master=215 Derived.P(215){40} --> {50} + {40} + [-inf, 49] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=301 Master=267 Derived.P(267){50} --> {60} + {50} + [-inf, 59] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=353 Master=319 Derived.P(319){60} --> {70} + {60} + [-inf, 69] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=405 Master=371 Derived.P(371){70} --> {80} + {70} + [-inf, 79] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=457 Master=423 Derived.P(423){80} --> {90} + {80} + [-inf, 89] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=509 Master=475 Derived.P(475){90} --> {100} + {90} +Inactive Tokens: ************************* + [-inf, -1] + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=47 Master=26 g0(26){0} --> {10} + {0} + {100} + Derived.P(x=int:CLOSED[-inf, +inf]i=int:CLOSED[-inf, +inf]) + Key=527 Master=475 Derived.P(475){90} --> {100} + [101, +inf] + +Finished diff --git a/src/PLASMA/System/test/data/run-nddl-interp-unary-resource-test-transaction.nddl-ReusableTestConfig.xml.out b/src/PLASMA/System/test/data/run-nddl-interp-unary-resource-test-transaction.nddl-ReusableTestConfig.xml.out new file mode 100644 index 000000000..cba0a4698 --- /dev/null +++ b/src/PLASMA/System/test/data/run-nddl-interp-unary-resource-test-transaction.nddl-ReusableTestConfig.xml.out @@ -0,0 +1,114 @@ +Created node [id_354] initially enabled +Created node [id_355] initially enabled +Maximum flow instance created with source [id_354] and sink [id_355] +Created node [id_354] initially enabled +Created node [id_355] initially enabled +Maximum flow instance created with source [id_354] and sink [id_355] +Objects ************************* + PlannerConfig:config************************* + Variables ************************* + config.m_horizonStart=int:CLOSED[0, 0] + config.m_horizonEnd=int:CLOSED[100, 100] + config.m_maxPlannerSteps=int:CLOSED[100, 100] + config.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:config************************* + IntermediateUnary:unary************************* + Tokens ************************* + {0} + IntermediateUnary.use() + Key=89 Master=37 bar11(37){0} --> {10} + {10} + {10} + IntermediateUnary.use() + Key=118 Master=54 bar12(54){10} --> {50} + {50} + [50, 99] + IntermediateUnary.use() + Key=153 Master=70 bar21(70)[50, 99] --> [51, 100] + [51, 100] + End Tokens ********************* + Variables ************************* + unary.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End IntermediateUnary:unary************************* + Foo:proj1************************* + Tokens ************************* + {0} + Foo.bar() + Key=37 Master=NONE + {10} + {10} + Foo.bar() + Key=54 Master=NONE + {50} + End Tokens ********************* + End Foo:proj1************************* + Foo:proj2************************* + Tokens ************************* + [50, 99] + Foo.bar() + Key=70 Master=NONE + [51, 100] + End Tokens ********************* + End Foo:proj2************************* +Global Variables************************* + config=PlannerConfig:CLOSED{config(12)} + unary=IntermediateUnary:CLOSED{unary(23)} + proj1=Foo:CLOSED{proj1(31)} + proj2=Foo:CLOSED{proj2(34)} +Objects ************************* + PlannerConfig:config************************* + Variables ************************* + config.m_horizonStart=int:CLOSED[0, 0] + config.m_horizonEnd=int:CLOSED[100, 100] + config.m_maxPlannerSteps=int:CLOSED[100, 100] + config.m_maxPlannerDepth=int:CLOSED[+inf, +inf] + End Variables ********************* + End PlannerConfig:config************************* + IntermediateUnary:unary************************* + Tokens ************************* + {0} + IntermediateUnary.use() + Key=89 Master=37 bar11(37){0} --> {10} + {10} + {10} + IntermediateUnary.use() + Key=118 Master=54 bar12(54){10} --> {50} + {50} + [50, 99] + IntermediateUnary.use() + Key=153 Master=70 bar21(70)[50, 99] --> [51, 100] + [51, 100] + End Tokens ********************* + Variables ************************* + unary.consumptionMax=float:CLOSED[+inf, +inf] + End Variables ********************* + End IntermediateUnary:unary************************* + Foo:proj1************************* + Tokens ************************* + {0} + Foo.bar() + Key=37 Master=NONE + {10} + {10} + Foo.bar() + Key=54 Master=NONE + {50} + End Tokens ********************* + End Foo:proj1************************* + Foo:proj2************************* + Tokens ************************* + [50, 99] + Foo.bar() + Key=70 Master=NONE + [51, 100] + End Tokens ********************* + End Foo:proj2************************* +Global Variables************************* + config=PlannerConfig:CLOSED{config(12)} + unary=IntermediateUnary:CLOSED{unary(23)} + proj1=Foo:CLOSED{proj1(31)} + proj2=Foo:CLOSED{proj2(34)} + +Finished diff --git a/src/PLASMA/System/test/plan-and-compare.cmake b/src/PLASMA/System/test/plan-and-compare.cmake new file mode 100644 index 000000000..698b07c28 --- /dev/null +++ b/src/PLASMA/System/test/plan-and-compare.cmake @@ -0,0 +1,16 @@ +execute_process(COMMAND ${exec_plan} ${model} ${configFile} ${language} + OUTPUT_FILE ${output_file} + ERROR_FILE ${output_file} + RESULT_VARIABLE result) +if(NOT ${result} EQUAL 0) + message(FATAL_ERROR ${result}) +endif(NOT ${result} EQUAL 0) + +if(plan_compare AND (${compare} STREQUAL "true")) + execute_process(COMMAND ${plan_compare} ${gold_file} ${output_file} + OUTPUT_FILE ${diff_file} + RESULT_VARIABLE diff_result) + if(NOT ${diff_result} EQUAL 0) + message(FATAL_ERROR ${diff_result}) + endif(NOT ${diff_result} EQUAL 0) +endif(plan_compare AND (${compare} STREQUAL "true")) \ No newline at end of file diff --git a/src/PLASMA/System/test/plan-diff.pl b/src/PLASMA/System/test/plan-diff.pl new file mode 100755 index 000000000..13a2e4999 --- /dev/null +++ b/src/PLASMA/System/test/plan-diff.pl @@ -0,0 +1,144 @@ +#!/usr/bin/perl -w + +use warnings qw/all/; +use strict; + +use Algorithm::Diff; + +my %plans = (); +my $token_key_rx = qr/Key=\d+\s+Master=(?:\d+|NONE)/; +my $merge_key_rx = qr/Merged Key=\d+/; + +exit(plan_compare($ARGV[0], $ARGV[1])); + +sub plan_compare { + my $planfile1 = shift; + my $planfile2 = shift; + + my $plan1 = get_plan($planfile1); + my $plan2 = get_plan($planfile2); + + my $diff = Algorithm::Diff->new($plan1, $plan2); + + my %diffs1 = (); + my %diffs2 = (); + my @lines1 = (); + my @lines2 = (); + my $retval = 0; + $diff->Base(1); #use line numbers + while($diff->Next()) { + next if($diff->Same()); #skip anything that's the same + my @items1 = $diff->Items(1); #empty if the diff is only insertions + my @items2 = $diff->Items(2); #empty if the diff is only deletions + + @items1 = remove_rx($token_key_rx, @items1); #token key differences don't matter + @items2 = remove_rx($token_key_rx, @items2); + next if (@items1 == @items2 && @items1 == 0); + + if(@items1 == @items2) { + @items1 = remove_rx($merge_key_rx, @items1); #merged key differences don't matter + @items2 = remove_rx($merge_key_rx, @items2); #as long as there are the same number of merged tokens + next if(@items1 == @items2 && @items1 == 0); + } + + @items1 = remove_rx(qr/world\./, @items1); #differences in the world object don't matter + @items2 = remove_rx(qr/world\./, @items2); + + @items1 = remove_rx(qr/ound plan/, @items1); #differences in step numbers don't matter + @items2 = remove_rx(qr/ound plan/, @items2); + next if(@items1 == @items2 && @items1 == 0); + + if(@items1 > 0) { + $diffs1{$diff->Min(1)} = \@items1; + push @lines1, $diff->Min(1); + } + if(@items2 > 0) { + $diffs2{$diff->Min(2)} = \@items2 ; + push @lines2, $diff->Min(2); + } + } + + if(@lines1 != @lines2) { + # print "Plans $planfile1 and $planfile2 are very definitely different.\n"; + $retval = 1; + } + + my $min = (@lines1 < @lines2 ? @lines1 : @lines2); + # print "The minimum number of differing lines is: " . $min . "\n"; + foreach my $i (0..$min) { + next if !(defined($lines1[$i]) && defined($lines2[$i])); + + my $subdiff = Algorithm::Diff->new($diffs1{$lines1[$i]}, + $diffs2{$lines2[$i]}); + while($subdiff->Next()) { + next if ($subdiff->Same()); + my @subitems1 = $subdiff->Items(1); + my @subitems2 = $subdiff->Items(2); + print "=====================\n"; + print "$planfile1: [", $lines1[$i] + $subdiff->Min(1), "]\n"; + map {print $_} @subitems1; + print "======================\n"; + print "$planfile2: [", $lines2[$i] + $subdiff->Min(2), "]\n"; + map {print $_} @subitems2; + $retval = 1; + } + } + + if(@lines1 > @lines2) { + foreach(($min == 0 ? $min : $min+1)..$#lines1) { + print "===================\n"; + print "$planfile1: [", $lines1[$_], "]\n"; + map {print $_} @{$diffs1{$lines1[$_]}}; + $retval = 1; + } + } + elsif(@lines2 > @lines1) { + foreach(($min == 0 ? $min : $min+1)..$#lines2) { + print "===================\n"; + print "$planfile2: [", $lines2[$_], "]\n"; + map {print $_} @{$diffs2{$lines2[$_]}}; + $retval = 1; + } + } + return $retval; +} + +sub get_plan { + my $file = shift; + open my $fh, $file or die "Failed to open file $file: $!\n"; + return extract_plan($fh); +} + +sub extract_plan { + my $fh = shift; + my @plan = (); + local $_; + while(<$fh>) { + #print "$.: $_"; + last if /Objects\s+\*+/; + } + #print "Pushing line: $_"; + push @plan, $_; + while(<$fh>) { + #given the current plan output + #there are only merged and inactive tokens after this point, + #which don't really matter + last if(/Merged Tokens:\s*\*{4,}/); + + if(/.+\s*\*{4,}/ || # Objects **** or Variables ***** etc. + /.+=.+:.+/ || #object.var=type:DOMAIN + /\[\s+.+:.+\s+\]/ || # [ INT_INTERVAL:CLOSED[50, 65] ] + /\.+\((?:.+=.+[}\]])*\)/ || #object.predicate(parameter=type:DOMAINparameter=type:DOMAIN) + /$token_key_rx/ || #Key=123 Master=none + /$merge_key_rx/ ) { + #print "Pushing line: $_"; + push @plan, $_; + } + } + return \@plan; +} + +sub remove_rx { + my $rx = shift; + return grep {$_ !~ /$rx/} @_; +} diff --git a/src/PLASMA/System/test/runProblem.cc b/src/PLASMA/System/test/runProblem.cc index 96aa924d9..9bab036be 100644 --- a/src/PLASMA/System/test/runProblem.cc +++ b/src/PLASMA/System/test/runProblem.cc @@ -40,7 +40,8 @@ class TestEngine : public EuropaEngine /** TODO: REPLAY IS BROKEN WITH THE INTERPRETER AND NEEDS TO BE FIXED!!!! */ -void replay(const std::string& s1,const DbClientTransactionLogId& txLog, const char* language) +namespace { +void replay(const std::string& s1,const DbClientTransactionLogId , const char* language) { TestEngine replayed; replayed.playTransactions(TestEngine::TX_LOG(),language); @@ -75,19 +76,17 @@ bool runPlanner(const char* modelFile, try { assert(engine.plan(modelFile,plannerConfig,language)); - debugMsg("Main:runPlanner", "Found a plan at depth " << engine.getDepthReached() << " after " << engine.getTotalNodesSearched()); - + engine.write(std::cout); if(replayRequired) { - engine.write(std::cout); std::string s1 = PlanDatabaseWriter::toString(engine.getPlanDatabase(), false); std::ofstream out(TestEngine::TX_LOG()); txLog->flush(out); out.close(); replay(s1, txLog,language); - std::cout << engine.getPlanDatabase()->toString();/// } + std::cout << engine.getPlanDatabase()->toString() << std::endl;/// debugMsg("IdTypeCounts", dumpIdTable("after")); } @@ -127,7 +126,7 @@ bool copyFromFile(const char* language){ return true; } - +} // Args to main() #define ARGC 4 #define MODEL_INDEX 1 @@ -163,11 +162,13 @@ int main(int argc, const char** argv) if (performanceTest != NULL && strcmp(performanceTest, "1") == 0) { replayRequired = false; - EUROPA_runTest(runPlanner,modelFile,plannerConfig,language,replayRequired); + assert(runPlanner(modelFile, plannerConfig, language, replayRequired)); + // EUROPA_runTest(runPlanner,modelFile,plannerConfig,language,replayRequired); } else { replayRequired = false; //= true; - EUROPA_runTest(runPlanner,modelFile,plannerConfig,language,replayRequired); + assert(runPlanner(modelFile, plannerConfig, language, replayRequired)); + // EUROPA_runTest(runPlanner,modelFile,plannerConfig,language,replayRequired); //EUROPA_runTest(copyFromFile,language); } diff --git a/src/PLASMA/System/test/smallerInconsistency-initial-state.nddl b/src/PLASMA/System/test/smallerInconsistency-initial-state.nddl new file mode 100644 index 000000000..8541a5c6c --- /dev/null +++ b/src/PLASMA/System/test/smallerInconsistency-initial-state.nddl @@ -0,0 +1,19 @@ +#include "smallerInconsistency-model.nddl" +#include "PlannerConfig.nddl" +// Sample object +YourObject object = new YourObject(); +PlannerConfig plannerConfig = new PlannerConfig(0, 1, 100, 100); +// Close the the PLASMA Database - no more objects can be created. +close(); + +// place your goals here. +goal(YourObject.helloWorld initialToken); +initialToken.start.specify(0); // Starts at beginning of the horizon +initialToken.end.specify(1); +initialToken.activate(); +object.constrain(initialToken, initialToken); + +// The planner should take it form here! +initialToken.guard.specify(true); +initialToken.guard.reset(); +initialToken.guard.specify(false); diff --git a/src/PLASMA/System/test/smallerInconsistency-model.nddl b/src/PLASMA/System/test/smallerInconsistency-model.nddl new file mode 100644 index 000000000..cb7eadfbb --- /dev/null +++ b/src/PLASMA/System/test/smallerInconsistency-model.nddl @@ -0,0 +1,24 @@ +#include "Plasma.nddl" + +/** + * @brief Place holder class with a single predicate + */ +class YourObject { + predicate helloWorld{ + bool guard; + } /*!< Predicate with no arguments */ +} + +/** + * @brief A simple rule to force a repeated cycle + */ +YourObject::helloWorld{ + // meets (object.helloWorld); + // met_by(object.helloWorld); + if(guard == true) { + guard == true; + } + if(guard == false) { + guard == false; + } +} diff --git a/src/PLASMA/TemporalNetwork/CMakeLists.txt b/src/PLASMA/TemporalNetwork/CMakeLists.txt index 0fc3b569c..a9bfec43a 100644 --- a/src/PLASMA/TemporalNetwork/CMakeLists.txt +++ b/src/PLASMA/TemporalNetwork/CMakeLists.txt @@ -1,7 +1,7 @@ include(EuropaModule) -set(internal_dependencies RulesEngine PlanDatabase ConstraintEngine Utils TinyXml) +set(internal_dependencies RulesEngine PlanDatabase ConstraintEngine Utils) set(root_sources ModuleTemporalNetwork.cc) -set(base_sources DispatchGraph.cc DistanceGraph.cc TemporalNetwork.cc queues.cc) +set(base_sources DistanceGraph.cc TemporalNetwork.cc queues.cc) set(component_sources STNTemporalAdvisor.cc TemporalNetworkListener.cc TemporalPropagator.cc TimepointWrapper.cc) set(test_sources TestSubgoalRule.cc module-tests.cc tn-test-module.cc) diff --git a/src/PLASMA/TemporalNetwork/ModuleTemporalNetwork.cc b/src/PLASMA/TemporalNetwork/ModuleTemporalNetwork.cc index 352b0eeae..3a78663ed 100644 --- a/src/PLASMA/TemporalNetwork/ModuleTemporalNetwork.cc +++ b/src/PLASMA/TemporalNetwork/ModuleTemporalNetwork.cc @@ -6,6 +6,9 @@ #include "Propagators.hh" #include "TemporalPropagator.hh" #include "STNTemporalAdvisor.hh" +#include "CESchema.hh" + +#include namespace EUROPA { @@ -26,31 +29,31 @@ namespace EUROPA { { } - void ModuleTemporalNetwork::initialize(EngineId engine) - { - ConstraintEngine* ce = (ConstraintEngine*)engine->getComponent("ConstraintEngine"); - CESchema* ces = ce->getCESchema(); - - REGISTER_SYSTEM_CONSTRAINT(ces,EqualConstraint, "concurrent", "Temporal"); - REGISTER_SYSTEM_CONSTRAINT(ces,LessThanEqualConstraint, "precedes", "Temporal"); - REGISTER_SYSTEM_CONSTRAINT(ces, LessThanConstraint, "strictlyPrecedes", "Temporal"); - REGISTER_SYSTEM_CONSTRAINT(ces,AddEqualConstraint, "temporalDistance", "Temporal"); - - PlanDatabase* pdb = (PlanDatabase*)engine->getComponent("PlanDatabase"); - - PropagatorId temporalPropagator; - if (engine->getConfig()->getProperty("TemporalNetwork.useTemporalPropagator") != "N") { - temporalPropagator = (new TemporalPropagator(LabelStr("Temporal"), ce->getId()))->getId(); - pdb->setTemporalAdvisor((new STNTemporalAdvisor(temporalPropagator))->getId()); - } - else { - temporalPropagator = (new DefaultPropagator(LabelStr("Temporal"), ce->getId()))->getId(); - pdb->setTemporalAdvisor((new DefaultTemporalAdvisor(ce->getId()))->getId()); - } - } +void ModuleTemporalNetwork::initialize(EngineId engine) { + ConstraintEngine* ce = + boost::polymorphic_cast(engine->getComponent("ConstraintEngine")); + CESchema* ces = ce->getCESchema(); - void ModuleTemporalNetwork::uninitialize(EngineId engine) - { - // TODO: cleanup + REGISTER_SYSTEM_CONSTRAINT(ces,EqualConstraint, "concurrent", "Temporal"); + REGISTER_SYSTEM_CONSTRAINT(ces,LessThanEqualConstraint, "precedes", "Temporal"); + REGISTER_SYSTEM_CONSTRAINT(ces, LessThanConstraint, "strictlyPrecedes", "Temporal"); + REGISTER_SYSTEM_CONSTRAINT(ces,AddEqualConstraint, "temporalDistance", "Temporal"); + + PlanDatabase* pdb = + boost::polymorphic_cast(engine->getComponent("PlanDatabase")); + + PropagatorId temporalPropagator; + if (engine->getConfig()->getProperty("TemporalNetwork.useTemporalPropagator") != "N") { + temporalPropagator = (new TemporalPropagator("Temporal", ce->getId()))->getId(); + pdb->setTemporalAdvisor((new STNTemporalAdvisor(temporalPropagator))->getId()); + } + else { + temporalPropagator = (new DefaultPropagator("Temporal", ce->getId()))->getId(); + pdb->setTemporalAdvisor((new DefaultTemporalAdvisor(ce->getId()))->getId()); } } + +void ModuleTemporalNetwork::uninitialize(EngineId) { + // TODO: cleanup +} +} diff --git a/src/PLASMA/TemporalNetwork/ModuleTemporalNetwork.hh b/src/PLASMA/TemporalNetwork/ModuleTemporalNetwork.hh index 7e6677a2f..7a37b85d4 100644 --- a/src/PLASMA/TemporalNetwork/ModuleTemporalNetwork.hh +++ b/src/PLASMA/TemporalNetwork/ModuleTemporalNetwork.hh @@ -1,6 +1,6 @@ -#ifndef _H_ModuleTemporalNetwork -#define _H_ModuleTemporalNetwork +#ifndef H_ModuleTemporalNetwork +#define H_ModuleTemporalNetwork #include "Module.hh" @@ -29,4 +29,4 @@ namespace EUROPA { } -#endif /* #ifndef _H_ModuleTemporalNetwork */ +#endif /* #ifndef H_ModuleTemporalNetwork */ diff --git a/src/PLASMA/TemporalNetwork/TemporalNetworkDefs.hh b/src/PLASMA/TemporalNetwork/TemporalNetworkDefs.hh index 46fd193d8..1cd83da6c 100644 --- a/src/PLASMA/TemporalNetwork/TemporalNetworkDefs.hh +++ b/src/PLASMA/TemporalNetwork/TemporalNetworkDefs.hh @@ -1,8 +1,9 @@ -#ifndef _H_TemporalNetworkDefs -#define _H_TemporalNetworkDefs +#ifndef H_TemporalNetworkDefs +#define H_TemporalNetworkDefs #include "Error.hh" #include "Id.hh" +#include /*!< Type definitions to map for ht ones we were using in Europa */ namespace EUROPA { @@ -15,44 +16,44 @@ namespace EUROPA { //door and let the tnet only deal with longs/ints internally //turns out this is the case - class Dnode; - typedef Id DnodeId; - - class Dedge; - typedef Id DedgeId; - - class Tnode; - typedef Id< Tnode > TimepointId; - - class Tspec; - typedef Id TemporalConstraintId; - - class TemporalNetwork; - typedef Id TemporalNetworkId; - - class TemporalPropagator; - typedef Id TemporalPropagatorId; - - class TemporalNetworkListener; - typedef Id TemporalNetworkListenerId; - - class TimepointWrapper; - typedef Id TimepointWrapperId; - - #define noIndex -1; - - class TempNetErr { - public: - DECLARE_ERROR(DistanceGraphInconsistentError); - DECLARE_ERROR(TempNetMemoryError); - DECLARE_ERROR(TempNetInternalError); - DECLARE_ERROR(TimeOutOfBoundsError); - DECLARE_ERROR(TempNetInconsistentError); - DECLARE_ERROR(TempNetInvalidTimepointError); - DECLARE_ERROR(TempNetEmptyConstraintError); - DECLARE_ERROR(TempNetInvalidConstraintError); - DECLARE_ERROR(TempNetDeletingOriginError); - DECLARE_ERROR(TempNetNoInconsistencyError); - }; +class Dnode; +typedef boost::shared_ptr DnodeId; + +class Dedge; +typedef boost::shared_ptr DedgeId; + +class Tnode; +typedef Tnode Timepoint; +typedef boost::shared_ptr TimepointId; + +class Tspec; +typedef Tspec TemporalConstraint; +//typedef Tspec* TemporalConstraintId; +typedef boost::shared_ptr TemporalConstraintId; + +class TemporalNetwork; +typedef TemporalNetwork* TemporalNetworkId; + +class TemporalPropagator; +typedef TemporalPropagator* TemporalPropagatorId; + +class TemporalNetworkListener; +typedef TemporalNetworkListener* TemporalNetworkListenerId; + +#define noIndex -1; + +class TempNetErr { + public: + DECLARE_ERROR(DistanceGraphInconsistentError); + DECLARE_ERROR(TempNetMemoryError); + DECLARE_ERROR(TempNetInternalError); + DECLARE_ERROR(TimeOutOfBoundsError); + DECLARE_ERROR(TempNetInconsistentError); + DECLARE_ERROR(TempNetInvalidTimepointError); + DECLARE_ERROR(TempNetEmptyConstraintError); + DECLARE_ERROR(TempNetInvalidConstraintError); + DECLARE_ERROR(TempNetDeletingOriginError); + DECLARE_ERROR(TempNetNoInconsistencyError); +}; } #endif diff --git a/src/PLASMA/TemporalNetwork/base/DispatchGraph.cc b/src/PLASMA/TemporalNetwork/base/DispatchGraph.cc deleted file mode 100644 index e00b62156..000000000 --- a/src/PLASMA/TemporalNetwork/base/DispatchGraph.cc +++ /dev/null @@ -1,407 +0,0 @@ - -// Copyright Notices - -// This software was developed for use by the U.S. Government as -// represented by the Administrator of the National Aeronautics and -// Space Administration. No copyright is claimed in the United States -// under 17 U.S.C. 105. - -// This software may be used, copied, and provided to others only as -// permitted under the terms of the contract or other agreement under -// which it was acquired from the U.S. Government. Neither title to nor -// ownership of the software is hereby transferred. This notice shall -// remain on all copies of the software. - -/************************************************************************** - File: DispatchGraph.cc - Author: Paul H. Morris -Purpose: - Define DispatchGraph module for dispatchability processing. -Contents: - The implementation of the DispatchGraph class and associated classes. -Updates: - 20000406 - PHM - Initial version -Notes: - Efficiency is paramount since we have to do a full propagation - from each node. (At least O(n^2) complexity.) We use the - algorithm of Tsamardinos, Muscettola, Morris in AAAI-98. - This is a fairly straight port of the Lisp version (file filter.lisp) - used in the RAX experiment. -**************************************************************************/ - -#include -#include -#include "DispatchGraph.hh" -#include "Error.hh" - -namespace EUROPA { - -DnodeId DispatchGraph::makeNode() -{ - // Overrides the definition in DistanceGraph class. - DispatchNode* node = new DispatchNode(); - return node; -} - -DispatchNode* DispatchGraph::createNode(Referent name) -{ - DispatchNode* node = (DispatchNode*)DistanceGraph::createNode(); - node->name = name; - node->isSccMember = false; - return node; -} - -void DispatchGraph::createEdge(DispatchNode* from, DispatchNode* to, - Time length) -{ - (void)DistanceGraph::createEdge(from,to,length); -} - -void DispatchGraph::filter( void (*keepEdge)(DispatchNode*, DispatchNode*, - Time) ) -{ - if (bellmanFord() == false) - handle_error(bellmanFord() == false, - "Dispatchability analysis called on inconsistent graph", - TempNetErr::DistanceGraphInconsistentError()); - this->reversePostorder = new DispatchNode*[this->nodes.size()]; - - if (!this->reversePostorder) - handle_error(!this->reversePostorder, - "Could not allocate memory to process dispatchability", - TempNetErr::TempNetMemoryError()); - this->sccLeaders = std::vector(); - // Set initial distances to same as potential - for (std::vector::const_iterator it=nodes.begin(); it != nodes.end(); ++it) { - DispatchNode* node = (DispatchNode*) *it; - node->distance = node->potential; - } - - this->findSccs(keepEdge); // Processes SCCs and sets sccLeaders. - for (std::vector::const_iterator it=sccLeaders.begin(); it != sccLeaders.end(); ++it) { - DispatchNode* node = *it; - this->dijkstra(node); - this->findKeptEdges(node, keepEdge); - } - delete[] this->reversePostorder; -} - -Int compareNodes (const DispatchNode** node1, const DispatchNode** node2) -{ - Time d1 = (*node1)->distance; - Time d2 = (*node2)->distance; - if (d1 < d2) - return -1; - else if (d1 == d2) - return 0; - else - return 1; -} - -void DispatchGraph::findSccs( void (*keepEdge)(DispatchNode*, DispatchNode*, - Time) ) -{ - // SCC = Strongly Connected Component. - // See P. 488 in "Introduction To Algorithms" - // by Cormen, Leiverson, & Rivest. - // The SCCs contain all the rigid (no slack) edges in the network. - Int nodeCount = this->nodes.size(); - DispatchNode** scc = new DispatchNode*[nodeCount]; // Scratch list for SCCs. - if (!scc) - handle_error(!scc, - "Could not allocate memory to process dispatchability", - TempNetErr::TempNetMemoryError()); - buildReversePostorder (this->nodes); - Dnode::unmarkAll(); - for (Int i=0; i < nodeCount; i++) { - DispatchNode* node = this->reversePostorder[i]; - if (!node->isMarked()) { - size_t sccSize = 0; - predGraphTraceScc (node, scc, sccSize, nodeCount); // Builds scc. - qsort ((void*)scc, sccSize, sizeof(DispatchNode*), - (Int (*)(const void*,const void*)) compareNodes); - processScc (scc, sccSize, keepEdge); - } - } - delete[] scc; -} - -void DispatchGraph::buildReversePostorder (std::vector& argNodes) -{ - // Do depth-first searches, collecting nodes into reverse-postorder. - Dnode::unmarkAll(); - Int position = argNodes.size(); - for (std::vector::const_iterator it=argNodes.begin(); it != argNodes.end(); ++it) { - Dnode* node = *it; - if (!node->isMarked()) - predGraphDfs ((DispatchNode*)node, position); - } - - check_error(!(position > 0), "Lost some nodes from reversePostorder list", - TempNetErr::TempNetInternalError()); -} - -void DispatchGraph::predGraphDfs (DispatchNode* node, Int& position) -{ - // Depth-first-search through predecessor graph (PG). An edge - // is in PG if start_distance + length(edge) == end_distance. - node->mark(); - for (Int i=0; i < node->outCount; i++) { - Dedge* edge = node->outArray[i]; - DispatchNode* next = (DispatchNode*) edge->to; - if (!next->isMarked() && node->distance + edge->length == next->distance) - this->predGraphDfs (next, position); - } - - check_error(!(position <= 0), "Inserting node before start of node-array", - TempNetErr::TempNetInternalError()); - - this->reversePostorder[--position] = node; -} - -void DispatchGraph::predGraphTraceScc (DispatchNode* node, DispatchNode* scc[], - size_t& sccSize, Int nodeCount) -{ - node->mark(); - node->isSccMember = true; - check_error(!((Int)sccSize >= nodeCount), "Inserting node beyond end of node-array", - TempNetErr::TempNetInternalError()); - - scc[sccSize++] = node; - - for (Int i=0; i< node->inCount; i++) { - Dedge* edge = node->inArray[i]; - DispatchNode* parent = (DispatchNode*) edge->from; - if (!parent->isMarked() - && parent->distance + edge->length == node->distance) - predGraphTraceScc (parent, scc, sccSize, nodeCount); - } -} - -void DispatchGraph::processScc (DispatchNode* scc[], size_t sccSize, - void (*keepEdge)(DispatchNode*, DispatchNode*, - Time)) -{ - // This figures out what edges in the SCC to keep, - // and detaches the interior of the SCC from the graph. - check_error(!(sccSize < 1), "Strongly Connected Component with no nodes", - TempNetErr::TempNetInternalError()); - - DispatchNode* leader = scc[0]; - this->sccLeaders.push_back(leader); - // Manually compute the filtered edges internal to the SCC. - // Arrange in a doubly-linked chain. - DispatchNode* previous = leader; - Time prevdistance = leader->distance; - for (Int i=1; i < (Int)sccSize; i++) { - DispatchNode* node = scc[i]; - Time distance = node->distance; - Time increment = distance - prevdistance; - (*keepEdge) (previous, node, increment); - (*keepEdge) (node, previous, -increment); - // Move the dangling edges to the leader. - sccMoveFluids (node, leader); - previous = node; - prevdistance = distance; - } - // Finished with this scc, reset isSccMember value. - // Only need to do it for leader because interior - // of scc is now detached from the rest of the graph. - leader->isSccMember = false; -} - -void DispatchGraph::sccMoveFluids (DispatchNode* node, DispatchNode* leader) -{ - // The purpose of this function is to replace all constraints - // between the interior of the SCC and the outside with equivalent - // constraints between the leader and the outside. This is - // visualized as "moving" those constraints (which are called - // "fluids" here). - - Time relativeDistance = node->distance - leader->distance; - - // First move edges from the node to outside - sccMoveDirectional (node, - leader, - relativeDistance, - &DispatchNode::inArray, &DispatchNode::inCount, - &DispatchNode::outArray, &DispatchNode::outCount, - &DispatchNode::outArraySize, - &Dedge::to, &Dedge::from); - - // Now move edges TO the node FROM outside, by reversing directions. - sccMoveDirectional (node, - leader, - -relativeDistance, - &DispatchNode::outArray, &DispatchNode::outCount, - &DispatchNode::inArray, &DispatchNode::inCount, - &DispatchNode::inArraySize, - &Dedge::from, &Dedge::to); - -} - -// Following are defined in DistanceGraph.cc -Void attachEdge (DedgeId*& edgeArray, Int& size, Int& count, DedgeId edge); -Void detachEdge (DedgeId*& edgeArray, Int& count, DedgeId edge); - - -/* TBW: Replaced by newer version that does more error checking -void DispatchGraph::sccMoveDirectional (DispatchNode* node, - DispatchNode* leader, - Time offset, - Dedge** Dnode::*ins, - int Dnode::*inCount, - Dedge** Dnode::*outs, - int Dnode::*outCount, - int Dnode::*outSize, - Dnode* Dedge::*to, - Dnode* Dedge::*from) -{ - // We use args that are pointers to the graph traversal member functions - // so we can easily reverse the direction of graph operations. - // For example, Dnode::*ins = Dnode::ins in the forward call, - // Dnode::*ins = Dnode::outs in the reverse call. - - for (Int i=0; i< node->*outCount; i++) { - Dedge* edge = (node->*outs)[i]; - DispatchNode* next = (DispatchNode*) (edge->*to); - if (next == leader) // Delink from leader - detachEdge (leader->*ins, leader->*inCount, edge); - if (next->isSccMember == false) { // next is not in the SCC. - Time movedDistance = edge->length + offset; - // Look for an *out edge of the leader that also points *to next - Dedge* leaderEdge = 0; - for (Int j=0; j < leader->*outCount; j++) { - Dedge* e = (leader->*outs)[j]; - if (e->*to == next) - leaderEdge = e; - } - if (leaderEdge) { - // Move the constraint to the leaderEdge and delink edge. - if (movedDistance < leaderEdge->length) - leaderEdge->length = movedDistance; - detachEdge (next->*ins, next->*inCount, edge); - } - else { - // Modify and redirect the edge. - edge->length = movedDistance; - edge->*from = leader; - attachEdge (leader->*outs, leader->*outSize, leader->*outCount, edge); - } - // No need to remove edge from node->*outs because - // node will be unreachable from sccLeaders. - } - } -} -*/ - -void DispatchGraph::sccMoveDirectional (DispatchNode* node, - DispatchNode* leader, - Time offset, - DedgeId* Dnode::*ins, - int Dnode::*inCount, - DedgeId* Dnode::*outs, - int Dnode::*outCount, - int Dnode::*outSize, - DnodeId Dedge::*to, - DnodeId Dedge::*from) -{ - // We use args that are pointers to the graph traversal member functions - // so we can easily reverse the direction of graph operations. - // For example, Dnode::*ins = Dnode::ins in the forward call, - // Dnode::*ins = Dnode::outs in the reverse call. - - for (Int i=0; i< node->*outCount; i++) { - Dedge* edge = (node->*outs)[i]; - DispatchNode* next = (DispatchNode*) (edge->*to); - if (next == leader) // Delink from leader - detachEdge (leader->*ins, leader->*inCount, edge); - if (next->isSccMember == false) { // next is not in the SCC. - Time movedDistance = edge->length + offset; - check_error(!(movedDistance > MAX_LENGTH || movedDistance < MIN_LENGTH), - "Dispatchability edge with length too large or too small", - TempNetErr::TempNetInternalError()); - // Look for an *out edge of the leader that also points *to next - Dedge* leaderEdge = 0; - for (Int j=0; j < leader->*outCount; j++) { - Dedge* e = (leader->*outs)[j]; - Dnode* eTo = (Dnode*)(e->*to); - if (eTo == next) - leaderEdge = e; - } - if (leaderEdge) { - // Move the constraint to the leaderEdge and delink edge. - if (movedDistance < leaderEdge->length) - leaderEdge->length = movedDistance; - detachEdge (next->*ins, next->*inCount, edge); - } - else { - // Modify and redirect the edge. - edge->length = movedDistance; - edge->*from = leader; - attachEdge (leader->*outs, leader->*outSize, leader->*outCount, edge); - } - // No need to remove edge from node->*outs because - // node will be unreachable from sccLeaders. - } - } -} - -void DispatchGraph::findKeptEdges (DispatchNode* source, - void (*keepEdge)(DispatchNode*, - DispatchNode*, - Time)) -{ - // This computes what edges to keep among those that are outside - // the SCCs. These are the fluid (non-rigid) edges. - Int leaderCount = this->sccLeaders.size(); - Dnode::unmarkAll(); - Int position = leaderCount; - // Following collects nodes downward into reverse-postorder - // while decrementing position. - predGraphDfs (source, position); - // - // First find lower dominators = minimal negative-distance nodes. - // Minimality determined by marking descendants. - Dnode::unmarkAll(); - for (Int i=position; i < leaderCount; i++) { - DispatchNode* node = this->reversePostorder[i]; - if ( !node->isMarked() && node->distance < 0 ) { - // Found minimal (= unmarked) neg-distance node - (*keepEdge) (source, node, node->distance); - node->mark(); - } - // Propagate mark to pred-graph children. - if ( node->isMarked() ) { - for (Int j=0; j < node->outCount; j++) { - Dedge* edge = node->outArray[j]; - DispatchNode* child = (DispatchNode*) edge->to; - if ( node->distance + edge->length == child->distance ) - child->mark(); - } - } - } - // Next we find the upper dominators. - // Propagate mins of ancestors (except source node). - source->minDistance = POS_INFINITY; // source distance not included in min. - for (Int j=position+1; j < leaderCount; j++) { - DispatchNode* node = this->reversePostorder[j]; - Time minDistance = POS_INFINITY; - for (Int k=0; k < node->inCount; k++) { - Dedge* edge = node->inArray[k]; - DispatchNode* parent = (DispatchNode*) edge->from; - if ( parent->distance + edge->length == node->distance // Pred graph - && parent->minDistance < minDistance) - minDistance = parent->minDistance; - } - if (minDistance > node->distance) { // Not upper-dominated. - if (node->distance >= 0) - (*keepEdge) (source, node, node->distance); - node->minDistance = node->distance; - } - else - node->minDistance = minDistance; - } -} - -} /* namespace Europa */ diff --git a/src/PLASMA/TemporalNetwork/base/DispatchGraph.hh b/src/PLASMA/TemporalNetwork/base/DispatchGraph.hh deleted file mode 100644 index 788f63049..000000000 --- a/src/PLASMA/TemporalNetwork/base/DispatchGraph.hh +++ /dev/null @@ -1,101 +0,0 @@ - -// Copyright Notices - -// This software was developed for use by the U.S. Government as -// represented by the Administrator of the National Aeronautics and -// Space Administration. No copyright is claimed in the United States -// under 17 U.S.C. 105. - -// This software may be used, copied, and provided to others only as -// permitted under the terms of the contract or other agreement under -// which it was acquired from the U.S. Government. Neither title to nor -// ownership of the software is hereby transferred. This notice shall -// remain on all copies of the software. - -#ifndef _H_DispGraph -#define _H_DispGraph - -#include "DistanceGraph.hh" - -namespace EUROPA { - -class DispatchNode; - -typedef int Referent; // Expected to be an index into a caller array. - -/** - * @class DispatchGraph - * @author Paul H. Morris - * @brief Specialization of DistanceGraph for dispatching activities - * from a Simple Temporal Network - * in the case when the timing of external events is not - * under the full control of agent we have planned for. - * - * Efficiency is paramount since we have to do a full propagation - * from each node. We use the algorithm of - * Tsamardinos, Muscettola, Morris in AAAI-98. - * This is a fairly straight port of the Lisp version (file filter.lisp) - * used in the RAX experiment. - * - * The definition of class Dnode must come before class DispatchGraph - * so that DispatchGraph::createNode may be defined in the DispatchGraph - * class definition. - * - * @ingroup TemporalNetwork - */ - -class DispatchGraph : public DistanceGraph { - std::vector sccLeaders; // Strongly Connected Component leaders. - DispatchNode** reversePostorder; // A scratch list for ordering nodes. -public: - DispatchNode* createNode(Referent name); - void createEdge(DispatchNode* from, DispatchNode* to, Time length); - void filter( void (*keepEdge)(DispatchNode*, DispatchNode*, Time) ); - // Constructor & Destructor - DispatchGraph () {} - // Destructor inherited from DistanceGraph is ok. -private: - void findSccs( void (*keepEdge)(DispatchNode*, DispatchNode*, Time) ); - void buildReversePostorder (std::vector& nodes); - void predGraphDfs (DispatchNode* node, int& position); - void predGraphTraceScc (DispatchNode* node, DispatchNode* scc[], - size_t& sccSize, int nodeCount); - void processScc (DispatchNode* scc[], size_t sccSize, - void (*keepEdge)(DispatchNode*, DispatchNode*, Time)); - void sccMoveFluids (DispatchNode* node, DispatchNode* leader); - void sccMoveDirectional (DispatchNode* node, DispatchNode* leader, - Time offset, - DedgeId* Dnode::*ins, - int Dnode::*inCount, - DedgeId* Dnode::*outs, - int Dnode::*outCount, - int Dnode::*outSize, - DnodeId Dedge::*to, - DnodeId Dedge::*from); - void findKeptEdges (DispatchNode* source, - void (*keepEdge)(DispatchNode*, DispatchNode*, Time) - ); -protected: // Overridden virtual functions - DnodeId makeNode(); -}; - - /** - * @class DispatchNode - * @author Paul H. Morris - * @brief Node is a Dispatch Graph - * @ingroup TemporalNetwork - */ -class DispatchNode : public Dnode { - friend class DispatchGraph; - friend int compareNodes (const DispatchNode** node1, - const DispatchNode** node2); - Referent name; // Used by caller to match nodes with caller objects. - Bool isSccMember; // Used during SCC construction. - Time minDistance; // Minimum over node and ancestors, excepting source. -public: - Referent getRef() { return name; } -}; - -} /* namespace Europa */ - -#endif diff --git a/src/PLASMA/TemporalNetwork/base/DistanceGraph.cc b/src/PLASMA/TemporalNetwork/base/DistanceGraph.cc index 90fe2f3d6..e89127e71 100644 --- a/src/PLASMA/TemporalNetwork/base/DistanceGraph.cc +++ b/src/PLASMA/TemporalNetwork/base/DistanceGraph.cc @@ -21,6 +21,8 @@ #include "Utils.hh" //#include "Debug.hh" +#include + namespace EUROPA { @@ -35,41 +37,54 @@ void deleteIfEqual(std::vector& elements, ELEMENT element){ } // Global value overridden only for Rax-derived system test. -Bool IsOkToRemoveConstraintTwice = false; +// Bool IsOkToRemoveConstraintTwice = false; -DistanceGraph::DistanceGraph () +DistanceGraph::DistanceGraph() : edges(), dijkstraGeneration(0), nodes(), + dqueue(new Dqueue()), + bqueue(new BucketQueue(100)), edgeNogoodList() { - dijkstraGeneration=0; - dqueue= new Dqueue; - bqueue= new BucketQueue(100); } DistanceGraph::~DistanceGraph() { - cleanup(edges); - Entity::discardAll(nodes); - delete dqueue; - delete bqueue; +} + +void DistanceGraph::addNode(DnodeId node) { + node->potential = 0; + this->nodes.push_back(node); + } DnodeId DistanceGraph::makeNode() { - return (new Dnode())->getId(); + return boost::make_shared(); } DnodeId DistanceGraph::createNode() { DnodeId node = makeNode(); - check_error(node.isValid(), "Memory allocation failed for TemporalNetwork node", + check_error(node, "Memory allocation failed for TemporalNetwork node", TempNetErr::TempNetMemoryError()); - - node->potential = 0; - this->nodes.push_back(node); + addNode(node); return node; } -Void detachEdge (DedgeId*& edgeArray, Int& count, DedgeId edge); +Void DistanceGraph::attachEdge(std::vector& edgeArray, Int& size, Int& count, DedgeId edge) { + check_error(!(count > size), "Corrupted edge-array in TemporalNetwork", + TempNetErr::TempNetInternalError()); + + edgeArray.push_back(edge); + count = edgeArray.size(); + size = edgeArray.capacity(); +} + + +Void DistanceGraph::detachEdge (std::vector& edgeArray, Int& count, DedgeId edge) +{ + edgeArray.erase(std::find(edgeArray.begin(), edgeArray.end(), edge)); + count = edgeArray.size(); +} Void DistanceGraph::deleteNode(DnodeId node) { @@ -77,18 +92,17 @@ Void DistanceGraph::deleteNode(DnodeId node) for (Int i=0; i < node->outCount; i++) { DedgeId edge = node->outArray[i]; - detachEdge (edge->to->inArray, edge->to->inCount, edge); + detachEdge(edge->to->inArray, edge->to->inCount, edge); eraseEdge(edge); } for (Int j=0; j < node->inCount; j++) { DedgeId edge = node->inArray[j]; - detachEdge (edge->from->outArray, edge->from->outCount, edge); + detachEdge(edge->from->outArray, edge->from->outCount, edge); eraseEdge(edge); } node->inCount = node->outCount = 0; node->potential = 99; // A clue for debugging purposes deleteIfEqual(nodes, node); - node->discard(); } DedgeId DistanceGraph::findEdge(DnodeId from, DnodeId to) @@ -110,56 +124,17 @@ DedgeId DistanceGraph::findEdge(DnodeId from, DnodeId to) // PHM 06/20/2007 Speedup by using map instead. return from->edgemap[to]; } - return DedgeId::noId(); + return DedgeId(); } -Void attachEdge (DedgeId*& edgeArray, Int& size, Int& count, DedgeId edge) -{ - check_error(!(count > size), "Corrupted edge-array in TemporalNetwork", - TempNetErr::TempNetInternalError()); - - if (count == size) { - // Grow edge-array - if (size < 1) - size = 1; - else - size = 2*size; - DedgeId* newEdgeArray = new DedgeId[size]; - if(!newEdgeArray) - handle_error(!newEdgeArray, - "Memory allocation failed for TemporalNetwork edge-array", - TempNetErr::TempNetMemoryError()); - for (Int i=0; igetId(); - check_error(edge.isValid(), "Memory allocation failed for TemporalNetwork edge", + DedgeId edge = boost::make_shared(); + check_error(edge, "Memory allocation failed for TemporalNetwork edge", TempNetErr::TempNetMemoryError()); edge->from = from; @@ -172,6 +147,8 @@ DedgeId DistanceGraph::createEdge(DnodeId from, DnodeId to, Time length) return edge; } +void DistanceGraph::handleNodeUpdate(const DnodeId) {} + Void DistanceGraph::deleteEdge(DedgeId edge) { detachEdge (edge->from->outArray, edge->from->outCount, edge); @@ -184,10 +161,9 @@ Void DistanceGraph::eraseEdge(DedgeId edge) { //deleteIfEqual(edges, edge); edges.erase(edge); - edge->from = DnodeId::noId(); - edge->to = DnodeId::noId(); + edge->from.reset(); + edge->to.reset(); edge->length = 99; // A clue for debugging purposes - delete (Dedge*) edge; } Void DistanceGraph::addEdgeSpec(DnodeId from, DnodeId to, Time length) @@ -198,7 +174,7 @@ Void DistanceGraph::addEdgeSpec(DnodeId from, DnodeId to, Time length) TempNetErr::TempNetInternalError()); DedgeId edge = findEdge (from,to); - if (edge.isNoId()) + if (edge == NULL) edge = createEdge(from,to,length); edge->lengthSpecs.push_back(length); if (length < edge->length) @@ -216,7 +192,7 @@ Void DistanceGraph::removeEdgeSpec(DnodeId from, DnodeId to, Time length) TempNetErr::TempNetInternalError()); DedgeId edge = findEdge (from,to); - check_error(edge.isValid(), "Removing spec from non-existent edge", + check_error(edge, "Removing spec from non-existent edge", TempNetErr::TempNetInternalError()); std::vector